Annotation of freem/doc/texinfo.tex, revision 1.5
1.1 snw 1: % texinfo.tex -- TeX macros to handle Texinfo files.
2: %
3: % Load plain if necessary, i.e., if running under initex.
4: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5: %
1.5 ! snw 6: \def\texinfoversion{2020-02-11.09}
1.1 snw 7: %
1.5 ! snw 8: % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc.
1.1 snw 9: %
10: % This texinfo.tex file is free software: you can redistribute it and/or
11: % modify it under the terms of the GNU General Public License as
12: % published by the Free Software Foundation, either version 3 of the
13: % License, or (at your option) any later version.
14: %
15: % This texinfo.tex file is distributed in the hope that it will be
16: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18: % General Public License for more details.
19: %
20: % You should have received a copy of the GNU General Public License
21: % along with this program. If not, see <https://www.gnu.org/licenses/>.
22: %
23: % As a special exception, when this file is read by TeX when processing
24: % a Texinfo source document, you may use the result without
25: % restriction. This Exception is an additional permission under section 7
26: % of the GNU General Public License, version 3 ("GPLv3").
27: %
28: % Please try the latest version of texinfo.tex before submitting bug
29: % reports; you can get the latest version from:
30: % https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
31: % https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
32: % https://www.gnu.org/software/texinfo/ (the Texinfo home page)
33: % The texinfo.tex in any given distribution could well be out
34: % of date, so if that's what you're using, please check.
35: %
1.5 ! snw 36: % Send bug reports to bug-texinfo@gnu.org. Please include including a
1.1 snw 37: % complete document in each bug report with which we can reproduce the
38: % problem. Patches are, of course, greatly appreciated.
39: %
40: % To process a Texinfo manual with TeX, it's most reliable to use the
41: % texi2dvi shell script that comes with the distribution. For a simple
42: % manual foo.texi, however, you can get away with this:
43: % tex foo.texi
44: % texindex foo.??
45: % tex foo.texi
46: % tex foo.texi
47: % dvips foo.dvi -o # or whatever; this makes foo.ps.
48: % The extra TeX runs get the cross-reference information correct.
49: % Sometimes one run after texindex suffices, and sometimes you need more
50: % than two; texi2dvi does it as many times as necessary.
51: %
52: % It is possible to adapt texinfo.tex for other languages, to some
53: % extent. You can get the existing language-specific files from the
54: % full Texinfo distribution.
55: %
56: % The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
57:
58:
59: \message{Loading texinfo [version \texinfoversion]:}
60:
1.5 ! snw 61: % If in a .fmt file, print the version number
! 62: % and turn on active characters that we couldn't do earlier because
! 63: % they might have appeared in the input file name.
! 64: \everyjob{\message{[Texinfo version \texinfoversion]}%
! 65: \catcode`+=\active \catcode`\_=\active}
! 66:
1.1 snw 67: % LaTeX's \typeout. This ensures that the messages it is used for
68: % are identical in format to the corresponding ones from latex/pdflatex.
69: \def\typeout{\immediate\write17}%
70:
71: \chardef\other=12
72:
73: % We never want plain's \outer definition of \+ in Texinfo.
74: % For @tex, we can use \tabalign.
75: \let\+ = \relax
76:
77: % Save some plain tex macros whose names we will redefine.
78: \let\ptexb=\b
79: \let\ptexbullet=\bullet
80: \let\ptexc=\c
81: \let\ptexcomma=\,
82: \let\ptexdot=\.
83: \let\ptexdots=\dots
84: \let\ptexend=\end
85: \let\ptexequiv=\equiv
86: \let\ptexexclam=\!
87: \let\ptexfootnote=\footnote
88: \let\ptexgtr=>
89: \let\ptexhat=^
90: \let\ptexi=\i
91: \let\ptexindent=\indent
92: \let\ptexinsert=\insert
93: \let\ptexlbrace=\{
94: \let\ptexless=<
95: \let\ptexnewwrite\newwrite
96: \let\ptexnoindent=\noindent
97: \let\ptexplus=+
98: \let\ptexraggedright=\raggedright
99: \let\ptexrbrace=\}
100: \let\ptexslash=\/
101: \let\ptexsp=\sp
102: \let\ptexstar=\*
103: \let\ptexsup=\sup
104: \let\ptext=\t
105: \let\ptextop=\top
106: {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
107:
108: % If this character appears in an error message or help string, it
109: % starts a new line in the output.
110: \newlinechar = `^^J
111:
112: % Use TeX 3.0's \inputlineno to get the line number, for better error
113: % messages, but if we're using an old version of TeX, don't do anything.
114: %
115: \ifx\inputlineno\thisisundefined
116: \let\linenumber = \empty % Pre-3.0.
117: \else
118: \def\linenumber{l.\the\inputlineno:\space}
119: \fi
120:
121: % Set up fixed words for English if not already set.
122: \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
123: \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
124: \ifx\putworderror\undefined \gdef\putworderror{error}\fi
125: \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
126: \ifx\putwordin\undefined \gdef\putwordin{in}\fi
127: \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
128: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
129: \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
130: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
131: \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
132: \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
133: \ifx\putwordof\undefined \gdef\putwordof{of}\fi
134: \ifx\putwordon\undefined \gdef\putwordon{on}\fi
135: \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
136: \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
137: \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
138: \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
139: \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
140: \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
141: \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
142: %
143: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
144: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
145: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
146: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
147: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
148: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
149: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
150: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
151: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
152: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
153: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
154: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
155: %
156: \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
157: \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
158: \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
159: \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
160: \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
161:
162: % Give the space character the catcode for a space.
163: \def\spaceisspace{\catcode`\ =10\relax}
164:
165: % Likewise for ^^M, the end of line character.
166: \def\endlineisspace{\catcode13=10\relax}
167:
168: \chardef\dashChar = `\-
169: \chardef\slashChar = `\/
170: \chardef\underChar = `\_
171:
172: % Ignore a token.
173: %
174: \def\gobble#1{}
175:
176: % The following is used inside several \edef's.
177: \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178:
179: % Hyphenation fixes.
180: \hyphenation{
181: Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182: ap-pen-dix bit-map bit-maps
183: data-base data-bases eshell fall-ing half-way long-est man-u-script
184: man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185: par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186: spell-ing spell-ings
187: stand-alone strong-est time-stamp time-stamps which-ever white-space
188: wide-spread wrap-around
189: }
190:
191: % Sometimes it is convenient to have everything in the transcript file
192: % and nothing on the terminal. We don't just call \tracingall here,
193: % since that produces some useless output on the terminal. We also make
194: % some effort to order the tracing commands to reduce output in the log
195: % file; cf. trace.sty in LaTeX.
196: %
197: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198: \def\loggingall{%
199: \tracingstats2
200: \tracingpages1
201: \tracinglostchars2 % 2 gives us more in etex
202: \tracingparagraphs1
203: \tracingoutput1
204: \tracingmacros2
205: \tracingrestores1
206: \showboxbreadth\maxdimen \showboxdepth\maxdimen
207: \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208: \tracingscantokens1
209: \tracingifs1
210: \tracinggroups1
211: \tracingnesting2
212: \tracingassigns1
213: \fi
214: \tracingcommands3 % 3 gives us more in etex
215: \errorcontextlines16
216: }%
217:
218: % @errormsg{MSG}. Do the index-like expansions on MSG, but if things
219: % aren't perfect, it's not the end of the world, being an error message,
220: % after all.
221: %
222: \def\errormsg{\begingroup \indexnofonts \doerrormsg}
223: \def\doerrormsg#1{\errmessage{#1}}
224:
225: % add check for \lastpenalty to plain's definitions. If the last thing
226: % we did was a \nobreak, we don't want to insert more space.
227: %
228: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229: \removelastskip\penalty-50\smallskip\fi\fi}
230: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231: \removelastskip\penalty-100\medskip\fi\fi}
232: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233: \removelastskip\penalty-200\bigskip\fi\fi}
234:
235: % Output routine
236: %
237:
238: % For a final copy, take out the rectangles
239: % that mark overfull boxes (in case you have decided
240: % that the text looks ok even though it passes the margin).
241: %
242: \def\finalout{\overfullrule=0pt }
243:
1.5 ! snw 244: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
! 245: \newdimen\topandbottommargin \topandbottommargin=.75in
! 246:
1.1 snw 247: % Output a mark which sets \thischapter, \thissection and \thiscolor.
248: % We dump everything together because we only have one kind of mark.
249: % This works because we only use \botmark / \topmark, not \firstmark.
250: %
251: % A mark contains a subexpression of the \ifcase ... \fi construct.
252: % \get*marks macros below extract the needed part using \ifcase.
253: %
254: % Another complication is to let the user choose whether \thischapter
255: % (\thissection) refers to the chapter (section) in effect at the top
256: % of a page, or that at the bottom of a page.
257:
258: % \domark is called twice inside \chapmacro, to add one
259: % mark before the section break, and one after.
260: % In the second call \prevchapterdefs is the same as \currentchapterdefs,
261: % and \prevsectiondefs is the same as \currentsectiondefs.
262: % Then if the page is not broken at the mark, some of the previous
263: % section appears on the page, and we can get the name of this section
264: % from \firstmark for @everyheadingmarks top.
265: % @everyheadingmarks bottom uses \botmark.
266: %
267: % See page 260 of The TeXbook.
268: \def\domark{%
269: \toks0=\expandafter{\currentchapterdefs}%
270: \toks2=\expandafter{\currentsectiondefs}%
271: \toks4=\expandafter{\prevchapterdefs}%
272: \toks6=\expandafter{\prevsectiondefs}%
273: \toks8=\expandafter{\currentcolordefs}%
274: \mark{%
275: \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top
276: \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom
277: \noexpand\else \the\toks8 % 2: color marks
278: }%
279: }
280:
281: % \gettopheadingmarks, \getbottomheadingmarks,
282: % \getcolormarks - extract needed part of mark.
283: %
284: % \topmark doesn't work for the very first chapter (after the title
285: % page or the contents), so we use \firstmark there -- this gets us
286: % the mark with the chapter defs, unless the user sneaks in, e.g.,
1.5 ! snw 287: % @setcolor (or @url, or @link, etc.) between @contents and the very
! 288: % first @chapter.
1.1 snw 289: \def\gettopheadingmarks{%
290: \ifcase0\the\savedtopmark\fi
291: \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
292: }
293: \def\getbottomheadingmarks{\ifcase1\botmark\fi}
294: \def\getcolormarks{\ifcase2\the\savedtopmark\fi}
295:
296: % Avoid "undefined control sequence" errors.
297: \def\currentchapterdefs{}
298: \def\currentsectiondefs{}
299: \def\currentsection{}
300: \def\prevchapterdefs{}
301: \def\prevsectiondefs{}
302: \def\currentcolordefs{}
303:
304: % Margin to add to right of even pages, to left of odd pages.
305: \newdimen\bindingoffset
306: \newdimen\normaloffset
307: \newdimen\txipagewidth \newdimen\txipageheight
308:
309: % Main output routine.
310: %
311: \chardef\PAGE = 255
312: \newtoks\defaultoutput
313: \defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
314: \output=\expandafter{\the\defaultoutput}
315:
316: \newbox\headlinebox
317: \newbox\footlinebox
318:
319: % When outputting the double column layout for indices, an output routine
1.5 ! snw 320: % is run several times, which hides the original value of \topmark. This
! 321: % can lead to a page heading being output and duplicating the chapter heading
! 322: % of the index. Hence, save the contents of \topmark at the beginning of
! 323: % the output routine. The saved contents are valid until we actually
! 324: % \shipout a page.
! 325: %
! 326: % (We used to run a short output routine to actually set \topmark and
! 327: % \firstmark to the right values, but if this was called with an empty page
! 328: % containing whatsits for writing index entries, the whatsits would be thrown
! 329: % away and the index auxiliary file would remain empty.)
1.1 snw 330: %
331: \newtoks\savedtopmark
332: \newif\iftopmarksaved
333: \topmarksavedtrue
334: \def\savetopmark{%
335: \iftopmarksaved\else
336: \global\savedtopmark=\expandafter{\topmark}%
337: \global\topmarksavedtrue
338: \fi
339: }
340:
341: % \onepageout takes a vbox as an argument.
342: % \shipout a vbox for a single page, adding an optional header, footer
343: % and footnote. This also causes index entries for this page to be written
344: % to the auxiliary files.
345: %
346: \def\onepageout#1{%
347: \hoffset=\normaloffset
348: %
349: \ifodd\pageno \advance\hoffset by \bindingoffset
350: \else \advance\hoffset by -\bindingoffset\fi
351: %
1.5 ! snw 352: % Retrieve the information for the headings from the marks in the page,
! 353: % and call Plain TeX's \makeheadline and \makefootline, which use the
! 354: % values in \headline and \footline.
! 355: %
! 356: % This is used to check if we are on the first page of a chapter.
! 357: \ifcase1\the\savedtopmark\fi
! 358: \let\prevchaptername\thischaptername
! 359: \ifcase0\firstmark\fi
! 360: \let\curchaptername\thischaptername
! 361: %
! 362: \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
! 363: %
! 364: \ifx\curchaptername\prevchaptername
! 365: \let\thischapterheading\thischapter
! 366: \else
! 367: % \thischapterheading is the same as \thischapter except it is blank
! 368: % for the first page of a chapter. This is to prevent the chapter name
! 369: % being shown twice.
! 370: \def\thischapterheading{}%
! 371: \fi
1.1 snw 372: %
1.5 ! snw 373: % Common context changes for both heading and footing.
! 374: % Do this outside of the \shipout so @code etc. will be expanded in
! 375: % the headline as they should be, not taken literally (outputting ''code).
1.1 snw 376: \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
1.5 ! snw 377: %
1.1 snw 378: \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
1.5 ! snw 379: %
1.1 snw 380: \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
381: \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
382: %
383: {%
384: % Set context for writing to auxiliary files like index files.
385: % Have to do this stuff outside the \shipout because we want it to
386: % take effect in \write's, yet the group defined by the \vbox ends
387: % before the \shipout runs.
388: %
389: \atdummies % don't expand commands in the output.
390: \turnoffactive
391: \shipout\vbox{%
392: % Do this early so pdf references go to the beginning of the page.
393: \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
394: %
395: \unvbox\headlinebox
396: \pagebody{#1}%
397: \ifdim\ht\footlinebox > 0pt
398: % Only leave this space if the footline is nonempty.
399: % (We lessened \vsize for it in \oddfootingyyy.)
400: % The \baselineskip=24pt in plain's \makefootline has no effect.
401: \vskip 24pt
402: \unvbox\footlinebox
403: \fi
404: %
405: }%
406: }%
407: \global\topmarksavedfalse
408: \advancepageno
409: \ifnum\outputpenalty>-20000 \else\dosupereject\fi
410: }
411:
412: \newinsert\margin \dimen\margin=\maxdimen
413:
414: % Main part of page, including any footnotes
415: \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
416: {\catcode`\@ =11
417: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
418: % marginal hacks, juha@viisa.uucp (Juha Takala)
419: \ifvoid\margin\else % marginal info is present
420: \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
421: \dimen@=\dp#1\relax \unvbox#1\relax
422: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
423: \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
424: }
425:
426:
427: % Argument parsing
428:
429: % Parse an argument, then pass it to #1. The argument is the rest of
430: % the input line (except we remove a trailing comment). #1 should be a
431: % macro which expects an ordinary undelimited TeX argument.
432: % For example, \def\foo{\parsearg\fooxxx}.
433: %
434: \def\parsearg{\parseargusing{}}
435: \def\parseargusing#1#2{%
436: \def\argtorun{#2}%
437: \begingroup
438: \obeylines
439: \spaceisspace
440: #1%
441: \parseargline\empty% Insert the \empty token, see \finishparsearg below.
442: }
443:
444: {\obeylines %
445: \gdef\parseargline#1^^M{%
446: \endgroup % End of the group started in \parsearg.
447: \argremovecomment #1\comment\ArgTerm%
448: }%
449: }
450:
451: % First remove any @comment, then any @c comment. Pass the result on to
1.5 ! snw 452: % \argcheckspaces.
1.1 snw 453: \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
1.5 ! snw 454: \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
! 455:
! 456: % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
! 457: %
! 458: % \argremovec might leave us with trailing space, e.g.,
1.1 snw 459: % @end itemize @c foo
1.5 ! snw 460: % This space token undergoes the same procedure and is eventually removed
! 461: % by \finishparsearg.
! 462: %
! 463: \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
! 464: \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
! 465: \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
! 466: \def\temp{#3}%
! 467: \ifx\temp\empty
! 468: % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
! 469: \let\temp\finishparsearg
! 470: \else
! 471: \let\temp\argcheckspaces
! 472: \fi
! 473: % Put the space token in:
! 474: \temp#1 #3\ArgTerm
! 475: }
1.1 snw 476:
477: % If a _delimited_ argument is enclosed in braces, they get stripped; so
478: % to get _exactly_ the rest of the line, we had to prevent such situation.
1.5 ! snw 479: % We prepended an \empty token at the very beginning and we expand it now,
! 480: % just before passing the control to \argtorun.
! 481: % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
! 482: % either the null string, or it ends with \^^M---thus there is no danger
! 483: % that a pair of braces would be stripped.
! 484: %
! 485: % But first, we have to remove the trailing space token.
! 486: %
! 487: \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
1.1 snw 488:
489:
490: % \parseargdef - define a command taking an argument on the line
491: %
492: % \parseargdef\foo{...}
493: % is roughly equivalent to
494: % \def\foo{\parsearg\Xfoo}
495: % \def\Xfoo#1{...}
496: \def\parseargdef#1{%
497: \expandafter \doparseargdef \csname\string#1\endcsname #1%
498: }
499: \def\doparseargdef#1#2{%
500: \def#2{\parsearg#1}%
501: \def#1##1%
502: }
503:
504: % Several utility definitions with active space:
505: {
506: \obeyspaces
507: \gdef\obeyedspace{ }
508:
509: % Make each space character in the input produce a normal interword
510: % space in the output. Don't allow a line break at this space, as this
511: % is used only in environments like @example, where each line of input
512: % should produce a line of output anyway.
513: %
514: \gdef\sepspaces{\obeyspaces\let =\tie}
515:
516: % If an index command is used in an @example environment, any spaces
517: % therein should become regular spaces in the raw index file, not the
518: % expansion of \tie (\leavevmode \penalty \@M \ ).
519: \gdef\unsepspaces{\let =\space}
520: }
521:
522:
523: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
524:
525: % Define the framework for environments in texinfo.tex. It's used like this:
526: %
527: % \envdef\foo{...}
528: % \def\Efoo{...}
529: %
530: % It's the responsibility of \envdef to insert \begingroup before the
531: % actual body; @end closes the group after calling \Efoo. \envdef also
532: % defines \thisenv, so the current environment is known; @end checks
533: % whether the environment name matches. The \checkenv macro can also be
534: % used to check whether the current environment is the one expected.
535: %
536: % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
537: % are not treated as environments; they don't open a group. (The
538: % implementation of @end takes care not to call \endgroup in this
539: % special case.)
540:
541:
542: % At run-time, environments start with this:
543: \def\startenvironment#1{\begingroup\def\thisenv{#1}}
544: % initialize
545: \let\thisenv\empty
546:
547: % ... but they get defined via ``\envdef\foo{...}'':
548: \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
1.5 ! snw 549: \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
1.1 snw 550:
551: % Check whether we're in the right environment:
552: \def\checkenv#1{%
553: \def\temp{#1}%
554: \ifx\thisenv\temp
555: \else
556: \badenverr
557: \fi
558: }
559:
560: % Environment mismatch, #1 expected:
561: \def\badenverr{%
562: \errhelp = \EMsimple
563: \errmessage{This command can appear only \inenvironment\temp,
564: not \inenvironment\thisenv}%
565: }
566: \def\inenvironment#1{%
567: \ifx#1\empty
568: outside of any environment%
569: \else
570: in environment \expandafter\string#1%
571: \fi
572: }
573:
1.5 ! snw 574: % @end foo executes the definition of \Efoo.
! 575: % But first, it executes a specialized version of \checkenv
! 576: %
1.1 snw 577: \parseargdef\end{%
578: \if 1\csname iscond.#1\endcsname
579: \else
580: % The general wording of \badenverr may not be ideal.
581: \expandafter\checkenv\csname#1\endcsname
582: \csname E#1\endcsname
583: \endgroup
584: \fi
585: }
586:
587: \newhelp\EMsimple{Press RETURN to continue.}
588:
589:
590: % Be sure we're in horizontal mode when doing a tie, since we make space
591: % equivalent to this in @example-like environments. Otherwise, a space
592: % at the beginning of a line will start with \penalty -- and
593: % since \penalty is valid in vertical mode, we'd end up putting the
594: % penalty on the vertical list instead of in the new paragraph.
595: {\catcode`@ = 11
596: % Avoid using \@M directly, because that causes trouble
597: % if the definition is written into an index file.
598: \global\let\tiepenalty = \@M
599: \gdef\tie{\leavevmode\penalty\tiepenalty\ }
600: }
601:
602: % @: forces normal size whitespace following.
603: \def\:{\spacefactor=1000 }
604:
605: % @* forces a line break.
606: \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
607:
608: % @/ allows a line break.
609: \let\/=\allowbreak
610:
611: % @. is an end-of-sentence period.
612: \def\.{.\spacefactor=\endofsentencespacefactor\space}
613:
614: % @! is an end-of-sentence bang.
615: \def\!{!\spacefactor=\endofsentencespacefactor\space}
616:
617: % @? is an end-of-sentence query.
618: \def\?{?\spacefactor=\endofsentencespacefactor\space}
619:
1.5 ! snw 620: % @frenchspacing on|off says whether to put extra space after punctuation.
! 621: %
! 622: \def\onword{on}
! 623: \def\offword{off}
! 624: %
! 625: \parseargdef\frenchspacing{%
! 626: \def\temp{#1}%
! 627: \ifx\temp\onword \plainfrenchspacing
! 628: \else\ifx\temp\offword \plainnonfrenchspacing
! 629: \else
! 630: \errhelp = \EMsimple
! 631: \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
! 632: \fi\fi
! 633: }
! 634:
1.1 snw 635: % @w prevents a word break. Without the \leavevmode, @w at the
636: % beginning of a paragraph, when TeX is still in vertical mode, would
637: % produce a whole line of output instead of starting the paragraph.
638: \def\w#1{\leavevmode\hbox{#1}}
639:
640: % @group ... @end group forces ... to be all on one page, by enclosing
641: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
642: % to keep its height that of a normal line. According to the rules for
643: % \topskip (p.114 of the TeXbook), the glue inserted is
644: % max (\topskip - \ht (first item), 0). If that height is large,
645: % therefore, no glue is inserted, and the space between the headline and
646: % the text is small, which looks bad.
647: %
648: % Another complication is that the group might be very large. This can
649: % cause the glue on the previous page to be unduly stretched, because it
650: % does not have much material. In this case, it's better to add an
651: % explicit \vfill so that the extra space is at the bottom. The
652: % threshold for doing this is if the group is more than \vfilllimit
653: % percent of a page (\vfilllimit can be changed inside of @tex).
654: %
655: \newbox\groupbox
656: \def\vfilllimit{0.7}
657: %
658: \envdef\group{%
659: \ifnum\catcode`\^^M=\active \else
660: \errhelp = \groupinvalidhelp
661: \errmessage{@group invalid in context where filling is enabled}%
662: \fi
663: \startsavinginserts
664: %
665: \setbox\groupbox = \vtop\bgroup
666: % Do @comment since we are called inside an environment such as
667: % @example, where each end-of-line in the input causes an
668: % end-of-line in the output. We don't want the end-of-line after
669: % the `@group' to put extra space in the output. Since @group
670: % should appear on a line by itself (according to the Texinfo
671: % manual), we don't worry about eating any user text.
672: \comment
673: }
674: %
675: % The \vtop produces a box with normal height and large depth; thus, TeX puts
676: % \baselineskip glue before it, and (when the next line of text is done)
677: % \lineskip glue after it. Thus, space below is not quite equal to space
678: % above. But it's pretty close.
679: \def\Egroup{%
680: % To get correct interline space between the last line of the group
681: % and the first line afterwards, we have to propagate \prevdepth.
682: \endgraf % Not \par, as it may have been set to \lisppar.
683: \global\dimen1 = \prevdepth
684: \egroup % End the \vtop.
685: \addgroupbox
686: \prevdepth = \dimen1
687: \checkinserts
688: }
689:
690: \def\addgroupbox{
691: % \dimen0 is the vertical size of the group's box.
692: \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
693: % \dimen2 is how much space is left on the page (more or less).
694: \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal
695: % if the group doesn't fit on the current page, and it's a big big
696: % group, force a page break.
697: \ifdim \dimen0 > \dimen2
698: \ifdim \pagetotal < \vfilllimit\txipageheight
699: \page
700: \fi
701: \fi
702: \box\groupbox
703: }
704:
705: %
706: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
707: % message, so this ends up printing `@group can only ...'.
708: %
709: \newhelp\groupinvalidhelp{%
710: group can only be used in environments such as @example,^^J%
711: where each line of input produces a line of output.}
712:
713: % @need space-in-mils
714: % forces a page break if there is not space-in-mils remaining.
715:
716: \newdimen\mil \mil=0.001in
717:
718: \parseargdef\need{%
719: % Ensure vertical mode, so we don't make a big box in the middle of a
720: % paragraph.
721: \par
722: %
723: % If the @need value is less than one line space, it's useless.
724: \dimen0 = #1\mil
725: \dimen2 = \ht\strutbox
726: \advance\dimen2 by \dp\strutbox
727: \ifdim\dimen0 > \dimen2
1.5 ! snw 728: %
! 729: % Do a \strut just to make the height of this box be normal, so the
! 730: % normal leading is inserted relative to the preceding line.
! 731: % And a page break here is fine.
! 732: \vtop to #1\mil{\strut\vfil}%
! 733: %
! 734: % TeX does not even consider page breaks if a penalty added to the
! 735: % main vertical list is 10000 or more. But in order to see if the
! 736: % empty box we just added fits on the page, we must make it consider
! 737: % page breaks. On the other hand, we don't want to actually break the
! 738: % page after the empty box. So we use a penalty of 9999.
! 739: %
! 740: % There is an extremely small chance that TeX will actually break the
! 741: % page at this \penalty, if there are no other feasible breakpoints in
! 742: % sight. (If the user is using lots of big @group commands, which
! 743: % almost-but-not-quite fill up a page, TeX will have a hard time doing
! 744: % good page breaking, for example.) However, I could not construct an
! 745: % example where a page broke at this \penalty; if it happens in a real
! 746: % document, then we can reconsider our strategy.
1.1 snw 747: \penalty9999
1.5 ! snw 748: %
! 749: % Back up by the size of the box, whether we did a page break or not.
! 750: \kern -#1\mil
! 751: %
! 752: % Do not allow a page break right after this kern.
! 753: \nobreak
1.1 snw 754: \fi
755: }
756:
757: % @br forces paragraph break (and is undocumented).
758:
759: \let\br = \par
760:
761: % @page forces the start of a new page.
762: %
763: \def\page{\par\vfill\supereject}
764:
765: % @exdent text....
766: % outputs text on separate line in roman font, starting at standard page margin
767:
768: % This records the amount of indent in the innermost environment.
769: % That's how much \exdent should take out.
770: \newskip\exdentamount
771:
772: % This defn is used inside fill environments such as @defun.
773: \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
774:
775: % This defn is used inside nofill environments such as @example.
776: \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
777: \leftline{\hskip\leftskip{\rm#1}}}}
778:
779: % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
780: % paragraph. For more general purposes, use the \margin insertion
781: % class. WHICH is `l' or `r'. Not documented, written for gawk manual.
782: %
783: \newskip\inmarginspacing \inmarginspacing=1cm
784: \def\strutdepth{\dp\strutbox}
785: %
786: \def\doinmargin#1#2{\strut\vadjust{%
787: \nobreak
788: \kern-\strutdepth
789: \vtop to \strutdepth{%
790: \baselineskip=\strutdepth
791: \vss
792: % if you have multiple lines of stuff to put here, you'll need to
793: % make the vbox yourself of the appropriate size.
794: \ifx#1l%
795: \llap{\ignorespaces #2\hskip\inmarginspacing}%
796: \else
797: \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
798: \fi
799: \null
800: }%
801: }}
802: \def\inleftmargin{\doinmargin l}
803: \def\inrightmargin{\doinmargin r}
804: %
805: % @inmargin{TEXT [, RIGHT-TEXT]}
806: % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
807: % else use TEXT for both).
808: %
809: \def\inmargin#1{\parseinmargin #1,,\finish}
810: \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
811: \setbox0 = \hbox{\ignorespaces #2}%
812: \ifdim\wd0 > 0pt
813: \def\lefttext{#1}% have both texts
814: \def\righttext{#2}%
815: \else
816: \def\lefttext{#1}% have only one text
817: \def\righttext{#1}%
818: \fi
819: %
820: \ifodd\pageno
821: \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
822: \else
823: \def\temp{\inleftmargin\lefttext}%
824: \fi
825: \temp
826: }
827:
828: % @include FILE -- \input text of FILE.
829: %
830: \def\include{\parseargusing\filenamecatcodes\includezzz}
831: \def\includezzz#1{%
832: \pushthisfilestack
833: \def\thisfile{#1}%
834: {%
835: \makevalueexpandable % we want to expand any @value in FILE.
836: \turnoffactive % and allow special characters in the expansion
837: \indexnofonts % Allow `@@' and other weird things in file names.
838: \wlog{texinfo.tex: doing @include of #1^^J}%
839: \edef\temp{\noexpand\input #1 }%
840: %
841: % This trickery is to read FILE outside of a group, in case it makes
842: % definitions, etc.
843: \expandafter
844: }\temp
845: \popthisfilestack
846: }
847: \def\filenamecatcodes{%
848: \catcode`\\=\other
849: \catcode`~=\other
850: \catcode`^=\other
851: \catcode`_=\other
852: \catcode`|=\other
853: \catcode`<=\other
854: \catcode`>=\other
855: \catcode`+=\other
856: \catcode`-=\other
857: \catcode`\`=\other
858: \catcode`\'=\other
859: }
860:
861: \def\pushthisfilestack{%
862: \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
863: }
864: \def\pushthisfilestackX{%
865: \expandafter\pushthisfilestackY\thisfile\StackTerm
866: }
867: \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
868: \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
869: }
870:
871: \def\popthisfilestack{\errthisfilestackempty}
872: \def\errthisfilestackempty{\errmessage{Internal error:
873: the stack of filenames is empty.}}
874: %
875: \def\thisfile{}
876:
877: % @center line
878: % outputs that line, centered.
879: %
880: \parseargdef\center{%
881: \ifhmode
882: \let\centersub\centerH
883: \else
884: \let\centersub\centerV
885: \fi
886: \centersub{\hfil \ignorespaces#1\unskip \hfil}%
887: \let\centersub\relax % don't let the definition persist, just in case
888: }
889: \def\centerH#1{{%
890: \hfil\break
891: \advance\hsize by -\leftskip
892: \advance\hsize by -\rightskip
893: \line{#1}%
894: \break
895: }}
896: %
897: \newcount\centerpenalty
898: \def\centerV#1{%
899: % The idea here is the same as in \startdefun, \cartouche, etc.: if
900: % @center is the first thing after a section heading, we need to wipe
901: % out the negative parskip inserted by \sectionheading, but still
902: % prevent a page break here.
903: \centerpenalty = \lastpenalty
904: \ifnum\centerpenalty>10000 \vskip\parskip \fi
905: \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
906: \line{\kern\leftskip #1\kern\rightskip}%
907: }
908:
909: % @sp n outputs n lines of vertical space
910: %
911: \parseargdef\sp{\vskip #1\baselineskip}
912:
913: % @comment ...line which is ignored...
914: % @c is the same as @comment
915: % @ignore ... @end ignore is another way to write a comment
916:
917:
918: \def\c{\begingroup \catcode`\^^M=\active%
919: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
920: \cxxx}
921: {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
922: %
923: \let\comment\c
924:
925: % @paragraphindent NCHARS
926: % We'll use ems for NCHARS, close enough.
927: % NCHARS can also be the word `asis' or `none'.
928: % We cannot feasibly implement @paragraphindent asis, though.
929: %
930: \def\asisword{asis} % no translation, these are keywords
931: \def\noneword{none}
932: %
933: \parseargdef\paragraphindent{%
934: \def\temp{#1}%
935: \ifx\temp\asisword
936: \else
937: \ifx\temp\noneword
938: \defaultparindent = 0pt
939: \else
940: \defaultparindent = #1em
941: \fi
942: \fi
943: \parindent = \defaultparindent
944: }
945:
946: % @exampleindent NCHARS
947: % We'll use ems for NCHARS like @paragraphindent.
948: % It seems @exampleindent asis isn't necessary, but
949: % I preserve it to make it similar to @paragraphindent.
950: \parseargdef\exampleindent{%
951: \def\temp{#1}%
952: \ifx\temp\asisword
953: \else
954: \ifx\temp\noneword
955: \lispnarrowing = 0pt
956: \else
957: \lispnarrowing = #1em
958: \fi
959: \fi
960: }
961:
962: % @firstparagraphindent WORD
963: % If WORD is `none', then suppress indentation of the first paragraph
964: % after a section heading. If WORD is `insert', then do indent at such
965: % paragraphs.
966: %
967: % The paragraph indentation is suppressed or not by calling
968: % \suppressfirstparagraphindent, which the sectioning commands do.
969: % We switch the definition of this back and forth according to WORD.
970: % By default, we suppress indentation.
971: %
972: \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
973: \def\insertword{insert}
974: %
975: \parseargdef\firstparagraphindent{%
976: \def\temp{#1}%
977: \ifx\temp\noneword
978: \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
979: \else\ifx\temp\insertword
980: \let\suppressfirstparagraphindent = \relax
981: \else
982: \errhelp = \EMsimple
983: \errmessage{Unknown @firstparagraphindent option `\temp'}%
984: \fi\fi
985: }
986:
987: % Here is how we actually suppress indentation. Redefine \everypar to
988: % \kern backwards by \parindent, and then reset itself to empty.
989: %
990: % We also make \indent itself not actually do anything until the next
991: % paragraph.
992: %
993: \gdef\dosuppressfirstparagraphindent{%
994: \gdef\indent {\restorefirstparagraphindent \indent}%
995: \gdef\noindent{\restorefirstparagraphindent \noindent}%
996: \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
997: }
998: %
999: \gdef\restorefirstparagraphindent{%
1000: \global\let\indent = \ptexindent
1001: \global\let\noindent = \ptexnoindent
1002: \global\everypar = {}%
1003: }
1004:
1005:
1006: % @refill is a no-op.
1007: \let\refill=\relax
1008:
1009: % @setfilename INFO-FILENAME - ignored
1010: \let\setfilename=\comment
1011:
1012: % @bye.
1.5 ! snw 1013: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1.1 snw 1014:
1015:
1016: \message{pdf,}
1017: % adobe `portable' document format
1018: \newcount\tempnum
1019: \newcount\lnkcount
1020: \newtoks\filename
1021: \newcount\filenamelength
1022: \newcount\pgn
1023: \newtoks\toksA
1024: \newtoks\toksB
1025: \newtoks\toksC
1026: \newtoks\toksD
1027: \newbox\boxA
1028: \newbox\boxB
1029: \newcount\countA
1030: \newif\ifpdf
1031: \newif\ifpdfmakepagedest
1032:
1033: %
1034: % For LuaTeX
1035: %
1036:
1037: \newif\iftxiuseunicodedestname
1038: \txiuseunicodedestnamefalse % For pdfTeX etc.
1039:
1040: \ifx\luatexversion\thisisundefined
1041: \else
1042: % Use Unicode destination names
1043: \txiuseunicodedestnametrue
1044: % Escape PDF strings with converting UTF-16 from UTF-8
1045: \begingroup
1046: \catcode`\%=12
1047: \directlua{
1048: function UTF16oct(str)
1049: tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1050: for c in string.utfvalues(str) do
1051: if c < 0x10000 then
1052: tex.sprint(
1053: string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1054: string.char(0x5c) .. string.char(0x25) .. '03o',
1055: math.floor(c / 256), math.floor(c % 256)))
1056: else
1057: c = c - 0x10000
1058: local c_hi = c / 1024 + 0xd800
1059: local c_lo = c % 1024 + 0xdc00
1060: tex.sprint(
1061: string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1062: string.char(0x5c) .. string.char(0x25) .. '03o' ..
1063: string.char(0x5c) .. string.char(0x25) .. '03o' ..
1064: string.char(0x5c) .. string.char(0x25) .. '03o',
1065: math.floor(c_hi / 256), math.floor(c_hi % 256),
1066: math.floor(c_lo / 256), math.floor(c_lo % 256)))
1067: end
1068: end
1069: end
1070: }
1071: \endgroup
1072: \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1073: % Escape PDF strings without converting
1074: \begingroup
1075: \directlua{
1076: function PDFescstr(str)
1077: for c in string.bytes(str) do
1078: if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1079: tex.sprint(-2,
1080: string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1081: c))
1082: else
1083: tex.sprint(-2, string.char(c))
1084: end
1085: end
1086: end
1087: }
1088: % The -2 in the arguments here gives all the input to TeX catcode 12
1089: % (other) or 10 (space), preventing undefined control sequence errors. See
1090: % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1091: %
1092: \endgroup
1093: \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1094: \ifnum\luatexversion>84
1095: % For LuaTeX >= 0.85
1096: \def\pdfdest{\pdfextension dest}
1097: \let\pdfoutput\outputmode
1098: \def\pdfliteral{\pdfextension literal}
1099: \def\pdfcatalog{\pdfextension catalog}
1100: \def\pdftexversion{\numexpr\pdffeedback version\relax}
1101: \let\pdfximage\saveimageresource
1102: \let\pdfrefximage\useimageresource
1103: \let\pdflastximage\lastsavedimageresourceindex
1104: \def\pdfendlink{\pdfextension endlink\relax}
1105: \def\pdfoutline{\pdfextension outline}
1106: \def\pdfstartlink{\pdfextension startlink}
1107: \def\pdffontattr{\pdfextension fontattr}
1108: \def\pdfobj{\pdfextension obj}
1109: \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1110: \let\pdfpagewidth\pagewidth
1111: \let\pdfpageheight\pageheight
1112: \edef\pdfhorigin{\pdfvariable horigin}
1113: \edef\pdfvorigin{\pdfvariable vorigin}
1114: \fi
1115: \fi
1116:
1117: % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1118: % can be set). So we test for \relax and 0 as well as being undefined.
1119: \ifx\pdfoutput\thisisundefined
1120: \else
1121: \ifx\pdfoutput\relax
1122: \else
1123: \ifcase\pdfoutput
1124: \else
1125: \pdftrue
1126: \fi
1127: \fi
1128: \fi
1129:
1130: \newif\ifpdforxetex
1131: \pdforxetexfalse
1132: \ifpdf
1133: \pdforxetextrue
1134: \fi
1135: \ifx\XeTeXrevision\thisisundefined\else
1136: \pdforxetextrue
1137: \fi
1138:
1139:
1140: % PDF uses PostScript string constants for the names of xref targets,
1141: % for display in the outlines, and in other places. Thus, we have to
1142: % double any backslashes. Otherwise, a name like "\node" will be
1143: % interpreted as a newline (\n), followed by o, d, e. Not good.
1144: %
1145: % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1146: % related messages. The final outcome is that it is up to the TeX user
1147: % to double the backslashes and otherwise make the string valid, so
1148: % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
1149: % do this reliably, so we use it.
1150:
1151: % #1 is a control sequence in which to do the replacements,
1152: % which we \xdef.
1153: \def\txiescapepdf#1{%
1154: \ifx\pdfescapestring\thisisundefined
1155: % No primitive available; should we give a warning or log?
1156: % Many times it won't matter.
1157: \xdef#1{#1}%
1158: \else
1159: % The expandable \pdfescapestring primitive escapes parentheses,
1160: % backslashes, and other special chars.
1161: \xdef#1{\pdfescapestring{#1}}%
1162: \fi
1163: }
1164: \def\txiescapepdfutfsixteen#1{%
1165: \ifx\pdfescapestrutfsixteen\thisisundefined
1166: % No UTF-16 converting macro available.
1167: \txiescapepdf{#1}%
1168: \else
1169: \xdef#1{\pdfescapestrutfsixteen{#1}}%
1170: \fi
1171: }
1172:
1173: \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1174: with PDF output, and none of those formats could be found. (.eps cannot
1175: be supported due to the design of the PDF format; use regular TeX (DVI
1176: output) for that.)}
1177:
1178: \ifpdf
1179: %
1180: % Color manipulation macros using ideas from pdfcolor.tex,
1181: % except using rgb instead of cmyk; the latter is said to render as a
1182: % very dark gray on-screen and a very dark halftone in print, instead
1183: % of actual black. The dark red here is dark enough to print on paper as
1184: % nearly black, but still distinguishable for online viewing. We use
1185: % black by default, though.
1186: \def\rgbDarkRed{0.50 0.09 0.12}
1187: \def\rgbBlack{0 0 0}
1188: %
1189: % rg sets the color for filling (usual text, etc.);
1190: % RG sets the color for stroking (thin rules, e.g., normal _'s).
1191: \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
1192: %
1193: % Set color, and create a mark which defines \thiscolor accordingly,
1194: % so that \makeheadline knows which color to restore.
1195: \def\setcolor#1{%
1.5 ! snw 1196: \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
! 1197: \domark
! 1198: \pdfsetcolor{#1}%
1.1 snw 1199: }
1200: %
1.5 ! snw 1201: \def\maincolor{\rgbBlack}
1.1 snw 1202: \pdfsetcolor{\maincolor}
1203: \edef\thiscolor{\maincolor}
1204: \def\currentcolordefs{}
1205: %
1206: \def\makefootline{%
1207: \baselineskip24pt
1208: \line{\pdfsetcolor{\maincolor}\the\footline}%
1209: }
1210: %
1211: \def\makeheadline{%
1212: \vbox to 0pt{%
1213: \vskip-22.5pt
1214: \line{%
1215: \vbox to8.5pt{}%
1216: % Extract \thiscolor definition from the marks.
1217: \getcolormarks
1218: % Typeset the headline with \maincolor, then restore the color.
1219: \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1220: }%
1221: \vss
1222: }%
1223: \nointerlineskip
1224: }
1225: %
1226: %
1227: \pdfcatalog{/PageMode /UseOutlines}
1228: %
1229: % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1230: \def\dopdfimage#1#2#3{%
1231: \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1232: \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1233: %
1234: % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1235: % others). Let's try in that order, PDF first since if
1236: % someone has a scalable image, presumably better to use that than a
1237: % bitmap.
1238: \let\pdfimgext=\empty
1239: \begingroup
1240: \openin 1 #1.pdf \ifeof 1
1241: \openin 1 #1.PDF \ifeof 1
1242: \openin 1 #1.png \ifeof 1
1243: \openin 1 #1.jpg \ifeof 1
1244: \openin 1 #1.jpeg \ifeof 1
1245: \openin 1 #1.JPG \ifeof 1
1246: \errhelp = \nopdfimagehelp
1247: \errmessage{Could not find image file #1 for pdf}%
1248: \else \gdef\pdfimgext{JPG}%
1249: \fi
1250: \else \gdef\pdfimgext{jpeg}%
1251: \fi
1252: \else \gdef\pdfimgext{jpg}%
1253: \fi
1254: \else \gdef\pdfimgext{png}%
1255: \fi
1256: \else \gdef\pdfimgext{PDF}%
1257: \fi
1258: \else \gdef\pdfimgext{pdf}%
1259: \fi
1260: \closein 1
1261: \endgroup
1262: %
1263: % without \immediate, ancient pdftex seg faults when the same image is
1264: % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
1265: \ifnum\pdftexversion < 14
1266: \immediate\pdfimage
1267: \else
1268: \immediate\pdfximage
1269: \fi
1270: \ifdim \wd0 >0pt width \pdfimagewidth \fi
1271: \ifdim \wd2 >0pt height \pdfimageheight \fi
1272: \ifnum\pdftexversion<13
1273: #1.\pdfimgext
1274: \else
1275: {#1.\pdfimgext}%
1276: \fi
1277: \ifnum\pdftexversion < 14 \else
1278: \pdfrefximage \pdflastximage
1279: \fi}
1280: %
1281: \def\setpdfdestname#1{{%
1282: % We have to set dummies so commands such as @code, and characters
1283: % such as \, aren't expanded when present in a section title.
1284: \indexnofonts
1285: \makevalueexpandable
1286: \turnoffactive
1287: \iftxiuseunicodedestname
1288: \ifx \declaredencoding \latone
1289: % Pass through Latin-1 characters.
1290: % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1291: \else
1292: \ifx \declaredencoding \utfeight
1293: % Pass through Unicode characters.
1294: \else
1295: % Use ASCII approximations in destination names.
1296: \passthroughcharsfalse
1297: \fi
1298: \fi
1299: \else
1300: % Use ASCII approximations in destination names.
1301: \passthroughcharsfalse
1302: \fi
1303: \def\pdfdestname{#1}%
1304: \txiescapepdf\pdfdestname
1305: }}
1306: %
1307: \def\setpdfoutlinetext#1{{%
1308: \indexnofonts
1309: \makevalueexpandable
1310: \turnoffactive
1311: \ifx \declaredencoding \latone
1312: % The PDF format can use an extended form of Latin-1 in bookmark
1313: % strings. See Appendix D of the PDF Reference, Sixth Edition, for
1314: % the "PDFDocEncoding".
1315: \passthroughcharstrue
1316: % Pass through Latin-1 characters.
1317: % LuaTeX: Convert to Unicode
1318: % pdfTeX: Use Latin-1 as PDFDocEncoding
1319: \def\pdfoutlinetext{#1}%
1320: \else
1321: \ifx \declaredencoding \utfeight
1322: \ifx\luatexversion\thisisundefined
1323: % For pdfTeX with UTF-8.
1324: % TODO: the PDF format can use UTF-16 in bookmark strings,
1325: % but the code for this isn't done yet.
1326: % Use ASCII approximations.
1327: \passthroughcharsfalse
1328: \def\pdfoutlinetext{#1}%
1329: \else
1330: % For LuaTeX with UTF-8.
1331: % Pass through Unicode characters for title texts.
1332: \passthroughcharstrue
1333: \def\pdfoutlinetext{#1}%
1334: \fi
1335: \else
1336: % For non-Latin-1 or non-UTF-8 encodings.
1337: % Use ASCII approximations.
1338: \passthroughcharsfalse
1339: \def\pdfoutlinetext{#1}%
1340: \fi
1341: \fi
1342: % LuaTeX: Convert to UTF-16
1343: % pdfTeX: Use Latin-1 as PDFDocEncoding
1344: \txiescapepdfutfsixteen\pdfoutlinetext
1345: }}
1346: %
1347: \def\pdfmkdest#1{%
1348: \setpdfdestname{#1}%
1349: \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1350: }
1351: %
1352: % used to mark target names; must be expandable.
1353: \def\pdfmkpgn#1{#1}
1354: %
1355: % by default, use black for everything.
1356: \def\urlcolor{\rgbBlack}
1.5 ! snw 1357: \def\linkcolor{\rgbBlack}
1.1 snw 1358: \def\endlink{\setcolor{\maincolor}\pdfendlink}
1359: %
1360: % Adding outlines to PDF; macros for calculating structure of outlines
1361: % come from Petr Olsak
1362: \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1363: \else \csname#1\endcsname \fi}
1364: \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1365: \advance\tempnum by 1
1366: \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1367: %
1368: % #1 is the section text, which is what will be displayed in the
1369: % outline by the pdf viewer. #2 is the pdf expression for the number
1370: % of subentries (or empty, for subsubsections). #3 is the node text,
1371: % which might be empty if this toc entry had no corresponding node.
1372: % #4 is the page number
1373: %
1374: \def\dopdfoutline#1#2#3#4{%
1375: % Generate a link to the node text if that exists; else, use the
1376: % page number. We could generate a destination for the section
1377: % text in the case where a section has no node, but it doesn't
1378: % seem worth the trouble, since most documents are normally structured.
1379: \setpdfoutlinetext{#1}
1380: \setpdfdestname{#3}
1381: \ifx\pdfdestname\empty
1382: \def\pdfdestname{#4}%
1383: \fi
1384: %
1385: \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1386: }
1387: %
1388: \def\pdfmakeoutlines{%
1389: \begingroup
1390: % Read toc silently, to get counts of subentries for \pdfoutline.
1391: \def\partentry##1##2##3##4{}% ignore parts in the outlines
1392: \def\numchapentry##1##2##3##4{%
1393: \def\thischapnum{##2}%
1394: \def\thissecnum{0}%
1395: \def\thissubsecnum{0}%
1396: }%
1397: \def\numsecentry##1##2##3##4{%
1398: \advancenumber{chap\thischapnum}%
1399: \def\thissecnum{##2}%
1400: \def\thissubsecnum{0}%
1401: }%
1402: \def\numsubsecentry##1##2##3##4{%
1403: \advancenumber{sec\thissecnum}%
1404: \def\thissubsecnum{##2}%
1405: }%
1406: \def\numsubsubsecentry##1##2##3##4{%
1407: \advancenumber{subsec\thissubsecnum}%
1408: }%
1409: \def\thischapnum{0}%
1410: \def\thissecnum{0}%
1411: \def\thissubsecnum{0}%
1412: %
1413: % use \def rather than \let here because we redefine \chapentry et
1414: % al. a second time, below.
1415: \def\appentry{\numchapentry}%
1416: \def\appsecentry{\numsecentry}%
1417: \def\appsubsecentry{\numsubsecentry}%
1418: \def\appsubsubsecentry{\numsubsubsecentry}%
1419: \def\unnchapentry{\numchapentry}%
1420: \def\unnsecentry{\numsecentry}%
1421: \def\unnsubsecentry{\numsubsecentry}%
1422: \def\unnsubsubsecentry{\numsubsubsecentry}%
1423: \readdatafile{toc}%
1424: %
1425: % Read toc second time, this time actually producing the outlines.
1426: % The `-' means take the \expnumber as the absolute number of
1427: % subentries, which we calculated on our first read of the .toc above.
1428: %
1429: % We use the node names as the destinations.
1430: \def\numchapentry##1##2##3##4{%
1431: \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1432: \def\numsecentry##1##2##3##4{%
1433: \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1434: \def\numsubsecentry##1##2##3##4{%
1435: \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1436: \def\numsubsubsecentry##1##2##3##4{% count is always zero
1437: \dopdfoutline{##1}{}{##3}{##4}}%
1438: %
1439: % PDF outlines are displayed using system fonts, instead of
1440: % document fonts. Therefore we cannot use special characters,
1441: % since the encoding is unknown. For example, the eogonek from
1442: % Latin 2 (0xea) gets translated to a | character. Info from
1443: % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1444: %
1445: % TODO this right, we have to translate 8-bit characters to
1446: % their "best" equivalent, based on the @documentencoding. Too
1447: % much work for too little return. Just use the ASCII equivalents
1448: % we use for the index sort strings.
1449: %
1450: \indexnofonts
1451: \setupdatafile
1452: % We can have normal brace characters in the PDF outlines, unlike
1453: % Texinfo index files. So set that up.
1454: \def\{{\lbracecharliteral}%
1455: \def\}{\rbracecharliteral}%
1456: \catcode`\\=\active \otherbackslash
1457: \input \tocreadfilename
1458: \endgroup
1459: }
1460: {\catcode`[=1 \catcode`]=2
1461: \catcode`{=\other \catcode`}=\other
1462: \gdef\lbracecharliteral[{]%
1463: \gdef\rbracecharliteral[}]%
1464: ]
1465: %
1466: \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1467: \ifx\PP\D\let\nextsp\relax
1468: \else\let\nextsp\skipspaces
1469: \addtokens{\filename}{\PP}%
1470: \advance\filenamelength by 1
1471: \fi
1472: \nextsp}
1473: \def\getfilename#1{%
1474: \filenamelength=0
1475: % If we don't expand the argument now, \skipspaces will get
1476: % snagged on things like "@value{foo}".
1477: \edef\temp{#1}%
1478: \expandafter\skipspaces\temp|\relax
1479: }
1480: \ifnum\pdftexversion < 14
1481: \let \startlink \pdfannotlink
1482: \else
1483: \let \startlink \pdfstartlink
1484: \fi
1485: % make a live url in pdf output.
1486: \def\pdfurl#1{%
1487: \begingroup
1488: % it seems we really need yet another set of dummies; have not
1489: % tried to figure out what each command should do in the context
1490: % of @url. for now, just make @/ a no-op, that's the only one
1491: % people have actually reported a problem with.
1492: %
1493: \normalturnoffactive
1494: \def\@{@}%
1495: \let\/=\empty
1496: \makevalueexpandable
1497: % do we want to go so far as to use \indexnofonts instead of just
1498: % special-casing \var here?
1499: \def\var##1{##1}%
1500: %
1501: \leavevmode\setcolor{\urlcolor}%
1502: \startlink attr{/Border [0 0 0]}%
1503: user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1504: \endgroup}
1505: % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may
1506: % be a simple number, or a list of numbers in the case of an index
1507: % entry.
1508: \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1509: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1510: \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1511: \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1512: \def\maketoks{%
1513: \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1514: \ifx\first0\adn0
1515: \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1516: \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1517: \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1518: \else
1519: \ifnum0=\countA\else\makelink\fi
1520: \ifx\first.\let\next=\done\else
1521: \let\next=\maketoks
1522: \addtokens{\toksB}{\the\toksD}
1523: \ifx\first,\addtokens{\toksB}{\space}\fi
1524: \fi
1525: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1526: \next}
1527: \def\makelink{\addtokens{\toksB}%
1528: {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1.5 ! snw 1529: \def\pdflink#1{%
1.1 snw 1530: \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1.5 ! snw 1531: \setcolor{\linkcolor}#1\endlink}
1.1 snw 1532: \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1533: \else
1534: % non-pdf mode
1535: \let\pdfmkdest = \gobble
1536: \let\pdfurl = \gobble
1537: \let\endlink = \relax
1538: \let\setcolor = \gobble
1539: \let\pdfsetcolor = \gobble
1540: \let\pdfmakeoutlines = \relax
1541: \fi % \ifx\pdfoutput
1542:
1543: %
1544: % For XeTeX
1545: %
1546: \ifx\XeTeXrevision\thisisundefined
1547: \else
1548: %
1549: % XeTeX version check
1550: %
1551: \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1552: % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1553: % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1554: % For avoiding PDF destination name replacement, we use this special
1555: % instead of xdvipdfmx's command line option `-C 0x0010'.
1556: \special{dvipdfmx:config C 0x0010}
1557: % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1558: % It can handle Unicode destination names for PDF.
1559: \txiuseunicodedestnametrue
1560: \else
1561: % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1562: % `dvipdfmx:config' special.
1563: % So for avoiding PDF destination name replacement,
1564: % xdvipdfmx's command line option `-C 0x0010' is necessary.
1565: %
1566: % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1567: % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1568: % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1569: \txiuseunicodedestnamefalse
1570: \fi
1571: %
1572: % Color support
1573: %
1574: \def\rgbDarkRed{0.50 0.09 0.12}
1575: \def\rgbBlack{0 0 0}
1576: %
1577: \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1578: %
1579: % Set color, and create a mark which defines \thiscolor accordingly,
1580: % so that \makeheadline knows which color to restore.
1581: \def\setcolor#1{%
1582: \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1583: \domark
1584: \pdfsetcolor{#1}%
1585: }
1586: %
1587: \def\maincolor{\rgbBlack}
1588: \pdfsetcolor{\maincolor}
1589: \edef\thiscolor{\maincolor}
1590: \def\currentcolordefs{}
1591: %
1592: \def\makefootline{%
1593: \baselineskip24pt
1594: \line{\pdfsetcolor{\maincolor}\the\footline}%
1595: }
1596: %
1597: \def\makeheadline{%
1598: \vbox to 0pt{%
1599: \vskip-22.5pt
1600: \line{%
1601: \vbox to8.5pt{}%
1602: % Extract \thiscolor definition from the marks.
1603: \getcolormarks
1604: % Typeset the headline with \maincolor, then restore the color.
1605: \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1606: }%
1607: \vss
1608: }%
1609: \nointerlineskip
1610: }
1611: %
1612: % PDF outline support
1613: %
1614: % Emulate pdfTeX primitive
1615: \def\pdfdest name#1 xyz{%
1616: \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1617: }
1618: %
1619: \def\setpdfdestname#1{{%
1620: % We have to set dummies so commands such as @code, and characters
1621: % such as \, aren't expanded when present in a section title.
1622: \indexnofonts
1623: \makevalueexpandable
1624: \turnoffactive
1625: \iftxiuseunicodedestname
1626: % Pass through Unicode characters.
1627: \else
1628: % Use ASCII approximations in destination names.
1629: \passthroughcharsfalse
1630: \fi
1631: \def\pdfdestname{#1}%
1632: \txiescapepdf\pdfdestname
1633: }}
1634: %
1635: \def\setpdfoutlinetext#1{{%
1636: \turnoffactive
1637: % Always use Unicode characters in title texts.
1638: \def\pdfoutlinetext{#1}%
1639: % For XeTeX, xdvipdfmx converts to UTF-16.
1640: % So we do not convert.
1641: \txiescapepdf\pdfoutlinetext
1642: }}
1643: %
1644: \def\pdfmkdest#1{%
1645: \setpdfdestname{#1}%
1646: \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1647: }
1648: %
1649: % by default, use black for everything.
1650: \def\urlcolor{\rgbBlack}
1651: \def\linkcolor{\rgbBlack}
1652: \def\endlink{\setcolor{\maincolor}\pdfendlink}
1653: %
1654: \def\dopdfoutline#1#2#3#4{%
1655: \setpdfoutlinetext{#1}
1656: \setpdfdestname{#3}
1657: \ifx\pdfdestname\empty
1658: \def\pdfdestname{#4}%
1659: \fi
1660: %
1661: \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1662: << /S /GoTo /D (\pdfdestname) >> >> }%
1663: }
1664: %
1665: \def\pdfmakeoutlines{%
1666: \begingroup
1667: %
1668: % For XeTeX, counts of subentries are not necessary.
1669: % Therefore, we read toc only once.
1670: %
1671: % We use node names as destinations.
1672: \def\partentry##1##2##3##4{}% ignore parts in the outlines
1673: \def\numchapentry##1##2##3##4{%
1.5 ! snw 1674: \dopdfoutline{##1}{1}{##3}{##4}}%
1.1 snw 1675: \def\numsecentry##1##2##3##4{%
1676: \dopdfoutline{##1}{2}{##3}{##4}}%
1677: \def\numsubsecentry##1##2##3##4{%
1678: \dopdfoutline{##1}{3}{##3}{##4}}%
1679: \def\numsubsubsecentry##1##2##3##4{%
1680: \dopdfoutline{##1}{4}{##3}{##4}}%
1681: %
1682: \let\appentry\numchapentry%
1683: \let\appsecentry\numsecentry%
1684: \let\appsubsecentry\numsubsecentry%
1685: \let\appsubsubsecentry\numsubsubsecentry%
1.5 ! snw 1686: \let\unnchapentry\numchapentry%
1.1 snw 1687: \let\unnsecentry\numsecentry%
1688: \let\unnsubsecentry\numsubsecentry%
1689: \let\unnsubsubsecentry\numsubsubsecentry%
1690: %
1691: % For XeTeX, xdvipdfmx converts strings to UTF-16.
1692: % Therefore, the encoding and the language may not be considered.
1693: %
1694: \indexnofonts
1695: \setupdatafile
1696: % We can have normal brace characters in the PDF outlines, unlike
1697: % Texinfo index files. So set that up.
1698: \def\{{\lbracecharliteral}%
1699: \def\}{\rbracecharliteral}%
1700: \catcode`\\=\active \otherbackslash
1701: \input \tocreadfilename
1702: \endgroup
1703: }
1704: {\catcode`[=1 \catcode`]=2
1705: \catcode`{=\other \catcode`}=\other
1706: \gdef\lbracecharliteral[{]%
1707: \gdef\rbracecharliteral[}]%
1708: ]
1709:
1710: \special{pdf:docview << /PageMode /UseOutlines >> }
1711: % ``\special{pdf:tounicode ...}'' is not necessary
1712: % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1713: % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1714: % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1715: % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1716: %
1717: \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1718: \ifx\PP\D\let\nextsp\relax
1719: \else\let\nextsp\skipspaces
1720: \addtokens{\filename}{\PP}%
1721: \advance\filenamelength by 1
1722: \fi
1723: \nextsp}
1724: \def\getfilename#1{%
1725: \filenamelength=0
1726: % If we don't expand the argument now, \skipspaces will get
1727: % snagged on things like "@value{foo}".
1728: \edef\temp{#1}%
1729: \expandafter\skipspaces\temp|\relax
1730: }
1731: % make a live url in pdf output.
1732: \def\pdfurl#1{%
1733: \begingroup
1734: % it seems we really need yet another set of dummies; have not
1735: % tried to figure out what each command should do in the context
1736: % of @url. for now, just make @/ a no-op, that's the only one
1737: % people have actually reported a problem with.
1738: %
1739: \normalturnoffactive
1740: \def\@{@}%
1741: \let\/=\empty
1742: \makevalueexpandable
1743: % do we want to go so far as to use \indexnofonts instead of just
1744: % special-casing \var here?
1745: \def\var##1{##1}%
1746: %
1747: \leavevmode\setcolor{\urlcolor}%
1748: \special{pdf:bann << /Border [0 0 0]
1749: /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1750: \endgroup}
1751: \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1752: \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1753: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1754: \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1755: \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1756: \def\maketoks{%
1757: \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1758: \ifx\first0\adn0
1759: \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1760: \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1761: \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1762: \else
1763: \ifnum0=\countA\else\makelink\fi
1764: \ifx\first.\let\next=\done\else
1765: \let\next=\maketoks
1766: \addtokens{\toksB}{\the\toksD}
1767: \ifx\first,\addtokens{\toksB}{\space}\fi
1768: \fi
1769: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1770: \next}
1771: \def\makelink{\addtokens{\toksB}%
1772: {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1.5 ! snw 1773: \def\pdflink#1{%
1.1 snw 1774: \special{pdf:bann << /Border [0 0 0]
1775: /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1.5 ! snw 1776: \setcolor{\linkcolor}#1\endlink}
1.1 snw 1777: \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1778: %
1779: %
1780: % @image support
1781: %
1782: % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1783: \def\doxeteximage#1#2#3{%
1784: \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1785: \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1786: %
1787: % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1788: % others). Let's try in that order, PDF first since if
1789: % someone has a scalable image, presumably better to use that than a
1790: % bitmap.
1791: \let\xeteximgext=\empty
1792: \begingroup
1793: \openin 1 #1.pdf \ifeof 1
1794: \openin 1 #1.PDF \ifeof 1
1795: \openin 1 #1.png \ifeof 1
1796: \openin 1 #1.jpg \ifeof 1
1797: \openin 1 #1.jpeg \ifeof 1
1798: \openin 1 #1.JPG \ifeof 1
1799: \errmessage{Could not find image file #1 for XeTeX}%
1800: \else \gdef\xeteximgext{JPG}%
1801: \fi
1802: \else \gdef\xeteximgext{jpeg}%
1803: \fi
1804: \else \gdef\xeteximgext{jpg}%
1805: \fi
1806: \else \gdef\xeteximgext{png}%
1807: \fi
1808: \else \gdef\xeteximgext{PDF}%
1809: \fi
1810: \else \gdef\xeteximgext{pdf}%
1811: \fi
1812: \closein 1
1813: \endgroup
1814: %
1.5 ! snw 1815: \def\xetexpdfext{pdf}%
! 1816: \ifx\xeteximgext\xetexpdfext
! 1817: \XeTeXpdffile "#1".\xeteximgext ""
! 1818: \else
! 1819: \def\xetexpdfext{PDF}%
1.1 snw 1820: \ifx\xeteximgext\xetexpdfext
1821: \XeTeXpdffile "#1".\xeteximgext ""
1822: \else
1.5 ! snw 1823: \XeTeXpicfile "#1".\xeteximgext ""
1.1 snw 1824: \fi
1.5 ! snw 1825: \fi
! 1826: \ifdim \wd0 >0pt width \xeteximagewidth \fi
! 1827: \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1.1 snw 1828: }
1829: \fi
1830:
1831:
1832: %
1833: \message{fonts,}
1834:
1835: % Set the baselineskip to #1, and the lineskip and strut size
1836: % correspondingly. There is no deep meaning behind these magic numbers
1837: % used as factors; they just match (closely enough) what Knuth defined.
1838: %
1839: \def\lineskipfactor{.08333}
1840: \def\strutheightpercent{.70833}
1841: \def\strutdepthpercent {.29167}
1842: %
1843: % can get a sort of poor man's double spacing by redefining this.
1844: \def\baselinefactor{1}
1845: %
1846: \newdimen\textleading
1847: \def\setleading#1{%
1848: \dimen0 = #1\relax
1849: \normalbaselineskip = \baselinefactor\dimen0
1850: \normallineskip = \lineskipfactor\normalbaselineskip
1851: \normalbaselines
1852: \setbox\strutbox =\hbox{%
1853: \vrule width0pt height\strutheightpercent\baselineskip
1854: depth \strutdepthpercent \baselineskip
1855: }%
1856: }
1857:
1858: % PDF CMaps. See also LaTeX's t1.cmap.
1859: %
1860: % do nothing with this by default.
1861: \expandafter\let\csname cmapOT1\endcsname\gobble
1862: \expandafter\let\csname cmapOT1IT\endcsname\gobble
1863: \expandafter\let\csname cmapOT1TT\endcsname\gobble
1864:
1865: % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1866: % (\pdffontattr was introduced many years ago, but people still run
1867: % older pdftex's; it's easy to conditionalize, so we do.)
1868: \ifpdf \ifx\pdffontattr\thisisundefined \else
1869: \begingroup
1870: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1871: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1872: %%DocumentNeededResources: ProcSet (CIDInit)
1873: %%IncludeResource: ProcSet (CIDInit)
1874: %%BeginResource: CMap (TeX-OT1-0)
1875: %%Title: (TeX-OT1-0 TeX OT1 0)
1876: %%Version: 1.000
1877: %%EndComments
1878: /CIDInit /ProcSet findresource begin
1879: 12 dict begin
1880: begincmap
1881: /CIDSystemInfo
1882: << /Registry (TeX)
1883: /Ordering (OT1)
1884: /Supplement 0
1885: >> def
1886: /CMapName /TeX-OT1-0 def
1887: /CMapType 2 def
1888: 1 begincodespacerange
1889: <00> <7F>
1890: endcodespacerange
1891: 8 beginbfrange
1892: <00> <01> <0393>
1893: <09> <0A> <03A8>
1894: <23> <26> <0023>
1895: <28> <3B> <0028>
1896: <3F> <5B> <003F>
1897: <5D> <5E> <005D>
1898: <61> <7A> <0061>
1899: <7B> <7C> <2013>
1900: endbfrange
1901: 40 beginbfchar
1902: <02> <0398>
1903: <03> <039B>
1904: <04> <039E>
1905: <05> <03A0>
1906: <06> <03A3>
1907: <07> <03D2>
1908: <08> <03A6>
1909: <0B> <00660066>
1910: <0C> <00660069>
1911: <0D> <0066006C>
1912: <0E> <006600660069>
1913: <0F> <00660066006C>
1914: <10> <0131>
1915: <11> <0237>
1916: <12> <0060>
1917: <13> <00B4>
1918: <14> <02C7>
1919: <15> <02D8>
1920: <16> <00AF>
1921: <17> <02DA>
1922: <18> <00B8>
1923: <19> <00DF>
1924: <1A> <00E6>
1925: <1B> <0153>
1926: <1C> <00F8>
1927: <1D> <00C6>
1928: <1E> <0152>
1929: <1F> <00D8>
1930: <21> <0021>
1931: <22> <201D>
1932: <27> <2019>
1933: <3C> <00A1>
1934: <3D> <003D>
1935: <3E> <00BF>
1936: <5C> <201C>
1937: <5F> <02D9>
1938: <60> <2018>
1939: <7D> <02DD>
1940: <7E> <007E>
1941: <7F> <00A8>
1942: endbfchar
1943: endcmap
1944: CMapName currentdict /CMap defineresource pop
1945: end
1946: end
1947: %%EndResource
1948: %%EOF
1949: }\endgroup
1950: \expandafter\edef\csname cmapOT1\endcsname#1{%
1951: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1952: }%
1953: %
1954: % \cmapOT1IT
1955: \begingroup
1956: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1957: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1958: %%DocumentNeededResources: ProcSet (CIDInit)
1959: %%IncludeResource: ProcSet (CIDInit)
1960: %%BeginResource: CMap (TeX-OT1IT-0)
1961: %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1962: %%Version: 1.000
1963: %%EndComments
1964: /CIDInit /ProcSet findresource begin
1965: 12 dict begin
1966: begincmap
1967: /CIDSystemInfo
1968: << /Registry (TeX)
1969: /Ordering (OT1IT)
1970: /Supplement 0
1971: >> def
1972: /CMapName /TeX-OT1IT-0 def
1973: /CMapType 2 def
1974: 1 begincodespacerange
1975: <00> <7F>
1976: endcodespacerange
1977: 8 beginbfrange
1978: <00> <01> <0393>
1979: <09> <0A> <03A8>
1980: <25> <26> <0025>
1981: <28> <3B> <0028>
1982: <3F> <5B> <003F>
1983: <5D> <5E> <005D>
1984: <61> <7A> <0061>
1985: <7B> <7C> <2013>
1986: endbfrange
1987: 42 beginbfchar
1988: <02> <0398>
1989: <03> <039B>
1990: <04> <039E>
1991: <05> <03A0>
1992: <06> <03A3>
1993: <07> <03D2>
1994: <08> <03A6>
1995: <0B> <00660066>
1996: <0C> <00660069>
1997: <0D> <0066006C>
1998: <0E> <006600660069>
1999: <0F> <00660066006C>
2000: <10> <0131>
2001: <11> <0237>
2002: <12> <0060>
2003: <13> <00B4>
2004: <14> <02C7>
2005: <15> <02D8>
2006: <16> <00AF>
2007: <17> <02DA>
2008: <18> <00B8>
2009: <19> <00DF>
2010: <1A> <00E6>
2011: <1B> <0153>
2012: <1C> <00F8>
2013: <1D> <00C6>
2014: <1E> <0152>
2015: <1F> <00D8>
2016: <21> <0021>
2017: <22> <201D>
2018: <23> <0023>
2019: <24> <00A3>
2020: <27> <2019>
2021: <3C> <00A1>
2022: <3D> <003D>
2023: <3E> <00BF>
2024: <5C> <201C>
2025: <5F> <02D9>
2026: <60> <2018>
2027: <7D> <02DD>
2028: <7E> <007E>
2029: <7F> <00A8>
2030: endbfchar
2031: endcmap
2032: CMapName currentdict /CMap defineresource pop
2033: end
2034: end
2035: %%EndResource
2036: %%EOF
2037: }\endgroup
2038: \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2039: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2040: }%
2041: %
2042: % \cmapOT1TT
2043: \begingroup
2044: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2045: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2046: %%DocumentNeededResources: ProcSet (CIDInit)
2047: %%IncludeResource: ProcSet (CIDInit)
2048: %%BeginResource: CMap (TeX-OT1TT-0)
2049: %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2050: %%Version: 1.000
2051: %%EndComments
2052: /CIDInit /ProcSet findresource begin
2053: 12 dict begin
2054: begincmap
2055: /CIDSystemInfo
2056: << /Registry (TeX)
2057: /Ordering (OT1TT)
2058: /Supplement 0
2059: >> def
2060: /CMapName /TeX-OT1TT-0 def
2061: /CMapType 2 def
2062: 1 begincodespacerange
2063: <00> <7F>
2064: endcodespacerange
2065: 5 beginbfrange
2066: <00> <01> <0393>
2067: <09> <0A> <03A8>
2068: <21> <26> <0021>
2069: <28> <5F> <0028>
2070: <61> <7E> <0061>
2071: endbfrange
2072: 32 beginbfchar
2073: <02> <0398>
2074: <03> <039B>
2075: <04> <039E>
2076: <05> <03A0>
2077: <06> <03A3>
2078: <07> <03D2>
2079: <08> <03A6>
2080: <0B> <2191>
2081: <0C> <2193>
2082: <0D> <0027>
2083: <0E> <00A1>
2084: <0F> <00BF>
2085: <10> <0131>
2086: <11> <0237>
2087: <12> <0060>
2088: <13> <00B4>
2089: <14> <02C7>
2090: <15> <02D8>
2091: <16> <00AF>
2092: <17> <02DA>
2093: <18> <00B8>
2094: <19> <00DF>
2095: <1A> <00E6>
2096: <1B> <0153>
2097: <1C> <00F8>
2098: <1D> <00C6>
2099: <1E> <0152>
2100: <1F> <00D8>
2101: <20> <2423>
2102: <27> <2019>
2103: <60> <2018>
2104: <7F> <00A8>
2105: endbfchar
2106: endcmap
2107: CMapName currentdict /CMap defineresource pop
2108: end
2109: end
2110: %%EndResource
2111: %%EOF
2112: }\endgroup
2113: \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2114: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2115: }%
2116: \fi\fi
2117:
2118:
2119: % Set the font macro #1 to the font named \fontprefix#2.
2120: % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2121: % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2122: % Example:
2123: % #1 = \textrm
2124: % #2 = \rmshape
2125: % #3 = 10
2126: % #4 = \mainmagstep
2127: % #5 = OT1
2128: %
2129: \def\setfont#1#2#3#4#5{%
2130: \font#1=\fontprefix#2#3 scaled #4
2131: \csname cmap#5\endcsname#1%
2132: }
1.5 ! snw 2133: % This is what gets called when #5 of \setfont is empty.
! 2134: \let\cmap\gobble
! 2135: %
! 2136: % (end of cmaps)
1.1 snw 2137:
2138: % Use cm as the default font prefix.
2139: % To specify the font prefix, you must define \fontprefix
2140: % before you read in texinfo.tex.
2141: \ifx\fontprefix\thisisundefined
2142: \def\fontprefix{cm}
2143: \fi
2144: % Support font families that don't use the same naming scheme as CM.
2145: \def\rmshape{r}
2146: \def\rmbshape{bx} % where the normal face is bold
2147: \def\bfshape{b}
2148: \def\bxshape{bx}
2149: \def\ttshape{tt}
2150: \def\ttbshape{tt}
2151: \def\ttslshape{sltt}
2152: \def\itshape{ti}
2153: \def\itbshape{bxti}
2154: \def\slshape{sl}
2155: \def\slbshape{bxsl}
2156: \def\sfshape{ss}
2157: \def\sfbshape{ss}
2158: \def\scshape{csc}
2159: \def\scbshape{csc}
2160:
2161: % Definitions for a main text size of 11pt. (The default in Texinfo.)
2162: %
2163: \def\definetextfontsizexi{%
2164: % Text fonts (11.2pt, magstep1).
2165: \def\textnominalsize{11pt}
2166: \edef\mainmagstep{\magstephalf}
2167: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2168: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2169: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2170: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2171: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2172: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2173: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2174: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2175: \font\texti=cmmi10 scaled \mainmagstep
2176: \font\textsy=cmsy10 scaled \mainmagstep
2177: \def\textecsize{1095}
2178:
2179: % A few fonts for @defun names and args.
2180: \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2181: \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2182: \setfont\defsl\slshape{10}{\magstep1}{OT1}
2183: \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2184: \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2185: \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2186:
2187: % Fonts for indices, footnotes, small examples (9pt).
2188: \def\smallnominalsize{9pt}
2189: \setfont\smallrm\rmshape{9}{1000}{OT1}
2190: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2191: \setfont\smallbf\bfshape{10}{900}{OT1}
2192: \setfont\smallit\itshape{9}{1000}{OT1IT}
2193: \setfont\smallsl\slshape{9}{1000}{OT1}
2194: \setfont\smallsf\sfshape{9}{1000}{OT1}
2195: \setfont\smallsc\scshape{10}{900}{OT1}
2196: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2197: \font\smalli=cmmi9
2198: \font\smallsy=cmsy9
2199: \def\smallecsize{0900}
2200:
2201: % Fonts for small examples (8pt).
2202: \def\smallernominalsize{8pt}
2203: \setfont\smallerrm\rmshape{8}{1000}{OT1}
2204: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2205: \setfont\smallerbf\bfshape{10}{800}{OT1}
2206: \setfont\smallerit\itshape{8}{1000}{OT1IT}
2207: \setfont\smallersl\slshape{8}{1000}{OT1}
2208: \setfont\smallersf\sfshape{8}{1000}{OT1}
2209: \setfont\smallersc\scshape{10}{800}{OT1}
2210: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2211: \font\smalleri=cmmi8
2212: \font\smallersy=cmsy8
2213: \def\smallerecsize{0800}
2214:
2215: % Fonts for math mode superscripts (7pt).
2216: \def\sevennominalsize{7pt}
2217: \setfont\sevenrm\rmshape{7}{1000}{OT1}
2218: \setfont\seventt\ttshape{10}{700}{OT1TT}
2219: \setfont\sevenbf\bfshape{10}{700}{OT1}
2220: \setfont\sevenit\itshape{7}{1000}{OT1IT}
2221: \setfont\sevensl\slshape{10}{700}{OT1}
2222: \setfont\sevensf\sfshape{10}{700}{OT1}
2223: \setfont\sevensc\scshape{10}{700}{OT1}
2224: \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2225: \font\seveni=cmmi7
2226: \font\sevensy=cmsy7
2227: \def\sevenecsize{0700}
2228:
2229: % Fonts for title page (20.4pt):
2230: \def\titlenominalsize{20pt}
2231: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2232: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2233: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2234: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2235: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2236: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2237: \let\titlebf=\titlerm
2238: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2239: \font\titlei=cmmi12 scaled \magstep3
2240: \font\titlesy=cmsy10 scaled \magstep4
2241: \def\titleecsize{2074}
2242:
2243: % Chapter (and unnumbered) fonts (17.28pt).
2244: \def\chapnominalsize{17pt}
2245: \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2246: \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2247: \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2248: \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2249: \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2250: \setfont\chapsf\sfbshape{17}{1000}{OT1}
2251: \let\chapbf=\chaprm
2252: \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2253: \font\chapi=cmmi12 scaled \magstep2
2254: \font\chapsy=cmsy10 scaled \magstep3
2255: \def\chapecsize{1728}
2256:
2257: % Section fonts (14.4pt).
2258: \def\secnominalsize{14pt}
2259: \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2260: \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2261: \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2262: \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2263: \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2264: \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2265: \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2266: \let\secbf\secrm
2267: \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2268: \font\seci=cmmi12 scaled \magstep1
2269: \font\secsy=cmsy10 scaled \magstep2
2270: \def\sececsize{1440}
2271:
2272: % Subsection fonts (13.15pt).
2273: \def\ssecnominalsize{13pt}
2274: \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2275: \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2276: \setfont\ssecsl\slbshape{10}{1315}{OT1}
2277: \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2278: \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2279: \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2280: \let\ssecbf\ssecrm
2281: \setfont\ssecsc\scbshape{10}{1315}{OT1}
2282: \font\sseci=cmmi12 scaled \magstephalf
2283: \font\ssecsy=cmsy10 scaled 1315
2284: \def\ssececsize{1200}
2285:
2286: % Reduced fonts for @acronym in text (10pt).
2287: \def\reducednominalsize{10pt}
2288: \setfont\reducedrm\rmshape{10}{1000}{OT1}
2289: \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2290: \setfont\reducedbf\bfshape{10}{1000}{OT1}
2291: \setfont\reducedit\itshape{10}{1000}{OT1IT}
2292: \setfont\reducedsl\slshape{10}{1000}{OT1}
2293: \setfont\reducedsf\sfshape{10}{1000}{OT1}
2294: \setfont\reducedsc\scshape{10}{1000}{OT1}
2295: \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2296: \font\reducedi=cmmi10
2297: \font\reducedsy=cmsy10
2298: \def\reducedecsize{1000}
2299:
2300: \textleading = 13.2pt % line spacing for 11pt CM
2301: \textfonts % reset the current fonts
2302: \rm
2303: } % end of 11pt text font size definitions, \definetextfontsizexi
2304:
2305:
2306: % Definitions to make the main text be 10pt Computer Modern, with
2307: % section, chapter, etc., sizes following suit. This is for the GNU
2308: % Press printing of the Emacs 22 manual. Maybe other manuals in the
2309: % future. Used with @smallbook, which sets the leading to 12pt.
2310: %
2311: \def\definetextfontsizex{%
2312: % Text fonts (10pt).
2313: \def\textnominalsize{10pt}
2314: \edef\mainmagstep{1000}
2315: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2316: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2317: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2318: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2319: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2320: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2321: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2322: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2323: \font\texti=cmmi10 scaled \mainmagstep
2324: \font\textsy=cmsy10 scaled \mainmagstep
2325: \def\textecsize{1000}
2326:
2327: % A few fonts for @defun names and args.
2328: \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2329: \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2330: \setfont\defsl\slshape{10}{\magstephalf}{OT1}
2331: \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2332: \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2333: \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2334:
2335: % Fonts for indices, footnotes, small examples (9pt).
2336: \def\smallnominalsize{9pt}
2337: \setfont\smallrm\rmshape{9}{1000}{OT1}
2338: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2339: \setfont\smallbf\bfshape{10}{900}{OT1}
2340: \setfont\smallit\itshape{9}{1000}{OT1IT}
2341: \setfont\smallsl\slshape{9}{1000}{OT1}
2342: \setfont\smallsf\sfshape{9}{1000}{OT1}
2343: \setfont\smallsc\scshape{10}{900}{OT1}
2344: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2345: \font\smalli=cmmi9
2346: \font\smallsy=cmsy9
2347: \def\smallecsize{0900}
2348:
2349: % Fonts for small examples (8pt).
2350: \def\smallernominalsize{8pt}
2351: \setfont\smallerrm\rmshape{8}{1000}{OT1}
2352: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2353: \setfont\smallerbf\bfshape{10}{800}{OT1}
2354: \setfont\smallerit\itshape{8}{1000}{OT1IT}
2355: \setfont\smallersl\slshape{8}{1000}{OT1}
2356: \setfont\smallersf\sfshape{8}{1000}{OT1}
2357: \setfont\smallersc\scshape{10}{800}{OT1}
2358: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2359: \font\smalleri=cmmi8
2360: \font\smallersy=cmsy8
2361: \def\smallerecsize{0800}
2362:
2363: % Fonts for math mode superscripts (7pt).
2364: \def\sevennominalsize{7pt}
2365: \setfont\sevenrm\rmshape{7}{1000}{OT1}
2366: \setfont\seventt\ttshape{10}{700}{OT1TT}
2367: \setfont\sevenbf\bfshape{10}{700}{OT1}
2368: \setfont\sevenit\itshape{7}{1000}{OT1IT}
2369: \setfont\sevensl\slshape{10}{700}{OT1}
2370: \setfont\sevensf\sfshape{10}{700}{OT1}
2371: \setfont\sevensc\scshape{10}{700}{OT1}
2372: \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2373: \font\seveni=cmmi7
2374: \font\sevensy=cmsy7
2375: \def\sevenecsize{0700}
2376:
2377: % Fonts for title page (20.4pt):
2378: \def\titlenominalsize{20pt}
2379: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2380: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2381: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2382: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2383: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2384: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2385: \let\titlebf=\titlerm
2386: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2387: \font\titlei=cmmi12 scaled \magstep3
2388: \font\titlesy=cmsy10 scaled \magstep4
2389: \def\titleecsize{2074}
2390:
2391: % Chapter fonts (14.4pt).
2392: \def\chapnominalsize{14pt}
2393: \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2394: \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2395: \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2396: \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2397: \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2398: \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2399: \let\chapbf\chaprm
2400: \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2401: \font\chapi=cmmi12 scaled \magstep1
2402: \font\chapsy=cmsy10 scaled \magstep2
2403: \def\chapecsize{1440}
2404:
2405: % Section fonts (12pt).
2406: \def\secnominalsize{12pt}
2407: \setfont\secrm\rmbshape{12}{1000}{OT1}
2408: \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2409: \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2410: \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2411: \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2412: \setfont\secsf\sfbshape{12}{1000}{OT1}
2413: \let\secbf\secrm
2414: \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2415: \font\seci=cmmi12
2416: \font\secsy=cmsy10 scaled \magstep1
2417: \def\sececsize{1200}
2418:
2419: % Subsection fonts (10pt).
2420: \def\ssecnominalsize{10pt}
2421: \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2422: \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2423: \setfont\ssecsl\slbshape{10}{1000}{OT1}
2424: \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2425: \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2426: \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2427: \let\ssecbf\ssecrm
2428: \setfont\ssecsc\scbshape{10}{1000}{OT1}
2429: \font\sseci=cmmi10
2430: \font\ssecsy=cmsy10
2431: \def\ssececsize{1000}
2432:
2433: % Reduced fonts for @acronym in text (9pt).
2434: \def\reducednominalsize{9pt}
2435: \setfont\reducedrm\rmshape{9}{1000}{OT1}
2436: \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2437: \setfont\reducedbf\bfshape{10}{900}{OT1}
2438: \setfont\reducedit\itshape{9}{1000}{OT1IT}
2439: \setfont\reducedsl\slshape{9}{1000}{OT1}
2440: \setfont\reducedsf\sfshape{9}{1000}{OT1}
2441: \setfont\reducedsc\scshape{10}{900}{OT1}
2442: \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2443: \font\reducedi=cmmi9
2444: \font\reducedsy=cmsy9
2445: \def\reducedecsize{0900}
2446:
2447: \divide\parskip by 2 % reduce space between paragraphs
2448: \textleading = 12pt % line spacing for 10pt CM
2449: \textfonts % reset the current fonts
2450: \rm
2451: } % end of 10pt text font size definitions, \definetextfontsizex
2452:
2453: % Fonts for short table of contents.
2454: \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2455: \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
2456: \setfont\shortcontsl\slshape{12}{1000}{OT1}
2457: \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2458:
2459:
2460: % We provide the user-level command
2461: % @fonttextsize 10
2462: % (or 11) to redefine the text font size. pt is assumed.
2463: %
2464: \def\xiword{11}
2465: \def\xword{10}
2466: \def\xwordpt{10pt}
2467: %
2468: \parseargdef\fonttextsize{%
2469: \def\textsizearg{#1}%
2470: %\wlog{doing @fonttextsize \textsizearg}%
2471: %
2472: % Set \globaldefs so that documents can use this inside @tex, since
2473: % makeinfo 4.8 does not support it, but we need it nonetheless.
2474: %
2475: \begingroup \globaldefs=1
2476: \ifx\textsizearg\xword \definetextfontsizex
2477: \else \ifx\textsizearg\xiword \definetextfontsizexi
2478: \else
2479: \errhelp=\EMsimple
2480: \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2481: \fi\fi
2482: \endgroup
2483: }
2484:
2485: %
2486: % Change the current font style to #1, remembering it in \curfontstyle.
2487: % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2488: % italics, not bold italics.
2489: %
2490: \def\setfontstyle#1{%
2491: \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2492: \csname #1font\endcsname % change the current font
2493: }
2494:
2495: \def\rm{\fam=0 \setfontstyle{rm}}
2496: \def\it{\fam=\itfam \setfontstyle{it}}
2497: \def\sl{\fam=\slfam \setfontstyle{sl}}
2498: \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1.4 snw 2499: \def\tt{\fam=\ttfam \setfontstyle{tt}}
1.1 snw 2500:
2501: % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2502: % So we set up a \sf.
2503: \newfam\sffam
2504: \def\sf{\fam=\sffam \setfontstyle{sf}}
2505:
2506: % We don't need math for this font style.
2507: \def\ttsl{\setfontstyle{ttsl}}
2508:
2509:
2510: % In order for the font changes to affect most math symbols and letters,
2511: % we have to define the \textfont of the standard families.
2512: % We don't bother to reset \scriptscriptfont; awaiting user need.
2513: %
2514: \def\resetmathfonts{%
2515: \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2516: \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2517: \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2518: %
2519: % Fonts for superscript. Note that the 7pt fonts are used regardless
2520: % of the current font size.
2521: \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2522: \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2523: \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2524: \scriptfont\sffam=\sevensf
2525: }
2526:
1.5 ! snw 2527: %
1.1 snw 2528:
1.5 ! snw 2529: % The font-changing commands (all called \...fonts) redefine the meanings
! 2530: % of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs
! 2531: % to also set the current \fam for math mode. Our \STYLE (e.g., \rm)
! 2532: % commands hardwire \STYLEfont to set the current font.
! 2533: %
! 2534: % The fonts used for \ifont are for "math italics" (\itfont is for italics
! 2535: % in regular text). \syfont is also used in math mode only.
! 2536: %
! 2537: % Each font-changing command also sets the names \lsize (one size lower)
! 2538: % and \lllsize (three sizes lower). These relative commands are used
! 2539: % in, e.g., the LaTeX logo and acronyms.
! 2540: %
! 2541: % This all needs generalizing, badly.
! 2542: %
1.1 snw 2543:
2544: \def\assignfonts#1{%
1.5 ! snw 2545: \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
! 2546: \expandafter\let\expandafter\itfont\csname #1it\endcsname
! 2547: \expandafter\let\expandafter\slfont\csname #1sl\endcsname
! 2548: \expandafter\let\expandafter\bffont\csname #1bf\endcsname
! 2549: \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
! 2550: \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
! 2551: \expandafter\let\expandafter\sffont \csname #1sf\endcsname
! 2552: \expandafter\let\expandafter\ifont \csname #1i\endcsname
! 2553: \expandafter\let\expandafter\syfont \csname #1sy\endcsname
! 2554: \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
1.1 snw 2555: }
2556:
2557: \newif\ifrmisbold
2558:
2559: % Select smaller font size with the current style. Used to change font size
2560: % in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for
2561: % normal roman text, also use bold fonts for roman text in the smaller size.
2562: \def\switchtolllsize{%
2563: \expandafter\assignfonts\expandafter{\lllsize}%
2564: \ifrmisbold
2565: \let\rmfont\bffont
2566: \fi
2567: \csname\curfontstyle\endcsname
2568: }%
2569:
2570: \def\switchtolsize{%
2571: \expandafter\assignfonts\expandafter{\lsize}%
2572: \ifrmisbold
2573: \let\rmfont\bffont
2574: \fi
2575: \csname\curfontstyle\endcsname
2576: }%
2577:
2578: \def\definefontsetatsize#1#2#3#4#5{%
2579: \expandafter\def\csname #1fonts\endcsname{%
2580: \def\curfontsize{#1}%
2581: \def\lsize{#2}\def\lllsize{#3}%
2582: \csname rmisbold#5\endcsname
1.5 ! snw 2583: \assignfonts{#1}%
1.1 snw 2584: \resetmathfonts
2585: \setleading{#4}%
2586: }}
2587:
2588: \definefontsetatsize{text} {reduced}{smaller}{\textleading}{false}
2589: \definefontsetatsize{title} {chap} {subsec} {27pt} {true}
2590: \definefontsetatsize{chap} {sec} {text} {19pt} {true}
2591: \definefontsetatsize{sec} {subsec} {reduced}{17pt} {true}
2592: \definefontsetatsize{ssec} {text} {small} {15pt} {true}
2593: \definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false}
2594: \definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false}
2595: \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2596:
2597: \def\titlefont#1{{\titlefonts\rm #1}}
2598: \let\subsecfonts = \ssecfonts
2599: \let\subsubsecfonts = \ssecfonts
2600:
2601: % Define these just so they can be easily changed for other fonts.
2602: \def\angleleft{$\langle$}
2603: \def\angleright{$\rangle$}
2604:
2605: % Set the fonts to use with the @small... environments.
2606: \let\smallexamplefonts = \smallfonts
2607:
2608: % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
2609: % can fit this many characters:
2610: % 8.5x11=86 smallbook=72 a4=90 a5=69
2611: % If we use \scriptfonts (8pt), then we can fit this many characters:
2612: % 8.5x11=90+ smallbook=80 a4=90+ a5=77
2613: % For me, subjectively, the few extra characters that fit aren't worth
2614: % the additional smallness of 8pt. So I'm making the default 9pt.
2615: %
2616: % By the way, for comparison, here's what fits with @example (10pt):
2617: % 8.5x11=71 smallbook=60 a4=75 a5=58
2618: % --karl, 24jan03.
2619:
2620: % Set up the default fonts, so we can use them for creating boxes.
2621: %
2622: \definetextfontsizexi
2623:
2624:
1.5 ! snw 2625: \message{markup,}
! 2626:
1.1 snw 2627: % Check if we are currently using a typewriter font. Since all the
2628: % Computer Modern typewriter fonts have zero interword stretch (and
2629: % shrink), and it is reasonable to expect all typewriter fonts to have
1.5 ! snw 2630: % this property, we can check that font parameter.
! 2631: %
! 2632: \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
! 2633:
! 2634: % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
! 2635: % define and register \INITMACRO to be called on markup style changes.
! 2636: % \INITMACRO can check \currentmarkupstyle for the innermost
! 2637: % style.
! 2638:
! 2639: \let\currentmarkupstyle\empty
! 2640:
! 2641: \def\setupmarkupstyle#1{%
! 2642: \def\currentmarkupstyle{#1}%
! 2643: \markupstylesetup
! 2644: }
! 2645:
! 2646: \let\markupstylesetup\empty
1.4 snw 2647:
1.5 ! snw 2648: \def\defmarkupstylesetup#1{%
! 2649: \expandafter\def\expandafter\markupstylesetup
! 2650: \expandafter{\markupstylesetup #1}%
! 2651: \def#1%
! 2652: }
1.4 snw 2653:
1.5 ! snw 2654: % Markup style setup for left and right quotes.
! 2655: \defmarkupstylesetup\markupsetuplq{%
! 2656: \expandafter\let\expandafter \temp
! 2657: \csname markupsetuplq\currentmarkupstyle\endcsname
! 2658: \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
! 2659: }
1.4 snw 2660:
1.5 ! snw 2661: \defmarkupstylesetup\markupsetuprq{%
! 2662: \expandafter\let\expandafter \temp
! 2663: \csname markupsetuprq\currentmarkupstyle\endcsname
! 2664: \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
1.4 snw 2665: }
1.1 snw 2666:
2667: {
2668: \catcode`\'=\active
2669: \catcode`\`=\active
2670:
1.5 ! snw 2671: \gdef\markupsetuplqdefault{\let`\lq}
! 2672: \gdef\markupsetuprqdefault{\let'\rq}
! 2673:
! 2674: \gdef\markupsetcodequoteleft{\let`\codequoteleft}
! 2675: \gdef\markupsetcodequoteright{\let'\codequoteright}
1.1 snw 2676: }
2677:
1.5 ! snw 2678: \let\markupsetuplqcode \markupsetcodequoteleft
! 2679: \let\markupsetuprqcode \markupsetcodequoteright
! 2680: %
! 2681: \let\markupsetuplqexample \markupsetcodequoteleft
! 2682: \let\markupsetuprqexample \markupsetcodequoteright
! 2683: %
! 2684: \let\markupsetuplqkbd \markupsetcodequoteleft
! 2685: \let\markupsetuprqkbd \markupsetcodequoteright
! 2686: %
! 2687: \let\markupsetuplqsamp \markupsetcodequoteleft
! 2688: \let\markupsetuprqsamp \markupsetcodequoteright
! 2689: %
! 2690: \let\markupsetuplqverb \markupsetcodequoteleft
! 2691: \let\markupsetuprqverb \markupsetcodequoteright
! 2692: %
! 2693: \let\markupsetuplqverbatim \markupsetcodequoteleft
! 2694: \let\markupsetuprqverbatim \markupsetcodequoteright
! 2695:
! 2696: % Allow an option to not use regular directed right quote/apostrophe
! 2697: % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
! 2698: % The undirected quote is ugly, so don't make it the default, but it
! 2699: % works for pasting with more pdf viewers (at least evince), the
! 2700: % lilypond developers report. xpdf does work with the regular 0x27.
1.1 snw 2701: %
2702: \def\codequoteright{%
1.5 ! snw 2703: \ifmonospace
! 2704: \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
! 2705: \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
! 2706: '%
! 2707: \else \char'15 \fi
! 2708: \else \char'15 \fi
! 2709: \else
! 2710: '%
! 2711: \fi
1.1 snw 2712: }
1.5 ! snw 2713: %
! 2714: % and a similar option for the left quote char vs. a grave accent.
! 2715: % Modern fonts display ASCII 0x60 as a grave accent, so some people like
! 2716: % the code environments to do likewise.
1.1 snw 2717: %
2718: \def\codequoteleft{%
1.5 ! snw 2719: \ifmonospace
! 2720: \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
! 2721: \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
! 2722: % [Knuth] pp. 380,381,391
! 2723: % \relax disables Spanish ligatures ?` and !` of \tt font.
! 2724: \relax`%
! 2725: \else \char'22 \fi
! 2726: \else \char'22 \fi
! 2727: \else
! 2728: \relax`%
! 2729: \fi
1.1 snw 2730: }
2731:
2732: % Commands to set the quote options.
2733: %
2734: \parseargdef\codequoteundirected{%
2735: \def\temp{#1}%
2736: \ifx\temp\onword
2737: \expandafter\let\csname SETtxicodequoteundirected\endcsname
2738: = t%
2739: \else\ifx\temp\offword
2740: \expandafter\let\csname SETtxicodequoteundirected\endcsname
2741: = \relax
2742: \else
2743: \errhelp = \EMsimple
2744: \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2745: \fi\fi
2746: }
1.5 ! snw 2747: %
1.1 snw 2748: \parseargdef\codequotebacktick{%
2749: \def\temp{#1}%
2750: \ifx\temp\onword
2751: \expandafter\let\csname SETtxicodequotebacktick\endcsname
2752: = t%
2753: \else\ifx\temp\offword
2754: \expandafter\let\csname SETtxicodequotebacktick\endcsname
2755: = \relax
2756: \else
2757: \errhelp = \EMsimple
2758: \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2759: \fi\fi
2760: }
2761:
2762: % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2763: \def\noligaturesquoteleft{\relax\lq}
2764:
2765: % Count depth in font-changes, for error checks
2766: \newcount\fontdepth \fontdepth=0
2767:
2768: % Font commands.
2769:
2770: % #1 is the font command (\sl or \it), #2 is the text to slant.
2771: % If we are in a monospaced environment, however, 1) always use \ttsl,
2772: % and 2) do not add an italic correction.
2773: \def\dosmartslant#1#2{%
2774: \ifusingtt
2775: {{\ttsl #2}\let\next=\relax}%
1.5 ! snw 2776: {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
1.1 snw 2777: \next
2778: }
2779: \def\smartslanted{\dosmartslant\sl}
2780: \def\smartitalic{\dosmartslant\it}
2781:
1.5 ! snw 2782: % Output an italic correction unless \next (presumed to be the following
! 2783: % character) is such as not to need one.
! 2784: \def\smartitaliccorrection{%
1.1 snw 2785: \ifx\next,%
2786: \else\ifx\next-%
2787: \else\ifx\next.%
2788: \else\ifx\next\.%
2789: \else\ifx\next\comma%
2790: \else\ptexslash
2791: \fi\fi\fi\fi\fi
2792: \aftersmartic
2793: }
2794:
1.5 ! snw 2795: % Unconditional use \ttsl, and no ic. @var is set to this for defuns.
! 2796: \def\ttslanted#1{{\ttsl #1}}
! 2797:
! 2798: % @cite is like \smartslanted except unconditionally use \sl. We never want
! 2799: % ttsl for book titles, do we?
! 2800: \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
1.1 snw 2801:
2802: \def\aftersmartic{}
2803: \def\var#1{%
2804: \let\saveaftersmartic = \aftersmartic
2805: \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
1.5 ! snw 2806: \smartslanted{#1}%
1.1 snw 2807: }
2808:
2809: \let\i=\smartitalic
2810: \let\slanted=\smartslanted
2811: \let\dfn=\smartslanted
2812: \let\emph=\smartitalic
2813:
1.5 ! snw 2814: % Explicit font changes: @r, @sc, undocumented @ii.
! 2815: \def\r#1{{\rm #1}} % roman font
1.1 snw 2816: \def\sc#1{{\smallcaps#1}} % smallcaps font
2817: \def\ii#1{{\it #1}} % italic font
2818:
2819: % @b, explicit bold. Also @strong.
2820: \def\b#1{{\bf #1}}
2821: \let\strong=\b
2822:
2823: % @sansserif, explicit sans.
2824: \def\sansserif#1{{\sf #1}}
2825:
1.5 ! snw 2826: % We can't just use \exhyphenpenalty, because that only has effect at
! 2827: % the end of a paragraph. Restore normal hyphenation at the end of the
! 2828: % group within which \nohyphenation is presumably called.
! 2829: %
! 2830: \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
! 2831: \def\restorehyphenation{\hyphenchar\font = `- }
1.1 snw 2832:
2833: % Set sfcode to normal for the chars that usually have another value.
2834: % Can't use plain's \frenchspacing because it uses the `\x notation, and
2835: % sometimes \x has an active definition that messes things up.
2836: %
2837: \catcode`@=11
2838: \def\plainfrenchspacing{%
1.5 ! snw 2839: \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
! 2840: \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
! 2841: \def\endofsentencespacefactor{1000}% for @. and friends
1.1 snw 2842: }
2843: \def\plainnonfrenchspacing{%
1.5 ! snw 2844: \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
! 2845: \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
! 2846: \def\endofsentencespacefactor{3000}% for @. and friends
1.1 snw 2847: }
2848: \catcode`@=\other
2849: \def\endofsentencespacefactor{3000}% default
2850:
2851: % @t, explicit typewriter.
2852: \def\t#1{%
1.5 ! snw 2853: {\tt \plainfrenchspacing #1}%
1.1 snw 2854: \null
2855: }
2856:
2857: % @samp.
1.5 ! snw 2858: \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
1.1 snw 2859:
2860: % @indicateurl is \samp, that is, with quotes.
2861: \let\indicateurl=\samp
2862:
2863: % @code (and similar) prints in typewriter, but with spaces the same
2864: % size as normal in the surrounding text, without hyphenation, etc.
2865: % This is a subroutine for that.
2866: \def\tclose#1{%
2867: {%
2868: % Change normal interword space to be same as for the current font.
2869: \spaceskip = \fontdimen2\font
2870: %
2871: % Switch to typewriter.
2872: \tt
2873: %
1.5 ! snw 2874: % But `\ ' produces the large typewriter interword space.
1.1 snw 2875: \def\ {{\spaceskip = 0pt{} }}%
2876: %
1.5 ! snw 2877: % Turn off hyphenation.
! 2878: \nohyphenation
! 2879: %
1.1 snw 2880: \plainfrenchspacing
2881: #1%
2882: }%
2883: \null % reset spacefactor to 1000
2884: }
2885:
1.5 ! snw 2886: % We *must* turn on hyphenation at `-' and `_' in @code.
! 2887: % (But see \codedashfinish below.)
1.1 snw 2888: % Otherwise, it is too hard to avoid overfull hboxes
2889: % in the Emacs manual, the Library manual, etc.
2890: %
1.5 ! snw 2891: % Unfortunately, TeX uses one parameter (\hyphenchar) to control
! 2892: % both hyphenation at - and hyphenation within words.
! 2893: % We must therefore turn them both off (\tclose does that)
! 2894: % and arrange explicitly to hyphenate at a dash. -- rms.
1.1 snw 2895: {
2896: \catcode`\-=\active \catcode`\_=\active
2897: \catcode`\'=\active \catcode`\`=\active
2898: \global\let'=\rq \global\let`=\lq % default definitions
2899: %
2900: \global\def\code{\begingroup
1.5 ! snw 2901: \setupmarkupstyle{code}%
! 2902: % The following should really be moved into \setupmarkupstyle handlers.
1.1 snw 2903: \catcode\dashChar=\active \catcode\underChar=\active
2904: \ifallowcodebreaks
2905: \let-\codedash
2906: \let_\codeunder
2907: \else
1.5 ! snw 2908: \let-\normaldash
1.1 snw 2909: \let_\realunder
2910: \fi
1.5 ! snw 2911: % Given -foo (with a single dash), we do not want to allow a break
! 2912: % after the hyphen.
! 2913: \global\let\codedashprev=\codedash
! 2914: %
1.1 snw 2915: \codex
2916: }
2917: %
2918: \gdef\codedash{\futurelet\next\codedashfinish}
2919: \gdef\codedashfinish{%
2920: \normaldash % always output the dash character itself.
2921: %
2922: % Now, output a discretionary to allow a line break, unless
2923: % (a) the next character is a -, or
1.5 ! snw 2924: % (b) the preceding character is a -.
1.1 snw 2925: % E.g., given --posix, we do not want to allow a break after either -.
2926: % Given --foo-bar, we do want to allow a break between the - and the b.
2927: \ifx\next\codedash \else
1.5 ! snw 2928: \ifx\codedashprev\codedash
1.1 snw 2929: \else \discretionary{}{}{}\fi
2930: \fi
2931: % we need the space after the = for the case when \next itself is a
2932: % space token; it would get swallowed otherwise. As in @code{- a}.
1.5 ! snw 2933: \global\let\codedashprev= \next
1.1 snw 2934: }
2935: }
2936: \def\normaldash{-}
2937: %
1.5 ! snw 2938: \def\codex #1{\tclose{#1}\endgroup}
1.1 snw 2939:
2940: \def\codeunder{%
2941: % this is all so @math{@code{var_name}+1} can work. In math mode, _
2942: % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2943: % will therefore expand the active definition of _, which is us
2944: % (inside @code that is), therefore an endless loop.
2945: \ifusingtt{\ifmmode
2946: \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2947: \else\normalunderscore \fi
2948: \discretionary{}{}{}}%
2949: {\_}%
2950: }
2951:
2952: % An additional complication: the above will allow breaks after, e.g.,
2953: % each of the four underscores in __typeof__. This is bad.
2954: % @allowcodebreaks provides a document-level way to turn breaking at -
2955: % and _ on and off.
2956: %
2957: \newif\ifallowcodebreaks \allowcodebreakstrue
2958:
2959: \def\keywordtrue{true}
2960: \def\keywordfalse{false}
2961:
2962: \parseargdef\allowcodebreaks{%
2963: \def\txiarg{#1}%
2964: \ifx\txiarg\keywordtrue
2965: \allowcodebreakstrue
2966: \else\ifx\txiarg\keywordfalse
2967: \allowcodebreaksfalse
2968: \else
2969: \errhelp = \EMsimple
2970: \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2971: \fi\fi
2972: }
2973:
2974: % For @command, @env, @file, @option quotes seem unnecessary,
2975: % so use \code rather than \samp.
2976: \let\command=\code
2977: \let\env=\code
2978: \let\file=\code
2979: \let\option=\code
2980:
2981: % @uref (abbreviation for `urlref') aka @url takes an optional
2982: % (comma-separated) second argument specifying the text to display and
2983: % an optional third arg as text to display instead of (rather than in
2984: % addition to) the url itself. First (mandatory) arg is the url.
2985:
2986: % TeX-only option to allow changing PDF output to show only the second
2987: % arg (if given), and not the url (which is then just the link target).
2988: \newif\ifurefurlonlylink
2989:
2990: % The main macro is \urefbreak, which allows breaking at expected
1.5 ! snw 2991: % places within the url. (There used to be another version, which
! 2992: % didn't support automatic breaking.)
! 2993: \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
1.1 snw 2994: \let\uref=\urefbreak
2995: %
2996: \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2997: \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2998: \unsepspaces
2999: \pdfurl{#1}%
3000: \setbox0 = \hbox{\ignorespaces #3}%
3001: \ifdim\wd0 > 0pt
3002: \unhbox0 % third arg given, show only that
3003: \else
3004: \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3005: \ifdim\wd0 > 0pt
3006: \ifpdf
3007: % For pdfTeX and LuaTeX
3008: \ifurefurlonlylink
3009: % PDF plus option to not display url, show just arg
3010: \unhbox0
3011: \else
3012: % PDF, normally display both arg and url for consistency,
3013: % visibility, if the pdf is eventually used to print, etc.
3014: \unhbox0\ (\urefcode{#1})%
3015: \fi
3016: \else
3017: \ifx\XeTeXrevision\thisisundefined
3018: \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3019: \else
3020: % For XeTeX
3021: \ifurefurlonlylink
3022: % PDF plus option to not display url, show just arg
3023: \unhbox0
3024: \else
3025: % PDF, normally display both arg and url for consistency,
3026: % visibility, if the pdf is eventually used to print, etc.
3027: \unhbox0\ (\urefcode{#1})%
3028: \fi
3029: \fi
3030: \fi
3031: \else
3032: \urefcode{#1}% only url given, so show it
3033: \fi
3034: \fi
3035: \endlink
3036: \endgroup}
3037:
3038: % Allow line breaks around only a few characters (only).
3039: \def\urefcatcodes{%
3040: \catcode`\&=\active \catcode`\.=\active
3041: \catcode`\#=\active \catcode`\?=\active
3042: \catcode`\/=\active
3043: }
3044: {
3045: \urefcatcodes
3046: %
3047: \global\def\urefcode{\begingroup
1.5 ! snw 3048: \setupmarkupstyle{code}%
1.1 snw 3049: \urefcatcodes
3050: \let&\urefcodeamp
3051: \let.\urefcodedot
3052: \let#\urefcodehash
3053: \let?\urefcodequest
3054: \let/\urefcodeslash
3055: \codex
3056: }
3057: %
3058: % By default, they are just regular characters.
3059: \global\def&{\normalamp}
3060: \global\def.{\normaldot}
3061: \global\def#{\normalhash}
3062: \global\def?{\normalquest}
3063: \global\def/{\normalslash}
3064: }
3065:
3066: \def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3067: \def\urefcodedot{\urefprebreak .\urefpostbreak}
3068: \def\urefcodehash{\urefprebreak \#\urefpostbreak}
3069: \def\urefcodequest{\urefprebreak ?\urefpostbreak}
3070: \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3071: {
3072: \catcode`\/=\active
3073: \global\def\urefcodeslashfinish{%
3074: \urefprebreak \slashChar
3075: % Allow line break only after the final / in a sequence of
3076: % slashes, to avoid line break between the slashes in http://.
3077: \ifx\next/\else \urefpostbreak \fi
3078: }
3079: }
3080:
3081: % By default we'll break after the special characters, but some people like to
3082: % break before the special chars, so allow that. Also allow no breaking at
3083: % all, for manual control.
3084: %
3085: \parseargdef\urefbreakstyle{%
3086: \def\txiarg{#1}%
3087: \ifx\txiarg\wordnone
3088: \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3089: \else\ifx\txiarg\wordbefore
3090: \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3091: \else\ifx\txiarg\wordafter
3092: \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3093: \else
3094: \errhelp = \EMsimple
3095: \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3096: \fi\fi\fi
3097: }
3098: \def\wordafter{after}
3099: \def\wordbefore{before}
3100: \def\wordnone{none}
3101:
3102: % Allow a ragged right output to aid breaking long URL's. There can
3103: % be a break at the \allowbreak with no extra glue (if the existing stretch in
1.5 ! snw 3104: % the line is sufficent), a break at the \penalty100 with extra glue added
1.1 snw 3105: % at the end of the line, or no break at all here.
3106: % Changing the value of the penalty and/or the amount of stretch affects how
1.5 ! snw 3107: % preferrable one choice is over the other.
1.1 snw 3108: \def\urefallowbreak{%
1.5 ! snw 3109: \allowbreak
1.1 snw 3110: \hskip 0pt plus 2 em\relax
1.5 ! snw 3111: \penalty300
1.1 snw 3112: \hskip 0pt plus -2 em\relax
3113: }
3114:
3115: \urefbreakstyle after
3116:
3117: % @url synonym for @uref, since that's how everyone uses it.
3118: %
3119: \let\url=\uref
3120:
3121: % rms does not like angle brackets --karl, 17may97.
3122: % So now @email is just like @uref, unless we are pdf.
3123: %
3124: %\def\email#1{\angleleft{\tt #1}\angleright}
3125: \ifpdforxetex
3126: \def\email#1{\doemail#1,,\finish}
3127: \def\doemail#1,#2,#3\finish{\begingroup
3128: \unsepspaces
3129: \pdfurl{mailto:#1}%
3130: \setbox0 = \hbox{\ignorespaces #2}%
3131: \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3132: \endlink
3133: \endgroup}
3134: \else
3135: \let\email=\uref
3136: \fi
3137:
3138: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3139: % `example' (@kbd uses ttsl only inside of @example and friends),
3140: % or `code' (@kbd uses normal tty font always).
3141: \parseargdef\kbdinputstyle{%
3142: \def\txiarg{#1}%
3143: \ifx\txiarg\worddistinct
3144: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3145: \else\ifx\txiarg\wordexample
3146: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3147: \else\ifx\txiarg\wordcode
3148: \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3149: \else
3150: \errhelp = \EMsimple
3151: \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3152: \fi\fi\fi
3153: }
3154: \def\worddistinct{distinct}
3155: \def\wordexample{example}
3156: \def\wordcode{code}
3157:
3158: % Default is `distinct'.
3159: \kbdinputstyle distinct
3160:
1.5 ! snw 3161: % @kbd is like @code, except that if the argument is just one @key command,
! 3162: % then @kbd has no effect.
! 3163: \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
! 3164:
! 3165: \def\xkey{\key}
! 3166: \def\kbdsub#1#2#3\par{%
! 3167: \def\one{#1}\def\three{#3}\def\threex{??}%
! 3168: \ifx\one\xkey\ifx\threex\three \key{#2}%
! 3169: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
! 3170: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
1.1 snw 3171: }
3172:
3173: % definition of @key that produces a lozenge. Doesn't adjust to text size.
3174: %\setfont\keyrm\rmshape{8}{1000}{OT1}
3175: %\font\keysy=cmsy9
3176: %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3177: % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3178: % \vbox{\hrule\kern-0.4pt
3179: % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3180: % \kern-0.4pt\hrule}%
3181: % \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3182:
1.5 ! snw 3183: % definition of @key with no lozenge. If the current font is already
! 3184: % monospace, don't change it; that way, we respect @kbdinputstyle. But
! 3185: % if it isn't monospace, then use \tt.
! 3186: %
! 3187: \def\key#1{{\setupmarkupstyle{key}%
! 3188: \nohyphenation
! 3189: \ifmonospace\else\tt\fi
! 3190: #1}\null}
1.1 snw 3191:
3192: % @clicksequence{File @click{} Open ...}
3193: \def\clicksequence#1{\begingroup #1\endgroup}
3194:
3195: % @clickstyle @arrow (by default)
3196: \parseargdef\clickstyle{\def\click{#1}}
3197: \def\click{\arrow}
3198:
3199: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
3200: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3201: %
3202: \def\dmn#1{\thinspace #1}
3203:
3204: % @acronym for "FBI", "NATO", and the like.
3205: % We print this one point size smaller, since it's intended for
3206: % all-uppercase.
3207: %
3208: \def\acronym#1{\doacronym #1,,\finish}
3209: \def\doacronym#1,#2,#3\finish{%
3210: {\switchtolsize #1}%
3211: \def\temp{#2}%
3212: \ifx\temp\empty \else
3213: \space ({\unsepspaces \ignorespaces \temp \unskip})%
3214: \fi
3215: \null % reset \spacefactor=1000
3216: }
3217:
3218: % @abbr for "Comput. J." and the like.
3219: % No font change, but don't do end-of-sentence spacing.
3220: %
3221: \def\abbr#1{\doabbr #1,,\finish}
3222: \def\doabbr#1,#2,#3\finish{%
3223: {\plainfrenchspacing #1}%
3224: \def\temp{#2}%
3225: \ifx\temp\empty \else
3226: \space ({\unsepspaces \ignorespaces \temp \unskip})%
3227: \fi
3228: \null % reset \spacefactor=1000
3229: }
3230:
3231: % @asis just yields its argument. Used with @table, for example.
3232: %
3233: \def\asis#1{#1}
3234:
3235: % @math outputs its argument in math mode.
3236: %
3237: % One complication: _ usually means subscripts, but it could also mean
3238: % an actual _ character, as in @math{@var{some_variable} + 1}. So make
3239: % _ active, and distinguish by seeing if the current family is \slfam,
3240: % which is what @var uses.
3241: {
3242: \catcode`\_ = \active
3243: \gdef\mathunderscore{%
3244: \catcode`\_=\active
3245: \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3246: }
3247: }
3248: % Another complication: we want \\ (and @\) to output a math (or tt) \.
3249: % FYI, plain.tex uses \\ as a temporary control sequence (for no
3250: % particular reason), but this is not advertised and we don't care.
3251: %
3252: % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3253: \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3254: %
3255: \def\math{%
3256: \ifmmode\else % only go into math if not in math mode already
3257: \tex
3258: \mathunderscore
3259: \let\\ = \mathbackslash
3260: \mathactive
3261: % make the texinfo accent commands work in math mode
3262: \let\"=\ddot
3263: \let\'=\acute
3264: \let\==\bar
3265: \let\^=\hat
3266: \let\`=\grave
3267: \let\u=\breve
3268: \let\v=\check
3269: \let\~=\tilde
3270: \let\dotaccent=\dot
3271: % have to provide another name for sup operator
3272: \let\mathopsup=\sup
3273: $\expandafter\finishmath\fi
3274: }
3275: \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
3276:
3277: % Some active characters (such as <) are spaced differently in math.
3278: % We have to reset their definitions in case the @math was an argument
3279: % to a command which sets the catcodes (such as @item or @section).
3280: %
3281: {
3282: \catcode`^ = \active
3283: \catcode`< = \active
3284: \catcode`> = \active
3285: \catcode`+ = \active
3286: \catcode`' = \active
3287: \gdef\mathactive{%
3288: \let^ = \ptexhat
3289: \let< = \ptexless
3290: \let> = \ptexgtr
3291: \let+ = \ptexplus
3292: \let' = \ptexquoteright
3293: }
3294: }
3295:
3296: % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3297: % If in text, use math to place as sub/superscript, but switch
3298: % into text mode, with smaller fonts. This is a different font than the
3299: % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3300: % fix it (significant additions to font machinery) until someone notices.
3301: %
3302: \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3303: \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3304: %
3305: \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3306: \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3307:
3308: % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3309: % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3310: % except specified as a normal braced arg, so no newlines to worry about.
3311: %
3312: \def\outfmtnametex{tex}
3313: %
3314: \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3315: \long\def\doinlinefmt#1,#2,\finish{%
3316: \def\inlinefmtname{#1}%
3317: \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3318: }
3319: %
3320: % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3321: % FMTNAME is tex, else ELSE-TEXT.
3322: \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3323: \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3324: \def\inlinefmtname{#1}%
3325: \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3326: }
3327: %
3328: % For raw, must switch into @tex before parsing the argument, to avoid
3329: % setting catcodes prematurely. Doing it this way means that, for
3330: % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3331: % ignored. But this isn't important because if people want a literal
3332: % *right* brace they would have to use a command anyway, so they may as
3333: % well use a command to get a left brace too. We could re-use the
3334: % delimiter character idea from \verb, but it seems like overkill.
3335: %
3336: \long\def\inlineraw{\tex \doinlineraw}
3337: \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3338: \def\doinlinerawtwo#1,#2,\finish{%
3339: \def\inlinerawname{#1}%
3340: \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3341: \endgroup % close group opened by \tex.
3342: }
3343:
3344: % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3345: %
3346: \long\def\inlineifset#1{\doinlineifset #1,\finish}
3347: \long\def\doinlineifset#1,#2,\finish{%
3348: \def\inlinevarname{#1}%
3349: \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3350: \else\ignorespaces#2\fi
3351: }
3352:
3353: % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3354: %
3355: \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3356: \long\def\doinlineifclear#1,#2,\finish{%
3357: \def\inlinevarname{#1}%
3358: \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3359: }
3360:
3361:
3362: \message{glyphs,}
3363: % and logos.
3364:
3365: % @@ prints an @, as does @atchar{}.
3366: \def\@{\char64 }
3367: \let\atchar=\@
3368:
3369: % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
1.5 ! snw 3370: \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
! 3371: \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
1.1 snw 3372: \let\{=\lbracechar
3373: \let\}=\rbracechar
3374:
3375: % @comma{} to avoid , parsing problems.
3376: \let\comma = ,
3377:
3378: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3379: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3380: \let\, = \ptexc
3381: \let\dotaccent = \ptexdot
3382: \def\ringaccent#1{{\accent23 #1}}
3383: \let\tieaccent = \ptext
3384: \let\ubaraccent = \ptexb
3385: \let\udotaccent = \d
3386:
3387: % Other special characters: @questiondown @exclamdown @ordf @ordm
3388: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3389: \def\questiondown{?`}
3390: \def\exclamdown{!`}
3391: \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3392: \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3393:
3394: % Dotless i and dotless j, used for accents.
3395: \def\imacro{i}
3396: \def\jmacro{j}
3397: \def\dotless#1{%
3398: \def\temp{#1}%
3399: \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3400: \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3401: \else \errmessage{@dotless can be used only with i or j}%
3402: \fi\fi
3403: }
3404:
3405: % The \TeX{} logo, as in plain, but resetting the spacing so that a
3406: % period following counts as ending a sentence. (Idea found in latex.)
3407: %
3408: \edef\TeX{\TeX \spacefactor=1000 }
3409:
3410: % @LaTeX{} logo. Not quite the same results as the definition in
3411: % latex.ltx, since we use a different font for the raised A; it's most
3412: % convenient for us to use an explicitly smaller font, rather than using
3413: % the \scriptstyle font (since we don't reset \scriptstyle and
3414: % \scriptscriptstyle).
3415: %
3416: \def\LaTeX{%
3417: L\kern-.36em
3418: {\setbox0=\hbox{T}%
3419: \vbox to \ht0{\hbox{%
3420: \ifx\textnominalsize\xwordpt
3421: % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3422: % Revert to plain's \scriptsize, which is 7pt.
3423: \count255=\the\fam $\fam\count255 \scriptstyle A$%
3424: \else
1.5 ! snw 3425: % For 11pt, we can use our lllsize.
! 3426: \switchtolllsize A%
1.1 snw 3427: \fi
3428: }%
3429: \vss
3430: }}%
3431: \kern-.15em
3432: \TeX
3433: }
3434:
3435: % Some math mode symbols. Define \ensuremath to switch into math mode
3436: % unless we are already there. Expansion tricks may not be needed here,
3437: % but safer, and can't hurt.
3438: \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3439: \def\ensuredmath#1{$\relax#1$}
3440: %
3441: \def\bullet{\ensuremath\ptexbullet}
3442: \def\geq{\ensuremath\ge}
3443: \def\leq{\ensuremath\le}
3444: \def\minus{\ensuremath-}
3445:
3446: % @dots{} outputs an ellipsis using the current font.
3447: % We do .5em per period so that it has the same spacing in the cm
3448: % typewriter fonts as three actual period characters; on the other hand,
3449: % in other typewriter fonts three periods are wider than 1.5em. So do
3450: % whichever is larger.
3451: %
3452: \def\dots{%
3453: \leavevmode
3454: \setbox0=\hbox{...}% get width of three periods
3455: \ifdim\wd0 > 1.5em
3456: \dimen0 = \wd0
3457: \else
3458: \dimen0 = 1.5em
3459: \fi
3460: \hbox to \dimen0{%
3461: \hskip 0pt plus.25fil
3462: .\hskip 0pt plus1fil
3463: .\hskip 0pt plus1fil
3464: .\hskip 0pt plus.5fil
3465: }%
3466: }
3467:
3468: % @enddots{} is an end-of-sentence ellipsis.
3469: %
3470: \def\enddots{%
3471: \dots
3472: \spacefactor=\endofsentencespacefactor
3473: }
3474:
3475: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3476: %
3477: % Since these characters are used in examples, they should be an even number of
3478: % \tt widths. Each \tt character is 1en, so two makes it 1em.
3479: %
3480: \def\point{$\star$}
3481: \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3482: \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3483: \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3484: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3485: \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3486:
3487: % The @error{} command.
3488: % Adapted from the TeXbook's \boxit.
3489: %
3490: \newbox\errorbox
3491: %
3492: {\ttfont \global\dimen0 = 3em}% Width of the box.
3493: \dimen2 = .55pt % Thickness of rules
3494: % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3495: \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3496: %
3497: \setbox\errorbox=\hbox to \dimen0{\hfil
3498: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3499: \advance\hsize by -2\dimen2 % Rules.
3500: \vbox{%
3501: \hrule height\dimen2
3502: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
3503: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3504: \kern3pt\vrule width\dimen2}% Space to right.
3505: \hrule height\dimen2}
3506: \hfil}
3507: %
3508: \def\error{\leavevmode\lower.7ex\copy\errorbox}
3509:
3510: % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3511: %
1.5 ! snw 3512: \def\pounds{{\it\$}}
1.1 snw 3513:
3514: % @euro{} comes from a separate font, depending on the current style.
3515: % We use the free feym* fonts from the eurosym package by Henrik
3516: % Theiling, which support regular, slanted, bold and bold slanted (and
3517: % "outlined" (blackboard board, sort of) versions, which we don't need).
3518: % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3519: %
3520: % Although only regular is the truly official Euro symbol, we ignore
3521: % that. The Euro is designed to be slightly taller than the regular
3522: % font height.
3523: %
3524: % feymr - regular
3525: % feymo - slanted
3526: % feybr - bold
3527: % feybo - bold slanted
3528: %
3529: % There is no good (free) typewriter version, to my knowledge.
3530: % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3531: % Hmm.
3532: %
3533: % Also doesn't work in math. Do we need to do math with euro symbols?
3534: % Hope not.
3535: %
3536: %
3537: \def\euro{{\eurofont e}}
3538: \def\eurofont{%
3539: % We set the font at each command, rather than predefining it in
3540: % \textfonts and the other font-switching commands, so that
3541: % installations which never need the symbol don't have to have the
3542: % font installed.
3543: %
3544: % There is only one designed size (nominal 10pt), so we always scale
3545: % that to the current nominal size.
3546: %
3547: % By the way, simply using "at 1em" works for cmr10 and the like, but
3548: % does not work for cmbx10 and other extended/shrunken fonts.
3549: %
3550: \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3551: %
3552: \ifx\curfontstyle\bfstylename
3553: % bold:
3554: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3555: \else
3556: % regular:
3557: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3558: \fi
3559: \thiseurofont
3560: }
3561:
3562: % Glyphs from the EC fonts. We don't use \let for the aliases, because
3563: % sometimes we redefine the original macro, and the alias should reflect
3564: % the redefinition.
3565: %
3566: % Use LaTeX names for the Icelandic letters.
3567: \def\DH{{\ecfont \char"D0}} % Eth
3568: \def\dh{{\ecfont \char"F0}} % eth
3569: \def\TH{{\ecfont \char"DE}} % Thorn
3570: \def\th{{\ecfont \char"FE}} % thorn
3571: %
3572: \def\guillemetleft{{\ecfont \char"13}}
3573: \def\guillemotleft{\guillemetleft}
3574: \def\guillemetright{{\ecfont \char"14}}
3575: \def\guillemotright{\guillemetright}
3576: \def\guilsinglleft{{\ecfont \char"0E}}
3577: \def\guilsinglright{{\ecfont \char"0F}}
3578: \def\quotedblbase{{\ecfont \char"12}}
3579: \def\quotesinglbase{{\ecfont \char"0D}}
3580: %
3581: % This positioning is not perfect (see the ogonek LaTeX package), but
3582: % we have the precomposed glyphs for the most common cases. We put the
3583: % tests to use those glyphs in the single \ogonek macro so we have fewer
3584: % dummy definitions to worry about for index entries, etc.
3585: %
3586: % ogonek is also used with other letters in Lithuanian (IOU), but using
3587: % the precomposed glyphs for those is not so easy since they aren't in
3588: % the same EC font.
3589: \def\ogonek#1{{%
3590: \def\temp{#1}%
3591: \ifx\temp\macrocharA\Aogonek
3592: \else\ifx\temp\macrochara\aogonek
3593: \else\ifx\temp\macrocharE\Eogonek
3594: \else\ifx\temp\macrochare\eogonek
3595: \else
3596: \ecfont \setbox0=\hbox{#1}%
3597: \ifdim\ht0=1ex\accent"0C #1%
3598: \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3599: \fi
3600: \fi\fi\fi\fi
3601: }%
3602: }
3603: \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3604: \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3605: \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3606: \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3607: %
3608: % Use the European Computer Modern fonts (cm-super in outline format)
3609: % for non-CM glyphs. That is ec* for regular text and tc* for the text
3610: % companion symbols (LaTeX TS1 encoding). Both are part of the ec
3611: % package and follow the same conventions.
3612: %
3613: \def\ecfont{\etcfont{e}}
3614: \def\tcfont{\etcfont{t}}
3615: %
3616: \def\etcfont#1{%
3617: % We can't distinguish serif/sans and italic/slanted, but this
3618: % is used for crude hacks anyway (like adding French and German
3619: % quotes to documents typeset with CM, where we lose kerning), so
3620: % hopefully nobody will notice/care.
3621: \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3622: \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
1.5 ! snw 3623: \ifmonospace
! 3624: % typewriter:
! 3625: \font\thisecfont = #1ctt\ecsize \space at \nominalsize
! 3626: \else
! 3627: \ifx\curfontstyle\bfstylename
! 3628: % bold:
! 3629: \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
! 3630: \else
! 3631: % regular:
! 3632: \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
! 3633: \fi
! 3634: \fi
1.1 snw 3635: \thisecfont
3636: }
3637:
3638: % @registeredsymbol - R in a circle. The font for the R should really
3639: % be smaller yet, but lllsize is the best we can do for now.
3640: % Adapted from the plain.tex definition of \copyright.
3641: %
3642: \def\registeredsymbol{%
3643: $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3644: \hfil\crcr\Orb}}%
3645: }$%
3646: }
3647:
3648: % @textdegree - the normal degrees sign.
3649: %
1.5 ! snw 3650: \def\textdegree{$^\circ$}
1.1 snw 3651:
3652: % Laurent Siebenmann reports \Orb undefined with:
3653: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
3654: % so we'll define it if necessary.
3655: %
3656: \ifx\Orb\thisisundefined
3657: \def\Orb{\mathhexbox20D}
3658: \fi
3659:
3660: % Quotes.
1.5 ! snw 3661: \chardef\quotedblleft="5C
! 3662: \chardef\quotedblright=`\"
1.1 snw 3663: \chardef\quoteleft=`\`
3664: \chardef\quoteright=`\'
3665:
3666:
3667: \message{page headings,}
3668:
3669: \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3670: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3671:
3672: % First the title page. Must do @settitle before @titlepage.
3673: \newif\ifseenauthor
3674: \newif\iffinishedtitlepage
3675:
3676: % @setcontentsaftertitlepage used to do an implicit @contents or
3677: % @shortcontents after @end titlepage, but it is now obsolete.
3678: \def\setcontentsaftertitlepage{%
3679: \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3680: command; move your @contents command if you want the contents
3681: after the title page.}}%
3682: \def\setshortcontentsaftertitlepage{%
3683: \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3684: command; move your @shortcontents and @contents commands if you
3685: want the contents after the title page.}}%
3686:
3687: \parseargdef\shorttitlepage{%
1.5 ! snw 3688: \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
! 3689: \endgroup\page\hbox{}\page}
1.1 snw 3690:
3691: \envdef\titlepage{%
3692: % Open one extra group, as we want to close it in the middle of \Etitlepage.
3693: \begingroup
3694: \parindent=0pt \textfonts
3695: % Leave some space at the very top of the page.
3696: \vglue\titlepagetopglue
3697: % No rule at page bottom unless we print one at the top with @title.
3698: \finishedtitlepagetrue
3699: %
3700: % Most title ``pages'' are actually two pages long, with space
3701: % at the top of the second. We don't want the ragged left on the second.
3702: \let\oldpage = \page
3703: \def\page{%
3704: \iffinishedtitlepage\else
3705: \finishtitlepage
3706: \fi
3707: \let\page = \oldpage
3708: \page
3709: \null
3710: }%
3711: }
3712:
3713: \def\Etitlepage{%
3714: \iffinishedtitlepage\else
3715: \finishtitlepage
3716: \fi
3717: % It is important to do the page break before ending the group,
3718: % because the headline and footline are only empty inside the group.
3719: % If we use the new definition of \page, we always get a blank page
3720: % after the title page, which we certainly don't want.
3721: \oldpage
3722: \endgroup
3723: %
1.5 ! snw 3724: % Need this before the \...aftertitlepage checks so that if they are
! 3725: % in effect the toc pages will come out with page numbers.
! 3726: \HEADINGSon
1.1 snw 3727: }
3728:
3729: \def\finishtitlepage{%
3730: \vskip4pt \hrule height 2pt width \hsize
3731: \vskip\titlepagebottomglue
3732: \finishedtitlepagetrue
3733: }
3734:
3735: % Settings used for typesetting titles: no hyphenation, no indentation,
3736: % don't worry much about spacing, ragged right. This should be used
3737: % inside a \vbox, and fonts need to be set appropriately first. \par should
3738: % be specified before the end of the \vbox, since a vbox is a group.
3739: %
3740: \def\raggedtitlesettings{%
3741: \rm
3742: \hyphenpenalty=10000
3743: \parindent=0pt
3744: \tolerance=5000
3745: \ptexraggedright
3746: }
3747:
3748: % Macros to be used within @titlepage:
3749:
3750: \let\subtitlerm=\rmfont
3751: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3752:
3753: \parseargdef\title{%
3754: \checkenv\titlepage
3755: \vbox{\titlefonts \raggedtitlesettings #1\par}%
3756: % print a rule at the page bottom also.
3757: \finishedtitlepagefalse
3758: \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3759: }
3760:
3761: \parseargdef\subtitle{%
3762: \checkenv\titlepage
3763: {\subtitlefont \rightline{#1}}%
3764: }
3765:
3766: % @author should come last, but may come many times.
3767: % It can also be used inside @quotation.
3768: %
3769: \parseargdef\author{%
3770: \def\temp{\quotation}%
3771: \ifx\thisenv\temp
3772: \def\quotationauthor{#1}% printed in \Equotation.
3773: \else
3774: \checkenv\titlepage
3775: \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3776: {\secfonts\rm \leftline{#1}}%
3777: \fi
3778: }
3779:
3780:
3781: % Set up page headings and footings.
3782:
3783: \let\thispage=\folio
3784:
3785: \newtoks\evenheadline % headline on even pages
3786: \newtoks\oddheadline % headline on odd pages
3787: \newtoks\evenfootline % footline on even pages
3788: \newtoks\oddfootline % footline on odd pages
3789:
3790: % Now make \makeheadline and \makefootline in Plain TeX use those variables
1.5 ! snw 3791: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
! 3792: \else \the\evenheadline \fi}}
! 3793: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
! 3794: \else \the\evenfootline \fi}\HEADINGShook}
1.1 snw 3795: \let\HEADINGShook=\relax
3796:
3797: % Commands to set those variables.
3798: % For example, this is what @headings on does
3799: % @evenheading @thistitle|@thispage|@thischapter
3800: % @oddheading @thischapter|@thispage|@thistitle
3801: % @evenfooting @thisfile||
3802: % @oddfooting ||@thisfile
3803:
3804:
3805: \def\evenheading{\parsearg\evenheadingxxx}
3806: \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3807: \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
1.5 ! snw 3808: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1.1 snw 3809:
3810: \def\oddheading{\parsearg\oddheadingxxx}
3811: \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3812: \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
1.5 ! snw 3813: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1.1 snw 3814:
3815: \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3816:
3817: \def\evenfooting{\parsearg\evenfootingxxx}
3818: \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3819: \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3820: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3821:
3822: \def\oddfooting{\parsearg\oddfootingxxx}
3823: \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3824: \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3825: \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3826: %
3827: % Leave some space for the footline. Hopefully ok to assume
3828: % @evenfooting will not be used by itself.
3829: \global\advance\txipageheight by -12pt
3830: \global\advance\vsize by -12pt
3831: }
3832:
3833: \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3834:
3835: % @evenheadingmarks top \thischapter <- chapter at the top of a page
3836: % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
3837: %
3838: % The same set of arguments for:
3839: %
3840: % @oddheadingmarks
3841: % @evenfootingmarks
3842: % @oddfootingmarks
3843: % @everyheadingmarks
3844: % @everyfootingmarks
3845:
3846: % These define \getoddheadingmarks, \getevenheadingmarks,
3847: % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3848: % \gettopheadingmarks, \getbottomheadingmarks.
3849: %
3850: \def\evenheadingmarks{\headingmarks{even}{heading}}
3851: \def\oddheadingmarks{\headingmarks{odd}{heading}}
3852: \def\evenfootingmarks{\headingmarks{even}{footing}}
3853: \def\oddfootingmarks{\headingmarks{odd}{footing}}
3854: \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3855: \headingmarks{odd}{heading}{#1} }
3856: \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3857: \headingmarks{odd}{footing}{#1} }
3858: % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3859: \def\headingmarks#1#2#3 {%
3860: \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3861: \global\expandafter\let\csname get#1#2marks\endcsname \temp
3862: }
3863:
3864: \everyheadingmarks bottom
3865: \everyfootingmarks bottom
3866:
3867: % @headings double turns headings on for double-sided printing.
3868: % @headings single turns headings on for single-sided printing.
3869: % @headings off turns them off.
3870: % @headings on same as @headings double, retained for compatibility.
3871: % @headings after turns on double-sided headings after this page.
3872: % @headings doubleafter turns on double-sided headings after this page.
3873: % @headings singleafter turns on single-sided headings after this page.
3874: % By default, they are off at the start of a document,
3875: % and turned `on' after @end titlepage.
3876:
3877: \parseargdef\headings{\csname HEADINGS#1\endcsname}
3878:
3879: \def\headingsoff{% non-global headings elimination
1.5 ! snw 3880: \evenheadline={\hfil}\evenfootline={\hfil}%
! 3881: \oddheadline={\hfil}\oddfootline={\hfil}%
1.1 snw 3882: }
3883:
3884: \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
1.5 ! snw 3885: \HEADINGSoff % it's the default
1.1 snw 3886:
1.5 ! snw 3887: % When we turn headings on, set the page number to 1.
1.1 snw 3888: % For double-sided printing, put current file name in lower left corner,
3889: % chapter name on inside top of right hand pages, document
3890: % title on inside top of left hand pages, and page numbers on outside top
3891: % edge of all pages.
1.3 snw 3892: \def\HEADINGSdouble{%
1.5 ! snw 3893: \global\pageno=1
1.1 snw 3894: \global\evenfootline={\hfil}
3895: \global\oddfootline={\hfil}
3896: \global\evenheadline={\line{\folio\hfil\thistitle}}
1.5 ! snw 3897: \global\oddheadline={\line{\thischapterheading\hfil\folio}}
1.1 snw 3898: \global\let\contentsalignmacro = \chapoddpage
3899: }
1.5 ! snw 3900: \let\contentsalignmacro = \chappager
1.1 snw 3901:
1.4 snw 3902: % For single-sided printing, chapter title goes across top left of page,
3903: % page number on top right.
3904: \def\HEADINGSsingle{%
1.5 ! snw 3905: \global\pageno=1
1.1 snw 3906: \global\evenfootline={\hfil}
3907: \global\oddfootline={\hfil}
1.5 ! snw 3908: \global\evenheadline={\line{\thischapterheading\hfil\folio}}
! 3909: \global\oddheadline={\line{\thischapterheading\hfil\folio}}
1.1 snw 3910: \global\let\contentsalignmacro = \chappager
3911: }
1.5 ! snw 3912: \def\HEADINGSon{\HEADINGSdouble}
! 3913:
! 3914: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
! 3915: \let\HEADINGSdoubleafter=\HEADINGSafter
! 3916: \def\HEADINGSdoublex{%
! 3917: \global\evenfootline={\hfil}
! 3918: \global\oddfootline={\hfil}
! 3919: \global\evenheadline={\line{\folio\hfil\thistitle}}
! 3920: \global\oddheadline={\line{\thischapterheading\hfil\folio}}
! 3921: \global\let\contentsalignmacro = \chapoddpage
! 3922: }
1.1 snw 3923:
1.5 ! snw 3924: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
! 3925: \def\HEADINGSsinglex{%
1.1 snw 3926: \global\evenfootline={\hfil}
3927: \global\oddfootline={\hfil}
1.5 ! snw 3928: \global\evenheadline={\line{\thischapterheading\hfil\folio}}
! 3929: \global\oddheadline={\line{\thischapterheading\hfil\folio}}
1.1 snw 3930: \global\let\contentsalignmacro = \chappager
3931: }
3932:
3933: % Subroutines used in generating headings
3934: % This produces Day Month Year style of output.
3935: % Only define if not already defined, in case a txi-??.tex file has set
3936: % up a different format (e.g., txi-cs.tex does this).
3937: \ifx\today\thisisundefined
3938: \def\today{%
3939: \number\day\space
3940: \ifcase\month
3941: \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3942: \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3943: \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3944: \fi
3945: \space\number\year}
3946: \fi
3947:
3948: % @settitle line... specifies the title of the document, for headings.
3949: % It generates no output of its own.
3950: \def\thistitle{\putwordNoTitle}
3951: \def\settitle{\parsearg{\gdef\thistitle}}
3952:
3953:
3954: \message{tables,}
3955: % Tables -- @table, @ftable, @vtable, @item(x).
3956:
3957: % default indentation of table text
3958: \newdimen\tableindent \tableindent=.8in
3959: % default indentation of @itemize and @enumerate text
3960: \newdimen\itemindent \itemindent=.3in
3961: % margin between end of table item and start of table text.
3962: \newdimen\itemmargin \itemmargin=.1in
3963:
3964: % used internally for \itemindent minus \itemmargin
3965: \newdimen\itemmax
3966:
3967: % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3968: % these defs.
3969: % They also define \itemindex
3970: % to index the item name in whatever manner is desired (perhaps none).
3971:
3972: \newif\ifitemxneedsnegativevskip
3973:
3974: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3975:
3976: \def\internalBitem{\smallbreak \parsearg\itemzzz}
3977: \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3978:
3979: \def\itemzzz #1{\begingroup %
3980: \advance\hsize by -\rightskip
3981: \advance\hsize by -\tableindent
3982: \setbox0=\hbox{\itemindicate{#1}}%
3983: \itemindex{#1}%
3984: \nobreak % This prevents a break before @itemx.
3985: %
3986: % If the item text does not fit in the space we have, put it on a line
3987: % by itself, and do not allow a page break either before or after that
3988: % line. We do not start a paragraph here because then if the next
3989: % command is, e.g., @kindex, the whatsit would get put into the
3990: % horizontal list on a line by itself, resulting in extra blank space.
3991: \ifdim \wd0>\itemmax
3992: %
3993: % Make this a paragraph so we get the \parskip glue and wrapping,
3994: % but leave it ragged-right.
3995: \begingroup
3996: \advance\leftskip by-\tableindent
3997: \advance\hsize by\tableindent
3998: \advance\rightskip by0pt plus1fil\relax
3999: \leavevmode\unhbox0\par
4000: \endgroup
4001: %
4002: % We're going to be starting a paragraph, but we don't want the
4003: % \parskip glue -- logically it's part of the @item we just started.
4004: \nobreak \vskip-\parskip
4005: %
4006: % Stop a page break at the \parskip glue coming up. However, if
4007: % what follows is an environment such as @example, there will be no
4008: % \parskip glue; then the negative vskip we just inserted would
4009: % cause the example and the item to crash together. So we use this
4010: % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4011: % \parskip glue after all. Section titles are handled this way also.
4012: %
4013: \penalty 10001
4014: \endgroup
4015: \itemxneedsnegativevskipfalse
4016: \else
4017: % The item text fits into the space. Start a paragraph, so that the
4018: % following text (if any) will end up on the same line.
4019: \noindent
4020: % Do this with kerns and \unhbox so that if there is a footnote in
4021: % the item text, it can migrate to the main vertical list and
4022: % eventually be printed.
4023: \nobreak\kern-\tableindent
4024: \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4025: \unhbox0
4026: \nobreak\kern\dimen0
4027: \endgroup
4028: \itemxneedsnegativevskiptrue
4029: \fi
4030: }
4031:
4032: \def\item{\errmessage{@item while not in a list environment}}
4033: \def\itemx{\errmessage{@itemx while not in a list environment}}
4034:
4035: % @table, @ftable, @vtable.
4036: \envdef\table{%
4037: \let\itemindex\gobble
4038: \tablecheck{table}%
4039: }
4040: \envdef\ftable{%
4041: \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4042: \tablecheck{ftable}%
4043: }
4044: \envdef\vtable{%
4045: \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4046: \tablecheck{vtable}%
4047: }
4048: \def\tablecheck#1{%
4049: \ifnum \the\catcode`\^^M=\active
4050: \endgroup
4051: \errmessage{This command won't work in this context; perhaps the problem is
4052: that we are \inenvironment\thisenv}%
4053: \def\next{\doignore{#1}}%
4054: \else
4055: \let\next\tablex
4056: \fi
4057: \next
4058: }
4059: \def\tablex#1{%
4060: \def\itemindicate{#1}%
4061: \parsearg\tabley
4062: }
4063: \def\tabley#1{%
4064: {%
4065: \makevalueexpandable
4066: \edef\temp{\noexpand\tablez #1\space\space\space}%
4067: \expandafter
4068: }\temp \endtablez
4069: }
4070: \def\tablez #1 #2 #3 #4\endtablez{%
4071: \aboveenvbreak
4072: \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4073: \ifnum 0#2>0 \tableindent=#2\mil \fi
4074: \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4075: \itemmax=\tableindent
4076: \advance \itemmax by -\itemmargin
4077: \advance \leftskip by \tableindent
4078: \exdentamount=\tableindent
4079: \parindent = 0pt
4080: \parskip = \smallskipamount
4081: \ifdim \parskip=0pt \parskip=2pt \fi
4082: \let\item = \internalBitem
4083: \let\itemx = \internalBitemx
4084: }
4085: \def\Etable{\endgraf\afterenvbreak}
4086: \let\Eftable\Etable
4087: \let\Evtable\Etable
4088: \let\Eitemize\Etable
4089: \let\Eenumerate\Etable
4090:
4091: % This is the counter used by @enumerate, which is really @itemize
4092:
4093: \newcount \itemno
4094:
4095: \envdef\itemize{\parsearg\doitemize}
4096:
4097: \def\doitemize#1{%
4098: \aboveenvbreak
4099: \itemmax=\itemindent
4100: \advance\itemmax by -\itemmargin
4101: \advance\leftskip by \itemindent
4102: \exdentamount=\itemindent
4103: \parindent=0pt
4104: \parskip=\smallskipamount
4105: \ifdim\parskip=0pt \parskip=2pt \fi
4106: %
4107: % Try typesetting the item mark so that if the document erroneously says
4108: % something like @itemize @samp (intending @table), there's an error
4109: % right away at the @itemize. It's not the best error message in the
4110: % world, but it's better than leaving it to the @item. This means if
4111: % the user wants an empty mark, they have to say @w{} not just @w.
4112: \def\itemcontents{#1}%
4113: \setbox0 = \hbox{\itemcontents}%
4114: %
4115: % @itemize with no arg is equivalent to @itemize @bullet.
4116: \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4117: %
4118: \let\item=\itemizeitem
4119: }
4120:
4121: % Definition of @item while inside @itemize and @enumerate.
4122: %
4123: \def\itemizeitem{%
4124: \advance\itemno by 1 % for enumerations
4125: {\let\par=\endgraf \smallbreak}% reasonable place to break
4126: {%
4127: % If the document has an @itemize directly after a section title, a
4128: % \nobreak will be last on the list, and \sectionheading will have
4129: % done a \vskip-\parskip. In that case, we don't want to zero
4130: % parskip, or the item text will crash with the heading. On the
4131: % other hand, when there is normal text preceding the item (as there
4132: % usually is), we do want to zero parskip, or there would be too much
4133: % space. In that case, we won't have a \nobreak before. At least
4134: % that's the theory.
4135: \ifnum\lastpenalty<10000 \parskip=0in \fi
4136: \noindent
4137: \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4138: %
4139: \ifinner\else
4140: \vadjust{\penalty 1200}% not good to break after first line of item.
4141: \fi
4142: % We can be in inner vertical mode in a footnote, although an
4143: % @itemize looks awful there.
4144: }%
4145: \flushcr
4146: }
4147:
4148: % \splitoff TOKENS\endmark defines \first to be the first token in
4149: % TOKENS, and \rest to be the remainder.
4150: %
4151: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4152:
4153: % Allow an optional argument of an uppercase letter, lowercase letter,
4154: % or number, to specify the first label in the enumerated list. No
4155: % argument is the same as `1'.
4156: %
4157: \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
4158: \def\enumeratey #1 #2\endenumeratey{%
4159: % If we were given no argument, pretend we were given `1'.
4160: \def\thearg{#1}%
4161: \ifx\thearg\empty \def\thearg{1}\fi
4162: %
4163: % Detect if the argument is a single token. If so, it might be a
4164: % letter. Otherwise, the only valid thing it can be is a number.
4165: % (We will always have one token, because of the test we just made.
4166: % This is a good thing, since \splitoff doesn't work given nothing at
4167: % all -- the first parameter is undelimited.)
4168: \expandafter\splitoff\thearg\endmark
4169: \ifx\rest\empty
4170: % Only one token in the argument. It could still be anything.
4171: % A ``lowercase letter'' is one whose \lccode is nonzero.
4172: % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4173: % not equal to itself.
4174: % Otherwise, we assume it's a number.
4175: %
4176: % We need the \relax at the end of the \ifnum lines to stop TeX from
4177: % continuing to look for a <number>.
4178: %
4179: \ifnum\lccode\expandafter`\thearg=0\relax
4180: \numericenumerate % a number (we hope)
4181: \else
4182: % It's a letter.
4183: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4184: \lowercaseenumerate % lowercase letter
4185: \else
4186: \uppercaseenumerate % uppercase letter
4187: \fi
4188: \fi
4189: \else
4190: % Multiple tokens in the argument. We hope it's a number.
4191: \numericenumerate
4192: \fi
4193: }
4194:
4195: % An @enumerate whose labels are integers. The starting integer is
4196: % given in \thearg.
4197: %
4198: \def\numericenumerate{%
4199: \itemno = \thearg
4200: \startenumeration{\the\itemno}%
4201: }
4202:
4203: % The starting (lowercase) letter is in \thearg.
4204: \def\lowercaseenumerate{%
4205: \itemno = \expandafter`\thearg
4206: \startenumeration{%
4207: % Be sure we're not beyond the end of the alphabet.
4208: \ifnum\itemno=0
4209: \errmessage{No more lowercase letters in @enumerate; get a bigger
4210: alphabet}%
4211: \fi
4212: \char\lccode\itemno
4213: }%
4214: }
4215:
4216: % The starting (uppercase) letter is in \thearg.
4217: \def\uppercaseenumerate{%
4218: \itemno = \expandafter`\thearg
4219: \startenumeration{%
4220: % Be sure we're not beyond the end of the alphabet.
4221: \ifnum\itemno=0
4222: \errmessage{No more uppercase letters in @enumerate; get a bigger
4223: alphabet}
4224: \fi
4225: \char\uccode\itemno
4226: }%
4227: }
4228:
4229: % Call \doitemize, adding a period to the first argument and supplying the
4230: % common last two arguments. Also subtract one from the initial value in
4231: % \itemno, since @item increments \itemno.
4232: %
4233: \def\startenumeration#1{%
4234: \advance\itemno by -1
4235: \doitemize{#1.}\flushcr
4236: }
4237:
1.5 ! snw 4238: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
! 4239: % to @enumerate.
! 4240: %
! 4241: \def\alphaenumerate{\enumerate{a}}
! 4242: \def\capsenumerate{\enumerate{A}}
! 4243: \def\Ealphaenumerate{\Eenumerate}
! 4244: \def\Ecapsenumerate{\Eenumerate}
! 4245:
1.1 snw 4246:
4247: % @multitable macros
1.5 ! snw 4248: % Amy Hendrickson, 8/18/94, 3/6/96
! 4249: %
! 4250: % @multitable ... @end multitable will make as many columns as desired.
! 4251: % Contents of each column will wrap at width given in preamble. Width
! 4252: % can be specified either with sample text given in a template line,
! 4253: % or in percent of \hsize, the current width of text on page.
! 4254:
! 4255: % Table can continue over pages but will only break between lines.
! 4256:
! 4257: % To make preamble:
! 4258: %
! 4259: % Either define widths of columns in terms of percent of \hsize:
! 4260: % @multitable @columnfractions .25 .3 .45
! 4261: % @item ...
! 4262: %
! 4263: % Numbers following @columnfractions are the percent of the total
! 4264: % current hsize to be used for each column. You may use as many
! 4265: % columns as desired.
! 4266:
! 4267:
! 4268: % Or use a template:
! 4269: % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
! 4270: % @item ...
! 4271: % using the widest term desired in each column.
! 4272:
! 4273: % Each new table line starts with @item, each subsequent new column
! 4274: % starts with @tab. Empty columns may be produced by supplying @tab's
! 4275: % with nothing between them for as many times as empty columns are needed,
! 4276: % ie, @tab@tab@tab will produce two empty columns.
! 4277:
! 4278: % @item, @tab do not need to be on their own lines, but it will not hurt
! 4279: % if they are.
! 4280:
! 4281: % Sample multitable:
! 4282:
! 4283: % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
! 4284: % @item first col stuff @tab second col stuff @tab third col
! 4285: % @item
! 4286: % first col stuff
! 4287: % @tab
! 4288: % second col stuff
! 4289: % @tab
! 4290: % third col
! 4291: % @item first col stuff @tab second col stuff
! 4292: % @tab Many paragraphs of text may be used in any column.
! 4293: %
! 4294: % They will wrap at the width determined by the template.
! 4295: % @item@tab@tab This will be in third column.
! 4296: % @end multitable
! 4297:
! 4298: % Default dimensions may be reset by user.
! 4299: % @multitableparskip is vertical space between paragraphs in table.
! 4300: % @multitableparindent is paragraph indent in table.
! 4301: % @multitablecolmargin is horizontal space to be left between columns.
! 4302: % @multitablelinespace is space to leave between table items, baseline
! 4303: % to baseline.
! 4304: % 0pt means it depends on current normal line spacing.
! 4305: %
! 4306: \newskip\multitableparskip
! 4307: \newskip\multitableparindent
! 4308: \newdimen\multitablecolspace
! 4309: \newskip\multitablelinespace
! 4310: \multitableparskip=0pt
! 4311: \multitableparindent=6pt
! 4312: \multitablecolspace=12pt
! 4313: \multitablelinespace=0pt
1.1 snw 4314:
4315: % Macros used to set up halign preamble:
4316: %
4317: \let\endsetuptable\relax
4318: \def\xendsetuptable{\endsetuptable}
4319: \let\columnfractions\relax
4320: \def\xcolumnfractions{\columnfractions}
4321: \newif\ifsetpercent
4322:
4323: % #1 is the @columnfraction, usually a decimal number like .5, but might
4324: % be just 1. We just use it, whatever it is.
4325: %
4326: \def\pickupwholefraction#1 {%
4327: \global\advance\colcount by 1
4328: \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4329: \setuptable
4330: }
4331:
4332: \newcount\colcount
4333: \def\setuptable#1{%
4334: \def\firstarg{#1}%
4335: \ifx\firstarg\xendsetuptable
4336: \let\go = \relax
4337: \else
4338: \ifx\firstarg\xcolumnfractions
4339: \global\setpercenttrue
4340: \else
4341: \ifsetpercent
4342: \let\go\pickupwholefraction
4343: \else
4344: \global\advance\colcount by 1
4345: \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4346: % separator; typically that is always in the input, anyway.
4347: \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4348: \fi
4349: \fi
4350: \ifx\go\pickupwholefraction
4351: % Put the argument back for the \pickupwholefraction call, so
4352: % we'll always have a period there to be parsed.
4353: \def\go{\pickupwholefraction#1}%
4354: \else
4355: \let\go = \setuptable
4356: \fi%
4357: \fi
4358: \go
4359: }
4360:
1.5 ! snw 4361: % multitable-only commands.
! 4362: %
1.1 snw 4363: % @headitem starts a heading row, which we typeset in bold. Assignments
4364: % have to be global since we are inside the implicit group of an
4365: % alignment entry. \everycr below resets \everytab so we don't have to
4366: % undo it ourselves.
4367: \def\headitemfont{\b}% for people to use in the template row; not changeable
4368: \def\headitem{%
1.5 ! snw 4369: \checkenv\multitable
! 4370: \crcr
1.1 snw 4371: \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4372: \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4373: \the\everytab % for the first item
4374: }%
4375: %
4376: % default for tables with no headings.
4377: \let\headitemcrhook=\relax
4378: %
1.5 ! snw 4379: % A \tab used to include \hskip1sp. But then the space in a template
! 4380: % line is not enough. That is bad. So let's go back to just `&' until
! 4381: % we again encounter the problem the 1sp was intended to solve.
! 4382: % --karl, nathan@acm.org, 20apr99.
1.1 snw 4383: \def\tab{\checkenv\multitable &\the\everytab}%
4384:
1.5 ! snw 4385: % @multitable ... @end multitable definitions:
! 4386: %
1.1 snw 4387: \newtoks\everytab % insert after every tab.
4388: %
4389: \envdef\multitable{%
4390: \vskip\parskip
4391: \startsavinginserts
4392: %
4393: % @item within a multitable starts a normal row.
4394: % We use \def instead of \let so that if one of the multitable entries
4395: % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4396: % \endtemplate) expanding \doitemize.
4397: \def\item{\crcr}%
4398: %
4399: \tolerance=9500
4400: \hbadness=9500
1.5 ! snw 4401: \setmultitablespacing
! 4402: \parskip=\multitableparskip
! 4403: \parindent=\multitableparindent
1.1 snw 4404: \overfullrule=0pt
4405: \global\colcount=0
4406: %
4407: \everycr = {%
4408: \noalign{%
4409: \global\everytab={}% Reset from possible headitem.
4410: \global\colcount=0 % Reset the column counter.
4411: %
4412: % Check for saved footnotes, etc.:
4413: \checkinserts
4414: %
4415: % Perhaps a \nobreak, then reset:
4416: \headitemcrhook
4417: \global\let\headitemcrhook=\relax
4418: }%
4419: }%
4420: %
4421: \parsearg\domultitable
4422: }
4423: \def\domultitable#1{%
4424: % To parse everything between @multitable and @item:
4425: \setuptable#1 \endsetuptable
4426: %
4427: % This preamble sets up a generic column definition, which will
4428: % be used as many times as user calls for columns.
4429: % \vtop will set a single line and will also let text wrap and
4430: % continue for many paragraphs if desired.
4431: \halign\bgroup &%
4432: \global\advance\colcount by 1
1.5 ! snw 4433: \multistrut
1.1 snw 4434: \vtop{%
1.5 ! snw 4435: % Use the current \colcount to find the correct column width:
1.1 snw 4436: \hsize=\expandafter\csname col\the\colcount\endcsname
4437: %
1.5 ! snw 4438: % In order to keep entries from bumping into each other
! 4439: % we will add a \leftskip of \multitablecolspace to all columns after
! 4440: % the first one.
! 4441: %
! 4442: % If a template has been used, we will add \multitablecolspace
! 4443: % to the width of each template entry.
! 4444: %
! 4445: % If the user has set preamble in terms of percent of \hsize we will
! 4446: % use that dimension as the width of the column, and the \leftskip
! 4447: % will keep entries from bumping into each other. Table will start at
! 4448: % left margin and final column will justify at right margin.
! 4449: %
! 4450: % Make sure we don't inherit \rightskip from the outer environment.
! 4451: \rightskip=0pt
1.1 snw 4452: \ifnum\colcount=1
1.5 ! snw 4453: % The first column will be indented with the surrounding text.
! 4454: \advance\hsize by\leftskip
1.1 snw 4455: \else
1.5 ! snw 4456: \ifsetpercent \else
! 4457: % If user has not set preamble in terms of percent of \hsize
! 4458: % we will advance \hsize by \multitablecolspace.
! 4459: \advance\hsize by \multitablecolspace
! 4460: \fi
! 4461: % In either case we will make \leftskip=\multitablecolspace:
! 4462: \leftskip=\multitablecolspace
1.1 snw 4463: \fi
1.5 ! snw 4464: % Ignoring space at the beginning and end avoids an occasional spurious
! 4465: % blank line, when TeX decides to break the line at the space before the
! 4466: % box from the multistrut, so the strut ends up on a line by itself.
! 4467: % For example:
! 4468: % @multitable @columnfractions .11 .89
! 4469: % @item @code{#}
! 4470: % @tab Legal holiday which is valid in major parts of the whole country.
! 4471: % Is automatically provided with highlighting sequences respectively
! 4472: % marking characters.
! 4473: \noindent\ignorespaces##\unskip\multistrut
1.1 snw 4474: }\cr
4475: }
4476: \def\Emultitable{%
4477: \crcr
4478: \egroup % end the \halign
4479: \global\setpercentfalse
4480: }
4481:
1.5 ! snw 4482: \def\setmultitablespacing{%
! 4483: \def\multistrut{\strut}% just use the standard line spacing
! 4484: %
! 4485: % Compute \multitablelinespace (if not defined by user) for use in
! 4486: % \multitableparskip calculation. We used define \multistrut based on
! 4487: % this, but (ironically) that caused the spacing to be off.
! 4488: % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
! 4489: \ifdim\multitablelinespace=0pt
! 4490: \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
! 4491: \global\advance\multitablelinespace by-\ht0
! 4492: \fi
! 4493: % Test to see if parskip is larger than space between lines of
! 4494: % table. If not, do nothing.
! 4495: % If so, set to same dimension as multitablelinespace.
! 4496: \ifdim\multitableparskip>\multitablelinespace
! 4497: \global\multitableparskip=\multitablelinespace
! 4498: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
! 4499: % than skip between lines in the table.
! 4500: \fi%
! 4501: \ifdim\multitableparskip=0pt
! 4502: \global\multitableparskip=\multitablelinespace
! 4503: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
! 4504: % than skip between lines in the table.
! 4505: \fi}
! 4506:
1.1 snw 4507:
4508: \message{conditionals,}
4509:
1.5 ! snw 4510: % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
1.1 snw 4511: % @ifnotxml always succeed. They currently do nothing; we don't
4512: % attempt to check whether the conditionals are properly nested. But we
4513: % have to remember that they are conditionals, so that @end doesn't
4514: % attempt to close an environment group.
4515: %
4516: \def\makecond#1{%
4517: \expandafter\let\csname #1\endcsname = \relax
4518: \expandafter\let\csname iscond.#1\endcsname = 1
4519: }
4520: \makecond{iftex}
4521: \makecond{ifnotdocbook}
4522: \makecond{ifnothtml}
4523: \makecond{ifnotinfo}
4524: \makecond{ifnotplaintext}
4525: \makecond{ifnotxml}
4526:
4527: % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4528: %
4529: \def\direntry{\doignore{direntry}}
4530: \def\documentdescription{\doignore{documentdescription}}
4531: \def\docbook{\doignore{docbook}}
4532: \def\html{\doignore{html}}
4533: \def\ifdocbook{\doignore{ifdocbook}}
4534: \def\ifhtml{\doignore{ifhtml}}
4535: \def\ifinfo{\doignore{ifinfo}}
4536: \def\ifnottex{\doignore{ifnottex}}
4537: \def\ifplaintext{\doignore{ifplaintext}}
4538: \def\ifxml{\doignore{ifxml}}
4539: \def\ignore{\doignore{ignore}}
4540: \def\menu{\doignore{menu}}
4541: \def\xml{\doignore{xml}}
4542:
4543: % Ignore text until a line `@end #1', keeping track of nested conditionals.
4544: %
4545: % A count to remember the depth of nesting.
4546: \newcount\doignorecount
4547:
4548: \def\doignore#1{\begingroup
4549: % Scan in ``verbatim'' mode:
4550: \obeylines
4551: \catcode`\@ = \other
4552: \catcode`\{ = \other
4553: \catcode`\} = \other
4554: %
4555: % Make sure that spaces turn into tokens that match what \doignoretext wants.
4556: \spaceisspace
4557: %
4558: % Count number of #1's that we've seen.
4559: \doignorecount = 0
4560: %
4561: % Swallow text until we reach the matching `@end #1'.
4562: \dodoignore{#1}%
4563: }
4564:
4565: { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4566: \obeylines %
4567: %
4568: \gdef\dodoignore#1{%
4569: % #1 contains the command name as a string, e.g., `ifinfo'.
4570: %
4571: % Define a command to find the next `@end #1'.
4572: \long\def\doignoretext##1^^M@end #1{%
4573: \doignoretextyyy##1^^M@#1\_STOP_}%
4574: %
4575: % And this command to find another #1 command, at the beginning of a
4576: % line. (Otherwise, we would consider a line `@c @ifset', for
4577: % example, to count as an @ifset for nesting.)
4578: \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4579: %
4580: % And now expand that command.
4581: \doignoretext ^^M%
4582: }%
4583: }
4584:
4585: \def\doignoreyyy#1{%
4586: \def\temp{#1}%
4587: \ifx\temp\empty % Nothing found.
4588: \let\next\doignoretextzzz
4589: \else % Found a nested condition, ...
4590: \advance\doignorecount by 1
4591: \let\next\doignoretextyyy % ..., look for another.
4592: % If we're here, #1 ends with ^^M\ifinfo (for example).
4593: \fi
4594: \next #1% the token \_STOP_ is present just after this macro.
4595: }
4596:
4597: % We have to swallow the remaining "\_STOP_".
4598: %
4599: \def\doignoretextzzz#1{%
4600: \ifnum\doignorecount = 0 % We have just found the outermost @end.
4601: \let\next\enddoignore
4602: \else % Still inside a nested condition.
4603: \advance\doignorecount by -1
4604: \let\next\doignoretext % Look for the next @end.
4605: \fi
4606: \next
4607: }
4608:
4609: % Finish off ignored text.
4610: { \obeylines%
4611: % Ignore anything after the last `@end #1'; this matters in verbatim
4612: % environments, where otherwise the newline after an ignored conditional
4613: % would result in a blank line in the output.
4614: \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4615: }
4616:
4617:
4618: % @set VAR sets the variable VAR to an empty value.
4619: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4620: %
4621: % Since we want to separate VAR from REST-OF-LINE (which might be
4622: % empty), we can't just use \parsearg; we have to insert a space of our
4623: % own to delimit the rest of the line, and then take it out again if we
4624: % didn't need it.
4625: % We rely on the fact that \parsearg sets \catcode`\ =10.
4626: %
4627: \parseargdef\set{\setyyy#1 \endsetyyy}
4628: \def\setyyy#1 #2\endsetyyy{%
4629: {%
4630: \makevalueexpandable
4631: \def\temp{#2}%
4632: \edef\next{\gdef\makecsname{SET#1}}%
4633: \ifx\temp\empty
4634: \next{}%
4635: \else
4636: \setzzz#2\endsetzzz
4637: \fi
4638: }%
4639: }
4640: % Remove the trailing space \setxxx inserted.
4641: \def\setzzz#1 \endsetzzz{\next{#1}}
4642:
4643: % @clear VAR clears (i.e., unsets) the variable VAR.
4644: %
4645: \parseargdef\clear{%
4646: {%
4647: \makevalueexpandable
4648: \global\expandafter\let\csname SET#1\endcsname=\relax
4649: }%
4650: }
4651:
4652: % @value{foo} gets the text saved in variable foo.
4653: \def\value{\begingroup\makevalueexpandable\valuexxx}
4654: \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4655: {
4656: \catcode`\-=\active \catcode`\_=\active
4657: %
4658: \gdef\makevalueexpandable{%
4659: \let\value = \expandablevalue
4660: % We don't want these characters active, ...
4661: \catcode`\-=\other \catcode`\_=\other
4662: % ..., but we might end up with active ones in the argument if
4663: % we're called from @code, as @code{@value{foo-bar_}}, though.
4664: % So \let them to their normal equivalents.
4665: \let-\normaldash \let_\normalunderscore
4666: }
4667: }
4668:
4669: \def\expandablevalue#1{%
4670: \expandafter\ifx\csname SET#1\endcsname\relax
4671: {[No value for ``#1'']}%
4672: \message{Variable `#1', used in @value, is not set.}%
4673: \else
4674: \csname SET#1\endcsname
4675: \fi
4676: }
4677:
4678: % Like \expandablevalue, but completely expandable (the \message in the
4679: % definition above operates at the execution level of TeX). Used when
4680: % writing to auxiliary files, due to the expansion that \write does.
4681: % If flag is undefined, pass through an unexpanded @value command: maybe it
4682: % will be set by the time it is read back in.
4683: %
4684: % NB flag names containing - or _ may not work here.
4685: \def\dummyvalue#1{%
4686: \expandafter\ifx\csname SET#1\endcsname\relax
4687: \string\value{#1}%
4688: \else
4689: \csname SET#1\endcsname
4690: \fi
4691: }
4692:
4693: % Used for @value's in index entries to form the sort key: expand the @value
4694: % if possible, otherwise sort late.
4695: \def\indexnofontsvalue#1{%
4696: \expandafter\ifx\csname SET#1\endcsname\relax
4697: ZZZZZZZ%
4698: \else
4699: \csname SET#1\endcsname
4700: \fi
4701: }
4702:
4703: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4704: % with @set.
4705: %
4706: % To get the special treatment we need for `@end ifset,' we call
4707: % \makecond and then redefine.
4708: %
4709: \makecond{ifset}
4710: \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4711: \def\doifset#1#2{%
4712: {%
4713: \makevalueexpandable
4714: \let\next=\empty
4715: \expandafter\ifx\csname SET#2\endcsname\relax
4716: #1% If not set, redefine \next.
4717: \fi
4718: \expandafter
4719: }\next
4720: }
4721: \def\ifsetfail{\doignore{ifset}}
4722:
4723: % @ifclear VAR ... @end executes the `...' iff VAR has never been
4724: % defined with @set, or has been undefined with @clear.
4725: %
4726: % The `\else' inside the `\doifset' parameter is a trick to reuse the
4727: % above code: if the variable is not set, do nothing, if it is set,
4728: % then redefine \next to \ifclearfail.
4729: %
4730: \makecond{ifclear}
4731: \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4732: \def\ifclearfail{\doignore{ifclear}}
4733:
4734: % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4735: % without the @) is in fact defined. We can only feasibly check at the
4736: % TeX level, so something like `mathcode' is going to considered
4737: % defined even though it is not a Texinfo command.
4738: %
4739: \makecond{ifcommanddefined}
4740: \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4741: %
4742: \def\doifcmddefined#1#2{{%
4743: \makevalueexpandable
4744: \let\next=\empty
4745: \expandafter\ifx\csname #2\endcsname\relax
4746: #1% If not defined, \let\next as above.
4747: \fi
4748: \expandafter
4749: }\next
4750: }
4751: \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4752:
4753: % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4754: \makecond{ifcommandnotdefined}
4755: \def\ifcommandnotdefined{%
4756: \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4757: \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4758:
4759: % Set the `txicommandconditionals' variable, so documents have a way to
4760: % test if the @ifcommand...defined conditionals are available.
4761: \set txicommandconditionals
4762:
4763: % @dircategory CATEGORY -- specify a category of the dir file
4764: % which this file should belong to. Ignore this in TeX.
4765: \let\dircategory=\comment
4766:
4767: % @defininfoenclose.
4768: \let\definfoenclose=\comment
4769:
4770:
4771: \message{indexing,}
4772: % Index generation facilities
4773:
4774: % Define \newwrite to be identical to plain tex's \newwrite
4775: % except not \outer, so it can be used within macros and \if's.
4776: \edef\newwrite{\makecsname{ptexnewwrite}}
4777:
1.5 ! snw 4778: % \newindex {foo} defines an index named IX.
1.1 snw 4779: % It automatically defines \IXindex such that
4780: % \IXindex ...rest of line... puts an entry in the index IX.
4781: % It also defines \IXindfile to be the number of the output channel for
4782: % the file that accumulates this index. The file's extension is IX.
1.5 ! snw 4783: % The name of an index should be no more than 2 characters long
! 4784: % for the sake of vms.
1.1 snw 4785: %
4786: \def\newindex#1{%
4787: \expandafter\chardef\csname#1indfile\endcsname=0
4788: \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
4789: \noexpand\doindex{#1}}
4790: }
4791:
4792: % @defindex foo == \newindex{foo}
4793: %
4794: \def\defindex{\parsearg\newindex}
4795:
4796: % Define @defcodeindex, like @defindex except put all entries in @code.
4797: %
4798: \def\defcodeindex{\parsearg\newcodeindex}
4799: %
4800: \def\newcodeindex#1{%
4801: \expandafter\chardef\csname#1indfile\endcsname=0
4802: \expandafter\xdef\csname#1index\endcsname{%
4803: \noexpand\docodeindex{#1}}%
4804: }
4805:
4806: % The default indices:
4807: \newindex{cp}% concepts,
4808: \newcodeindex{fn}% functions,
4809: \newcodeindex{vr}% variables,
4810: \newcodeindex{tp}% types,
4811: \newcodeindex{ky}% keys
4812: \newcodeindex{pg}% and programs.
4813:
4814:
4815: % @synindex foo bar makes index foo feed into index bar.
4816: % Do this instead of @defindex foo if you don't want it as a separate index.
4817: %
4818: % @syncodeindex foo bar similar, but put all entries made for index foo
4819: % inside @code.
4820: %
4821: \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4822: \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4823:
4824: % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4825: % #3 the target index (bar).
4826: \def\dosynindex#1#2#3{%
4827: \requireopenindexfile{#3}%
4828: % redefine \fooindfile:
4829: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4830: \expandafter\let\csname#2indfile\endcsname=\temp
4831: % redefine \fooindex:
4832: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4833: }
4834:
4835: % Define \doindex, the driver for all index macros.
4836: % Argument #1 is generated by the calling \fooindex macro,
4837: % and it is the two-letter name of the index.
4838:
4839: \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4840: \def\doindexxxx #1{\doind{\indexname}{#1}}
4841:
4842: % like the previous two, but they put @code around the argument.
4843: \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
1.5 ! snw 4844: \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
! 4845:
1.1 snw 4846:
1.5 ! snw 4847: % Used for the aux, toc and index files to prevent expansion of Texinfo
! 4848: % commands.
! 4849: %
! 4850: \def\atdummies{%
! 4851: \definedummyletter\@%
! 4852: \definedummyletter\ %
! 4853: \definedummyletter\{%
! 4854: \definedummyletter\}%
! 4855: \definedummyletter\&%
! 4856: %
! 4857: % Do the redefinitions.
! 4858: \definedummies
! 4859: \otherbackslash
! 4860: }
1.1 snw 4861:
4862: % \definedummyword defines \#1 as \string\#1\space, thus effectively
4863: % preventing its expansion. This is used only for control words,
4864: % not control letters, because the \space would be incorrect for
4865: % control characters, but is needed to separate the control word
4866: % from whatever follows.
4867: %
4868: % These can be used both for control words that take an argument and
4869: % those that do not. If it is followed by {arg} in the input, then
4870: % that will dutifully get written to the index (or wherever).
4871: %
4872: % For control letters, we have \definedummyletter, which omits the
4873: % space.
4874: %
4875: \def\definedummyword #1{\def#1{\string#1\space}}%
4876: \def\definedummyletter#1{\def#1{\string#1}}%
1.5 ! snw 4877: \let\definedummyaccent\definedummyletter
1.1 snw 4878:
1.5 ! snw 4879: % Called from \atdummies to prevent the expansion of commands.
1.1 snw 4880: %
1.5 ! snw 4881: \def\definedummies{%
1.1 snw 4882: %
1.5 ! snw 4883: \let\commondummyword\definedummyword
! 4884: \let\commondummyletter\definedummyletter
! 4885: \let\commondummyaccent\definedummyaccent
! 4886: \commondummiesnofonts
1.1 snw 4887: %
4888: \definedummyletter\_%
4889: \definedummyletter\-%
4890: %
1.5 ! snw 4891: % Non-English letters.
! 4892: \definedummyword\AA
! 4893: \definedummyword\AE
! 4894: \definedummyword\DH
! 4895: \definedummyword\L
! 4896: \definedummyword\O
! 4897: \definedummyword\OE
! 4898: \definedummyword\TH
! 4899: \definedummyword\aa
! 4900: \definedummyword\ae
! 4901: \definedummyword\dh
! 4902: \definedummyword\exclamdown
! 4903: \definedummyword\l
! 4904: \definedummyword\o
! 4905: \definedummyword\oe
! 4906: \definedummyword\ordf
! 4907: \definedummyword\ordm
! 4908: \definedummyword\questiondown
! 4909: \definedummyword\ss
! 4910: \definedummyword\th
! 4911: %
! 4912: % Although these internal commands shouldn't show up, sometimes they do.
! 4913: \definedummyword\bf
! 4914: \definedummyword\gtr
! 4915: \definedummyword\hat
! 4916: \definedummyword\less
! 4917: \definedummyword\sf
! 4918: \definedummyword\sl
! 4919: \definedummyword\tclose
! 4920: \definedummyword\tt
! 4921: %
! 4922: \definedummyword\LaTeX
! 4923: \definedummyword\TeX
! 4924: %
! 4925: % Assorted special characters.
! 4926: \definedummyword\ampchar
! 4927: \definedummyword\atchar
! 4928: \definedummyword\arrow
! 4929: \definedummyword\backslashchar
! 4930: \definedummyword\bullet
! 4931: \definedummyword\comma
! 4932: \definedummyword\copyright
! 4933: \definedummyword\registeredsymbol
! 4934: \definedummyword\dots
! 4935: \definedummyword\enddots
! 4936: \definedummyword\entrybreak
! 4937: \definedummyword\equiv
! 4938: \definedummyword\error
! 4939: \definedummyword\euro
! 4940: \definedummyword\expansion
! 4941: \definedummyword\geq
! 4942: \definedummyword\guillemetleft
! 4943: \definedummyword\guillemetright
! 4944: \definedummyword\guilsinglleft
! 4945: \definedummyword\guilsinglright
! 4946: \definedummyword\lbracechar
! 4947: \definedummyword\leq
! 4948: \definedummyword\mathopsup
! 4949: \definedummyword\minus
! 4950: \definedummyword\ogonek
! 4951: \definedummyword\pounds
! 4952: \definedummyword\point
! 4953: \definedummyword\print
! 4954: \definedummyword\quotedblbase
! 4955: \definedummyword\quotedblleft
! 4956: \definedummyword\quotedblright
! 4957: \definedummyword\quoteleft
! 4958: \definedummyword\quoteright
! 4959: \definedummyword\quotesinglbase
! 4960: \definedummyword\rbracechar
! 4961: \definedummyword\result
! 4962: \definedummyword\sub
! 4963: \definedummyword\sup
! 4964: \definedummyword\textdegree
! 4965: %
1.1 snw 4966: \definedummyword\subentry
4967: %
4968: % We want to disable all macros so that they are not expanded by \write.
4969: \macrolist
4970: \let\value\dummyvalue
4971: %
1.5 ! snw 4972: \normalturnoffactive
1.1 snw 4973: }
4974:
1.5 ! snw 4975: % \commondummiesnofonts: common to \definedummies and \indexnofonts.
! 4976: % Define \commondummyletter, \commondummyaccent and \commondummyword before
! 4977: % using. Used for accents, font commands, and various control letters.
! 4978: %
! 4979: \def\commondummiesnofonts{%
! 4980: % Control letters and accents.
1.1 snw 4981: \commondummyletter\!%
4982: \commondummyaccent\"%
4983: \commondummyaccent\'%
4984: \commondummyletter\*%
4985: \commondummyaccent\,%
4986: \commondummyletter\.%
4987: \commondummyletter\/%
4988: \commondummyletter\:%
4989: \commondummyaccent\=%
4990: \commondummyletter\?%
4991: \commondummyaccent\^%
4992: \commondummyaccent\`%
4993: \commondummyaccent\~%
1.5 ! snw 4994: \commondummyword\u
! 4995: \commondummyword\v
! 4996: \commondummyword\H
! 4997: \commondummyword\dotaccent
! 4998: \commondummyword\ogonek
! 4999: \commondummyword\ringaccent
! 5000: \commondummyword\tieaccent
! 5001: \commondummyword\ubaraccent
! 5002: \commondummyword\udotaccent
! 5003: \commondummyword\dotless
1.1 snw 5004: %
5005: % Texinfo font commands.
1.5 ! snw 5006: \commondummyword\b
! 5007: \commondummyword\i
! 5008: \commondummyword\r
! 5009: \commondummyword\sansserif
! 5010: \commondummyword\sc
! 5011: \commondummyword\slanted
! 5012: \commondummyword\t
1.1 snw 5013: %
5014: % Commands that take arguments.
1.5 ! snw 5015: \commondummyword\abbr
! 5016: \commondummyword\acronym
! 5017: \commondummyword\anchor
! 5018: \commondummyword\cite
! 5019: \commondummyword\code
! 5020: \commondummyword\command
! 5021: \commondummyword\dfn
! 5022: \commondummyword\dmn
! 5023: \commondummyword\email
! 5024: \commondummyword\emph
! 5025: \commondummyword\env
! 5026: \commondummyword\file
! 5027: \commondummyword\image
! 5028: \commondummyword\indicateurl
! 5029: \commondummyword\inforef
! 5030: \commondummyword\kbd
! 5031: \commondummyword\key
! 5032: \commondummyword\math
! 5033: \commondummyword\option
! 5034: \commondummyword\pxref
! 5035: \commondummyword\ref
! 5036: \commondummyword\samp
! 5037: \commondummyword\strong
! 5038: \commondummyword\tie
! 5039: \commondummyword\U
! 5040: \commondummyword\uref
! 5041: \commondummyword\url
! 5042: \commondummyword\var
! 5043: \commondummyword\verb
! 5044: \commondummyword\w
! 5045: \commondummyword\xref
1.1 snw 5046: }
5047:
5048: \let\indexlbrace\relax
5049: \let\indexrbrace\relax
5050: \let\indexatchar\relax
5051: \let\indexbackslash\relax
5052:
5053: {\catcode`\@=0
5054: \catcode`\\=13
5055: @gdef@backslashdisappear{@def\{}}
5056: }
5057:
5058: {
5059: \catcode`\<=13
5060: \catcode`\-=13
5061: \catcode`\`=13
5062: \gdef\indexnonalnumdisappear{%
1.5 ! snw 5063: \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
1.1 snw 5064: % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5065: % (Introduced for FSFS 2nd ed.)
5066: \let`=\empty
1.5 ! snw 5067: \fi
1.1 snw 5068: %
1.5 ! snw 5069: \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
1.1 snw 5070: \backslashdisappear
1.5 ! snw 5071: \fi
! 5072: %
! 5073: \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
1.1 snw 5074: \def-{}%
1.5 ! snw 5075: \fi
! 5076: \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
1.1 snw 5077: \def<{}%
1.5 ! snw 5078: \fi
! 5079: \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
1.1 snw 5080: \def\@{}%
1.5 ! snw 5081: \fi
1.1 snw 5082: }
5083:
5084: \gdef\indexnonalnumreappear{%
5085: \let-\normaldash
5086: \let<\normalless
5087: }
5088: }
5089:
5090:
5091: % \indexnofonts is used when outputting the strings to sort the index
5092: % by, and when constructing control sequence names. It eliminates all
5093: % control sequences and just writes whatever the best ASCII sort string
5094: % would be for a given command (usually its argument).
5095: %
5096: \def\indexnofonts{%
1.5 ! snw 5097: % Accent commands should become @asis.
! 5098: \def\commondummyaccent##1{\let##1\asis}%
! 5099: % We can just ignore other control letters.
! 5100: \def\commondummyletter##1{\let##1\empty}%
! 5101: % All control words become @asis by default; overrides below.
! 5102: \let\commondummyword\commondummyaccent
! 5103: \commondummiesnofonts
! 5104: %
! 5105: % Don't no-op \tt, since it isn't a user-level command
! 5106: % and is used in the definitions of the active chars like <, >, |, etc.
! 5107: % Likewise with the other plain tex font commands.
! 5108: %\let\tt=\asis
1.1 snw 5109: %
5110: \def\ { }%
5111: \def\@{@}%
5112: \def\_{\normalunderscore}%
5113: \def\-{}% @- shouldn't affect sorting
5114: %
5115: \uccode`\1=`\{ \uppercase{\def\{{1}}%
5116: \uccode`\1=`\} \uppercase{\def\}{1}}%
5117: \let\lbracechar\{%
5118: \let\rbracechar\}%
5119: %
1.5 ! snw 5120: % Non-English letters.
! 5121: \def\AA{AA}%
! 5122: \def\AE{AE}%
! 5123: \def\DH{DZZ}%
! 5124: \def\L{L}%
! 5125: \def\OE{OE}%
! 5126: \def\O{O}%
! 5127: \def\TH{TH}%
! 5128: \def\aa{aa}%
! 5129: \def\ae{ae}%
! 5130: \def\dh{dzz}%
! 5131: \def\exclamdown{!}%
! 5132: \def\l{l}%
! 5133: \def\oe{oe}%
! 5134: \def\ordf{a}%
! 5135: \def\ordm{o}%
! 5136: \def\o{o}%
! 5137: \def\questiondown{?}%
! 5138: \def\ss{ss}%
! 5139: \def\th{th}%
! 5140: %
! 5141: \def\LaTeX{LaTeX}%
! 5142: \def\TeX{TeX}%
! 5143: %
! 5144: % Assorted special characters. \defglyph gives the control sequence a
! 5145: % definition that removes the {} that follows its use.
! 5146: \defglyph\atchar{@}%
! 5147: \defglyph\arrow{->}%
! 5148: \defglyph\bullet{bullet}%
! 5149: \defglyph\comma{,}%
! 5150: \defglyph\copyright{copyright}%
! 5151: \defglyph\dots{...}%
! 5152: \defglyph\enddots{...}%
! 5153: \defglyph\equiv{==}%
! 5154: \defglyph\error{error}%
! 5155: \defglyph\euro{euro}%
! 5156: \defglyph\expansion{==>}%
! 5157: \defglyph\geq{>=}%
! 5158: \defglyph\guillemetleft{<<}%
! 5159: \defglyph\guillemetright{>>}%
! 5160: \defglyph\guilsinglleft{<}%
! 5161: \defglyph\guilsinglright{>}%
! 5162: \defglyph\leq{<=}%
! 5163: \defglyph\lbracechar{\{}%
! 5164: \defglyph\minus{-}%
! 5165: \defglyph\point{.}%
! 5166: \defglyph\pounds{pounds}%
! 5167: \defglyph\print{-|}%
! 5168: \defglyph\quotedblbase{"}%
! 5169: \defglyph\quotedblleft{"}%
! 5170: \defglyph\quotedblright{"}%
! 5171: \defglyph\quoteleft{`}%
! 5172: \defglyph\quoteright{'}%
! 5173: \defglyph\quotesinglbase{,}%
! 5174: \defglyph\rbracechar{\}}%
! 5175: \defglyph\registeredsymbol{R}%
! 5176: \defglyph\result{=>}%
! 5177: \defglyph\textdegree{o}%
1.1 snw 5178: %
5179: % We need to get rid of all macros, leaving only the arguments (if present).
5180: % Of course this is not nearly correct, but it is the best we can do for now.
1.5 ! snw 5181: % makeinfo does not expand macros in the argument to @deffn, which ends up
! 5182: % writing an index entry, and texindex isn't prepared for an index sort entry
! 5183: % that starts with \.
1.1 snw 5184: %
5185: % Since macro invocations are followed by braces, we can just redefine them
5186: % to take a single TeX argument. The case of a macro invocation that
5187: % goes to end-of-line is not handled.
5188: %
5189: \macrolist
5190: \let\value\indexnofontsvalue
5191: }
1.5 ! snw 5192: \def\defglyph#1#2{\def#1##1{#2}} % see above
1.1 snw 5193:
5194:
5195:
5196:
5197: % #1 is the index name, #2 is the entry text.
5198: \def\doind#1#2{%
5199: \iflinks
5200: {%
5201: %
5202: \requireopenindexfile{#1}%
5203: \edef\writeto{\csname#1indfile\endcsname}%
5204: %
5205: \def\indextext{#2}%
5206: \safewhatsit\doindwrite
5207: }%
5208: \fi
5209: }
5210:
5211: % Check if an index file has been opened, and if not, open it.
5212: \def\requireopenindexfile#1{%
5213: \ifnum\csname #1indfile\endcsname=0
5214: \expandafter\newwrite \csname#1indfile\endcsname
5215: \edef\suffix{#1}%
5216: % A .fls suffix would conflict with the file extension for the output
5217: % of -recorder, so use .f1s instead.
5218: \ifx\suffix\indexisfl\def\suffix{f1}\fi
5219: % Open the file
5220: \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5221: % Using \immediate above here prevents an object entering into the current
5222: % box, which could confound checks such as those in \safewhatsit for
5223: % preceding skips.
5224: \typeout{Writing index file \jobname.\suffix}%
5225: \fi}
5226: \def\indexisfl{fl}
5227:
5228: % Definition for writing index entry sort key.
5229: {
5230: \catcode`\-=13
5231: \gdef\indexwritesortas{%
5232: \begingroup
5233: \indexnonalnumreappear
5234: \indexwritesortasxxx}
5235: \gdef\indexwritesortasxxx#1{%
5236: \xdef\indexsortkey{#1}\endgroup}
5237: }
5238:
5239: \def\indexwriteseealso#1{
5240: \gdef\pagenumbertext{\string\seealso{#1}}%
5241: }
5242: \def\indexwriteseeentry#1{
5243: \gdef\pagenumbertext{\string\seeentry{#1}}%
5244: }
5245:
5246: % The default definitions
5247: \def\sortas#1{}%
5248: \def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5249: \def\putwordSeeAlso{See also}
5250: \def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5251:
5252:
5253: % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5254: % * Set \bracedtext to "{aaa}{bbb}"
5255: % * Set \fullindexsortkey to "aaa @subentry ZZZ"
5256: % * If @seealso occurs, set \pagenumbertext
5257: %
5258: \def\splitindexentry#1{%
5259: \gdef\fullindexsortkey{}%
5260: \xdef\bracedtext{}%
5261: \def\sep{}%
5262: \def\seealso##1{}%
5263: \def\seeentry##1{}%
5264: \expandafter\doindexsegment#1\subentry\finish\subentry
5265: }
5266:
5267: % append the results from the next segment
5268: \def\doindexsegment#1\subentry{%
5269: \def\segment{#1}%
5270: \ifx\segment\isfinish
5271: \else
5272: %
5273: % Fully expand the segment, throwing away any @sortas directives, and
5274: % trim spaces.
5275: \edef\trimmed{\segment}%
5276: \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5277: %
5278: \xdef\bracedtext{\bracedtext{\trimmed}}%
5279: %
5280: % Get the string to sort by. Process the segment with all
5281: % font commands turned off.
5282: \bgroup
5283: \let\sortas\indexwritesortas
5284: \let\seealso\indexwriteseealso
5285: \let\seeentry\indexwriteseeentry
5286: \indexnofonts
5287: % The braces around the commands are recognized by texindex.
5288: \def\lbracechar{{\string\indexlbrace}}%
5289: \def\rbracechar{{\string\indexrbrace}}%
5290: \let\{=\lbracechar
5291: \let\}=\rbracechar
5292: \def\@{{\string\indexatchar}}%
5293: \def\atchar##1{\@}%
5294: \def\backslashchar{{\string\indexbackslash}}%
5295: \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5296: %
5297: \let\indexsortkey\empty
5298: \global\let\pagenumbertext\empty
5299: % Execute the segment and throw away the typeset output. This executes
5300: % any @sortas or @seealso commands in this segment.
5301: \setbox\dummybox = \hbox{\segment}%
5302: \ifx\indexsortkey\empty{%
5303: \indexnonalnumdisappear
5304: \xdef\trimmed{\segment}%
5305: \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5306: \xdef\indexsortkey{\trimmed}%
1.5 ! snw 5307: \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
1.1 snw 5308: }\fi
5309: %
5310: % Append to \fullindexsortkey.
5311: \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5312: \fullindexsortkey\sep\indexsortkey}}%
5313: \tmp
5314: \egroup
5315: \def\sep{\subentry}%
5316: %
5317: \expandafter\doindexsegment
5318: \fi
5319: }
5320: \def\isfinish{\finish}%
5321: \newbox\dummybox % used above
5322:
5323: \let\subentry\relax
5324:
5325: % Use \ instead of @ in index files. To support old texi2dvi and texindex.
5326: % This works without changing the escape character used in the toc or aux
5327: % files because the index entries are fully expanded here, and \string uses
5328: % the current value of \escapechar.
5329: \def\escapeisbackslash{\escapechar=`\\}
5330:
1.5 ! snw 5331: % Use \ in index files by default. texi2dvi didn't support @ as the escape
! 5332: % character (as it checked for "\entry" in the files, and not "@entry"). When
! 5333: % the new version of texi2dvi has had a chance to become more prevalent, then
! 5334: % the escape character can change back to @ again. This should be an easy
! 5335: % change to make now because both @ and \ are only used as escape characters in
! 5336: % index files, never standing for themselves.
1.1 snw 5337: %
1.5 ! snw 5338: \set txiindexescapeisbackslash
1.1 snw 5339:
5340: % Write the entry in \indextext to the index file.
5341: %
1.5 ! snw 5342: \def\doindwrite{%
1.1 snw 5343: \maybemarginindex
5344: %
5345: \atdummies
5346: %
1.5 ! snw 5347: \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
! 5348: \escapeisbackslash
! 5349: \fi
1.1 snw 5350: %
5351: % For texindex which always views { and } as separators.
5352: \def\{{\lbracechar{}}%
5353: \def\}{\rbracechar{}}%
5354: \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5355: %
5356: % Split the entry into primary entry and any subentries, and get the index
5357: % sort key.
5358: \splitindexentry\indextext
5359: %
5360: % Set up the complete index entry, with both the sort key and
5361: % the original text, including any font commands. We write
5362: % three arguments to \entry to the .?? file (four in the
5363: % subentry case), texindex reduces to two when writing the .??s
5364: % sorted result.
5365: %
5366: \edef\temp{%
5367: \write\writeto{%
5368: \string\entry{\fullindexsortkey}%
5369: {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5370: \bracedtext}%
5371: }%
5372: \temp
5373: }
5374:
5375: % Put the index entry in the margin if desired (undocumented).
5376: \def\maybemarginindex{%
5377: \ifx\SETmarginindex\relax\else
5378: \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5379: \fi
5380: }
5381: \let\SETmarginindex=\relax
5382:
5383:
5384: % Take care of unwanted page breaks/skips around a whatsit:
5385: %
5386: % If a skip is the last thing on the list now, preserve it
5387: % by backing up by \lastskip, doing the \write, then inserting
5388: % the skip again. Otherwise, the whatsit generated by the
5389: % \write or \pdfdest will make \lastskip zero. The result is that
5390: % sequences like this:
5391: % @end defun
5392: % @tindex whatever
5393: % @defun ...
5394: % will have extra space inserted, because the \medbreak in the
5395: % start of the @defun won't see the skip inserted by the @end of
5396: % the previous defun.
5397: %
5398: % But don't do any of this if we're not in vertical mode. We
5399: % don't want to do a \vskip and prematurely end a paragraph.
5400: %
5401: % Avoid page breaks due to these extra skips, too.
5402: %
5403: % But wait, there is a catch there:
5404: % We'll have to check whether \lastskip is zero skip. \ifdim is not
5405: % sufficient for this purpose, as it ignores stretch and shrink parts
5406: % of the skip. The only way seems to be to check the textual
5407: % representation of the skip.
5408: %
5409: % The following is almost like \def\zeroskipmacro{0.0pt} except that
5410: % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5411: %
5412: \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5413: %
5414: \newskip\whatsitskip
5415: \newcount\whatsitpenalty
5416: %
5417: % ..., ready, GO:
5418: %
5419: \def\safewhatsit#1{\ifhmode
5420: #1%
5421: \else
5422: % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5423: \whatsitskip = \lastskip
5424: \edef\lastskipmacro{\the\lastskip}%
5425: \whatsitpenalty = \lastpenalty
5426: %
5427: % If \lastskip is nonzero, that means the last item was a
5428: % skip. And since a skip is discardable, that means this
5429: % -\whatsitskip glue we're inserting is preceded by a
5430: % non-discardable item, therefore it is not a potential
5431: % breakpoint, therefore no \nobreak needed.
5432: \ifx\lastskipmacro\zeroskipmacro
5433: \else
5434: \vskip-\whatsitskip
5435: \fi
5436: %
5437: #1%
5438: %
5439: \ifx\lastskipmacro\zeroskipmacro
5440: % If \lastskip was zero, perhaps the last item was a penalty, and
5441: % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
5442: % to re-insert the same penalty (values >10000 are used for various
5443: % signals); since we just inserted a non-discardable item, any
5444: % following glue (such as a \parskip) would be a breakpoint. For example:
5445: % @deffn deffn-whatever
5446: % @vindex index-whatever
5447: % Description.
5448: % would allow a break between the index-whatever whatsit
5449: % and the "Description." paragraph.
5450: \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5451: \else
5452: % On the other hand, if we had a nonzero \lastskip,
5453: % this make-up glue would be preceded by a non-discardable item
5454: % (the whatsit from the \write), so we must insert a \nobreak.
5455: \nobreak\vskip\whatsitskip
5456: \fi
5457: \fi}
5458:
5459: % The index entry written in the file actually looks like
5460: % \entry {sortstring}{page}{topic}
5461: % or
5462: % \entry {sortstring}{page}{topic}{subtopic}
5463: % The texindex program reads in these files and writes files
5464: % containing these kinds of lines:
5465: % \initial {c}
5466: % before the first topic whose initial is c
5467: % \entry {topic}{pagelist}
5468: % for a topic that is used without subtopics
5469: % \primary {topic}
5470: % \entry {topic}{}
5471: % for the beginning of a topic that is used with subtopics
5472: % \secondary {subtopic}{pagelist}
5473: % for each subtopic.
5474: % \secondary {subtopic}{}
5475: % for a subtopic with sub-subtopics
5476: % \tertiary {subtopic}{subsubtopic}{pagelist}
5477: % for each sub-subtopic.
5478:
5479: % Define the user-accessible indexing commands
5480: % @findex, @vindex, @kindex, @cindex.
5481:
5482: \def\findex {\fnindex}
5483: \def\kindex {\kyindex}
5484: \def\cindex {\cpindex}
5485: \def\vindex {\vrindex}
5486: \def\tindex {\tpindex}
5487: \def\pindex {\pgindex}
5488:
5489: % Define the macros used in formatting output of the sorted index material.
5490:
5491: % @printindex causes a particular index (the ??s file) to get printed.
5492: % It does not print any chapter heading (usually an @unnumbered).
5493: %
5494: \parseargdef\printindex{\begingroup
5495: \dobreak \chapheadingskip{10000}%
5496: %
5497: \smallfonts \rm
5498: \tolerance = 9500
5499: \plainfrenchspacing
5500: \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5501: %
5502: % See comment in \requireopenindexfile.
5503: \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5504: %
5505: % See if the index file exists and is nonempty.
5506: \openin 1 \jobname.\indexname s
5507: \ifeof 1
5508: % \enddoublecolumns gets confused if there is no text in the index,
5509: % and it loses the chapter title and the aux file entries for the
5510: % index. The easiest way to prevent this problem is to make sure
5511: % there is some text.
5512: \putwordIndexNonexistent
5513: \typeout{No file \jobname.\indexname s.}%
5514: \else
5515: % If the index file exists but is empty, then \openin leaves \ifeof
5516: % false. We have to make TeX try to read something from the file, so
5517: % it can discover if there is anything in it.
5518: \read 1 to \thisline
5519: \ifeof 1
5520: \putwordIndexIsEmpty
5521: \else
5522: \expandafter\printindexzz\thisline\relax\relax\finish%
5523: \fi
5524: \fi
5525: \closein 1
5526: \endgroup}
5527:
5528: % If the index file starts with a backslash, forgo reading the index
5529: % file altogether. If somebody upgrades texinfo.tex they may still have
5530: % old index files using \ as the escape character. Reading this would
5531: % at best lead to typesetting garbage, at worst a TeX syntax error.
5532: \def\printindexzz#1#2\finish{%
1.5 ! snw 5533: \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
1.1 snw 5534: \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
1.5 ! snw 5535: \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
1.1 snw 5536: \errmessage{%
5537: ERROR: A sorted index file in an obsolete format was skipped.
5538: To fix this problem, please upgrade your version of 'texi2dvi'
5539: or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5540: If you are using an old version of 'texindex' (part of the Texinfo
5541: distribution), you may also need to upgrade to a newer version (at least 6.0).
5542: You may be able to typeset the index if you run
5543: 'texindex \jobname.\indexname' yourself.
5544: You could also try setting the 'txiindexescapeisbackslash' flag by
5545: running a command like
5546: 'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'. If you do
5547: this, Texinfo will try to use index files in the old format.
5548: If you continue to have problems, deleting the index files and starting again
5549: might help (with 'rm \jobname.?? \jobname.??s')%
5550: }%
1.5 ! snw 5551: \else
1.1 snw 5552: (Skipped sorted index file in obsolete format)
1.5 ! snw 5553: \fi
1.1 snw 5554: \else
5555: \begindoublecolumns
5556: \input \jobname.\indexname s
5557: \enddoublecolumns
5558: \fi
1.5 ! snw 5559: \else
1.1 snw 5560: \begindoublecolumns
5561: \catcode`\\=0\relax
1.5 ! snw 5562: \catcode`\@=12\relax
1.1 snw 5563: \input \jobname.\indexname s
5564: \enddoublecolumns
1.5 ! snw 5565: \fi
1.1 snw 5566: }
5567:
5568: % These macros are used by the sorted index file itself.
5569: % Change them to control the appearance of the index.
5570:
5571: {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5572: \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5573: \catcode`\$=3
5574: \gdef\initialglyphs{%
5575: % special control sequences used in the index sort key
5576: \let\indexlbrace\{%
5577: \let\indexrbrace\}%
5578: \let\indexatchar\@%
5579: \def\indexbackslash{\math{\backslash}}%
5580: %
5581: % Some changes for non-alphabetic characters. Using the glyphs from the
5582: % math fonts looks more consistent than the typewriter font used elsewhere
5583: % for these characters.
5584: \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5585: %
5586: % In case @\ is used for backslash
5587: \uppercase{\let\\=~}
5588: % Can't get bold backslash so don't use bold forward slash
5589: \catcode`\/=13
5590: \def/{{\secrmnotbold \normalslash}}%
5591: \def-{{\normaldash\normaldash}}% en dash `--'
5592: \def^{{\chapbf \normalcaret}}%
5593: \def~{{\chapbf \normaltilde}}%
5594: \def\_{%
5595: \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5596: \def|{$\vert$}%
5597: \def<{$\less$}%
5598: \def>{$\gtr$}%
5599: \def+{$\normalplus$}%
5600: }}
5601:
5602: \def\initial{%
5603: \bgroup
5604: \initialglyphs
5605: \initialx
5606: }
5607:
5608: \def\initialx#1{%
5609: % Remove any glue we may have, we'll be inserting our own.
5610: \removelastskip
5611: %
5612: % We like breaks before the index initials, so insert a bonus.
5613: % The glue before the bonus allows a little bit of space at the
5614: % bottom of a column to reduce an increase in inter-line spacing.
5615: \nobreak
5616: \vskip 0pt plus 5\baselineskip
5617: \penalty -300
5618: \vskip 0pt plus -5\baselineskip
5619: %
5620: % Typeset the initial. Making this add up to a whole number of
5621: % baselineskips increases the chance of the dots lining up from column
5622: % to column. It still won't often be perfect, because of the stretch
5623: % we need before each entry, but it's better.
5624: %
5625: % No shrink because it confuses \balancecolumns.
5626: \vskip 1.67\baselineskip plus 1\baselineskip
5627: \leftline{\secfonts \kern-0.05em \secbf #1}%
5628: % \secfonts is inside the argument of \leftline so that the change of
5629: % \baselineskip will not affect any glue inserted before the vbox that
5630: % \leftline creates.
5631: % Do our best not to break after the initial.
5632: \nobreak
5633: \vskip .33\baselineskip plus .1\baselineskip
5634: \egroup % \initialglyphs
5635: }
5636:
5637: \newdimen\entryrightmargin
5638: \entryrightmargin=0pt
5639:
5640: % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5641: % then page number (#2) flushed to the right margin. It is used for index
5642: % and table of contents entries. The paragraph is indented by \leftskip.
5643: %
5644: \def\entry{%
5645: \begingroup
5646: %
5647: % Start a new paragraph if necessary, so our assignments below can't
5648: % affect previous text.
5649: \par
5650: %
5651: % No extra space above this paragraph.
5652: \parskip = 0in
5653: %
5654: % When reading the text of entry, convert explicit line breaks
5655: % from @* into spaces. The user might give these in long section
5656: % titles, for instance.
5657: \def\*{\unskip\space\ignorespaces}%
5658: \def\entrybreak{\hfil\break}% An undocumented command
5659: %
5660: % Swallow the left brace of the text (first parameter):
5661: \afterassignment\doentry
5662: \let\temp =
5663: }
5664: \def\entrybreak{\unskip\space\ignorespaces}%
5665: \def\doentry{%
1.5 ! snw 5666: % Save the text of the entry
1.1 snw 5667: \global\setbox\boxA=\hbox\bgroup
5668: \bgroup % Instead of the swallowed brace.
5669: \noindent
5670: \aftergroup\finishentry
5671: % And now comes the text of the entry.
5672: % Not absorbing as a macro argument reduces the chance of problems
5673: % with catcodes occurring.
5674: }
5675: {\catcode`\@=11
5676: \gdef\finishentry#1{%
1.5 ! snw 5677: \egroup % end box A
1.1 snw 5678: \dimen@ = \wd\boxA % Length of text of entry
5679: \global\setbox\boxA=\hbox\bgroup
1.5 ! snw 5680: \unhbox\boxA
! 5681: % #1 is the page number.
1.1 snw 5682: %
5683: % Get the width of the page numbers, and only use
5684: % leaders if they are present.
5685: \global\setbox\boxB = \hbox{#1}%
5686: \ifdim\wd\boxB = 0pt
5687: \null\nobreak\hfill\ %
5688: \else
5689: %
5690: \null\nobreak\indexdotfill % Have leaders before the page number.
5691: %
5692: \ifpdforxetex
5693: \pdfgettoks#1.%
5694: \hskip\skip\thinshrinkable\the\toksA
5695: \else
5696: \hskip\skip\thinshrinkable #1%
5697: \fi
5698: \fi
5699: \egroup % end \boxA
5700: \ifdim\wd\boxB = 0pt
5701: \noindent\unhbox\boxA\par
5702: \nobreak
5703: \else\bgroup
5704: % We want the text of the entries to be aligned to the left, and the
5705: % page numbers to be aligned to the right.
5706: %
5707: \parindent = 0pt
5708: \advance\leftskip by 0pt plus 1fil
5709: \advance\leftskip by 0pt plus -1fill
5710: \rightskip = 0pt plus -1fil
5711: \advance\rightskip by 0pt plus 1fill
5712: % Cause last line, which could consist of page numbers on their own
5713: % if the list of page numbers is long, to be aligned to the right.
5714: \parfillskip=0pt plus -1fill
5715: %
5716: \advance\rightskip by \entryrightmargin
1.5 ! snw 5717: % Determine how far we can stretch into the margin.
! 5718: % This allows, e.g., "Appendix H GNU Free Documentation License" to
! 5719: % fit on one line in @letterpaper format.
! 5720: \ifdim\entryrightmargin>2.1em
! 5721: \dimen@i=2.1em
! 5722: \else
! 5723: \dimen@i=0em
! 5724: \fi
! 5725: \advance \parfillskip by 0pt minus 1\dimen@i
1.1 snw 5726: %
5727: \dimen@ii = \hsize
5728: \advance\dimen@ii by -1\leftskip
5729: \advance\dimen@ii by -1\entryrightmargin
1.5 ! snw 5730: \advance\dimen@ii by 1\dimen@i
1.1 snw 5731: \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5732: \ifdim\dimen@ > 0.8\dimen@ii % due to long index text
1.5 ! snw 5733: % Try to split the text roughly evenly. \dimen@ will be the length of
! 5734: % the first line.
! 5735: \dimen@ = 0.7\dimen@
! 5736: \dimen@ii = \hsize
! 5737: \ifnum\dimen@>\dimen@ii
! 5738: % If the entry is too long (for example, if it needs more than
! 5739: % two lines), use all the space in the first line.
! 5740: \dimen@ = \dimen@ii
! 5741: \fi
1.1 snw 5742: \advance\leftskip by 0pt plus 1fill % ragged right
1.5 ! snw 5743: \advance \dimen@ by 1\rightskip
! 5744: \parshape = 2 0pt \dimen@ 0em \dimen@ii
! 5745: % Ideally we'd add a finite glue at the end of the first line only,
! 5746: % instead of using \parshape with explicit line lengths, but TeX
! 5747: % doesn't seem to provide a way to do such a thing.
1.1 snw 5748: %
5749: % Indent all lines but the first one.
1.5 ! snw 5750: \advance\leftskip by 1em
! 5751: \advance\parindent by -1em
1.1 snw 5752: \fi\fi
5753: \indent % start paragraph
5754: \unhbox\boxA
5755: %
5756: % Do not prefer a separate line ending with a hyphen to fewer lines.
5757: \finalhyphendemerits = 0
5758: %
5759: % Word spacing - no stretch
5760: \spaceskip=\fontdimen2\font minus \fontdimen4\font
5761: %
5762: \linepenalty=1000 % Discourage line breaks.
5763: \hyphenpenalty=5000 % Discourage hyphenation.
5764: %
5765: \par % format the paragraph
5766: \egroup % The \vbox
5767: \fi
5768: \endgroup
5769: }}
5770:
5771: \newskip\thinshrinkable
5772: \skip\thinshrinkable=.15em minus .15em
5773:
1.5 ! snw 5774: % Like plain.tex's \dotfill, except uses up at least 1 em.
1.1 snw 5775: % The filll stretch here overpowers both the fil and fill stretch to push
5776: % the page number to the right.
5777: \def\indexdotfill{\cleaders
1.5 ! snw 5778: \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
! 5779:
1.1 snw 5780:
5781: \def\primary #1{\line{#1\hfil}}
5782:
5783: \def\secondary{\indententry{0.5cm}}
5784: \def\tertiary{\indententry{1cm}}
5785:
5786: \def\indententry#1#2#3{%
5787: \bgroup
5788: \leftskip=#1
5789: \entry{#2}{#3}%
5790: \egroup
5791: }
5792:
5793: % Define two-column mode, which we use to typeset indexes.
5794: % Adapted from the TeXbook, page 416, which is to say,
5795: % the manmac.tex format used to print the TeXbook itself.
5796: \catcode`\@=11 % private names
5797:
5798: \newbox\partialpage
5799: \newdimen\doublecolumnhsize
5800:
5801: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5802: % If not much space left on page, start a new page.
5803: \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5804: %
5805: % Grab any single-column material above us.
5806: \output = {%
5807: \savetopmark
5808: %
5809: \global\setbox\partialpage = \vbox{%
5810: % Unvbox the main output page.
5811: \unvbox\PAGE
5812: \kern-\topskip \kern\baselineskip
5813: }%
5814: }%
5815: \eject % run that output routine to set \partialpage
5816: %
5817: % Use the double-column output routine for subsequent pages.
5818: \output = {\doublecolumnout}%
5819: %
5820: % Change the page size parameters. We could do this once outside this
5821: % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5822: % format, but then we repeat the same computation. Repeating a couple
5823: % of assignments once per index is clearly meaningless for the
5824: % execution time, so we may as well do it in one place.
5825: %
5826: % First we halve the line length, less a little for the gutter between
5827: % the columns. We compute the gutter based on the line length, so it
5828: % changes automatically with the paper format. The magic constant
5829: % below is chosen so that the gutter has the same value (well, +-<1pt)
5830: % as it did when we hard-coded it.
5831: %
1.5 ! snw 5832: % We put the result in a separate register, \doublecolumhsize, so we
1.1 snw 5833: % can restore it in \pagesofar, after \hsize itself has (potentially)
5834: % been clobbered.
5835: %
5836: \doublecolumnhsize = \hsize
5837: \advance\doublecolumnhsize by -.04154\hsize
5838: \divide\doublecolumnhsize by 2
5839: \hsize = \doublecolumnhsize
5840: %
5841: % Get the available space for the double columns -- the normal
5842: % (undoubled) page height minus any material left over from the
5843: % previous page.
5844: \advance\vsize by -\ht\partialpage
5845: \vsize = 2\vsize
5846: %
5847: % For the benefit of balancing columns
5848: \advance\baselineskip by 0pt plus 0.5pt
5849: }
5850:
5851: % The double-column output routine for all double-column pages except
5852: % the last, which is done by \balancecolumns.
5853: %
5854: \def\doublecolumnout{%
5855: %
5856: \savetopmark
5857: \splittopskip=\topskip \splitmaxdepth=\maxdepth
5858: \dimen@ = \vsize
5859: \divide\dimen@ by 2
5860: %
5861: % box0 will be the left-hand column, box2 the right.
5862: \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5863: \global\advance\vsize by 2\ht\partialpage
5864: \onepageout\pagesofar % empty except for the first time we are called
5865: \unvbox\PAGE
5866: \penalty\outputpenalty
5867: }
5868: %
5869: % Re-output the contents of the output page -- any previous material,
5870: % followed by the two boxes we just split, in box0 and box2.
5871: \def\pagesofar{%
5872: \unvbox\partialpage
5873: %
5874: \hsize = \doublecolumnhsize
5875: \wd0=\hsize \wd2=\hsize
5876: \hbox to\txipagewidth{\box0\hfil\box2}%
5877: }
5878:
5879:
5880: % Finished with double columns.
5881: \def\enddoublecolumns{%
5882: % The following penalty ensures that the page builder is exercised
5883: % _before_ we change the output routine. This is necessary in the
5884: % following situation:
5885: %
5886: % The last section of the index consists only of a single entry.
5887: % Before this section, \pagetotal is less than \pagegoal, so no
5888: % break occurs before the last section starts. However, the last
5889: % section, consisting of \initial and the single \entry, does not
5890: % fit on the page and has to be broken off. Without the following
5891: % penalty the page builder will not be exercised until \eject
5892: % below, and by that time we'll already have changed the output
5893: % routine to the \balancecolumns version, so the next-to-last
5894: % double-column page will be processed with \balancecolumns, which
5895: % is wrong: The two columns will go to the main vertical list, with
5896: % the broken-off section in the recent contributions. As soon as
5897: % the output routine finishes, TeX starts reconsidering the page
5898: % break. The two columns and the broken-off section both fit on the
5899: % page, because the two columns now take up only half of the page
5900: % goal. When TeX sees \eject from below which follows the final
5901: % section, it invokes the new output routine that we've set after
5902: % \balancecolumns below; \onepageout will try to fit the two columns
5903: % and the final section into the vbox of \txipageheight (see
5904: % \pagebody), causing an overfull box.
5905: %
5906: % Note that glue won't work here, because glue does not exercise the
5907: % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5908: \penalty0
5909: %
5910: \output = {%
5911: % Split the last of the double-column material.
5912: \savetopmark
5913: \balancecolumns
5914: }%
5915: \eject % call the \output just set
5916: \ifdim\pagetotal=0pt
5917: % Having called \balancecolumns once, we do not
5918: % want to call it again. Therefore, reset \output to its normal
5919: % definition right away.
5920: \global\output=\expandafter{\the\defaultoutput}
5921: %
5922: \endgroup % started in \begindoublecolumns
5923: % Leave the double-column material on the current page, no automatic
5924: % page break.
5925: \box\balancedcolumns
5926: %
5927: % \pagegoal was set to the doubled \vsize above, since we restarted
5928: % the current page. We're now back to normal single-column
5929: % typesetting, so reset \pagegoal to the normal \vsize.
5930: \global\vsize = \txipageheight %
5931: \pagegoal = \txipageheight %
5932: \else
5933: % We had some left-over material. This might happen when \doublecolumnout
5934: % is called in \balancecolumns. Try again.
5935: \expandafter\enddoublecolumns
5936: \fi
5937: }
5938: \newbox\balancedcolumns
5939: \setbox\balancedcolumns=\vbox{shouldnt see this}%
5940: %
5941: % Only called for the last of the double column material. \doublecolumnout
5942: % does the others.
5943: \def\balancecolumns{%
5944: \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5945: \dimen@ = \ht0
5946: \ifdim\dimen@<7\baselineskip
5947: % Don't split a short final column in two.
5948: \setbox2=\vbox{}%
5949: \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5950: \else
5951: % double the leading vertical space
5952: \advance\dimen@ by \topskip
5953: \advance\dimen@ by-\baselineskip
5954: \divide\dimen@ by 2 % target to split to
5955: \dimen@ii = \dimen@
5956: \splittopskip = \topskip
5957: % Loop until left column is at least as high as the right column.
5958: {%
5959: \vbadness = 10000
5960: \loop
5961: \global\setbox3 = \copy0
5962: \global\setbox1 = \vsplit3 to \dimen@
5963: \ifdim\ht1<\ht3
5964: \global\advance\dimen@ by 1pt
5965: \repeat
5966: }%
5967: % Now the left column is in box 1, and the right column in box 3.
5968: %
5969: % Check whether the left column has come out higher than the page itself.
5970: % (Note that we have doubled \vsize for the double columns, so
5971: % the actual height of the page is 0.5\vsize).
5972: \ifdim2\ht1>\vsize
5973: % It appears that we have been called upon to balance too much material.
5974: % Output some of it with \doublecolumnout, leaving the rest on the page.
5975: \setbox\PAGE=\box0
5976: \doublecolumnout
5977: \else
5978: % Compare the heights of the two columns.
5979: \ifdim4\ht1>5\ht3
5980: % Column heights are too different, so don't make their bottoms
5981: % flush with each other.
5982: \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
5983: \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
5984: \else
5985: % Make column bottoms flush with each other.
5986: \setbox2=\vbox to\ht1{\unvbox3\unskip}%
5987: \setbox0=\vbox to\ht1{\unvbox1\unskip}%
5988: \fi
5989: \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5990: \fi
5991: \fi
5992: %
5993: }
5994: \catcode`\@ = \other
5995:
5996:
5997: \message{sectioning,}
5998: % Chapters, sections, etc.
5999:
6000: % Let's start with @part.
1.5 ! snw 6001: \outer\parseargdef\part{\partzzz{#1}}
1.1 snw 6002: \def\partzzz#1{%
6003: \chapoddpage
6004: \null
6005: \vskip.3\vsize % move it down on the page a bit
6006: \begingroup
6007: \noindent \titlefonts\rm #1\par % the text
6008: \let\lastnode=\empty % no node to associate with
6009: \writetocentry{part}{#1}{}% but put it in the toc
6010: \headingsoff % no headline or footline on the part page
6011: % This outputs a mark at the end of the page that clears \thischapter
6012: % and \thissection, as is done in \startcontents.
6013: \let\pchapsepmacro\relax
6014: \chapmacro{}{Yomitfromtoc}{}%
6015: \chapoddpage
6016: \endgroup
6017: }
6018:
6019: % \unnumberedno is an oxymoron. But we count the unnumbered
6020: % sections so that we can refer to them unambiguously in the pdf
6021: % outlines by their "section number". We avoid collisions with chapter
6022: % numbers by starting them at 10000. (If a document ever has 10000
6023: % chapters, we're in trouble anyway, I'm sure.)
6024: \newcount\unnumberedno \unnumberedno = 10000
6025: \newcount\chapno
6026: \newcount\secno \secno=0
6027: \newcount\subsecno \subsecno=0
6028: \newcount\subsubsecno \subsubsecno=0
6029:
6030: % This counter is funny since it counts through charcodes of letters A, B, ...
6031: \newcount\appendixno \appendixno = `\@
6032: %
6033: % \def\appendixletter{\char\the\appendixno}
6034: % We do the following ugly conditional instead of the above simple
6035: % construct for the sake of pdftex, which needs the actual
6036: % letter in the expansion, not just typeset.
6037: %
6038: \def\appendixletter{%
6039: \ifnum\appendixno=`A A%
6040: \else\ifnum\appendixno=`B B%
6041: \else\ifnum\appendixno=`C C%
6042: \else\ifnum\appendixno=`D D%
6043: \else\ifnum\appendixno=`E E%
6044: \else\ifnum\appendixno=`F F%
6045: \else\ifnum\appendixno=`G G%
6046: \else\ifnum\appendixno=`H H%
6047: \else\ifnum\appendixno=`I I%
6048: \else\ifnum\appendixno=`J J%
6049: \else\ifnum\appendixno=`K K%
6050: \else\ifnum\appendixno=`L L%
6051: \else\ifnum\appendixno=`M M%
6052: \else\ifnum\appendixno=`N N%
6053: \else\ifnum\appendixno=`O O%
6054: \else\ifnum\appendixno=`P P%
6055: \else\ifnum\appendixno=`Q Q%
6056: \else\ifnum\appendixno=`R R%
6057: \else\ifnum\appendixno=`S S%
6058: \else\ifnum\appendixno=`T T%
6059: \else\ifnum\appendixno=`U U%
6060: \else\ifnum\appendixno=`V V%
6061: \else\ifnum\appendixno=`W W%
6062: \else\ifnum\appendixno=`X X%
6063: \else\ifnum\appendixno=`Y Y%
6064: \else\ifnum\appendixno=`Z Z%
6065: % The \the is necessary, despite appearances, because \appendixletter is
6066: % expanded while writing the .toc file. \char\appendixno is not
6067: % expandable, thus it is written literally, thus all appendixes come out
6068: % with the same letter (or @) in the toc without it.
6069: \else\char\the\appendixno
6070: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6071: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6072:
6073: % Each @chapter defines these (using marks) as the number+name, number
6074: % and name of the chapter. Page headings and footings can use
6075: % these. @section does likewise.
6076: \def\thischapter{}
6077: \def\thischapternum{}
6078: \def\thischaptername{}
6079: \def\thissection{}
6080: \def\thissectionnum{}
6081: \def\thissectionname{}
6082:
6083: \newcount\absseclevel % used to calculate proper heading level
6084: \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6085:
6086: % @raisesections: treat @section as chapter, @subsection as section, etc.
6087: \def\raisesections{\global\advance\secbase by -1}
6088:
6089: % @lowersections: treat @chapter as section, @section as subsection, etc.
6090: \def\lowersections{\global\advance\secbase by 1}
6091:
6092: % we only have subsub.
6093: \chardef\maxseclevel = 3
6094: %
6095: % A numbered section within an unnumbered changes to unnumbered too.
6096: % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6097: \chardef\unnlevel = \maxseclevel
6098: %
6099: % Trace whether the current chapter is an appendix or not:
6100: % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6101: \def\chapheadtype{N}
6102:
6103: % Choose a heading macro
6104: % #1 is heading type
6105: % #2 is heading level
6106: % #3 is text for heading
6107: \def\genhead#1#2#3{%
6108: % Compute the abs. sec. level:
6109: \absseclevel=#2
6110: \advance\absseclevel by \secbase
6111: % Make sure \absseclevel doesn't fall outside the range:
6112: \ifnum \absseclevel < 0
6113: \absseclevel = 0
6114: \else
6115: \ifnum \absseclevel > 3
6116: \absseclevel = 3
6117: \fi
6118: \fi
6119: % The heading type:
6120: \def\headtype{#1}%
6121: \if \headtype U%
6122: \ifnum \absseclevel < \unnlevel
6123: \chardef\unnlevel = \absseclevel
6124: \fi
6125: \else
6126: % Check for appendix sections:
6127: \ifnum \absseclevel = 0
6128: \edef\chapheadtype{\headtype}%
6129: \else
6130: \if \headtype A\if \chapheadtype N%
6131: \errmessage{@appendix... within a non-appendix chapter}%
6132: \fi\fi
6133: \fi
6134: % Check for numbered within unnumbered:
6135: \ifnum \absseclevel > \unnlevel
6136: \def\headtype{U}%
6137: \else
6138: \chardef\unnlevel = 3
6139: \fi
6140: \fi
6141: % Now print the heading:
6142: \if \headtype U%
6143: \ifcase\absseclevel
6144: \unnumberedzzz{#3}%
6145: \or \unnumberedseczzz{#3}%
6146: \or \unnumberedsubseczzz{#3}%
6147: \or \unnumberedsubsubseczzz{#3}%
6148: \fi
6149: \else
6150: \if \headtype A%
6151: \ifcase\absseclevel
6152: \appendixzzz{#3}%
6153: \or \appendixsectionzzz{#3}%
6154: \or \appendixsubseczzz{#3}%
6155: \or \appendixsubsubseczzz{#3}%
6156: \fi
6157: \else
6158: \ifcase\absseclevel
6159: \chapterzzz{#3}%
6160: \or \seczzz{#3}%
6161: \or \numberedsubseczzz{#3}%
6162: \or \numberedsubsubseczzz{#3}%
6163: \fi
6164: \fi
6165: \fi
6166: \suppressfirstparagraphindent
6167: }
6168:
6169: % an interface:
6170: \def\numhead{\genhead N}
6171: \def\apphead{\genhead A}
6172: \def\unnmhead{\genhead U}
6173:
6174: % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
6175: % all lower-level sectioning counters to zero.
6176: %
6177: % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6178: % (e.g., figures), q.v. By default (before any chapter), that is empty.
6179: \let\chaplevelprefix = \empty
6180: %
6181: \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6182: \def\chapterzzz#1{%
6183: % section resetting is \global in case the chapter is in a group, such
6184: % as an @include file.
6185: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6186: \global\advance\chapno by 1
6187: %
6188: % Used for \float.
6189: \gdef\chaplevelprefix{\the\chapno.}%
6190: \resetallfloatnos
6191: %
6192: % \putwordChapter can contain complex things in translations.
6193: \toks0=\expandafter{\putwordChapter}%
6194: \message{\the\toks0 \space \the\chapno}%
6195: %
6196: % Write the actual heading.
6197: \chapmacro{#1}{Ynumbered}{\the\chapno}%
6198: %
6199: % So @section and the like are numbered underneath this chapter.
6200: \global\let\section = \numberedsec
6201: \global\let\subsection = \numberedsubsec
6202: \global\let\subsubsection = \numberedsubsubsec
6203: }
6204:
6205: \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6206: %
6207: \def\appendixzzz#1{%
6208: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6209: \global\advance\appendixno by 1
6210: \gdef\chaplevelprefix{\appendixletter.}%
6211: \resetallfloatnos
6212: %
6213: % \putwordAppendix can contain complex things in translations.
6214: \toks0=\expandafter{\putwordAppendix}%
6215: \message{\the\toks0 \space \appendixletter}%
6216: %
6217: \chapmacro{#1}{Yappendix}{\appendixletter}%
6218: %
6219: \global\let\section = \appendixsec
6220: \global\let\subsection = \appendixsubsec
6221: \global\let\subsubsection = \appendixsubsubsec
6222: }
6223:
6224: % normally unnmhead0 calls unnumberedzzz:
6225: \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6226: \def\unnumberedzzz#1{%
1.5 ! snw 6227: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
! 6228: \global\advance\unnumberedno by 1
1.1 snw 6229: %
6230: % Since an unnumbered has no number, no prefix for figures.
6231: \global\let\chaplevelprefix = \empty
6232: \resetallfloatnos
6233: %
6234: % This used to be simply \message{#1}, but TeX fully expands the
6235: % argument to \message. Therefore, if #1 contained @-commands, TeX
6236: % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
6237: % expanded @cite (which turns out to cause errors because \cite is meant
6238: % to be executed, not expanded).
6239: %
6240: % Anyway, we don't want the fully-expanded definition of @cite to appear
6241: % as a result of the \message, we just want `@cite' itself. We use
6242: % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6243: % simply yielding the contents of <toks register>. (We also do this for
6244: % the toc entries.)
6245: \toks0 = {#1}%
6246: \message{(\the\toks0)}%
6247: %
6248: \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6249: %
6250: \global\let\section = \unnumberedsec
6251: \global\let\subsection = \unnumberedsubsec
6252: \global\let\subsubsection = \unnumberedsubsubsec
6253: }
6254:
6255: % @centerchap is like @unnumbered, but the heading is centered.
6256: \outer\parseargdef\centerchap{%
6257: \let\centerparametersmaybe = \centerparameters
6258: \unnmhead0{#1}%
6259: \let\centerparametersmaybe = \relax
6260: }
6261:
6262: % @top is like @unnumbered.
6263: \let\top\unnumbered
6264:
6265: % Sections.
6266: %
6267: \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6268: \def\seczzz#1{%
6269: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6270: \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6271: }
6272:
6273: % normally calls appendixsectionzzz:
6274: \outer\parseargdef\appendixsection{\apphead1{#1}}
6275: \def\appendixsectionzzz#1{%
6276: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6277: \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6278: }
6279: \let\appendixsec\appendixsection
6280:
6281: % normally calls unnumberedseczzz:
6282: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6283: \def\unnumberedseczzz#1{%
1.5 ! snw 6284: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
! 6285: \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
1.1 snw 6286: }
6287:
6288: % Subsections.
6289: %
6290: % normally calls numberedsubseczzz:
6291: \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6292: \def\numberedsubseczzz#1{%
6293: \global\subsubsecno=0 \global\advance\subsecno by 1
6294: \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6295: }
6296:
6297: % normally calls appendixsubseczzz:
6298: \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6299: \def\appendixsubseczzz#1{%
6300: \global\subsubsecno=0 \global\advance\subsecno by 1
6301: \sectionheading{#1}{subsec}{Yappendix}%
6302: {\appendixletter.\the\secno.\the\subsecno}%
6303: }
6304:
6305: % normally calls unnumberedsubseczzz:
6306: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6307: \def\unnumberedsubseczzz#1{%
1.5 ! snw 6308: \global\subsubsecno=0 \global\advance\subsecno by 1
! 6309: \sectionheading{#1}{subsec}{Ynothing}%
! 6310: {\the\unnumberedno.\the\secno.\the\subsecno}%
1.1 snw 6311: }
6312:
6313: % Subsubsections.
6314: %
6315: % normally numberedsubsubseczzz:
6316: \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6317: \def\numberedsubsubseczzz#1{%
6318: \global\advance\subsubsecno by 1
6319: \sectionheading{#1}{subsubsec}{Ynumbered}%
6320: {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6321: }
6322:
6323: % normally appendixsubsubseczzz:
6324: \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6325: \def\appendixsubsubseczzz#1{%
6326: \global\advance\subsubsecno by 1
6327: \sectionheading{#1}{subsubsec}{Yappendix}%
6328: {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6329: }
6330:
6331: % normally unnumberedsubsubseczzz:
6332: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6333: \def\unnumberedsubsubseczzz#1{%
1.5 ! snw 6334: \global\advance\subsubsecno by 1
! 6335: \sectionheading{#1}{subsubsec}{Ynothing}%
! 6336: {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
1.1 snw 6337: }
6338:
6339: % These macros control what the section commands do, according
6340: % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6341: % Define them by default for a numbered chapter.
6342: \let\section = \numberedsec
6343: \let\subsection = \numberedsubsec
6344: \let\subsubsection = \numberedsubsubsec
6345:
6346: % Define @majorheading, @heading and @subheading
6347:
6348: \def\majorheading{%
6349: {\advance\chapheadingskip by 10pt \chapbreak }%
6350: \parsearg\chapheadingzzz
6351: }
6352:
6353: \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6354: \def\chapheadingzzz#1{%
6355: \vbox{\chapfonts \raggedtitlesettings #1\par}%
6356: \nobreak\bigskip \nobreak
6357: \suppressfirstparagraphindent
6358: }
6359:
6360: % @heading, @subheading, @subsubheading.
6361: \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6362: \suppressfirstparagraphindent}
6363: \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6364: \suppressfirstparagraphindent}
6365: \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6366: \suppressfirstparagraphindent}
6367:
6368: % These macros generate a chapter, section, etc. heading only
6369: % (including whitespace, linebreaking, etc. around it),
6370: % given all the information in convenient, parsed form.
6371:
6372: % Args are the skip and penalty (usually negative)
6373: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6374:
6375: % Parameter controlling skip before chapter headings (if needed)
6376: \newskip\chapheadingskip
6377:
6378: % Define plain chapter starts, and page on/off switching for it.
6379: \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6380:
6381: % Start a new page
6382: \def\chappager{\par\vfill\supereject}
6383:
6384: % \chapoddpage - start on an odd page for a new chapter
6385: % Because \domark is called before \chapoddpage, the filler page will
6386: % get the headings for the next chapter, which is wrong. But we don't
6387: % care -- we just disable all headings on the filler page.
6388: \def\chapoddpage{%
6389: \chappager
6390: \ifodd\pageno \else
6391: \begingroup
6392: \headingsoff
6393: \null
6394: \chappager
6395: \endgroup
6396: \fi
6397: }
6398:
1.5 ! snw 6399: \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
1.1 snw 6400:
6401: \def\CHAPPAGoff{%
6402: \global\let\contentsalignmacro = \chappager
6403: \global\let\pchapsepmacro=\chapbreak
1.5 ! snw 6404: \global\let\pagealignmacro=\chappager}
1.1 snw 6405:
6406: \def\CHAPPAGon{%
6407: \global\let\contentsalignmacro = \chappager
6408: \global\let\pchapsepmacro=\chappager
1.5 ! snw 6409: \global\let\pagealignmacro=\chappager
1.1 snw 6410: \global\def\HEADINGSon{\HEADINGSsingle}}
6411:
6412: \def\CHAPPAGodd{%
6413: \global\let\contentsalignmacro = \chapoddpage
6414: \global\let\pchapsepmacro=\chapoddpage
1.5 ! snw 6415: \global\let\pagealignmacro=\chapoddpage
1.1 snw 6416: \global\def\HEADINGSon{\HEADINGSdouble}}
6417:
1.5 ! snw 6418: \CHAPPAGon
1.1 snw 6419:
6420: % \chapmacro - Chapter opening.
6421: %
6422: % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6423: % Yappendix, Yomitfromtoc), #3 the chapter number.
6424: % Not used for @heading series.
6425: %
6426: % To test against our argument.
6427: \def\Ynothingkeyword{Ynothing}
6428: \def\Yappendixkeyword{Yappendix}
6429: \def\Yomitfromtockeyword{Yomitfromtoc}
6430: %
6431: \def\chapmacro#1#2#3{%
6432: \expandafter\ifx\thisenv\titlepage\else
6433: \checkenv{}% chapters, etc., should not start inside an environment.
6434: \fi
6435: % Insert the first mark before the heading break (see notes for \domark).
6436: \let\prevchapterdefs=\currentchapterdefs
6437: \let\prevsectiondefs=\currentsectiondefs
6438: \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6439: \gdef\thissection{}}%
6440: %
6441: \def\temptype{#2}%
6442: \ifx\temptype\Ynothingkeyword
6443: \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6444: \gdef\thischapter{\thischaptername}}%
6445: \else\ifx\temptype\Yomitfromtockeyword
6446: \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6447: \gdef\thischapter{}}%
6448: \else\ifx\temptype\Yappendixkeyword
6449: \toks0={#1}%
6450: \xdef\currentchapterdefs{%
6451: \gdef\noexpand\thischaptername{\the\toks0}%
6452: \gdef\noexpand\thischapternum{\appendixletter}%
1.5 ! snw 6453: % \noexpand\putwordAppendix avoids expanding indigestible
! 6454: % commands in some of the translations.
! 6455: \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
! 6456: \noexpand\thischapternum:
! 6457: \noexpand\thischaptername}%
1.1 snw 6458: }%
6459: \else
6460: \toks0={#1}%
6461: \xdef\currentchapterdefs{%
6462: \gdef\noexpand\thischaptername{\the\toks0}%
6463: \gdef\noexpand\thischapternum{\the\chapno}%
1.5 ! snw 6464: % \noexpand\putwordChapter avoids expanding indigestible
! 6465: % commands in some of the translations.
! 6466: \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
! 6467: \noexpand\thischapternum:
! 6468: \noexpand\thischaptername}%
1.1 snw 6469: }%
6470: \fi\fi\fi
6471: %
6472: % Output the mark. Pass it through \safewhatsit, to take care of
6473: % the preceding space.
6474: \safewhatsit\domark
6475: %
6476: % Insert the chapter heading break.
6477: \pchapsepmacro
6478: %
6479: % Now the second mark, after the heading break. No break points
6480: % between here and the heading.
6481: \let\prevchapterdefs=\currentchapterdefs
6482: \let\prevsectiondefs=\currentsectiondefs
6483: \domark
6484: %
6485: {%
6486: \chapfonts \rm
6487: \let\footnote=\errfootnoteheading % give better error message
6488: %
6489: % Have to define \currentsection before calling \donoderef, because the
6490: % xref code eventually uses it. On the other hand, it has to be called
6491: % after \pchapsepmacro, or the headline will change too soon.
6492: \gdef\currentsection{#1}%
6493: %
6494: % Only insert the separating space if we have a chapter/appendix
6495: % number, and don't print the unnumbered ``number''.
6496: \ifx\temptype\Ynothingkeyword
6497: \setbox0 = \hbox{}%
6498: \def\toctype{unnchap}%
6499: \else\ifx\temptype\Yomitfromtockeyword
6500: \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6501: \def\toctype{omit}%
6502: \else\ifx\temptype\Yappendixkeyword
6503: \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6504: \def\toctype{app}%
6505: \else
6506: \setbox0 = \hbox{#3\enspace}%
6507: \def\toctype{numchap}%
6508: \fi\fi\fi
6509: %
6510: % Write the toc entry for this chapter. Must come before the
6511: % \donoderef, because we include the current node name in the toc
6512: % entry, and \donoderef resets it to empty.
6513: \writetocentry{\toctype}{#1}{#3}%
6514: %
6515: % For pdftex, we have to write out the node definition (aka, make
6516: % the pdfdest) after any page break, but before the actual text has
6517: % been typeset. If the destination for the pdf outline is after the
6518: % text, then jumping from the outline may wind up with the text not
6519: % being visible, for instance under high magnification.
6520: \donoderef{#2}%
6521: %
6522: % Typeset the actual heading.
6523: \nobreak % Avoid page breaks at the interline glue.
6524: \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6525: \unhbox0 #1\par}%
6526: }%
6527: \nobreak\bigskip % no page break after a chapter title
6528: \nobreak
6529: }
6530:
6531: % @centerchap -- centered and unnumbered.
6532: \let\centerparametersmaybe = \relax
6533: \def\centerparameters{%
6534: \advance\rightskip by 3\rightskip
6535: \leftskip = \rightskip
6536: \parfillskip = 0pt
6537: }
6538:
6539:
6540: % Section titles. These macros combine the section number parts and
6541: % call the generic \sectionheading to do the printing.
6542: %
6543: \newskip\secheadingskip
6544: \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6545:
6546: % Subsection titles.
6547: \newskip\subsecheadingskip
6548: \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6549:
6550: % Subsubsection titles.
6551: \def\subsubsecheadingskip{\subsecheadingskip}
6552: \def\subsubsecheadingbreak{\subsecheadingbreak}
6553:
6554:
6555: % Print any size, any type, section title.
6556: %
6557: % #1 is the text of the title,
6558: % #2 is the section level (sec/subsec/subsubsec),
6559: % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6560: % #4 is the section number.
6561: %
6562: \def\seckeyword{sec}
6563: %
6564: \def\sectionheading#1#2#3#4{%
6565: {%
6566: \def\sectionlevel{#2}%
6567: \def\temptype{#3}%
6568: %
6569: % It is ok for the @heading series commands to appear inside an
6570: % environment (it's been historically allowed, though the logic is
6571: % dubious), but not the others.
6572: \ifx\temptype\Yomitfromtockeyword\else
6573: \checkenv{}% non-@*heading should not be in an environment.
6574: \fi
6575: \let\footnote=\errfootnoteheading
6576: %
6577: % Switch to the right set of fonts.
6578: \csname #2fonts\endcsname \rm
6579: %
6580: % Insert first mark before the heading break (see notes for \domark).
6581: \let\prevsectiondefs=\currentsectiondefs
6582: \ifx\temptype\Ynothingkeyword
6583: \ifx\sectionlevel\seckeyword
6584: \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6585: \gdef\thissection{\thissectionname}}%
6586: \fi
6587: \else\ifx\temptype\Yomitfromtockeyword
6588: % Don't redefine \thissection.
6589: \else\ifx\temptype\Yappendixkeyword
6590: \ifx\sectionlevel\seckeyword
6591: \toks0={#1}%
6592: \xdef\currentsectiondefs{%
6593: \gdef\noexpand\thissectionname{\the\toks0}%
6594: \gdef\noexpand\thissectionnum{#4}%
1.5 ! snw 6595: % \noexpand\putwordSection avoids expanding indigestible
! 6596: % commands in some of the translations.
! 6597: \gdef\noexpand\thissection{\noexpand\putwordSection{}
! 6598: \noexpand\thissectionnum:
! 6599: \noexpand\thissectionname}%
1.1 snw 6600: }%
6601: \fi
6602: \else
6603: \ifx\sectionlevel\seckeyword
6604: \toks0={#1}%
6605: \xdef\currentsectiondefs{%
6606: \gdef\noexpand\thissectionname{\the\toks0}%
6607: \gdef\noexpand\thissectionnum{#4}%
1.5 ! snw 6608: % \noexpand\putwordSection avoids expanding indigestible
! 6609: % commands in some of the translations.
! 6610: \gdef\noexpand\thissection{\noexpand\putwordSection{}
! 6611: \noexpand\thissectionnum:
! 6612: \noexpand\thissectionname}%
1.1 snw 6613: }%
6614: \fi
6615: \fi\fi\fi
6616: %
6617: % Go into vertical mode. Usually we'll already be there, but we
6618: % don't want the following whatsit to end up in a preceding paragraph
6619: % if the document didn't happen to have a blank line.
6620: \par
6621: %
6622: % Output the mark. Pass it through \safewhatsit, to take care of
6623: % the preceding space.
6624: \safewhatsit\domark
6625: %
6626: % Insert space above the heading.
6627: \csname #2headingbreak\endcsname
6628: %
6629: % Now the second mark, after the heading break. No break points
6630: % between here and the heading.
6631: \global\let\prevsectiondefs=\currentsectiondefs
6632: \domark
6633: %
6634: % Only insert the space after the number if we have a section number.
6635: \ifx\temptype\Ynothingkeyword
6636: \setbox0 = \hbox{}%
6637: \def\toctype{unn}%
6638: \gdef\currentsection{#1}%
6639: \else\ifx\temptype\Yomitfromtockeyword
6640: % for @headings -- no section number, don't include in toc,
6641: % and don't redefine \currentsection.
6642: \setbox0 = \hbox{}%
6643: \def\toctype{omit}%
6644: \let\sectionlevel=\empty
6645: \else\ifx\temptype\Yappendixkeyword
6646: \setbox0 = \hbox{#4\enspace}%
6647: \def\toctype{app}%
6648: \gdef\currentsection{#1}%
6649: \else
6650: \setbox0 = \hbox{#4\enspace}%
6651: \def\toctype{num}%
6652: \gdef\currentsection{#1}%
6653: \fi\fi\fi
6654: %
6655: % Write the toc entry (before \donoderef). See comments in \chapmacro.
6656: \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6657: %
6658: % Write the node reference (= pdf destination for pdftex).
6659: % Again, see comments in \chapmacro.
6660: \donoderef{#3}%
6661: %
6662: % Interline glue will be inserted when the vbox is completed.
6663: % That glue will be a valid breakpoint for the page, since it'll be
6664: % preceded by a whatsit (usually from the \donoderef, or from the
6665: % \writetocentry if there was no node). We don't want to allow that
6666: % break, since then the whatsits could end up on page n while the
6667: % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
6668: \nobreak
6669: %
6670: % Output the actual section heading.
6671: \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6672: \hangindent=\wd0 % zero if no section number
6673: \unhbox0 #1}%
6674: }%
6675: % Add extra space after the heading -- half of whatever came above it.
6676: % Don't allow stretch, though.
6677: \kern .5 \csname #2headingskip\endcsname
6678: %
6679: % Do not let the kern be a potential breakpoint, as it would be if it
6680: % was followed by glue.
6681: \nobreak
6682: %
6683: % We'll almost certainly start a paragraph next, so don't let that
6684: % glue accumulate. (Not a breakpoint because it's preceded by a
6685: % discardable item.) However, when a paragraph is not started next
6686: % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6687: % or the negative glue will cause weirdly wrong output, typically
6688: % obscuring the section heading with something else.
6689: \vskip-\parskip
6690: %
6691: % This is so the last item on the main vertical list is a known
6692: % \penalty > 10000, so \startdefun, etc., can recognize the situation
6693: % and do the needful.
6694: \penalty 10001
6695: }
6696:
6697:
6698: \message{toc,}
6699: % Table of contents.
6700: \newwrite\tocfile
6701:
6702: % Write an entry to the toc file, opening it if necessary.
6703: % Called from @chapter, etc.
6704: %
6705: % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6706: % We append the current node name (if any) and page number as additional
6707: % arguments for the \{chap,sec,...}entry macros which will eventually
6708: % read this. The node name is used in the pdf outlines as the
6709: % destination to jump to.
6710: %
6711: % We open the .toc file for writing here instead of at @setfilename (or
6712: % any other fixed time) so that @contents can be anywhere in the document.
6713: % But if #1 is `omit', then we don't do anything. This is used for the
6714: % table of contents chapter openings themselves.
6715: %
6716: \newif\iftocfileopened
6717: \def\omitkeyword{omit}%
6718: %
6719: \def\writetocentry#1#2#3{%
6720: \edef\writetoctype{#1}%
6721: \ifx\writetoctype\omitkeyword \else
6722: \iftocfileopened\else
6723: \immediate\openout\tocfile = \jobname.toc
6724: \global\tocfileopenedtrue
6725: \fi
6726: %
6727: \iflinks
6728: {\atdummies
6729: \edef\temp{%
6730: \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6731: \temp
6732: }%
6733: \fi
6734: \fi
6735: %
6736: % Tell \shipout to create a pdf destination on each page, if we're
6737: % writing pdf. These are used in the table of contents. We can't
6738: % just write one on every page because the title pages are numbered
6739: % 1 and 2 (the page numbers aren't printed), and so are the first
6740: % two pages of the document. Thus, we'd have two destinations named
6741: % `1', and two named `2'.
6742: \ifpdforxetex
6743: \global\pdfmakepagedesttrue
6744: \fi
6745: }
6746:
6747:
6748: % These characters do not print properly in the Computer Modern roman
6749: % fonts, so we must take special care. This is more or less redundant
6750: % with the Texinfo input format setup at the end of this file.
6751: %
6752: \def\activecatcodes{%
6753: \catcode`\"=\active
6754: \catcode`\$=\active
6755: \catcode`\<=\active
6756: \catcode`\>=\active
6757: \catcode`\\=\active
6758: \catcode`\^=\active
6759: \catcode`\_=\active
6760: \catcode`\|=\active
6761: \catcode`\~=\active
6762: }
6763:
6764:
6765: % Read the toc file, which is essentially Texinfo input.
6766: \def\readtocfile{%
6767: \setupdatafile
6768: \activecatcodes
6769: \input \tocreadfilename
6770: }
6771:
6772: \newskip\contentsrightmargin \contentsrightmargin=1in
6773: \newcount\savepageno
6774: \newcount\lastnegativepageno \lastnegativepageno = -1
6775:
6776: % Prepare to read what we've written to \tocfile.
6777: %
6778: \def\startcontents#1{%
6779: % If @setchapternewpage on, and @headings double, the contents should
1.5 ! snw 6780: % start on an odd page, unlike chapters. Thus, we maintain
! 6781: % \contentsalignmacro in parallel with \pagealignmacro.
! 6782: % From: Torbjorn Granlund <tege@matematik.su.se>
1.1 snw 6783: \contentsalignmacro
6784: \immediate\closeout\tocfile
6785: %
6786: % Don't need to put `Contents' or `Short Contents' in the headline.
6787: % It is abundantly clear what they are.
6788: \chapmacro{#1}{Yomitfromtoc}{}%
6789: %
6790: \savepageno = \pageno
6791: \begingroup % Set up to handle contents files properly.
6792: \raggedbottom % Worry more about breakpoints than the bottom.
6793: \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6794: %
6795: % Roman numerals for page numbers.
6796: \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6797: }
6798:
6799: % redefined for the two-volume lispref. We always output on
6800: % \jobname.toc even if this is redefined.
6801: %
6802: \def\tocreadfilename{\jobname.toc}
6803:
6804: % Normal (long) toc.
6805: %
6806: \def\contents{%
6807: \startcontents{\putwordTOC}%
6808: \openin 1 \tocreadfilename\space
6809: \ifeof 1 \else
6810: \readtocfile
6811: \fi
6812: \vfill \eject
6813: \contentsalignmacro % in case @setchapternewpage odd is in effect
6814: \ifeof 1 \else
6815: \pdfmakeoutlines
6816: \fi
6817: \closein 1
6818: \endgroup
1.5 ! snw 6819: \lastnegativepageno = \pageno
! 6820: \global\pageno = \savepageno
1.1 snw 6821: }
6822:
6823: % And just the chapters.
6824: \def\summarycontents{%
6825: \startcontents{\putwordShortTOC}%
6826: %
6827: \let\partentry = \shortpartentry
6828: \let\numchapentry = \shortchapentry
6829: \let\appentry = \shortchapentry
6830: \let\unnchapentry = \shortunnchapentry
6831: % We want a true roman here for the page numbers.
6832: \secfonts
6833: \let\rm=\shortcontrm \let\bf=\shortcontbf
6834: \let\sl=\shortcontsl \let\tt=\shortconttt
6835: \rm
6836: \hyphenpenalty = 10000
6837: \advance\baselineskip by 1pt % Open it up a little.
6838: \def\numsecentry##1##2##3##4{}
6839: \let\appsecentry = \numsecentry
6840: \let\unnsecentry = \numsecentry
6841: \let\numsubsecentry = \numsecentry
6842: \let\appsubsecentry = \numsecentry
6843: \let\unnsubsecentry = \numsecentry
6844: \let\numsubsubsecentry = \numsecentry
6845: \let\appsubsubsecentry = \numsecentry
6846: \let\unnsubsubsecentry = \numsecentry
6847: \openin 1 \tocreadfilename\space
6848: \ifeof 1 \else
6849: \readtocfile
6850: \fi
6851: \closein 1
6852: \vfill \eject
6853: \contentsalignmacro % in case @setchapternewpage odd is in effect
6854: \endgroup
1.5 ! snw 6855: \lastnegativepageno = \pageno
! 6856: \global\pageno = \savepageno
1.1 snw 6857: }
6858: \let\shortcontents = \summarycontents
6859:
6860: % Typeset the label for a chapter or appendix for the short contents.
6861: % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6862: %
6863: \def\shortchaplabel#1{%
6864: % This space should be enough, since a single number is .5em, and the
6865: % widest letter (M) is 1em, at least in the Computer Modern fonts.
6866: % But use \hss just in case.
1.5 ! snw 6867: % (This space doesn't include the extra space that gets added after
! 6868: % the label; that gets put in by \shortchapentry above.)
1.1 snw 6869: %
6870: % We'd like to right-justify chapter numbers, but that looks strange
6871: % with appendix letters. And right-justifying numbers and
6872: % left-justifying letters looks strange when there is less than 10
6873: % chapters. Have to read the whole toc once to know how many chapters
6874: % there are before deciding ...
6875: \hbox to 1em{#1\hss}%
6876: }
6877:
1.5 ! snw 6878: % These macros generate individual entries in the table of contents.
! 6879: % The first argument is the chapter or section name.
! 6880: % The last argument is the page number.
! 6881: % The arguments in between are the chapter number, section number, ...
1.1 snw 6882:
6883: % Parts, in the main contents. Replace the part number, which doesn't
6884: % exist, with an empty box. Let's hope all the numbers have the same width.
6885: % Also ignore the page number, which is conventionally not printed.
6886: \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6887: \def\partentry#1#2#3#4{%
6888: % Add stretch and a bonus for breaking the page before the part heading.
6889: % This reduces the chance of the page being broken immediately after the
6890: % part heading, before a following chapter heading.
6891: \vskip 0pt plus 5\baselineskip
6892: \penalty-300
6893: \vskip 0pt plus -5\baselineskip
1.5 ! snw 6894: \dochapentry{\numeralbox\labelspace#1}{}%
1.1 snw 6895: }
6896: %
6897: % Parts, in the short toc.
6898: \def\shortpartentry#1#2#3#4{%
6899: \penalty-300
6900: \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6901: \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6902: }
6903:
6904: % Chapters, in the main contents.
1.5 ! snw 6905: \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
1.1 snw 6906:
6907: % Chapters, in the short toc.
1.5 ! snw 6908: % See comments in \dochapentry re vbox and related settings.
1.1 snw 6909: \def\shortchapentry#1#2#3#4{%
1.5 ! snw 6910: \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
1.1 snw 6911: }
6912:
6913: % Appendices, in the main contents.
6914: % Need the word Appendix, and a fixed-size box.
6915: %
6916: \def\appendixbox#1{%
6917: % We use M since it's probably the widest letter.
6918: \setbox0 = \hbox{\putwordAppendix{} M}%
6919: \hbox to \wd0{\putwordAppendix{} #1\hss}}
6920: %
1.5 ! snw 6921: \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
1.1 snw 6922:
6923: % Unnumbered chapters.
1.5 ! snw 6924: \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
! 6925: \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
1.1 snw 6926:
6927: % Sections.
1.5 ! snw 6928: \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
1.1 snw 6929: \let\appsecentry=\numsecentry
1.5 ! snw 6930: \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
1.1 snw 6931:
6932: % Subsections.
1.5 ! snw 6933: \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
1.1 snw 6934: \let\appsubsecentry=\numsubsecentry
1.5 ! snw 6935: \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
1.1 snw 6936:
6937: % And subsubsections.
1.5 ! snw 6938: \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
1.1 snw 6939: \let\appsubsubsecentry=\numsubsubsecentry
1.5 ! snw 6940: \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
1.1 snw 6941:
6942: % This parameter controls the indentation of the various levels.
6943: % Same as \defaultparindent.
6944: \newdimen\tocindent \tocindent = 15pt
6945:
1.5 ! snw 6946: % Now for the actual typesetting. In all these, #1 is the text and #2 is the
! 6947: % page number.
1.1 snw 6948: %
6949: % If the toc has to be broken over pages, we want it to be at chapters
6950: % if at all possible; hence the \penalty.
1.5 ! snw 6951: \def\dochapentry#1#2{%
1.1 snw 6952: \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6953: \begingroup
6954: % Move the page numbers slightly to the right
6955: \advance\entryrightmargin by -0.05em
6956: \chapentryfonts
1.5 ! snw 6957: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
1.1 snw 6958: \endgroup
6959: \nobreak\vskip .25\baselineskip plus.1\baselineskip
6960: }
6961:
1.5 ! snw 6962: \def\dosecentry#1#2{\begingroup
1.1 snw 6963: \secentryfonts \leftskip=\tocindent
1.5 ! snw 6964: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
1.1 snw 6965: \endgroup}
6966:
1.5 ! snw 6967: \def\dosubsecentry#1#2{\begingroup
1.1 snw 6968: \subsecentryfonts \leftskip=2\tocindent
1.5 ! snw 6969: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
1.1 snw 6970: \endgroup}
6971:
1.5 ! snw 6972: \def\dosubsubsecentry#1#2{\begingroup
1.1 snw 6973: \subsubsecentryfonts \leftskip=3\tocindent
1.5 ! snw 6974: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
1.1 snw 6975: \endgroup}
6976:
1.5 ! snw 6977: % We use the same \entry macro as for the index entries.
! 6978: \let\tocentry = \entry
! 6979:
! 6980: % Space between chapter (or whatever) number and the title.
! 6981: \def\labelspace{\hskip1em \relax}
! 6982:
! 6983: \def\dopageno#1{{\rm #1}}
! 6984: \def\doshortpageno#1{{\rm #1}}
1.1 snw 6985:
6986: \def\chapentryfonts{\secfonts \rm}
6987: \def\secentryfonts{\textfonts}
6988: \def\subsecentryfonts{\textfonts}
6989: \def\subsubsecentryfonts{\textfonts}
6990:
6991:
6992: \message{environments,}
6993: % @foo ... @end foo.
6994:
6995: % @tex ... @end tex escapes into raw TeX temporarily.
6996: % One exception: @ is still an escape character, so that @end tex works.
6997: % But \@ or @@ will get a plain @ character.
6998:
6999: \envdef\tex{%
1.5 ! snw 7000: \setupmarkupstyle{tex}%
1.1 snw 7001: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7002: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7003: \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7004: \catcode `\%=14
7005: \catcode `\+=\other
7006: \catcode `\"=\other
7007: \catcode `\|=\other
7008: \catcode `\<=\other
7009: \catcode `\>=\other
7010: \catcode `\`=\other
7011: \catcode `\'=\other
7012: %
7013: % ' is active in math mode (mathcode"8000). So reset it, and all our
7014: % other math active characters (just in case), to plain's definitions.
7015: \mathactive
7016: %
7017: % Inverse of the list at the beginning of the file.
7018: \let\b=\ptexb
7019: \let\bullet=\ptexbullet
7020: \let\c=\ptexc
7021: \let\,=\ptexcomma
7022: \let\.=\ptexdot
7023: \let\dots=\ptexdots
7024: \let\equiv=\ptexequiv
7025: \let\!=\ptexexclam
7026: \let\i=\ptexi
7027: \let\indent=\ptexindent
7028: \let\noindent=\ptexnoindent
7029: \let\{=\ptexlbrace
7030: \let\+=\tabalign
7031: \let\}=\ptexrbrace
7032: \let\/=\ptexslash
7033: \let\sp=\ptexsp
7034: \let\*=\ptexstar
7035: %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7036: \let\t=\ptext
7037: \expandafter \let\csname top\endcsname=\ptextop % we've made it outer
7038: \let\frenchspacing=\plainfrenchspacing
7039: %
7040: \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7041: \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7042: \def\@{@}%
7043: }
7044: % There is no need to define \Etex.
7045:
7046: % Define @lisp ... @end lisp.
7047: % @lisp environment forms a group so it can rebind things,
7048: % including the definition of @end lisp (which normally is erroneous).
7049:
7050: % Amount to narrow the margins by for @lisp.
7051: \newskip\lispnarrowing \lispnarrowing=0.4in
7052:
7053: % This is the definition that ^^M gets inside @lisp, @example, and other
7054: % such environments. \null is better than a space, since it doesn't
7055: % have any width.
7056: \def\lisppar{\null\endgraf}
7057:
7058: % This space is always present above and below environments.
7059: \newskip\envskipamount \envskipamount = 0pt
7060:
7061: % Make spacing and below environment symmetrical. We use \parskip here
7062: % to help in doing that, since in @example-like environments \parskip
7063: % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7064: % start of the next paragraph will insert \parskip.
7065: %
7066: \def\aboveenvbreak{{%
7067: % =10000 instead of <10000 because of a special case in \itemzzz and
7068: % \sectionheading, q.v.
7069: \ifnum \lastpenalty=10000 \else
7070: \advance\envskipamount by \parskip
7071: \endgraf
7072: \ifdim\lastskip<\envskipamount
7073: \removelastskip
7074: \ifnum\lastpenalty<10000
7075: % Penalize breaking before the environment, because preceding text
7076: % often leads into it.
7077: \penalty100
7078: \fi
7079: \vskip\envskipamount
7080: \fi
7081: \fi
7082: }}
7083:
7084: \def\afterenvbreak{{%
7085: % =10000 instead of <10000 because of a special case in \itemzzz and
7086: % \sectionheading, q.v.
7087: \ifnum \lastpenalty=10000 \else
7088: \advance\envskipamount by \parskip
7089: \endgraf
7090: \ifdim\lastskip<\envskipamount
7091: \removelastskip
7092: % it's not a good place to break if the last penalty was \nobreak
7093: % or better ...
7094: \ifnum\lastpenalty<10000 \penalty-50 \fi
7095: \vskip\envskipamount
7096: \fi
7097: \fi
7098: }}
7099:
7100: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
7101: % also clear it, so that its embedded environments do the narrowing again.
7102: \let\nonarrowing=\relax
7103:
7104: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7105: % environment contents.
7106:
7107: %
7108: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7109: \def\ctr{{\hskip 6pt\circle\char'010}}
7110: \def\cbl{{\circle\char'012\hskip -6pt}}
7111: \def\cbr{{\hskip 6pt\circle\char'011}}
7112: \def\carttop{\hbox to \cartouter{\hskip\lskip
7113: \ctl\leaders\hrule height\circthick\hfil\ctr
7114: \hskip\rskip}}
7115: \def\cartbot{\hbox to \cartouter{\hskip\lskip
7116: \cbl\leaders\hrule height\circthick\hfil\cbr
7117: \hskip\rskip}}
7118: %
7119: \newskip\lskip\newskip\rskip
7120:
7121: % only require the font if @cartouche is actually used
7122: \def\cartouchefontdefs{%
7123: \font\circle=lcircle10\relax
7124: \circthick=\fontdimen8\circle
7125: }
7126: \newdimen\circthick
7127: \newdimen\cartouter\newdimen\cartinner
7128: \newskip\normbskip\newskip\normpskip\newskip\normlskip
7129:
1.5 ! snw 7130:
! 7131: \envdef\cartouche{%
1.1 snw 7132: \cartouchefontdefs
7133: \ifhmode\par\fi % can't be in the midst of a paragraph.
7134: \startsavinginserts
7135: \lskip=\leftskip \rskip=\rightskip
7136: \leftskip=0pt\rightskip=0pt % we want these *outside*.
7137: \cartinner=\hsize \advance\cartinner by-\lskip
7138: \advance\cartinner by-\rskip
7139: \cartouter=\hsize
1.5 ! snw 7140: \advance\cartouter by 18.4pt % allow for 3pt kerns on either
! 7141: % side, and for 6pt waste from
! 7142: % each corner char, and rule thickness
1.1 snw 7143: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7144: %
7145: % If this cartouche directly follows a sectioning command, we need the
7146: % \parskip glue (backspaced over by default) or the cartouche can
7147: % collide with the section heading.
7148: \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7149: %
1.5 ! snw 7150: \setbox\groupbox=\vbox\bgroup
1.1 snw 7151: \baselineskip=0pt\parskip=0pt\lineskip=0pt
7152: \carttop
7153: \hbox\bgroup
1.5 ! snw 7154: \hskip\lskip
! 7155: \vrule\kern3pt
! 7156: \vbox\bgroup
! 7157: \kern3pt
! 7158: \hsize=\cartinner
! 7159: \baselineskip=\normbskip
! 7160: \lineskip=\normlskip
! 7161: \parskip=\normpskip
! 7162: \vskip -\parskip
! 7163: \comment % For explanation, see the end of def\group.
1.1 snw 7164: }
7165: \def\Ecartouche{%
7166: \ifhmode\par\fi
7167: \kern3pt
7168: \egroup
7169: \kern3pt\vrule
7170: \hskip\rskip
7171: \egroup
7172: \cartbot
7173: \egroup
7174: \addgroupbox
7175: \checkinserts
7176: }
7177:
7178:
7179: % This macro is called at the beginning of all the @example variants,
7180: % inside a group.
7181: \newdimen\nonfillparindent
7182: \def\nonfillstart{%
7183: \aboveenvbreak
7184: \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7185: \sepspaces % Make spaces be word-separators rather than space tokens.
7186: \let\par = \lisppar % don't ignore blank lines
7187: \obeylines % each line of input is a line of output
7188: \parskip = 0pt
7189: % Turn off paragraph indentation but redefine \indent to emulate
7190: % the normal \indent.
7191: \nonfillparindent=\parindent
7192: \parindent = 0pt
7193: \let\indent\nonfillindent
7194: %
7195: \emergencystretch = 0pt % don't try to avoid overfull boxes
7196: \ifx\nonarrowing\relax
7197: \advance \leftskip by \lispnarrowing
7198: \exdentamount=\lispnarrowing
7199: \else
7200: \let\nonarrowing = \relax
7201: \fi
7202: \let\exdent=\nofillexdent
7203: }
7204:
7205: \begingroup
7206: \obeyspaces
7207: % We want to swallow spaces (but not other tokens) after the fake
7208: % @indent in our nonfill-environments, where spaces are normally
7209: % active and set to @tie, resulting in them not being ignored after
7210: % @indent.
7211: \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7212: \gdef\nonfillindentcheck{%
7213: \ifx\temp %
7214: \expandafter\nonfillindentgobble%
7215: \else%
7216: \leavevmode\nonfillindentbox%
7217: \fi%
7218: }%
7219: \endgroup
7220: \def\nonfillindentgobble#1{\nonfillindent}
7221: \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7222:
7223: % If you want all examples etc. small: @set dispenvsize small.
7224: % If you want even small examples the full size: @set dispenvsize nosmall.
7225: % This affects the following displayed environments:
1.5 ! snw 7226: % @example, @display, @format, @lisp
1.1 snw 7227: %
7228: \def\smallword{small}
7229: \def\nosmallword{nosmall}
7230: \let\SETdispenvsize\relax
7231: \def\setnormaldispenv{%
7232: \ifx\SETdispenvsize\smallword
7233: % end paragraph for sake of leading, in case document has no blank
7234: % line. This is redundant with what happens in \aboveenvbreak, but
7235: % we need to do it before changing the fonts, and it's inconvenient
7236: % to change the fonts afterward.
7237: \ifnum \lastpenalty=10000 \else \endgraf \fi
7238: \smallexamplefonts \rm
7239: \fi
7240: }
7241: \def\setsmalldispenv{%
7242: \ifx\SETdispenvsize\nosmallword
7243: \else
7244: \ifnum \lastpenalty=10000 \else \endgraf \fi
7245: \smallexamplefonts \rm
7246: \fi
7247: }
7248:
7249: % We often define two environments, @foo and @smallfoo.
7250: % Let's do it in one command. #1 is the env name, #2 the definition.
7251: \def\makedispenvdef#1#2{%
7252: \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7253: \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7254: \expandafter\let\csname E#1\endcsname \afterenvbreak
7255: \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7256: }
7257:
7258: % Define two environment synonyms (#1 and #2) for an environment.
7259: \def\maketwodispenvdef#1#2#3{%
7260: \makedispenvdef{#1}{#3}%
7261: \makedispenvdef{#2}{#3}%
7262: }
7263: %
7264: % @lisp: indented, narrowed, typewriter font;
7265: % @example: same as @lisp.
7266: %
7267: % @smallexample and @smalllisp: use smaller fonts.
7268: % Originally contributed by Pavel@xerox.
7269: %
7270: \maketwodispenvdef{lisp}{example}{%
7271: \nonfillstart
1.5 ! snw 7272: \tt\setupmarkupstyle{example}%
1.1 snw 7273: \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
1.5 ! snw 7274: \gobble % eat return
1.1 snw 7275: }
7276: % @display/@smalldisplay: same as @lisp except keep current font.
7277: %
7278: \makedispenvdef{display}{%
7279: \nonfillstart
7280: \gobble
7281: }
7282:
7283: % @format/@smallformat: same as @display except don't narrow margins.
7284: %
7285: \makedispenvdef{format}{%
7286: \let\nonarrowing = t%
7287: \nonfillstart
7288: \gobble
7289: }
7290:
7291: % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7292: \envdef\flushleft{%
7293: \let\nonarrowing = t%
7294: \nonfillstart
7295: \gobble
7296: }
7297: \let\Eflushleft = \afterenvbreak
7298:
7299: % @flushright.
7300: %
7301: \envdef\flushright{%
7302: \let\nonarrowing = t%
7303: \nonfillstart
7304: \advance\leftskip by 0pt plus 1fill\relax
7305: \gobble
7306: }
7307: \let\Eflushright = \afterenvbreak
7308:
7309:
7310: % @raggedright does more-or-less normal line breaking but no right
7311: % justification. From plain.tex.
7312: \envdef\raggedright{%
7313: \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7314: }
7315: \let\Eraggedright\par
7316:
1.5 ! snw 7317: \envdef\raggedleft{%
! 7318: \parindent=0pt \leftskip0pt plus2em
! 7319: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
! 7320: \hbadness=10000 % Last line will usually be underfull, so turn off
! 7321: % badness reporting.
! 7322: }
! 7323: \let\Eraggedleft\par
! 7324:
! 7325: \envdef\raggedcenter{%
! 7326: \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
! 7327: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
! 7328: \hbadness=10000 % Last line will usually be underfull, so turn off
! 7329: % badness reporting.
! 7330: }
! 7331: \let\Eraggedcenter\par
! 7332:
1.1 snw 7333:
7334: % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7335: % and narrows the margins. We keep \parskip nonzero in general, since
7336: % we're doing normal filling. So, when using \aboveenvbreak and
7337: % \afterenvbreak, temporarily make \parskip 0.
7338: %
7339: \makedispenvdef{quotation}{\quotationstart}
7340: %
7341: \def\quotationstart{%
7342: \indentedblockstart % same as \indentedblock, but increase right margin too.
7343: \ifx\nonarrowing\relax
7344: \advance\rightskip by \lispnarrowing
7345: \fi
7346: \parsearg\quotationlabel
7347: }
7348:
7349: % We have retained a nonzero parskip for the environment, since we're
7350: % doing normal filling.
7351: %
7352: \def\Equotation{%
7353: \par
7354: \ifx\quotationauthor\thisisundefined\else
7355: % indent a bit.
7356: \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7357: \fi
7358: {\parskip=0pt \afterenvbreak}%
7359: }
7360: \def\Esmallquotation{\Equotation}
7361:
7362: % If we're given an argument, typeset it in bold with a colon after.
7363: \def\quotationlabel#1{%
7364: \def\temp{#1}%
7365: \ifx\temp\empty \else
7366: {\bf #1: }%
7367: \fi
7368: }
7369:
7370: % @indentedblock is like @quotation, but indents only on the left and
7371: % has no optional argument.
7372: %
7373: \makedispenvdef{indentedblock}{\indentedblockstart}
7374: %
7375: \def\indentedblockstart{%
7376: {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7377: \parindent=0pt
7378: %
7379: % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7380: \ifx\nonarrowing\relax
7381: \advance\leftskip by \lispnarrowing
7382: \exdentamount = \lispnarrowing
7383: \else
7384: \let\nonarrowing = \relax
7385: \fi
7386: }
7387:
7388: % Keep a nonzero parskip for the environment, since we're doing normal filling.
7389: %
7390: \def\Eindentedblock{%
7391: \par
7392: {\parskip=0pt \afterenvbreak}%
7393: }
7394: \def\Esmallindentedblock{\Eindentedblock}
7395:
7396:
7397: % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7398: % If we want to allow any <char> as delimiter,
7399: % we need the curly braces so that makeinfo sees the @verb command, eg:
7400: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
7401: %
7402: % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
7403: %
7404: % [Knuth] p.344; only we need to do the other characters Texinfo sets
7405: % active too. Otherwise, they get lost as the first character on a
7406: % verbatim line.
7407: \def\dospecials{%
7408: \do\ \do\\\do\{\do\}\do\$\do\&%
7409: \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7410: \do\<\do\>\do\|\do\@\do+\do\"%
7411: % Don't do the quotes -- if we do, @set txicodequoteundirected and
7412: % @set txicodequotebacktick will not have effect on @verb and
7413: % @verbatim, and ?` and !` ligatures won't get disabled.
7414: %\do\`\do\'%
7415: }
7416: %
7417: % [Knuth] p. 380
7418: \def\uncatcodespecials{%
7419: \def\do##1{\catcode`##1=\other}\dospecials}
7420: %
7421: % Setup for the @verb command.
7422: %
7423: % Eight spaces for a tab
7424: \begingroup
7425: \catcode`\^^I=\active
7426: \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7427: \endgroup
7428: %
7429: \def\setupverb{%
1.5 ! snw 7430: \tt % easiest (and conventionally used) font for verbatim
1.1 snw 7431: \def\par{\leavevmode\endgraf}%
1.5 ! snw 7432: \setupmarkupstyle{verb}%
1.1 snw 7433: \tabeightspaces
7434: % Respect line breaks,
7435: % print special symbols as themselves, and
7436: % make each space count
7437: % must do in this order:
7438: \obeylines \uncatcodespecials \sepspaces
7439: }
7440:
7441: % Setup for the @verbatim environment
7442: %
7443: % Real tab expansion.
7444: \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7445: %
7446: % We typeset each line of the verbatim in an \hbox, so we can handle
1.5 ! snw 7447: % tabs. The \global is in case the verbatim line starts with an accent,
! 7448: % or some other command that starts with a begin-group. Otherwise, the
! 7449: % entire \verbbox would disappear at the corresponding end-group, before
! 7450: % it is typeset. Meanwhile, we can't have nested verbatim commands
! 7451: % (can we?), so the \global won't be overwriting itself.
1.1 snw 7452: \newbox\verbbox
1.5 ! snw 7453: \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
1.1 snw 7454: %
7455: \begingroup
7456: \catcode`\^^I=\active
7457: \gdef\tabexpand{%
7458: \catcode`\^^I=\active
7459: \def^^I{\leavevmode\egroup
7460: \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7461: \divide\dimen\verbbox by\tabw
7462: \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7463: \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
1.5 ! snw 7464: \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
1.1 snw 7465: }%
7466: }
7467: \endgroup
7468:
7469: % start the verbatim environment.
7470: \def\setupverbatim{%
7471: \let\nonarrowing = t%
7472: \nonfillstart
7473: \tt % easiest (and conventionally used) font for verbatim
1.5 ! snw 7474: % The \leavevmode here is for blank lines. Otherwise, we would
! 7475: % never \starttabbox and the \egroup would end verbatim mode.
! 7476: \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
1.1 snw 7477: \tabexpand
1.5 ! snw 7478: \setupmarkupstyle{verbatim}%
1.1 snw 7479: % Respect line breaks,
7480: % print special symbols as themselves, and
7481: % make each space count.
7482: % Must do in this order:
7483: \obeylines \uncatcodespecials \sepspaces
1.5 ! snw 7484: \everypar{\starttabbox}%
1.1 snw 7485: }
7486:
7487: % Do the @verb magic: verbatim text is quoted by unique
7488: % delimiter characters. Before first delimiter expect a
7489: % right brace, after last delimiter expect closing brace:
7490: %
7491: % \def\doverb'{'<char>#1<char>'}'{#1}
7492: %
7493: % [Knuth] p. 382; only eat outer {}
7494: \begingroup
7495: \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7496: \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7497: \endgroup
7498: %
7499: \def\verb{\begingroup\setupverb\doverb}
7500: %
7501: %
7502: % Do the @verbatim magic: define the macro \doverbatim so that
7503: % the (first) argument ends when '@end verbatim' is reached, ie:
7504: %
7505: % \def\doverbatim#1@end verbatim{#1}
7506: %
7507: % For Texinfo it's a lot easier than for LaTeX,
7508: % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7509: % we need not redefine '\', '{' and '}'.
7510: %
7511: % Inspired by LaTeX's verbatim command set [latex.ltx]
7512: %
7513: \begingroup
7514: \catcode`\ =\active
7515: \obeylines %
7516: % ignore everything up to the first ^^M, that's the newline at the end
7517: % of the @verbatim input line itself. Otherwise we get an extra blank
7518: % line in the output.
1.5 ! snw 7519: \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
1.1 snw 7520: % We really want {...\end verbatim} in the body of the macro, but
7521: % without the active space; thus we have to use \xdef and \gobble.
7522: \endgroup
7523: %
7524: \envdef\verbatim{%
1.5 ! snw 7525: \setupverbatim\doverbatim
1.1 snw 7526: }
7527: \let\Everbatim = \afterenvbreak
7528:
7529:
7530: % @verbatiminclude FILE - insert text of file in verbatim environment.
7531: %
7532: \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7533: %
7534: \def\doverbatiminclude#1{%
7535: {%
7536: \makevalueexpandable
7537: \setupverbatim
7538: {%
7539: \indexnofonts % Allow `@@' and other weird things in file names.
7540: \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7541: \edef\tmp{\noexpand\input #1 }
7542: \expandafter
1.5 ! snw 7543: }\tmp
1.1 snw 7544: \afterenvbreak
7545: }%
7546: }
7547:
7548: % @copying ... @end copying.
7549: % Save the text away for @insertcopying later.
7550: %
7551: % We save the uninterpreted tokens, rather than creating a box.
7552: % Saving the text in a box would be much easier, but then all the
7553: % typesetting commands (@smallbook, font changes, etc.) have to be done
7554: % beforehand -- and a) we want @copying to be done first in the source
7555: % file; b) letting users define the frontmatter in as flexible order as
7556: % possible is desirable.
7557: %
1.5 ! snw 7558: \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
! 7559: \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
! 7560: %
1.1 snw 7561: \def\insertcopying{%
7562: \begingroup
7563: \parindent = 0pt % paragraph indentation looks wrong on title page
7564: \scanexp\copyingtext
7565: \endgroup
7566: }
7567:
7568:
7569: \message{defuns,}
7570: % @defun etc.
7571:
7572: \newskip\defbodyindent \defbodyindent=.4in
7573: \newskip\defargsindent \defargsindent=50pt
7574: \newskip\deflastargmargin \deflastargmargin=18pt
7575: \newcount\defunpenalty
7576:
7577: % Start the processing of @deffn:
7578: \def\startdefun{%
7579: \ifnum\lastpenalty<10000
7580: \medbreak
7581: \defunpenalty=10003 % Will keep this @deffn together with the
7582: % following @def command, see below.
7583: \else
7584: % If there are two @def commands in a row, we'll have a \nobreak,
7585: % which is there to keep the function description together with its
7586: % header. But if there's nothing but headers, we need to allow a
7587: % break somewhere. Check specifically for penalty 10002, inserted
7588: % by \printdefunline, instead of 10000, since the sectioning
7589: % commands also insert a nobreak penalty, and we don't want to allow
7590: % a break between a section heading and a defun.
7591: %
7592: % As a further refinement, we avoid "club" headers by signalling
7593: % with penalty of 10003 after the very first @deffn in the
7594: % sequence (see above), and penalty of 10002 after any following
7595: % @def command.
7596: \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7597: %
7598: % Similarly, after a section heading, do not allow a break.
7599: % But do insert the glue.
7600: \medskip % preceded by discardable penalty, so not a breakpoint
7601: \fi
7602: %
7603: \parindent=0in
7604: \advance\leftskip by \defbodyindent
7605: \exdentamount=\defbodyindent
7606: }
7607:
1.5 ! snw 7608: \def\dodefunx#1{%
! 7609: % First, check whether we are in the right environment:
! 7610: \checkenv#1%
! 7611: %
! 7612: % As above, allow line break if we have multiple x headers in a row.
! 7613: % It's not a great place, though.
! 7614: \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
! 7615: %
! 7616: % And now, it's time to reuse the body of the original defun:
! 7617: \expandafter\gobbledefun#1%
! 7618: }
! 7619: \def\gobbledefun#1\startdefun{}
! 7620:
! 7621: % \printdefunline \deffnheader{text}
1.1 snw 7622: %
7623: \def\printdefunline#1#2{%
7624: \begingroup
1.5 ! snw 7625: % call \deffnheader:
1.1 snw 7626: #1#2 \endheader
7627: % common ending:
7628: \interlinepenalty = 10000
7629: \advance\rightskip by 0pt plus 1fil\relax
7630: \endgraf
7631: \nobreak\vskip -\parskip
1.5 ! snw 7632: \penalty\defunpenalty % signal to \startdefun and \dodefunx
1.1 snw 7633: % Some of the @defun-type tags do not enable magic parentheses,
7634: % rendering the following check redundant. But we don't optimize.
7635: \checkparencounts
7636: \endgroup
7637: }
7638:
7639: \def\Edefun{\endgraf\medbreak}
7640:
1.5 ! snw 7641: % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
! 7642: % the only thing remaining is to define \deffnheader.
1.1 snw 7643: %
7644: \def\makedefun#1{%
7645: \expandafter\let\csname E#1\endcsname = \Edefun
7646: \edef\temp{\noexpand\domakedefun
7647: \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7648: \temp
7649: }
1.5 ! snw 7650:
! 7651: % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
! 7652: %
! 7653: % Define \deffn and \deffnx, without parameters.
! 7654: % \deffnheader has to be defined explicitly.
! 7655: %
1.1 snw 7656: \def\domakedefun#1#2#3{%
7657: \envdef#1{%
7658: \startdefun
7659: \doingtypefnfalse % distinguish typed functions from all else
7660: \parseargusing\activeparens{\printdefunline#3}%
7661: }%
1.5 ! snw 7662: \def#2{\dodefunx#1}%
! 7663: \def#3%
1.1 snw 7664: }
7665:
7666: \newif\ifdoingtypefn % doing typed function?
7667: \newif\ifrettypeownline % typeset return type on its own line?
7668:
7669: % @deftypefnnewline on|off says whether the return type of typed functions
7670: % are printed on their own line. This affects @deftypefn, @deftypefun,
7671: % @deftypeop, and @deftypemethod.
7672: %
7673: \parseargdef\deftypefnnewline{%
7674: \def\temp{#1}%
7675: \ifx\temp\onword
7676: \expandafter\let\csname SETtxideftypefnnl\endcsname
7677: = \empty
7678: \else\ifx\temp\offword
7679: \expandafter\let\csname SETtxideftypefnnl\endcsname
7680: = \relax
7681: \else
7682: \errhelp = \EMsimple
7683: \errmessage{Unknown @txideftypefnnl value `\temp',
7684: must be on|off}%
7685: \fi\fi
7686: }
7687:
1.5 ! snw 7688: % \dosubind {index}{topic}{subtopic}
! 7689: %
! 7690: % If SUBTOPIC is present, precede it with a space, and call \doind.
! 7691: % (At some time during the 20th century, this made a two-level entry in an
! 7692: % index such as the operation index. Nobody seemed to notice the change in
! 7693: % behaviour though.)
! 7694: \def\dosubind#1#2#3{%
! 7695: \def\thirdarg{#3}%
! 7696: \ifx\thirdarg\empty
! 7697: \doind{#1}{#2}%
! 7698: \else
! 7699: \doind{#1}{#2\space#3}%
! 7700: \fi
! 7701: }
! 7702:
1.1 snw 7703: % Untyped functions:
7704:
7705: % @deffn category name args
1.5 ! snw 7706: \makedefun{deffn}{\deffngeneral{}}
! 7707:
! 7708: % @deffn category class name args
! 7709: \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
! 7710:
! 7711: % \defopon {category on}class name args
! 7712: \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
1.3 snw 7713:
1.5 ! snw 7714: % \deffngeneral {subind}category name args
! 7715: %
! 7716: \def\deffngeneral#1#2 #3 #4\endheader{%
! 7717: \dosubind{fn}{\code{#3}}{#1}%
! 7718: \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
1.1 snw 7719: }
7720:
7721: % Typed functions:
7722:
7723: % @deftypefn category type name args
1.5 ! snw 7724: \makedefun{deftypefn}{\deftypefngeneral{}}
1.1 snw 7725:
7726: % @deftypeop category class type name args
1.5 ! snw 7727: \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
! 7728:
! 7729: % \deftypeopon {category on}class type name args
! 7730: \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
! 7731:
! 7732: % \deftypefngeneral {subind}category type name args
! 7733: %
! 7734: \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
! 7735: \dosubind{fn}{\code{#4}}{#1}%
1.1 snw 7736: \doingtypefntrue
1.5 ! snw 7737: \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
1.1 snw 7738: }
7739:
7740: % Typed variables:
7741:
7742: % @deftypevr category type var args
1.5 ! snw 7743: \makedefun{deftypevr}{\deftypecvgeneral{}}
1.1 snw 7744:
7745: % @deftypecv category class type var args
1.5 ! snw 7746: \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
! 7747:
! 7748: % \deftypecvof {category of}class type var args
! 7749: \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
! 7750:
! 7751: % \deftypecvgeneral {subind}category type var args
! 7752: %
! 7753: \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
! 7754: \dosubind{vr}{\code{#4}}{#1}%
! 7755: \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
1.1 snw 7756: }
7757:
7758: % Untyped variables:
7759:
7760: % @defvr category var args
7761: \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7762:
7763: % @defcv category class var args
1.5 ! snw 7764: \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
! 7765:
! 7766: % \defcvof {category of}class var args
! 7767: \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
1.1 snw 7768:
7769: % Types:
7770:
7771: % @deftp category name args
7772: \makedefun{deftp}#1 #2 #3\endheader{%
7773: \doind{tp}{\code{#2}}%
1.5 ! snw 7774: \defname{#1}{}{#2}\defunargs{#3\unskip}%
1.1 snw 7775: }
7776:
7777: % Remaining @defun-like shortcuts:
7778: \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7779: \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7780: \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7781: \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7782: \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7783: \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7784: \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
1.5 ! snw 7785: \makedefun{defmethod}{\defopon\putwordMethodon}
! 7786: \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
! 7787: \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
! 7788: \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
1.1 snw 7789:
1.5 ! snw 7790: % \defname, which formats the name of the @def (not the args).
1.1 snw 7791: % #1 is the category, such as "Function".
7792: % #2 is the return type, if any.
7793: % #3 is the function name.
7794: %
7795: % We are followed by (but not passed) the arguments, if any.
7796: %
1.5 ! snw 7797: \def\defname#1#2#3{%
1.1 snw 7798: \par
7799: % Get the values of \leftskip and \rightskip as they were outside the @def...
7800: \advance\leftskip by -\defbodyindent
7801: %
7802: % Determine if we are typesetting the return type of a typed function
7803: % on a line by itself.
7804: \rettypeownlinefalse
7805: \ifdoingtypefn % doing a typed function specifically?
7806: % then check user option for putting return type on its own line:
1.5 ! snw 7807: \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
! 7808: \rettypeownlinetrue
! 7809: \fi
1.1 snw 7810: \fi
7811: %
7812: % How we'll format the category name. Putting it in brackets helps
7813: % distinguish it from the body text that may end up on the next line
7814: % just below it.
7815: \def\temp{#1}%
7816: \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7817: %
7818: % Figure out line sizes for the paragraph shape. We'll always have at
7819: % least two.
7820: \tempnum = 2
7821: %
7822: % The first line needs space for \box0; but if \rightskip is nonzero,
7823: % we need only space for the part of \box0 which exceeds it:
7824: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
7825: %
7826: % If doing a return type on its own line, we'll have another line.
7827: \ifrettypeownline
7828: \advance\tempnum by 1
7829: \def\maybeshapeline{0in \hsize}%
7830: \else
7831: \def\maybeshapeline{}%
7832: \fi
7833: %
7834: % The continuations:
7835: \dimen2=\hsize \advance\dimen2 by -\defargsindent
7836: %
7837: % The final paragraph shape:
7838: \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
7839: %
7840: % Put the category name at the right margin.
7841: \noindent
7842: \hbox to 0pt{%
7843: \hfil\box0 \kern-\hsize
7844: % \hsize has to be shortened this way:
7845: \kern\leftskip
7846: % Intentionally do not respect \rightskip, since we need the space.
7847: }%
7848: %
7849: % Allow all lines to be underfull without complaint:
7850: \tolerance=10000 \hbadness=10000
7851: \exdentamount=\defbodyindent
7852: {%
7853: % defun fonts. We use typewriter by default (used to be bold) because:
7854: % . we're printing identifiers, they should be in tt in principle.
7855: % . in languages with many accents, such as Czech or French, it's
7856: % common to leave accents off identifiers. The result looks ok in
7857: % tt, but exceedingly strange in rm.
7858: % . we don't want -- and --- to be treated as ligatures.
7859: % . this still does not fix the ?` and !` ligatures, but so far no
7860: % one has made identifiers using them :).
7861: \df \tt
7862: \def\temp{#2}% text of the return type
7863: \ifx\temp\empty\else
7864: \tclose{\temp}% typeset the return type
7865: \ifrettypeownline
7866: % put return type on its own line; prohibit line break following:
7867: \hfil\vadjust{\nobreak}\break
7868: \else
7869: \space % type on same line, so just followed by a space
7870: \fi
7871: \fi % no return type
7872: #3% output function name
7873: }%
1.5 ! snw 7874: {\rm\enskip}% hskip 0.5 em of \rmfont
1.1 snw 7875: %
7876: \boldbrax
7877: % arguments will be output next, if any.
7878: }
7879:
1.5 ! snw 7880: % Print arguments in slanted roman (not ttsl), inconsistently with using
! 7881: % tt for the name. This is because literal text is sometimes needed in
! 7882: % the argument list (groff manual), and ttsl and tt are not very
! 7883: % distinguishable. Prevent hyphenation at `-' chars.
! 7884: %
1.1 snw 7885: \def\defunargs#1{%
1.5 ! snw 7886: % use sl by default (not ttsl),
! 7887: % tt for the names.
! 7888: \df \sl \hyphenchar\font=0
! 7889: %
! 7890: % On the other hand, if an argument has two dashes (for instance), we
! 7891: % want a way to get ttsl. We used to recommend @var for that, so
! 7892: % leave the code in, but it's strange for @var to lead to typewriter.
! 7893: % Nowadays we recommend @code, since the difference between a ttsl hyphen
! 7894: % and a tt hyphen is pretty tiny. @code also disables ?` !`.
! 7895: \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
! 7896: #1%
! 7897: \sl\hyphenchar\font=45
1.1 snw 7898: }
7899:
7900: % We want ()&[] to print specially on the defun line.
7901: %
7902: \def\activeparens{%
7903: \catcode`\(=\active \catcode`\)=\active
7904: \catcode`\[=\active \catcode`\]=\active
7905: \catcode`\&=\active
7906: }
7907:
7908: % Make control sequences which act like normal parenthesis chars.
7909: \let\lparen = ( \let\rparen = )
7910:
7911: % Be sure that we always have a definition for `(', etc. For example,
7912: % if the fn name has parens in it, \boldbrax will not be in effect yet,
7913: % so TeX would otherwise complain about undefined control sequence.
7914: {
7915: \activeparens
1.5 ! snw 7916: \global\let(=\lparen \global\let)=\rparen
! 7917: \global\let[=\lbrack \global\let]=\rbrack
! 7918: \global\let& = \&
1.1 snw 7919:
7920: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7921: \gdef\magicamp{\let&=\amprm}
7922: }
7923: \let\ampchar\&
7924:
7925: \newcount\parencount
7926:
7927: % If we encounter &foo, then turn on ()-hacking afterwards
7928: \newif\ifampseen
1.5 ! snw 7929: \def\amprm#1 {\ampseentrue{\bf\ }}
1.1 snw 7930:
7931: \def\parenfont{%
7932: \ifampseen
7933: % At the first level, print parens in roman,
7934: % otherwise use the default font.
7935: \ifnum \parencount=1 \rm \fi
7936: \else
7937: % The \sf parens (in \boldbrax) actually are a little bolder than
7938: % the contained text. This is especially needed for [ and ] .
7939: \sf
7940: \fi
7941: }
7942: \def\infirstlevel#1{%
7943: \ifampseen
7944: \ifnum\parencount=1
7945: #1%
7946: \fi
7947: \fi
7948: }
7949: \def\bfafterword#1 {#1 \bf}
7950:
7951: \def\opnr{%
7952: \global\advance\parencount by 1
7953: {\parenfont(}%
7954: \infirstlevel \bfafterword
7955: }
7956: \def\clnr{%
7957: {\parenfont)}%
7958: \infirstlevel \sl
7959: \global\advance\parencount by -1
7960: }
7961:
7962: \newcount\brackcount
7963: \def\lbrb{%
7964: \global\advance\brackcount by 1
7965: {\bf[}%
7966: }
7967: \def\rbrb{%
7968: {\bf]}%
7969: \global\advance\brackcount by -1
7970: }
7971:
7972: \def\checkparencounts{%
7973: \ifnum\parencount=0 \else \badparencount \fi
7974: \ifnum\brackcount=0 \else \badbrackcount \fi
7975: }
7976: % these should not use \errmessage; the glibc manual, at least, actually
7977: % has such constructs (when documenting function pointers).
7978: \def\badparencount{%
7979: \message{Warning: unbalanced parentheses in @def...}%
7980: \global\parencount=0
7981: }
7982: \def\badbrackcount{%
7983: \message{Warning: unbalanced square brackets in @def...}%
7984: \global\brackcount=0
7985: }
7986:
7987:
7988: \message{macros,}
7989: % @macro.
7990:
7991: % To do this right we need a feature of e-TeX, \scantokens,
7992: % which we arrange to emulate with a temporary file in ordinary TeX.
7993: \ifx\eTeXversion\thisisundefined
7994: \newwrite\macscribble
7995: \def\scantokens#1{%
7996: \toks0={#1}%
7997: \immediate\openout\macscribble=\jobname.tmp
7998: \immediate\write\macscribble{\the\toks0}%
7999: \immediate\closeout\macscribble
8000: \input \jobname.tmp
8001: }
8002: \fi
8003:
8004: % Used at the time of macro expansion.
8005: % Argument is macro body with arguments substituted
8006: \def\scanmacro#1{%
8007: \newlinechar`\^^M
1.5 ! snw 8008: \def\xeatspaces{\eatspaces}%
1.1 snw 8009: %
8010: % Process the macro body under the current catcode regime.
8011: \scantokens{#1@comment}%
8012: %
8013: % The \comment is to remove the \newlinechar added by \scantokens, and
8014: % can be noticed by \parsearg. Note \c isn't used because this means cedilla
8015: % in math mode.
8016: }
8017:
8018: % Used for copying and captions
8019: \def\scanexp#1{%
8020: \expandafter\scanmacro\expandafter{#1}%
8021: }
8022:
8023: \newcount\paramno % Count of parameters
8024: \newtoks\macname % Macro name
8025: \newif\ifrecursive % Is it recursive?
8026:
8027: % List of all defined macros in the form
8028: % \commondummyword\macro1\commondummyword\macro2...
8029: % Currently is also contains all @aliases; the list can be split
8030: % if there is a need.
8031: \def\macrolist{}
8032:
8033: % Add the macro to \macrolist
8034: \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8035: \def\addtomacrolistxxx#1{%
8036: \toks0 = \expandafter{\macrolist\commondummyword#1}%
8037: \xdef\macrolist{\the\toks0}%
8038: }
8039:
8040: % Utility routines.
8041: % This does \let #1 = #2, with \csnames; that is,
8042: % \let \csname#1\endcsname = \csname#2\endcsname
8043: % (except of course we have to play expansion games).
8044: %
8045: \def\cslet#1#2{%
8046: \expandafter\let
8047: \csname#1\expandafter\endcsname
8048: \csname#2\endcsname
8049: }
8050:
8051: % Trim leading and trailing spaces off a string.
8052: % Concepts from aro-bend problem 15 (see CTAN).
8053: {\catcode`\@=11
8054: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8055: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8056: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8057: \def\unbrace#1{#1}
8058: \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8059: }
8060:
8061: % Trim a single trailing ^^M off a string.
8062: {\catcode`\^^M=\other \catcode`\Q=3%
8063: \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8064: \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8065: \gdef\eatcrb#1Q#2Q{#1}%
8066: }
8067:
8068: % Macro bodies are absorbed as an argument in a context where
8069: % all characters are catcode 10, 11 or 12, except \ which is active
8070: % (as in normal texinfo). It is necessary to change the definition of \
8071: % to recognize macro arguments; this is the job of \mbodybackslash.
8072: %
8073: % Non-ASCII encodings make 8-bit characters active, so un-activate
8074: % them to avoid their expansion. Must do this non-globally, to
8075: % confine the change to the current group.
8076: %
8077: % It's necessary to have hard CRs when the macro is executed. This is
8078: % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8079: % body, and then making it the \newlinechar in \scanmacro.
8080: %
8081: \def\scanctxt{% used as subroutine
8082: \catcode`\"=\other
8083: \catcode`\+=\other
8084: \catcode`\<=\other
8085: \catcode`\>=\other
8086: \catcode`\^=\other
8087: \catcode`\_=\other
8088: \catcode`\|=\other
8089: \catcode`\~=\other
1.5 ! snw 8090: \passthroughcharstrue
! 8091: }
! 8092:
! 8093: \def\scanargctxt{% used for copying and captions, not macros.
! 8094: \scanctxt
1.1 snw 8095: \catcode`\@=\other
1.5 ! snw 8096: \catcode`\\=\other
1.1 snw 8097: \catcode`\^^M=\other
8098: }
8099:
1.5 ! snw 8100: \def\macrobodyctxt{% used for @macro definitions
1.1 snw 8101: \scanctxt
8102: \catcode`\ =\other
1.5 ! snw 8103: \catcode`\@=\other
1.1 snw 8104: \catcode`\{=\other
8105: \catcode`\}=\other
1.5 ! snw 8106: \catcode`\^^M=\other
! 8107: \usembodybackslash
1.1 snw 8108: }
8109:
8110: % Used when scanning braced macro arguments. Note, however, that catcode
8111: % changes here are ineffectual if the macro invocation was nested inside
8112: % an argument to another Texinfo command.
8113: \def\macroargctxt{%
8114: \scanctxt
8115: \catcode`\ =\active
1.5 ! snw 8116: \catcode`\@=\other
! 8117: \catcode`\^^M=\other
! 8118: \catcode`\\=\active
1.1 snw 8119: }
8120:
8121: \def\macrolineargctxt{% used for whole-line arguments without braces
8122: \scanctxt
1.5 ! snw 8123: \catcode`\@=\other
1.1 snw 8124: \catcode`\{=\other
8125: \catcode`\}=\other
8126: }
8127:
8128: % \mbodybackslash is the definition of \ in @macro bodies.
8129: % It maps \foo\ => \csname macarg.foo\endcsname => #N
8130: % where N is the macro parameter number.
8131: % We define \csname macarg.\endcsname to be \realbackslash, so
8132: % \\ in macro replacement text gets you a backslash.
8133: %
8134: {\catcode`@=0 @catcode`@\=@active
8135: @gdef@usembodybackslash{@let\=@mbodybackslash}
8136: @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8137: }
8138: \expandafter\def\csname macarg.\endcsname{\realbackslash}
8139:
8140: \def\margbackslash#1{\char`\#1 }
8141:
8142: \def\macro{\recursivefalse\parsearg\macroxxx}
8143: \def\rmacro{\recursivetrue\parsearg\macroxxx}
8144:
8145: \def\macroxxx#1{%
8146: \getargs{#1}% now \macname is the macname and \argl the arglist
8147: \ifx\argl\empty % no arguments
8148: \paramno=0\relax
8149: \else
8150: \expandafter\parsemargdef \argl;%
8151: \if\paramno>256\relax
8152: \ifx\eTeXversion\thisisundefined
8153: \errhelp = \EMsimple
8154: \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8155: \fi
8156: \fi
8157: \fi
8158: \if1\csname ismacro.\the\macname\endcsname
8159: \message{Warning: redefining \the\macname}%
8160: \else
8161: \expandafter\ifx\csname \the\macname\endcsname \relax
8162: \else \errmessage{Macro name \the\macname\space already defined}\fi
8163: \global\cslet{macsave.\the\macname}{\the\macname}%
8164: \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8165: \addtomacrolist{\the\macname}%
8166: \fi
1.5 ! snw 8167: \begingroup \macrobodyctxt
1.1 snw 8168: \ifrecursive \expandafter\parsermacbody
8169: \else \expandafter\parsemacbody
8170: \fi}
8171:
8172: \parseargdef\unmacro{%
8173: \if1\csname ismacro.#1\endcsname
8174: \global\cslet{#1}{macsave.#1}%
8175: \global\expandafter\let \csname ismacro.#1\endcsname=0%
8176: % Remove the macro name from \macrolist:
8177: \begingroup
8178: \expandafter\let\csname#1\endcsname \relax
8179: \let\commondummyword\unmacrodo
8180: \xdef\macrolist{\macrolist}%
8181: \endgroup
1.5 ! snw 8182: \else
! 8183: \errmessage{Macro #1 not defined}%
1.1 snw 8184: \fi
8185: }
8186:
8187: % Called by \do from \dounmacro on each macro. The idea is to omit any
8188: % macro definitions that have been changed to \relax.
8189: %
8190: \def\unmacrodo#1{%
8191: \ifx #1\relax
8192: % remove this
8193: \else
8194: \noexpand\commondummyword \noexpand#1%
8195: \fi
8196: }
8197:
8198: % \getargs -- Parse the arguments to a @macro line. Set \macname to
8199: % the name of the macro, and \argl to the braced argument list.
8200: \def\getargs#1{\getargsxxx#1{}}
8201: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8202: \def\getmacname#1 #2\relax{\macname={#1}}
8203: \def\getmacargs#1{\def\argl{#1}}
8204: % This made use of the feature that if the last token of a
8205: % <parameter list> is #, then the preceding argument is delimited by
8206: % an opening brace, and that opening brace is not consumed.
8207:
8208: % Parse the optional {params} list to @macro or @rmacro.
8209: % Set \paramno to the number of arguments,
8210: % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8211: % three-param macro.) Define \macarg.BLAH for each BLAH in the params
8212: % list to some hook where the argument is to be expanded. If there are
8213: % less than 10 arguments that hook is to be replaced by ##N where N
8214: % is the position in that list, that is to say the macro arguments are to be
8215: % defined `a la TeX in the macro body.
8216: %
8217: % That gets used by \mbodybackslash (above).
8218: %
8219: % If there are 10 or more arguments, a different technique is used: see
8220: % \parsemmanyargdef.
8221: %
8222: \def\parsemargdef#1;{%
8223: \paramno=0\def\paramlist{}%
8224: \let\hash\relax
8225: % \hash is redefined to `#' later to get it into definitions
8226: \let\xeatspaces\relax
8227: \parsemargdefxxx#1,;,%
8228: \ifnum\paramno<10\relax\else
8229: \paramno0\relax
8230: \parsemmanyargdef@@#1,;,% 10 or more arguments
8231: \fi
8232: }
8233: \def\parsemargdefxxx#1,{%
8234: \if#1;\let\next=\relax
8235: \else \let\next=\parsemargdefxxx
8236: \advance\paramno by 1
8237: \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
1.5 ! snw 8238: {\xeatspaces{\hash\the\paramno}}%
1.1 snw 8239: \edef\paramlist{\paramlist\hash\the\paramno,}%
8240: \fi\next}
8241:
8242: % \parsemacbody, \parsermacbody
8243: %
8244: % Read recursive and nonrecursive macro bodies. (They're different since
8245: % rec and nonrec macros end differently.)
8246: %
1.5 ! snw 8247: % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
1.1 snw 8248: % body to be transformed.
1.5 ! snw 8249: % Set \macrobody to the body of the macro, and call \defmacro.
1.1 snw 8250: %
8251: {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
1.5 ! snw 8252: \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
1.1 snw 8253: {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
1.5 ! snw 8254: \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
1.1 snw 8255:
8256: % Make @ a letter, so that we can make private-to-Texinfo macro names.
8257: \edef\texiatcatcode{\the\catcode`\@}
8258: \catcode `@=11\relax
8259:
8260: %%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%%
8261:
8262: % If there are 10 or more arguments, a different technique is used, where the
8263: % hook remains in the body, and when macro is to be expanded the body is
8264: % processed again to replace the arguments.
8265: %
8266: % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8267: % argument N value and then \edef the body (nothing else will expand because of
8268: % the catcode regime under which the body was input).
8269: %
8270: % If you compile with TeX (not eTeX), and you have macros with 10 or more
8271: % arguments, no macro can have more than 256 arguments (else error).
8272: %
8273: % In case that there are 10 or more arguments we parse again the arguments
8274: % list to set new definitions for the \macarg.BLAH macros corresponding to
8275: % each BLAH argument. It was anyhow needed to parse already once this list
8276: % in order to count the arguments, and as macros with at most 9 arguments
8277: % are by far more frequent than macro with 10 or more arguments, defining
8278: % twice the \macarg.BLAH macros does not cost too much processing power.
8279: \def\parsemmanyargdef@@#1,{%
8280: \if#1;\let\next=\relax
8281: \else
8282: \let\next=\parsemmanyargdef@@
8283: \edef\tempb{\eatspaces{#1}}%
8284: \expandafter\def\expandafter\tempa
8285: \expandafter{\csname macarg.\tempb\endcsname}%
8286: % Note that we need some extra \noexpand\noexpand, this is because we
8287: % don't want \the to be expanded in the \parsermacbody as it uses an
8288: % \xdef .
8289: \expandafter\edef\tempa
8290: {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8291: \advance\paramno by 1\relax
8292: \fi\next}
8293:
8294:
8295: \let\endargs@\relax
8296: \let\nil@\relax
8297: \def\nilm@{\nil@}%
8298: \long\def\nillm@{\nil@}%
8299:
8300: % This macro is expanded during the Texinfo macro expansion, not during its
8301: % definition. It gets all the arguments' values and assigns them to macros
8302: % macarg.ARGNAME
8303: %
8304: % #1 is the macro name
8305: % #2 is the list of argument names
8306: % #3 is the list of argument values
8307: \def\getargvals@#1#2#3{%
8308: \def\macargdeflist@{}%
8309: \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8310: \def\paramlist{#2,\nil@}%
8311: \def\macroname{#1}%
8312: \begingroup
8313: \macroargctxt
8314: \def\argvaluelist{#3,\nil@}%
8315: \def\@tempa{#3}%
8316: \ifx\@tempa\empty
8317: \setemptyargvalues@
8318: \else
8319: \getargvals@@
8320: \fi
8321: }
8322: \def\getargvals@@{%
8323: \ifx\paramlist\nilm@
8324: % Some sanity check needed here that \argvaluelist is also empty.
8325: \ifx\argvaluelist\nillm@
8326: \else
8327: \errhelp = \EMsimple
8328: \errmessage{Too many arguments in macro `\macroname'!}%
8329: \fi
8330: \let\next\macargexpandinbody@
8331: \else
8332: \ifx\argvaluelist\nillm@
8333: % No more arguments values passed to macro. Set remaining named-arg
8334: % macros to empty.
8335: \let\next\setemptyargvalues@
8336: \else
8337: % pop current arg name into \@tempb
8338: \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8339: \expandafter\@tempa\expandafter{\paramlist}%
8340: % pop current argument value into \@tempc
8341: \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8342: \expandafter\@tempa\expandafter{\argvaluelist}%
8343: % Here \@tempb is the current arg name and \@tempc is the current arg value.
8344: % First place the new argument macro definition into \@tempd
8345: \expandafter\macname\expandafter{\@tempc}%
8346: \expandafter\let\csname macarg.\@tempb\endcsname\relax
8347: \expandafter\def\expandafter\@tempe\expandafter{%
8348: \csname macarg.\@tempb\endcsname}%
8349: \edef\@tempd{\long\def\@tempe{\the\macname}}%
8350: \push@\@tempd\macargdeflist@
8351: \let\next\getargvals@@
8352: \fi
8353: \fi
8354: \next
8355: }
8356:
8357: \def\push@#1#2{%
8358: \expandafter\expandafter\expandafter\def
8359: \expandafter\expandafter\expandafter#2%
8360: \expandafter\expandafter\expandafter{%
8361: \expandafter#1#2}%
8362: }
8363:
8364: % Replace arguments by their values in the macro body, and place the result
8365: % in macro \@tempa.
8366: %
8367: \def\macvalstoargs@{%
8368: % To do this we use the property that token registers that are \the'ed
8369: % within an \edef expand only once. So we are going to place all argument
8370: % values into respective token registers.
8371: %
8372: % First we save the token context, and initialize argument numbering.
8373: \begingroup
8374: \paramno0\relax
8375: % Then, for each argument number #N, we place the corresponding argument
8376: % value into a new token list register \toks#N
8377: \expandafter\putargsintokens@\saveparamlist@,;,%
8378: % Then, we expand the body so that argument are replaced by their
8379: % values. The trick for values not to be expanded themselves is that they
8380: % are within tokens and that tokens expand only once in an \edef .
8381: \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8382: % Now we restore the token stack pointer to free the token list registers
8383: % which we have used, but we make sure that expanded body is saved after
8384: % group.
8385: \expandafter
8386: \endgroup
8387: \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8388: }
8389:
8390: % Define the named-macro outside of this group and then close this group.
8391: %
8392: \def\macargexpandinbody@{%
8393: \expandafter
8394: \endgroup
8395: \macargdeflist@
8396: % First the replace in body the macro arguments by their values, the result
8397: % is in \@tempa .
8398: \macvalstoargs@
8399: % Then we point at the \norecurse or \gobble (for recursive) macro value
8400: % with \@tempb .
8401: \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8402: % Depending on whether it is recursive or not, we need some tailing
8403: % \egroup .
8404: \ifx\@tempb\gobble
8405: \let\@tempc\relax
8406: \else
8407: \let\@tempc\egroup
8408: \fi
8409: % And now we do the real job:
8410: \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8411: \@tempd
8412: }
8413:
8414: \def\putargsintokens@#1,{%
8415: \if#1;\let\next\relax
8416: \else
8417: \let\next\putargsintokens@
8418: % First we allocate the new token list register, and give it a temporary
8419: % alias \@tempb .
8420: \toksdef\@tempb\the\paramno
8421: % Then we place the argument value into that token list register.
8422: \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8423: \expandafter\@tempb\expandafter{\@tempa}%
8424: \advance\paramno by 1\relax
8425: \fi
8426: \next
8427: }
8428:
8429: % Trailing missing arguments are set to empty.
8430: %
8431: \def\setemptyargvalues@{%
8432: \ifx\paramlist\nilm@
8433: \let\next\macargexpandinbody@
8434: \else
8435: \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8436: \let\next\setemptyargvalues@
8437: \fi
8438: \next
8439: }
8440:
8441: \def\setemptyargvaluesparser@#1,#2\endargs@{%
8442: \expandafter\def\expandafter\@tempa\expandafter{%
8443: \expandafter\def\csname macarg.#1\endcsname{}}%
8444: \push@\@tempa\macargdeflist@
8445: \def\paramlist{#2}%
8446: }
8447:
8448: % #1 is the element target macro
8449: % #2 is the list macro
8450: % #3,#4\endargs@ is the list value
8451: \def\pop@#1#2#3,#4\endargs@{%
8452: \def#1{#3}%
8453: \def#2{#4}%
8454: }
8455: \long\def\longpop@#1#2#3,#4\endargs@{%
8456: \long\def#1{#3}%
8457: \long\def#2{#4}%
8458: }
8459:
8460:
8461: %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8462:
8463:
8464: % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8465: % \macrobody has the body of the macro in it, with placeholders for
8466: % its parameters, looking like "\xeatspaces{\hash 1}".
8467: % \paramno is the number of parameters
8468: % \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8469: % There are four cases: macros of zero, one, up to nine, and many arguments.
8470: % \xdef is used so that macro definitions will survive the file
8471: % they're defined in: @include reads the file inside a group.
8472: %
1.5 ! snw 8473: \def\defmacro{%
1.1 snw 8474: \let\hash=##% convert placeholders to macro parameter chars
8475: \ifnum\paramno=1
1.5 ! snw 8476: \def\xeatspaces##1{##1}%
! 8477: % This removes the pair of braces around the argument. We don't
! 8478: % use \eatspaces, because this can cause ends of lines to be lost
! 8479: % when the argument to \eatspaces is read, leading to line-based
! 8480: % commands like "@itemize" not being read correctly.
! 8481: \else
! 8482: \let\xeatspaces\relax % suppress expansion
1.1 snw 8483: \fi
8484: \ifcase\paramno
8485: % 0
8486: \expandafter\xdef\csname\the\macname\endcsname{%
1.5 ! snw 8487: \bgroup
1.1 snw 8488: \noexpand\spaceisspace
8489: \noexpand\endlineisspace
8490: \noexpand\expandafter % skip any whitespace after the macro name.
8491: \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8492: \expandafter\xdef\csname\the\macname @@@\endcsname{%
1.5 ! snw 8493: \egroup
1.1 snw 8494: \noexpand\scanmacro{\macrobody}}%
8495: \or % 1
8496: \expandafter\xdef\csname\the\macname\endcsname{%
1.5 ! snw 8497: \bgroup
1.1 snw 8498: \noexpand\braceorline
8499: \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8500: \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
1.5 ! snw 8501: \egroup
1.1 snw 8502: \noexpand\scanmacro{\macrobody}%
8503: }%
8504: \else % at most 9
8505: \ifnum\paramno<10\relax
8506: % @MACNAME sets the context for reading the macro argument
8507: % @MACNAME@@ gets the argument, processes backslashes and appends a
8508: % comma.
8509: % @MACNAME@@@ removes braces surrounding the argument list.
8510: % @MACNAME@@@@ scans the macro body with arguments substituted.
8511: \expandafter\xdef\csname\the\macname\endcsname{%
1.5 ! snw 8512: \bgroup
1.1 snw 8513: \noexpand\expandafter % This \expandafter skip any spaces after the
8514: \noexpand\macroargctxt % macro before we change the catcode of space.
8515: \noexpand\expandafter
8516: \expandafter\noexpand\csname\the\macname @@\endcsname}%
8517: \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8518: \noexpand\passargtomacro
8519: \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8520: \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8521: \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8522: \expandafter\expandafter
8523: \expandafter\xdef
8524: \expandafter\expandafter
8525: \csname\the\macname @@@@\endcsname\paramlist{%
1.5 ! snw 8526: \egroup\noexpand\scanmacro{\macrobody}}%
1.1 snw 8527: \else % 10 or more:
8528: \expandafter\xdef\csname\the\macname\endcsname{%
8529: \noexpand\getargvals@{\the\macname}{\argl}%
8530: }%
8531: \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8532: \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8533: \fi
8534: \fi}
8535:
8536: \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8537:
8538: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8539:
8540:
8541: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8542: %
8543: {\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape
8544: @catcode`@_=11 % private names
8545: @catcode`@!=11 % used as argument separator
8546:
8547: % \passargtomacro#1#2 -
8548: % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8549: % compressed to one.
8550: %
8551: % This implementation works by expansion, and not execution (so we cannot use
8552: % \def or similar). This reduces the risk of this failing in contexts where
8553: % complete expansion is done with no execution (for example, in writing out to
8554: % an auxiliary file for an index entry).
8555: %
8556: % State is kept in the input stream: the argument passed to
8557: % @look_ahead, @gobble_and_check_finish and @add_segment is
8558: %
8559: % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input)
8560: %
8561: % where:
8562: % THE_MACRO - name of the macro we want to call
8563: % ARG_RESULT - argument list we build to pass to that macro
8564: % PENDING_BS - either a backslash or nothing
8565: % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8566:
8567: @gdef@passargtomacro#1#2{%
8568: @add_segment #1!{}@relax#2\@_finish\%
8569: }
8570: @gdef@_finish{@_finishx} @global@let@_finishx@relax
8571:
8572: % #1 - THE_MACRO ARG_RESULT
8573: % #2 - PENDING_BS
8574: % #3 - NEXT_TOKEN
8575: % #4 used to look ahead
8576: %
8577: % If the next token is not a backslash, process the rest of the argument;
8578: % otherwise, remove the next token.
8579: @gdef@look_ahead#1!#2#3#4{%
8580: @ifx#4\%
8581: @expandafter@gobble_and_check_finish
8582: @else
8583: @expandafter@add_segment
8584: @fi#1!{#2}#4#4%
8585: }
8586:
8587: % #1 - THE_MACRO ARG_RESULT
8588: % #2 - PENDING_BS
8589: % #3 - NEXT_TOKEN
8590: % #4 should be a backslash, which is gobbled.
8591: % #5 looks ahead
8592: %
8593: % Double backslash found. Add a single backslash, and look ahead.
8594: @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8595: @add_segment#1\!{}#5#5%
8596: }
8597:
8598: @gdef@is_fi{@fi}
8599:
8600: % #1 - THE_MACRO ARG_RESULT
8601: % #2 - PENDING_BS
8602: % #3 - NEXT_TOKEN
8603: % #4 is input stream until next backslash
8604: %
8605: % Input stream is either at the start of the argument, or just after a
8606: % backslash sequence, either a lone backslash, or a doubled backslash.
8607: % NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8608: % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8609: % the next backslash. PENDING_BACKSLASH contains a backslash to represent
8610: % a backslash just before the start of the input stream that has not been
8611: % added to ARG_RESULT.
8612: @gdef@add_segment#1!#2#3#4\{%
8613: @ifx#3@_finish
8614: @call_the_macro#1!%
8615: @else
8616: % append the pending backslash to the result, followed by the next segment
8617: @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8618: % this @fi is discarded by @look_ahead.
8619: % we can't get rid of it with \expandafter because we don't know how
8620: % long #4 is.
8621: }
8622:
8623: % #1 - THE_MACRO
8624: % #2 - ARG_RESULT
8625: % #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8626: % conditional.
8627: @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8628:
8629: }
8630: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8631:
8632: % \braceorline MAC is used for a one-argument macro MAC. It checks
8633: % whether the next non-whitespace character is a {. It sets the context
8634: % for reading the argument (slightly different in the two cases). Then,
8635: % to read the argument, in the whole-line case, it then calls the regular
8636: % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8637: %
8638: \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8639: \def\braceorlinexxx{%
8640: \ifx\nchar\bgroup
8641: \macroargctxt
8642: \expandafter\passargtomacro
8643: \else
8644: \macrolineargctxt\expandafter\parsearg
8645: \fi \macnamexxx}
8646:
8647:
8648: % @alias.
8649: % We need some trickery to remove the optional spaces around the equal
8650: % sign. Make them active and then expand them all to nothing.
8651: %
8652: \def\alias{\parseargusing\obeyspaces\aliasxxx}
8653: \def\aliasxxx #1{\aliasyyy#1\relax}
8654: \def\aliasyyy #1=#2\relax{%
8655: {%
8656: \expandafter\let\obeyedspace=\empty
8657: \addtomacrolist{#1}%
8658: \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8659: }%
8660: \next
8661: }
8662:
8663:
8664: \message{cross references,}
8665:
8666: \newwrite\auxfile
8667: \newif\ifhavexrefs % True if xref values are known.
8668: \newif\ifwarnedxrefs % True if we warned once that they aren't known.
8669:
8670: % @inforef is relatively simple.
8671: \def\inforef #1{\inforefzzz #1,,,,**}
8672: \def\inforefzzz #1,#2,#3,#4**{%
8673: \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8674: node \samp{\ignorespaces#1{}}}
8675:
8676: % @node's only job in TeX is to define \lastnode, which is used in
8677: % cross-references. The @node line might or might not have commas, and
8678: % might or might not have spaces before the first comma, like:
8679: % @node foo , bar , ...
8680: % We don't want such trailing spaces in the node name.
8681: %
8682: \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8683: %
8684: % also remove a trailing comma, in case of something like this:
8685: % @node Help-Cross, , , Cross-refs
8686: \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8687: \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
8688:
8689: % Used so that the @top node doesn't have to be wrapped in an @ifnottex
8690: % conditional.
8691: % \doignore goes to more effort to skip nested conditionals but we don't need
8692: % that here.
8693: \def\omittopnode{%
8694: \ifx\lastnode\wordTop
8695: \expandafter\ignorenode\fi
8696: }
8697: \def\wordTop{Top}
8698:
1.5 ! snw 8699: % Until the next @node or @bye command, divert output to a box that is not
! 8700: % output.
! 8701: \def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
1.1 snw 8702: \ignorenodebye
8703: }
8704:
8705: {\let\bye\relax
8706: \gdef\ignorenodebye{\let\bye\ignorenodebyedef}
8707: \gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
8708: % The redefinition of \bye here is because it is declared \outer
8709:
8710: \let\lastnode=\empty
8711:
8712: % Write a cross-reference definition for the current node. #1 is the
8713: % type (Ynumbered, Yappendix, Ynothing).
8714: %
8715: \def\donoderef#1{%
8716: \ifx\lastnode\empty\else
8717: \setref{\lastnode}{#1}%
8718: \global\let\lastnode=\empty
8719: \fi
8720: }
8721:
8722: % @anchor{NAME} -- define xref target at arbitrary point.
8723: %
8724: \newcount\savesfregister
8725: %
8726: \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8727: \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8728: \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8729:
8730: % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8731: % anchor), which consists of three parts:
8732: % 1) NAME-title - the current sectioning name taken from \currentsection,
8733: % or the anchor name.
8734: % 2) NAME-snt - section number and type, passed as the SNT arg, or
8735: % empty for anchors.
8736: % 3) NAME-pg - the page number.
8737: %
8738: % This is called from \donoderef, \anchor, and \dofloat. In the case of
8739: % floats, there is an additional part, which is not written here:
8740: % 4) NAME-lof - the text as it should appear in a @listoffloats.
8741: %
8742: \def\setref#1#2{%
8743: \pdfmkdest{#1}%
8744: \iflinks
8745: {%
8746: \requireauxfile
8747: \atdummies % preserve commands, but don't expand them
8748: % match definition in \xrdef, \refx, \xrefX.
8749: \def\value##1{##1}%
8750: \edef\writexrdef##1##2{%
8751: \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8752: ##1}{##2}}% these are parameters of \writexrdef
8753: }%
8754: \toks0 = \expandafter{\currentsection}%
8755: \immediate \writexrdef{title}{\the\toks0 }%
8756: \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8757: \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8758: }%
8759: \fi
8760: }
8761:
8762: % @xrefautosectiontitle on|off says whether @section(ing) names are used
8763: % automatically in xrefs, if the third arg is not explicitly specified.
8764: % This was provided as a "secret" @set xref-automatic-section-title
8765: % variable, now it's official.
8766: %
8767: \parseargdef\xrefautomaticsectiontitle{%
8768: \def\temp{#1}%
8769: \ifx\temp\onword
8770: \expandafter\let\csname SETxref-automatic-section-title\endcsname
8771: = \empty
8772: \else\ifx\temp\offword
8773: \expandafter\let\csname SETxref-automatic-section-title\endcsname
8774: = \relax
8775: \else
8776: \errhelp = \EMsimple
8777: \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8778: must be on|off}%
8779: \fi\fi
8780: }
8781:
8782: %
8783: % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
8784: % the node name, #2 the name of the Info cross-reference, #3 the printed
8785: % node name, #4 the name of the Info file, #5 the name of the printed
8786: % manual. All but the node name can be omitted.
8787: %
8788: \def\pxref{\putwordsee{} \xrefXX}
8789: \def\xref{\putwordSee{} \xrefXX}
8790: \def\ref{\xrefXX}
8791:
8792: \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8793: \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8794: %
8795: \newbox\toprefbox
8796: \newbox\printedrefnamebox
8797: \newbox\infofilenamebox
8798: \newbox\printedmanualbox
8799: %
8800: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8801: \unsepspaces
8802: %
1.5 ! snw 8803: % Get args without leading/trailing spaces.
! 8804: \def\printedrefname{\ignorespaces #3}%
! 8805: \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
! 8806: %
1.1 snw 8807: \def\infofilename{\ignorespaces #4}%
8808: \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8809: %
1.5 ! snw 8810: \def\printedmanual{\ignorespaces #5}%
! 8811: \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
1.1 snw 8812: %
1.5 ! snw 8813: % If the printed reference name (arg #3) was not explicitly given in
! 8814: % the @xref, figure out what we want to use.
! 8815: \ifdim \wd\printedrefnamebox = 0pt
! 8816: % No printed node name was explicitly given.
! 8817: \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
! 8818: % Not auto section-title: use node name inside the square brackets.
! 8819: \def\printedrefname{\ignorespaces #1}%
1.1 snw 8820: \else
1.5 ! snw 8821: % Auto section-title: use chapter/section title inside
! 8822: % the square brackets if we have it.
! 8823: \ifdim \wd\printedmanualbox > 0pt
! 8824: % It is in another manual, so we don't have it; use node name.
! 8825: \def\printedrefname{\ignorespaces #1}%
! 8826: \else
! 8827: \ifhavexrefs
! 8828: % We (should) know the real title if we have the xref values.
! 8829: \def\printedrefname{\refx{#1-title}{}}%
! 8830: \else
! 8831: % Otherwise just copy the Info node name.
! 8832: \def\printedrefname{\ignorespaces #1}%
! 8833: \fi%
! 8834: \fi
! 8835: \fi
! 8836: \fi
! 8837: %
! 8838: % Make link in pdf output.
! 8839: \ifpdf
! 8840: % For pdfTeX and LuaTeX
! 8841: {\indexnofonts
! 8842: \makevalueexpandable
! 8843: \turnoffactive
! 8844: % This expands tokens, so do it after making catcode changes, so _
! 8845: % etc. don't get their TeX definitions. This ignores all spaces in
! 8846: % #4, including (wrongly) those in the middle of the filename.
! 8847: \getfilename{#4}%
! 8848: %
! 8849: % This (wrongly) does not take account of leading or trailing
! 8850: % spaces in #1, which should be ignored.
! 8851: \setpdfdestname{#1}%
! 8852: %
! 8853: \ifx\pdfdestname\empty
! 8854: \def\pdfdestname{Top}% no empty targets
! 8855: \fi
! 8856: %
! 8857: \leavevmode
! 8858: \startlink attr{/Border [0 0 0]}%
! 8859: \ifnum\filenamelength>0
! 8860: goto file{\the\filename.pdf} name{\pdfdestname}%
! 8861: \else
! 8862: goto name{\pdfmkpgn{\pdfdestname}}%
! 8863: \fi
! 8864: }%
! 8865: \setcolor{\linkcolor}%
! 8866: \else
! 8867: \ifx\XeTeXrevision\thisisundefined
! 8868: \else
! 8869: % For XeTeX
! 8870: {\indexnofonts
! 8871: \makevalueexpandable
! 8872: \turnoffactive
! 8873: % This expands tokens, so do it after making catcode changes, so _
! 8874: % etc. don't get their TeX definitions. This ignores all spaces in
! 8875: % #4, including (wrongly) those in the middle of the filename.
! 8876: \getfilename{#4}%
! 8877: %
! 8878: % This (wrongly) does not take account of leading or trailing
! 8879: % spaces in #1, which should be ignored.
! 8880: \setpdfdestname{#1}%
! 8881: %
! 8882: \ifx\pdfdestname\empty
! 8883: \def\pdfdestname{Top}% no empty targets
! 8884: \fi
! 8885: %
! 8886: \leavevmode
! 8887: \ifnum\filenamelength>0
! 8888: % With default settings,
! 8889: % XeTeX (xdvipdfmx) replaces link destination names with integers.
! 8890: % In this case, the replaced destination names of
! 8891: % remote PDFs are no longer known. In order to avoid a replacement,
! 8892: % you can use xdvipdfmx's command line option `-C 0x0010'.
! 8893: % If you use XeTeX 0.99996+ (TeX Live 2016+),
! 8894: % this command line option is no longer necessary
! 8895: % because we can use the `dvipdfmx:config' special.
! 8896: \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
! 8897: << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
! 8898: \else
! 8899: \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
! 8900: << /S /GoTo /D (\pdfdestname) >> >>}%
! 8901: \fi
! 8902: }%
! 8903: \setcolor{\linkcolor}%
! 8904: \fi
! 8905: \fi
! 8906: {%
! 8907: % Have to otherify everything special to allow the \csname to
! 8908: % include an _ in the xref name, etc.
! 8909: \indexnofonts
! 8910: \turnoffactive
! 8911: \def\value##1{##1}%
! 8912: \expandafter\global\expandafter\let\expandafter\Xthisreftitle
! 8913: \csname XR#1-title\endcsname
! 8914: }%
! 8915: %
! 8916: % Float references are printed completely differently: "Figure 1.2"
! 8917: % instead of "[somenode], p.3". \iffloat distinguishes them by
! 8918: % \Xthisreftitle being set to a magic string.
! 8919: \iffloat\Xthisreftitle
! 8920: % If the user specified the print name (third arg) to the ref,
! 8921: % print it instead of our usual "Figure 1.2".
! 8922: \ifdim\wd\printedrefnamebox = 0pt
! 8923: \refx{#1-snt}{}%
! 8924: \else
! 8925: \printedrefname
1.1 snw 8926: \fi
8927: %
8928: % If the user also gave the printed manual name (fifth arg), append
8929: % "in MANUALNAME".
8930: \ifdim \wd\printedmanualbox > 0pt
8931: \space \putwordin{} \cite{\printedmanual}%
8932: \fi
8933: \else
8934: % node/anchor (non-float) references.
8935: %
8936: % If we use \unhbox to print the node names, TeX does not insert
8937: % empty discretionaries after hyphens, which means that it will not
8938: % find a line break at a hyphen in a node names. Since some manuals
8939: % are best written with fairly long node names, containing hyphens,
8940: % this is a loss. Therefore, we give the text of the node name
8941: % again, so it is as if TeX is seeing it for the first time.
8942: %
8943: \ifdim \wd\printedmanualbox > 0pt
8944: % Cross-manual reference with a printed manual name.
8945: %
8946: \crossmanualxref{\cite{\printedmanual\unskip}}%
8947: %
8948: \else\ifdim \wd\infofilenamebox > 0pt
8949: % Cross-manual reference with only an info filename (arg 4), no
8950: % printed manual name (arg 5). This is essentially the same as
8951: % the case above; we output the filename, since we have nothing else.
8952: %
8953: \crossmanualxref{\code{\infofilename\unskip}}%
8954: %
8955: \else
8956: % Reference within this manual.
8957: %
1.5 ! snw 8958: % Only output a following space if the -snt ref is nonempty; for
! 8959: % @unnumbered and @anchor, it won't be.
! 8960: \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
1.1 snw 8961: \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8962: %
8963: % output the `[mynode]' via the macro below so it can be overridden.
8964: \xrefprintnodename\printedrefname
8965: %
1.5 ! snw 8966: % But we always want a comma and a space:
! 8967: ,\space
! 8968: %
! 8969: % output the `page 3'.
! 8970: \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
! 8971: % Add a , if xref followed by a space
! 8972: \if\space\noexpand\tokenafterxref ,%
! 8973: \else\ifx\ \tokenafterxref ,% @TAB
! 8974: \else\ifx\*\tokenafterxref ,% @*
! 8975: \else\ifx\ \tokenafterxref ,% @SPACE
! 8976: \else\ifx\
! 8977: \tokenafterxref ,% @NL
! 8978: \else\ifx\tie\tokenafterxref ,% @tie
! 8979: \fi\fi\fi\fi\fi\fi
1.1 snw 8980: \fi\fi
8981: \fi
8982: \endlink
8983: \endgroup}
8984:
8985: % Output a cross-manual xref to #1. Used just above (twice).
8986: %
8987: % Only include the text "Section ``foo'' in" if the foo is neither
8988: % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
8989: % "see The Foo Manual", the idea being to refer to the whole manual.
8990: %
8991: % But, this being TeX, we can't easily compare our node name against the
8992: % string "Top" while ignoring the possible spaces before and after in
8993: % the input. By adding the arbitrary 7sp below, we make it much less
8994: % likely that a real node name would have the same width as "Top" (e.g.,
8995: % in a monospaced font). Hopefully it will never happen in practice.
8996: %
8997: % For the same basic reason, we retypeset the "Top" at every
8998: % reference, since the current font is indeterminate.
8999: %
9000: \def\crossmanualxref#1{%
9001: \setbox\toprefbox = \hbox{Top\kern7sp}%
9002: \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9003: \ifdim \wd2 > 7sp % nonempty?
9004: \ifdim \wd2 = \wd\toprefbox \else % same as Top?
9005: \putwordSection{} ``\printedrefname'' \putwordin{}\space
9006: \fi
9007: \fi
9008: #1%
9009: }
9010:
9011: % This macro is called from \xrefX for the `[nodename]' part of xref
9012: % output. It's a separate macro only so it can be changed more easily,
9013: % since square brackets don't work well in some documents. Particularly
9014: % one that Bob is working on :).
9015: %
9016: \def\xrefprintnodename#1{[#1]}
9017:
9018: % Things referred to by \setref.
9019: %
9020: \def\Ynothing{}
9021: \def\Yomitfromtoc{}
9022: \def\Ynumbered{%
9023: \ifnum\secno=0
9024: \putwordChapter@tie \the\chapno
9025: \else \ifnum\subsecno=0
9026: \putwordSection@tie \the\chapno.\the\secno
9027: \else \ifnum\subsubsecno=0
9028: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9029: \else
9030: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9031: \fi\fi\fi
9032: }
9033: \def\Yappendix{%
9034: \ifnum\secno=0
9035: \putwordAppendix@tie @char\the\appendixno{}%
9036: \else \ifnum\subsecno=0
9037: \putwordSection@tie @char\the\appendixno.\the\secno
9038: \else \ifnum\subsubsecno=0
9039: \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9040: \else
9041: \putwordSection@tie
9042: @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9043: \fi\fi\fi
9044: }
9045:
1.5 ! snw 9046: % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX
! 9047: % is output afterwards if non-empty.
! 9048: \def\refx#1#2{%
1.1 snw 9049: \requireauxfile
9050: {%
9051: \indexnofonts
9052: \turnoffactive
9053: \def\value##1{##1}%
9054: \expandafter\global\expandafter\let\expandafter\thisrefX
9055: \csname XR#1\endcsname
9056: }%
9057: \ifx\thisrefX\relax
9058: % If not defined, say something at least.
9059: \angleleft un\-de\-fined\angleright
9060: \iflinks
9061: \ifhavexrefs
9062: {\toks0 = {#1}% avoid expansion of possibly-complex value
9063: \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9064: \else
9065: \ifwarnedxrefs\else
9066: \global\warnedxrefstrue
9067: \message{Cross reference values unknown; you must run TeX again.}%
9068: \fi
9069: \fi
9070: \fi
9071: \else
9072: % It's defined, so just use it.
9073: \thisrefX
9074: \fi
1.5 ! snw 9075: #2% Output the suffix in any case.
1.1 snw 9076: }
9077:
9078: % This is the macro invoked by entries in the aux file. Define a control
9079: % sequence for a cross-reference target (we prepend XR to the control sequence
9080: % name to avoid collisions). The value is the page number. If this is a float
9081: % type, we have more work to do.
9082: %
9083: \def\xrdef#1#2{%
9084: {% Expand the node or anchor name to remove control sequences.
9085: % \turnoffactive stops 8-bit characters being changed to commands
9086: % like @'e. \refx does the same to retrieve the value in the definition.
9087: \indexnofonts
9088: \turnoffactive
9089: \def\value##1{##1}%
9090: \xdef\safexrefname{#1}%
9091: }%
9092: %
9093: \bgroup
9094: \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9095: \egroup
9096: % We put the \gdef inside a group to avoid the definitions building up on
9097: % TeX's save stack, which can cause it to run out of space for aux files with
9098: % thousands of lines. \gdef doesn't use the save stack, but \csname does
9099: % when it defines an unknown control sequence as \relax.
9100: %
9101: % Was that xref control sequence that we just defined for a float?
9102: \expandafter\iffloat\csname XR\safexrefname\endcsname
9103: % it was a float, and we have the (safe) float type in \iffloattype.
9104: \expandafter\let\expandafter\floatlist
9105: \csname floatlist\iffloattype\endcsname
9106: %
9107: % Is this the first time we've seen this float type?
9108: \expandafter\ifx\floatlist\relax
9109: \toks0 = {\do}% yes, so just \do
9110: \else
9111: % had it before, so preserve previous elements in list.
9112: \toks0 = \expandafter{\floatlist\do}%
9113: \fi
9114: %
9115: % Remember this xref in the control sequence \floatlistFLOATTYPE,
9116: % for later use in \listoffloats.
9117: \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9118: {\safexrefname}}%
9119: \fi
9120: }
9121:
9122: % If working on a large document in chapters, it is convenient to
9123: % be able to disable indexing, cross-referencing, and contents, for test runs.
9124: % This is done with @novalidate at the beginning of the file.
9125: %
9126: \newif\iflinks \linkstrue % by default we want the aux files.
9127: \let\novalidate = \linksfalse
9128:
9129: % Used when writing to the aux file, or when using data from it.
9130: \def\requireauxfile{%
9131: \iflinks
9132: \tryauxfile
9133: % Open the new aux file. TeX will close it automatically at exit.
9134: \immediate\openout\auxfile=\jobname.aux
9135: \fi
9136: \global\let\requireauxfile=\relax % Only do this once.
9137: }
9138:
9139: % Read the last existing aux file, if any. No error if none exists.
9140: %
9141: \def\tryauxfile{%
9142: \openin 1 \jobname.aux
9143: \ifeof 1 \else
9144: \readdatafile{aux}%
9145: \global\havexrefstrue
9146: \fi
9147: \closein 1
9148: }
9149:
9150: \def\setupdatafile{%
9151: \catcode`\^^@=\other
9152: \catcode`\^^A=\other
9153: \catcode`\^^B=\other
9154: \catcode`\^^C=\other
9155: \catcode`\^^D=\other
9156: \catcode`\^^E=\other
9157: \catcode`\^^F=\other
9158: \catcode`\^^G=\other
9159: \catcode`\^^H=\other
9160: \catcode`\^^K=\other
9161: \catcode`\^^L=\other
9162: \catcode`\^^N=\other
9163: \catcode`\^^P=\other
9164: \catcode`\^^Q=\other
9165: \catcode`\^^R=\other
9166: \catcode`\^^S=\other
9167: \catcode`\^^T=\other
9168: \catcode`\^^U=\other
9169: \catcode`\^^V=\other
9170: \catcode`\^^W=\other
9171: \catcode`\^^X=\other
9172: \catcode`\^^Z=\other
9173: \catcode`\^^[=\other
9174: \catcode`\^^\=\other
9175: \catcode`\^^]=\other
9176: \catcode`\^^^=\other
9177: \catcode`\^^_=\other
9178: \catcode`\^=\other
9179: %
9180: % Special characters. Should be turned off anyway, but...
9181: \catcode`\~=\other
9182: \catcode`\[=\other
9183: \catcode`\]=\other
9184: \catcode`\"=\other
1.5 ! snw 9185: \catcode`\_=\other
! 9186: \catcode`\|=\other
! 9187: \catcode`\<=\other
! 9188: \catcode`\>=\other
1.1 snw 9189: \catcode`\$=\other
9190: \catcode`\#=\other
9191: \catcode`\&=\other
9192: \catcode`\%=\other
9193: \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9194: %
9195: \catcode`\\=\active
9196: %
9197: % @ is our escape character in .aux files, and we need braces.
9198: \catcode`\{=1
9199: \catcode`\}=2
9200: \catcode`\@=0
9201: }
9202:
9203: \def\readdatafile#1{%
9204: \begingroup
9205: \setupdatafile
9206: \input\jobname.#1
9207: \endgroup}
9208:
9209:
9210: \message{insertions,}
9211: % including footnotes.
9212:
9213: \newcount \footnoteno
9214:
9215: % The trailing space in the following definition for supereject is
9216: % vital for proper filling; pages come out unaligned when you do a
9217: % pagealignmacro call if that space before the closing brace is
9218: % removed. (Generally, numeric constants should always be followed by a
9219: % space to prevent strange expansion errors.)
9220: \def\supereject{\par\penalty -20000\footnoteno =0 }
9221:
9222: % @footnotestyle is meaningful for Info output only.
9223: \let\footnotestyle=\comment
9224:
9225: {\catcode `\@=11
9226: %
9227: % Auto-number footnotes. Otherwise like plain.
9228: \gdef\footnote{%
9229: \global\advance\footnoteno by \@ne
9230: \edef\thisfootno{$^{\the\footnoteno}$}%
9231: %
9232: % In case the footnote comes at the end of a sentence, preserve the
9233: % extra spacing after we do the footnote number.
9234: \let\@sf\empty
9235: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9236: %
9237: % Remove inadvertent blank space before typesetting the footnote number.
9238: \unskip
9239: \thisfootno\@sf
9240: \dofootnote
9241: }%
9242:
9243: % Don't bother with the trickery in plain.tex to not require the
9244: % footnote text as a parameter. Our footnotes don't need to be so general.
9245: %
9246: % Oh yes, they do; otherwise, @ifset (and anything else that uses
9247: % \parseargline) fails inside footnotes because the tokens are fixed when
9248: % the footnote is read. --karl, 16nov96.
9249: %
9250: \gdef\dofootnote{%
9251: \insert\footins\bgroup
9252: %
9253: % Nested footnotes are not supported in TeX, that would take a lot
9254: % more work. (\startsavinginserts does not suffice.)
9255: \let\footnote=\errfootnotenest
9256: %
9257: % We want to typeset this text as a normal paragraph, even if the
9258: % footnote reference occurs in (for example) a display environment.
9259: % So reset some parameters.
9260: \hsize=\txipagewidth
9261: \interlinepenalty\interfootnotelinepenalty
9262: \splittopskip\ht\strutbox % top baseline for broken footnotes
9263: \splitmaxdepth\dp\strutbox
9264: \floatingpenalty\@MM
9265: \leftskip\z@skip
9266: \rightskip\z@skip
9267: \spaceskip\z@skip
9268: \xspaceskip\z@skip
9269: \parindent\defaultparindent
9270: %
9271: \smallfonts \rm
9272: %
9273: % Because we use hanging indentation in footnotes, a @noindent appears
9274: % to exdent this text, so make it be a no-op. makeinfo does not use
9275: % hanging indentation so @noindent can still be needed within footnote
9276: % text after an @example or the like (not that this is good style).
9277: \let\noindent = \relax
9278: %
9279: % Hang the footnote text off the number. Use \everypar in case the
9280: % footnote extends for more than one paragraph.
9281: \everypar = {\hang}%
9282: \textindent{\thisfootno}%
9283: %
9284: % Don't crash into the line above the footnote text. Since this
9285: % expands into a box, it must come within the paragraph, lest it
9286: % provide a place where TeX can split the footnote.
9287: \footstrut
9288: %
9289: % Invoke rest of plain TeX footnote routine.
9290: \futurelet\next\fo@t
9291: }
9292: }%end \catcode `\@=11
9293:
9294: \def\errfootnotenest{%
9295: \errhelp=\EMsimple
9296: \errmessage{Nested footnotes not supported in texinfo.tex,
9297: even though they work in makeinfo; sorry}
9298: }
9299:
9300: \def\errfootnoteheading{%
9301: \errhelp=\EMsimple
9302: \errmessage{Footnotes in chapters, sections, etc., are not supported}
9303: }
9304:
9305: % In case a @footnote appears in a vbox, save the footnote text and create
9306: % the real \insert just after the vbox finished. Otherwise, the insertion
9307: % would be lost.
9308: % Similarly, if a @footnote appears inside an alignment, save the footnote
9309: % text to a box and make the \insert when a row of the table is finished.
9310: % And the same can be done for other insert classes. --kasal, 16nov03.
9311: %
9312: % Replace the \insert primitive by a cheating macro.
9313: % Deeper inside, just make sure that the saved insertions are not spilled
9314: % out prematurely.
9315: %
9316: \def\startsavinginserts{%
9317: \ifx \insert\ptexinsert
9318: \let\insert\saveinsert
9319: \else
9320: \let\checkinserts\relax
9321: \fi
9322: }
9323:
9324: % This \insert replacement works for both \insert\footins{foo} and
9325: % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9326: %
9327: \def\saveinsert#1{%
9328: \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9329: \afterassignment\next
9330: % swallow the left brace
9331: \let\temp =
9332: }
9333: \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9334: \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9335:
9336: \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9337:
9338: \def\placesaveins#1{%
9339: \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9340: {\box#1}%
9341: }
9342:
9343: % eat @SAVE -- beware, all of them have catcode \other:
9344: {
9345: \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
9346: \gdef\gobblesave @SAVE{}
9347: }
9348:
9349: % initialization:
9350: \def\newsaveins #1{%
9351: \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9352: \next
9353: }
9354: \def\newsaveinsX #1{%
9355: \csname newbox\endcsname #1%
9356: \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9357: \checksaveins #1}%
9358: }
9359:
9360: % initialize:
9361: \let\checkinserts\empty
9362: \newsaveins\footins
9363: \newsaveins\margin
9364:
9365:
9366: % @image. We use the macros from epsf.tex to support this.
9367: % If epsf.tex is not installed and @image is used, we complain.
9368: %
9369: % Check for and read epsf.tex up front. If we read it only at @image
9370: % time, we might be inside a group, and then its definitions would get
9371: % undone and the next image would fail.
9372: \openin 1 = epsf.tex
9373: \ifeof 1 \else
9374: % Do not bother showing banner with epsf.tex v2.7k (available in
9375: % doc/epsf.tex and on ctan).
9376: \def\epsfannounce{\toks0 = }%
9377: \input epsf.tex
9378: \fi
9379: \closein 1
9380: %
9381: % We will only complain once about lack of epsf.tex.
9382: \newif\ifwarnednoepsf
9383: \newhelp\noepsfhelp{epsf.tex must be installed for images to
9384: work. It is also included in the Texinfo distribution, or you can get
9385: it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9386: %
9387: \def\image#1{%
9388: \ifx\epsfbox\thisisundefined
9389: \ifwarnednoepsf \else
9390: \errhelp = \noepsfhelp
9391: \errmessage{epsf.tex not found, images will be ignored}%
9392: \global\warnednoepsftrue
9393: \fi
9394: \else
9395: \imagexxx #1,,,,,\finish
9396: \fi
9397: }
9398: %
9399: % Arguments to @image:
9400: % #1 is (mandatory) image filename; we tack on .eps extension.
9401: % #2 is (optional) width, #3 is (optional) height.
9402: % #4 is (ignored optional) html alt text.
9403: % #5 is (ignored optional) extension.
9404: % #6 is just the usual extra ignored arg for parsing stuff.
9405: \newif\ifimagevmode
9406: \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9407: \catcode`\^^M = 5 % in case we're inside an example
9408: \normalturnoffactive % allow _ et al. in names
1.5 ! snw 9409: \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
! 9410: % If the image is by itself, center it.
1.1 snw 9411: \ifvmode
9412: \imagevmodetrue
1.5 ! snw 9413: \else \ifx\centersub\centerV
! 9414: % for @center @image, we need a vbox so we can have our vertical space
! 9415: \imagevmodetrue
! 9416: \vbox\bgroup % vbox has better behavior than vtop herev
! 9417: \fi\fi
! 9418: %
! 9419: \ifimagevmode
! 9420: \nobreak\medskip
1.1 snw 9421: % Usually we'll have text after the image which will insert
9422: % \parskip glue, so insert it here too to equalize the space
9423: % above and below.
1.5 ! snw 9424: \nobreak\vskip\parskip
! 9425: \nobreak
1.1 snw 9426: \fi
9427: %
1.5 ! snw 9428: % Leave vertical mode so that indentation from an enclosing
! 9429: % environment such as @quotation is respected.
! 9430: % However, if we're at the top level, we don't want the
! 9431: % normal paragraph indentation.
! 9432: % On the other hand, if we are in the case of @center @image, we don't
! 9433: % want to start a paragraph, which will create a hsize-width box and
! 9434: % eradicate the centering.
! 9435: \ifx\centersub\centerV\else \noindent \fi
1.1 snw 9436: %
9437: % Output the image.
9438: \ifpdf
9439: % For pdfTeX and LuaTeX <= 0.80
9440: \dopdfimage{#1}{#2}{#3}%
9441: \else
9442: \ifx\XeTeXrevision\thisisundefined
9443: % For epsf.tex
9444: % \epsfbox itself resets \epsf?size at each figure.
9445: \setbox0 = \hbox{\ignorespaces #2}%
9446: \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9447: \setbox0 = \hbox{\ignorespaces #3}%
9448: \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9449: \epsfbox{#1.eps}%
9450: \else
9451: % For XeTeX
9452: \doxeteximage{#1}{#2}{#3}%
9453: \fi
9454: \fi
9455: %
9456: \ifimagevmode
9457: \medskip % space after a standalone image
9458: \fi
1.5 ! snw 9459: \ifx\centersub\centerV \egroup \fi
1.1 snw 9460: \endgroup}
9461:
9462:
9463: % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9464: % etc. We don't actually implement floating yet, we always include the
9465: % float "here". But it seemed the best name for the future.
9466: %
9467: \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9468:
9469: % There may be a space before second and/or third parameter; delete it.
9470: \def\eatcommaspace#1, {#1,}
9471:
9472: % #1 is the optional FLOATTYPE, the text label for this float, typically
9473: % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
9474: % this float will not be numbered and cannot be referred to.
9475: %
9476: % #2 is the optional xref label. Also must be present for the float to
9477: % be referable.
9478: %
9479: % #3 is the optional positioning argument; for now, it is ignored. It
9480: % will somehow specify the positions allowed to float to (here, top, bottom).
9481: %
9482: % We keep a separate counter for each FLOATTYPE, which we reset at each
9483: % chapter-level command.
9484: \let\resetallfloatnos=\empty
9485: %
9486: \def\dofloat#1,#2,#3,#4\finish{%
9487: \let\thiscaption=\empty
9488: \let\thisshortcaption=\empty
9489: %
9490: % don't lose footnotes inside @float.
9491: %
9492: % BEWARE: when the floats start float, we have to issue warning whenever an
9493: % insert appears inside a float which could possibly float. --kasal, 26may04
9494: %
9495: \startsavinginserts
9496: %
9497: % We can't be used inside a paragraph.
9498: \par
9499: %
9500: \vtop\bgroup
9501: \def\floattype{#1}%
9502: \def\floatlabel{#2}%
9503: \def\floatloc{#3}% we do nothing with this yet.
9504: %
9505: \ifx\floattype\empty
9506: \let\safefloattype=\empty
9507: \else
9508: {%
9509: % the floattype might have accents or other special characters,
9510: % but we need to use it in a control sequence name.
9511: \indexnofonts
9512: \turnoffactive
9513: \xdef\safefloattype{\floattype}%
9514: }%
9515: \fi
9516: %
9517: % If label is given but no type, we handle that as the empty type.
9518: \ifx\floatlabel\empty \else
9519: % We want each FLOATTYPE to be numbered separately (Figure 1,
9520: % Table 1, Figure 2, ...). (And if no label, no number.)
9521: %
9522: \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9523: \global\advance\floatno by 1
9524: %
9525: {%
9526: % This magic value for \currentsection is output by \setref as the
9527: % XREFLABEL-title value. \xrefX uses it to distinguish float
9528: % labels (which have a completely different output format) from
9529: % node and anchor labels. And \xrdef uses it to construct the
9530: % lists of floats.
9531: %
9532: \edef\currentsection{\floatmagic=\safefloattype}%
9533: \setref{\floatlabel}{Yfloat}%
9534: }%
9535: \fi
9536: %
9537: % start with \parskip glue, I guess.
9538: \vskip\parskip
9539: %
9540: % Don't suppress indentation if a float happens to start a section.
9541: \restorefirstparagraphindent
9542: }
9543:
9544: % we have these possibilities:
9545: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9546: % @float Foo,lbl & no caption: Foo 1.1
9547: % @float Foo & @caption{Cap}: Foo: Cap
9548: % @float Foo & no caption: Foo
9549: % @float ,lbl & Caption{Cap}: 1.1: Cap
9550: % @float ,lbl & no caption: 1.1
9551: % @float & @caption{Cap}: Cap
9552: % @float & no caption:
9553: %
9554: \def\Efloat{%
9555: \let\floatident = \empty
9556: %
9557: % In all cases, if we have a float type, it comes first.
9558: \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9559: %
9560: % If we have an xref label, the number comes next.
9561: \ifx\floatlabel\empty \else
9562: \ifx\floattype\empty \else % if also had float type, need tie first.
9563: \appendtomacro\floatident{\tie}%
9564: \fi
9565: % the number.
9566: \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9567: \fi
9568: %
9569: % Start the printed caption with what we've constructed in
9570: % \floatident, but keep it separate; we need \floatident again.
9571: \let\captionline = \floatident
9572: %
9573: \ifx\thiscaption\empty \else
9574: \ifx\floatident\empty \else
9575: \appendtomacro\captionline{: }% had ident, so need a colon between
9576: \fi
9577: %
9578: % caption text.
9579: \appendtomacro\captionline{\scanexp\thiscaption}%
9580: \fi
9581: %
9582: % If we have anything to print, print it, with space before.
9583: % Eventually this needs to become an \insert.
9584: \ifx\captionline\empty \else
9585: \vskip.5\parskip
9586: \captionline
9587: %
9588: % Space below caption.
9589: \vskip\parskip
9590: \fi
9591: %
9592: % If have an xref label, write the list of floats info. Do this
9593: % after the caption, to avoid chance of it being a breakpoint.
9594: \ifx\floatlabel\empty \else
9595: % Write the text that goes in the lof to the aux file as
9596: % \floatlabel-lof. Besides \floatident, we include the short
9597: % caption if specified, else the full caption if specified, else nothing.
9598: {%
9599: \requireauxfile
9600: \atdummies
9601: %
9602: \ifx\thisshortcaption\empty
9603: \def\gtemp{\thiscaption}%
9604: \else
9605: \def\gtemp{\thisshortcaption}%
9606: \fi
9607: \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9608: \ifx\gtemp\empty \else : \gtemp \fi}}%
9609: }%
9610: \fi
9611: \egroup % end of \vtop
9612: %
9613: \checkinserts
9614: }
9615:
9616: % Append the tokens #2 to the definition of macro #1, not expanding either.
9617: %
9618: \def\appendtomacro#1#2{%
9619: \expandafter\def\expandafter#1\expandafter{#1#2}%
9620: }
9621:
9622: % @caption, @shortcaption
9623: %
9624: \def\caption{\docaption\thiscaption}
9625: \def\shortcaption{\docaption\thisshortcaption}
1.5 ! snw 9626: \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
! 9627: \def\defcaption#1#2{\egroup \def#1{#2}}
1.1 snw 9628:
9629: % The parameter is the control sequence identifying the counter we are
9630: % going to use. Create it if it doesn't exist and assign it to \floatno.
9631: \def\getfloatno#1{%
9632: \ifx#1\relax
9633: % Haven't seen this figure type before.
9634: \csname newcount\endcsname #1%
9635: %
9636: % Remember to reset this floatno at the next chap.
9637: \expandafter\gdef\expandafter\resetallfloatnos
9638: \expandafter{\resetallfloatnos #1=0 }%
9639: \fi
9640: \let\floatno#1%
9641: }
9642:
9643: % \setref calls this to get the XREFLABEL-snt value. We want an @xref
9644: % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
9645: % first read the @float command.
9646: %
9647: \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9648:
9649: % Magic string used for the XREFLABEL-title value, so \xrefX can
9650: % distinguish floats from other xref types.
9651: \def\floatmagic{!!float!!}
9652:
9653: % #1 is the control sequence we are passed; we expand into a conditional
9654: % which is true if #1 represents a float ref. That is, the magic
9655: % \currentsection value which we \setref above.
9656: %
9657: \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9658: %
9659: % #1 is (maybe) the \floatmagic string. If so, #2 will be the
9660: % (safe) float type for this float. We set \iffloattype to #2.
9661: %
9662: \def\doiffloat#1=#2=#3\finish{%
9663: \def\temp{#1}%
9664: \def\iffloattype{#2}%
9665: \ifx\temp\floatmagic
9666: }
9667:
9668: % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9669: %
9670: \parseargdef\listoffloats{%
9671: \def\floattype{#1}% floattype
9672: {%
9673: % the floattype might have accents or other special characters,
9674: % but we need to use it in a control sequence name.
9675: \indexnofonts
9676: \turnoffactive
9677: \xdef\safefloattype{\floattype}%
9678: }%
9679: %
9680: % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9681: \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9682: \ifhavexrefs
9683: % if the user said @listoffloats foo but never @float foo.
9684: \message{\linenumber No `\safefloattype' floats to list.}%
9685: \fi
9686: \else
9687: \begingroup
9688: \leftskip=\tocindent % indent these entries like a toc
9689: \let\do=\listoffloatsdo
9690: \csname floatlist\safefloattype\endcsname
9691: \endgroup
9692: \fi
9693: }
9694:
9695: % This is called on each entry in a list of floats. We're passed the
9696: % xref label, in the form LABEL-title, which is how we save it in the
9697: % aux file. We strip off the -title and look up \XRLABEL-lof, which
9698: % has the text we're supposed to typeset here.
9699: %
9700: % Figures without xref labels will not be included in the list (since
9701: % they won't appear in the aux file).
9702: %
9703: \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9704: \def\listoffloatsdoentry#1-title\finish{{%
9705: % Can't fully expand XR#1-lof because it can contain anything. Just
9706: % pass the control sequence. On the other hand, XR#1-pg is just the
9707: % page number, and we want to fully expand that so we can get a link
9708: % in pdf output.
9709: \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9710: %
9711: % use the same \entry macro we use to generate the TOC and index.
9712: \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9713: \writeentry
9714: }}
9715:
9716:
9717: \message{localization,}
9718:
9719: % For single-language documents, @documentlanguage is usually given very
9720: % early, just after @documentencoding. Single argument is the language
9721: % (de) or locale (de_DE) abbreviation.
9722: %
9723: {
9724: \catcode`\_ = \active
9725: \globaldefs=1
9726: \parseargdef\documentlanguage{%
9727: \tex % read txi-??.tex file in plain TeX.
9728: % Read the file by the name they passed if it exists.
9729: \let_ = \normalunderscore % normal _ character for filename test
9730: \openin 1 txi-#1.tex
9731: \ifeof 1
9732: \documentlanguagetrywithoutunderscore #1_\finish
9733: \else
9734: \globaldefs = 1 % everything in the txi-LL files needs to persist
9735: \input txi-#1.tex
9736: \fi
9737: \closein 1
9738: \endgroup % end raw TeX
9739: }
9740: %
9741: % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9742: % try txi-de.tex.
9743: %
9744: \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9745: \openin 1 txi-#1.tex
9746: \ifeof 1
9747: \errhelp = \nolanghelp
9748: \errmessage{Cannot read language file txi-#1.tex}%
9749: \else
9750: \globaldefs = 1 % everything in the txi-LL files needs to persist
9751: \input txi-#1.tex
9752: \fi
9753: \closein 1
9754: }
9755: }% end of special _ catcode
9756: %
9757: \newhelp\nolanghelp{The given language definition file cannot be found or
9758: is empty. Maybe you need to install it? Putting it in the current
9759: directory should work if nowhere else does.}
9760:
9761: % This macro is called from txi-??.tex files; the first argument is the
9762: % \language name to set (without the "\lang@" prefix), the second and
9763: % third args are \{left,right}hyphenmin.
9764: %
9765: % The language names to pass are determined when the format is built.
9766: % See the etex.log file created at that time, e.g.,
9767: % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9768: %
9769: % With TeX Live 2008, etex now includes hyphenation patterns for all
9770: % available languages. This means we can support hyphenation in
9771: % Texinfo, at least to some extent. (This still doesn't solve the
9772: % accented characters problem.)
9773: %
9774: \catcode`@=11
9775: \def\txisetlanguage#1#2#3{%
9776: % do not set the language if the name is undefined in the current TeX.
9777: \expandafter\ifx\csname lang@#1\endcsname \relax
9778: \message{no patterns for #1}%
9779: \else
9780: \global\language = \csname lang@#1\endcsname
9781: \fi
9782: % but there is no harm in adjusting the hyphenmin values regardless.
9783: \global\lefthyphenmin = #2\relax
9784: \global\righthyphenmin = #3\relax
9785: }
9786:
9787: % XeTeX and LuaTeX can handle Unicode natively.
9788: % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9789: % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9790: %
9791: \newif\iftxinativeunicodecapable
9792: \newif\iftxiusebytewiseio
9793:
9794: \ifx\XeTeXrevision\thisisundefined
9795: \ifx\luatexversion\thisisundefined
9796: \txinativeunicodecapablefalse
9797: \txiusebytewiseiotrue
9798: \else
9799: \txinativeunicodecapabletrue
9800: \txiusebytewiseiofalse
9801: \fi
9802: \else
9803: \txinativeunicodecapabletrue
9804: \txiusebytewiseiofalse
9805: \fi
9806:
9807: % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9808: % for non-UTF-8 (byte-wise) encodings.
9809: %
9810: \def\setbytewiseio{%
9811: \ifx\XeTeXrevision\thisisundefined
9812: \else
9813: \XeTeXdefaultencoding "bytes" % For subsequent files to be read
9814: \XeTeXinputencoding "bytes" % For document root file
9815: % Unfortunately, there seems to be no corresponding XeTeX command for
9816: % output encoding. This is a problem for auxiliary index and TOC files.
9817: % The only solution would be perhaps to write out @U{...} sequences in
9818: % place of non-ASCII characters.
9819: \fi
9820:
9821: \ifx\luatexversion\thisisundefined
9822: \else
9823: \directlua{
9824: local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9825: local function convert_char (char)
9826: return utf8_char(byte(char))
9827: end
9828:
9829: local function convert_line (line)
9830: return gsub(line, ".", convert_char)
9831: end
9832:
9833: callback.register("process_input_buffer", convert_line)
9834:
9835: local function convert_line_out (line)
9836: local line_out = ""
9837: for c in string.utfvalues(line) do
9838: line_out = line_out .. string.char(c)
9839: end
9840: return line_out
9841: end
9842:
9843: callback.register("process_output_buffer", convert_line_out)
9844: }
9845: \fi
9846:
9847: \txiusebytewiseiotrue
9848: }
9849:
9850:
9851: % Helpers for encodings.
9852: % Set the catcode of characters 128 through 255 to the specified number.
9853: %
9854: \def\setnonasciicharscatcode#1{%
9855: \count255=128
9856: \loop\ifnum\count255<256
9857: \global\catcode\count255=#1\relax
9858: \advance\count255 by 1
9859: \repeat
9860: }
9861:
9862: \def\setnonasciicharscatcodenonglobal#1{%
9863: \count255=128
9864: \loop\ifnum\count255<256
9865: \catcode\count255=#1\relax
9866: \advance\count255 by 1
9867: \repeat
9868: }
9869:
9870: % @documentencoding sets the definition of non-ASCII characters
9871: % according to the specified encoding.
9872: %
9873: \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9874: \def\documentencodingzzz#1{%
9875: %
9876: % Encoding being declared for the document.
9877: \def\declaredencoding{\csname #1.enc\endcsname}%
9878: %
9879: % Supported encodings: names converted to tokens in order to be able
9880: % to compare them with \ifx.
9881: \def\ascii{\csname US-ASCII.enc\endcsname}%
9882: \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9883: \def\latone{\csname ISO-8859-1.enc\endcsname}%
9884: \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9885: \def\utfeight{\csname UTF-8.enc\endcsname}%
9886: %
9887: \ifx \declaredencoding \ascii
9888: \asciichardefs
9889: %
9890: \else \ifx \declaredencoding \lattwo
9891: \iftxinativeunicodecapable
9892: \setbytewiseio
9893: \fi
9894: \setnonasciicharscatcode\active
9895: \lattwochardefs
9896: %
9897: \else \ifx \declaredencoding \latone
9898: \iftxinativeunicodecapable
9899: \setbytewiseio
9900: \fi
9901: \setnonasciicharscatcode\active
9902: \latonechardefs
9903: %
9904: \else \ifx \declaredencoding \latnine
9905: \iftxinativeunicodecapable
9906: \setbytewiseio
9907: \fi
9908: \setnonasciicharscatcode\active
9909: \latninechardefs
9910: %
9911: \else \ifx \declaredencoding \utfeight
9912: \iftxinativeunicodecapable
9913: % For native Unicode handling (XeTeX and LuaTeX)
9914: \nativeunicodechardefs
9915: \else
1.5 ! snw 9916: % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
1.1 snw 9917: \setnonasciicharscatcode\active
1.5 ! snw 9918: % since we already invoked \utfeightchardefs at the top level
! 9919: % (below), do not re-invoke it, otherwise our check for duplicated
! 9920: % definitions gets triggered. Making non-ascii chars active is
! 9921: % sufficient.
1.1 snw 9922: \fi
9923: %
9924: \else
9925: \message{Ignoring unknown document encoding: #1.}%
9926: %
9927: \fi % utfeight
9928: \fi % latnine
9929: \fi % latone
9930: \fi % lattwo
9931: \fi % ascii
9932: %
9933: \ifx\XeTeXrevision\thisisundefined
9934: \else
9935: \ifx \declaredencoding \utfeight
9936: \else
9937: \ifx \declaredencoding \ascii
9938: \else
9939: \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9940: non-ASCII characters in auxiliary files.}%
9941: \fi
9942: \fi
9943: \fi
9944: }
9945:
1.5 ! snw 9946: % emacs-page
1.1 snw 9947: % A message to be logged when using a character that isn't available
9948: % the default font encoding (OT1).
9949: %
9950: \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9951:
9952: % Take account of \c (plain) vs. \, (Texinfo) difference.
9953: \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9954:
1.5 ! snw 9955: % First, make active non-ASCII characters in order for them to be
! 9956: % correctly categorized when TeX reads the replacement text of
! 9957: % macros containing the character definitions.
! 9958: \setnonasciicharscatcode\active
! 9959: %
! 9960:
1.1 snw 9961: \def\gdefchar#1#2{%
9962: \gdef#1{%
9963: \ifpassthroughchars
9964: \string#1%
9965: \else
9966: #2%
9967: \fi
9968: }}
9969:
9970: % Latin1 (ISO-8859-1) character definitions.
1.5 ! snw 9971: \def\latonechardefs{%
1.1 snw 9972: \gdefchar^^a0{\tie}
9973: \gdefchar^^a1{\exclamdown}
9974: \gdefchar^^a2{{\tcfont \char162}} % cent
9975: \gdefchar^^a3{\pounds{}}
9976: \gdefchar^^a4{{\tcfont \char164}} % currency
9977: \gdefchar^^a5{{\tcfont \char165}} % yen
9978: \gdefchar^^a6{{\tcfont \char166}} % broken bar
9979: \gdefchar^^a7{\S}
9980: \gdefchar^^a8{\"{}}
9981: \gdefchar^^a9{\copyright{}}
9982: \gdefchar^^aa{\ordf}
9983: \gdefchar^^ab{\guillemetleft{}}
9984: \gdefchar^^ac{\ensuremath\lnot}
9985: \gdefchar^^ad{\-}
9986: \gdefchar^^ae{\registeredsymbol{}}
9987: \gdefchar^^af{\={}}
9988: %
9989: \gdefchar^^b0{\textdegree}
9990: \gdefchar^^b1{$\pm$}
9991: \gdefchar^^b2{$^2$}
9992: \gdefchar^^b3{$^3$}
9993: \gdefchar^^b4{\'{}}
9994: \gdefchar^^b5{$\mu$}
9995: \gdefchar^^b6{\P}
9996: \gdefchar^^b7{\ensuremath\cdot}
9997: \gdefchar^^b8{\cedilla\ }
9998: \gdefchar^^b9{$^1$}
9999: \gdefchar^^ba{\ordm}
10000: \gdefchar^^bb{\guillemetright{}}
10001: \gdefchar^^bc{$1\over4$}
10002: \gdefchar^^bd{$1\over2$}
10003: \gdefchar^^be{$3\over4$}
10004: \gdefchar^^bf{\questiondown}
10005: %
10006: \gdefchar^^c0{\`A}
10007: \gdefchar^^c1{\'A}
10008: \gdefchar^^c2{\^A}
10009: \gdefchar^^c3{\~A}
10010: \gdefchar^^c4{\"A}
10011: \gdefchar^^c5{\ringaccent A}
10012: \gdefchar^^c6{\AE}
10013: \gdefchar^^c7{\cedilla C}
10014: \gdefchar^^c8{\`E}
10015: \gdefchar^^c9{\'E}
10016: \gdefchar^^ca{\^E}
10017: \gdefchar^^cb{\"E}
10018: \gdefchar^^cc{\`I}
10019: \gdefchar^^cd{\'I}
10020: \gdefchar^^ce{\^I}
10021: \gdefchar^^cf{\"I}
10022: %
10023: \gdefchar^^d0{\DH}
10024: \gdefchar^^d1{\~N}
10025: \gdefchar^^d2{\`O}
10026: \gdefchar^^d3{\'O}
10027: \gdefchar^^d4{\^O}
10028: \gdefchar^^d5{\~O}
10029: \gdefchar^^d6{\"O}
10030: \gdefchar^^d7{$\times$}
10031: \gdefchar^^d8{\O}
10032: \gdefchar^^d9{\`U}
10033: \gdefchar^^da{\'U}
10034: \gdefchar^^db{\^U}
10035: \gdefchar^^dc{\"U}
10036: \gdefchar^^dd{\'Y}
10037: \gdefchar^^de{\TH}
10038: \gdefchar^^df{\ss}
10039: %
10040: \gdefchar^^e0{\`a}
10041: \gdefchar^^e1{\'a}
10042: \gdefchar^^e2{\^a}
10043: \gdefchar^^e3{\~a}
10044: \gdefchar^^e4{\"a}
10045: \gdefchar^^e5{\ringaccent a}
10046: \gdefchar^^e6{\ae}
10047: \gdefchar^^e7{\cedilla c}
10048: \gdefchar^^e8{\`e}
10049: \gdefchar^^e9{\'e}
10050: \gdefchar^^ea{\^e}
10051: \gdefchar^^eb{\"e}
10052: \gdefchar^^ec{\`{\dotless i}}
10053: \gdefchar^^ed{\'{\dotless i}}
10054: \gdefchar^^ee{\^{\dotless i}}
10055: \gdefchar^^ef{\"{\dotless i}}
10056: %
10057: \gdefchar^^f0{\dh}
10058: \gdefchar^^f1{\~n}
10059: \gdefchar^^f2{\`o}
10060: \gdefchar^^f3{\'o}
10061: \gdefchar^^f4{\^o}
10062: \gdefchar^^f5{\~o}
10063: \gdefchar^^f6{\"o}
10064: \gdefchar^^f7{$\div$}
10065: \gdefchar^^f8{\o}
10066: \gdefchar^^f9{\`u}
10067: \gdefchar^^fa{\'u}
10068: \gdefchar^^fb{\^u}
10069: \gdefchar^^fc{\"u}
10070: \gdefchar^^fd{\'y}
10071: \gdefchar^^fe{\th}
10072: \gdefchar^^ff{\"y}
10073: }
10074:
10075: % Latin9 (ISO-8859-15) encoding character definitions.
1.5 ! snw 10076: \def\latninechardefs{%
1.1 snw 10077: % Encoding is almost identical to Latin1.
10078: \latonechardefs
10079: %
10080: \gdefchar^^a4{\euro{}}
10081: \gdefchar^^a6{\v S}
10082: \gdefchar^^a8{\v s}
10083: \gdefchar^^b4{\v Z}
10084: \gdefchar^^b8{\v z}
10085: \gdefchar^^bc{\OE}
10086: \gdefchar^^bd{\oe}
10087: \gdefchar^^be{\"Y}
10088: }
10089:
10090: % Latin2 (ISO-8859-2) character definitions.
1.5 ! snw 10091: \def\lattwochardefs{%
1.1 snw 10092: \gdefchar^^a0{\tie}
10093: \gdefchar^^a1{\ogonek{A}}
10094: \gdefchar^^a2{\u{}}
10095: \gdefchar^^a3{\L}
10096: \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10097: \gdefchar^^a5{\v L}
10098: \gdefchar^^a6{\'S}
10099: \gdefchar^^a7{\S}
10100: \gdefchar^^a8{\"{}}
10101: \gdefchar^^a9{\v S}
10102: \gdefchar^^aa{\cedilla S}
10103: \gdefchar^^ab{\v T}
10104: \gdefchar^^ac{\'Z}
10105: \gdefchar^^ad{\-}
10106: \gdefchar^^ae{\v Z}
10107: \gdefchar^^af{\dotaccent Z}
10108: %
1.5 ! snw 10109: \gdefchar^^b0{\textdegree{}}
1.1 snw 10110: \gdefchar^^b1{\ogonek{a}}
10111: \gdefchar^^b2{\ogonek{ }}
10112: \gdefchar^^b3{\l}
10113: \gdefchar^^b4{\'{}}
10114: \gdefchar^^b5{\v l}
10115: \gdefchar^^b6{\'s}
10116: \gdefchar^^b7{\v{}}
10117: \gdefchar^^b8{\cedilla\ }
10118: \gdefchar^^b9{\v s}
10119: \gdefchar^^ba{\cedilla s}
10120: \gdefchar^^bb{\v t}
10121: \gdefchar^^bc{\'z}
10122: \gdefchar^^bd{\H{}}
10123: \gdefchar^^be{\v z}
10124: \gdefchar^^bf{\dotaccent z}
10125: %
10126: \gdefchar^^c0{\'R}
10127: \gdefchar^^c1{\'A}
10128: \gdefchar^^c2{\^A}
10129: \gdefchar^^c3{\u A}
10130: \gdefchar^^c4{\"A}
10131: \gdefchar^^c5{\'L}
10132: \gdefchar^^c6{\'C}
10133: \gdefchar^^c7{\cedilla C}
10134: \gdefchar^^c8{\v C}
10135: \gdefchar^^c9{\'E}
10136: \gdefchar^^ca{\ogonek{E}}
10137: \gdefchar^^cb{\"E}
10138: \gdefchar^^cc{\v E}
10139: \gdefchar^^cd{\'I}
10140: \gdefchar^^ce{\^I}
10141: \gdefchar^^cf{\v D}
10142: %
10143: \gdefchar^^d0{\DH}
10144: \gdefchar^^d1{\'N}
10145: \gdefchar^^d2{\v N}
10146: \gdefchar^^d3{\'O}
10147: \gdefchar^^d4{\^O}
10148: \gdefchar^^d5{\H O}
10149: \gdefchar^^d6{\"O}
10150: \gdefchar^^d7{$\times$}
10151: \gdefchar^^d8{\v R}
10152: \gdefchar^^d9{\ringaccent U}
10153: \gdefchar^^da{\'U}
10154: \gdefchar^^db{\H U}
10155: \gdefchar^^dc{\"U}
10156: \gdefchar^^dd{\'Y}
10157: \gdefchar^^de{\cedilla T}
10158: \gdefchar^^df{\ss}
10159: %
10160: \gdefchar^^e0{\'r}
10161: \gdefchar^^e1{\'a}
10162: \gdefchar^^e2{\^a}
10163: \gdefchar^^e3{\u a}
10164: \gdefchar^^e4{\"a}
10165: \gdefchar^^e5{\'l}
10166: \gdefchar^^e6{\'c}
10167: \gdefchar^^e7{\cedilla c}
10168: \gdefchar^^e8{\v c}
10169: \gdefchar^^e9{\'e}
10170: \gdefchar^^ea{\ogonek{e}}
10171: \gdefchar^^eb{\"e}
10172: \gdefchar^^ec{\v e}
10173: \gdefchar^^ed{\'{\dotless{i}}}
10174: \gdefchar^^ee{\^{\dotless{i}}}
10175: \gdefchar^^ef{\v d}
10176: %
10177: \gdefchar^^f0{\dh}
10178: \gdefchar^^f1{\'n}
10179: \gdefchar^^f2{\v n}
10180: \gdefchar^^f3{\'o}
10181: \gdefchar^^f4{\^o}
10182: \gdefchar^^f5{\H o}
10183: \gdefchar^^f6{\"o}
10184: \gdefchar^^f7{$\div$}
10185: \gdefchar^^f8{\v r}
10186: \gdefchar^^f9{\ringaccent u}
10187: \gdefchar^^fa{\'u}
10188: \gdefchar^^fb{\H u}
10189: \gdefchar^^fc{\"u}
10190: \gdefchar^^fd{\'y}
10191: \gdefchar^^fe{\cedilla t}
10192: \gdefchar^^ff{\dotaccent{}}
10193: }
10194:
10195: % UTF-8 character definitions.
10196: %
10197: % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10198: % changes for Texinfo conventions. It is included here under the GPL by
10199: % permission from Frank Mittelbach and the LaTeX team.
10200: %
10201: \newcount\countUTFx
10202: \newcount\countUTFy
10203: \newcount\countUTFz
10204:
10205: \gdef\UTFviiiTwoOctets#1#2{\expandafter
10206: \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10207: %
10208: \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10209: \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10210: %
10211: \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10212: \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10213:
10214: \gdef\UTFviiiDefined#1{%
10215: \ifx #1\relax
10216: \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10217: \else
10218: \expandafter #1%
10219: \fi
10220: }
10221:
10222: % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10223: \begingroup
10224: \catcode`\~13
10225: \catcode`\$12
10226: \catcode`\"12
10227:
10228: % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10229: % substituting ~ and $ with a character token of that value.
10230: \def\UTFviiiLoop{%
10231: \global\catcode\countUTFx\active
10232: \uccode`\~\countUTFx
10233: \uccode`\$\countUTFx
10234: \uppercase\expandafter{\UTFviiiTmp}%
10235: \advance\countUTFx by 1
10236: \ifnum\countUTFx < \countUTFy
10237: \expandafter\UTFviiiLoop
10238: \fi}
10239:
10240: % For bytes other than the first in a UTF-8 sequence. Not expected to
10241: % be expanded except when writing to auxiliary files.
10242: \countUTFx = "80
10243: \countUTFy = "C2
10244: \def\UTFviiiTmp{%
10245: \gdef~{%
10246: \ifpassthroughchars $\fi}}%
10247: \UTFviiiLoop
10248:
10249: \countUTFx = "C2
10250: \countUTFy = "E0
10251: \def\UTFviiiTmp{%
10252: \gdef~{%
10253: \ifpassthroughchars $%
10254: \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10255: \UTFviiiLoop
10256:
10257: \countUTFx = "E0
10258: \countUTFy = "F0
10259: \def\UTFviiiTmp{%
10260: \gdef~{%
10261: \ifpassthroughchars $%
10262: \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10263: \UTFviiiLoop
10264:
10265: \countUTFx = "F0
10266: \countUTFy = "F4
10267: \def\UTFviiiTmp{%
10268: \gdef~{%
10269: \ifpassthroughchars $%
10270: \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10271: }}%
10272: \UTFviiiLoop
10273: \endgroup
10274:
10275: \def\globallet{\global\let} % save some \expandafter's below
10276:
10277: % @U{xxxx} to produce U+xxxx, if we support it.
10278: \def\U#1{%
10279: \expandafter\ifx\csname uni:#1\endcsname \relax
10280: \iftxinativeunicodecapable
10281: % All Unicode characters can be used if native Unicode handling is
10282: % active. However, if the font does not have the glyph,
10283: % letters are missing.
10284: \begingroup
10285: \uccode`\.="#1\relax
10286: \uppercase{.}
10287: \endgroup
10288: \else
10289: \errhelp = \EMsimple
10290: \errmessage{Unicode character U+#1 not supported, sorry}%
10291: \fi
10292: \else
10293: \csname uni:#1\endcsname
10294: \fi
10295: }
10296:
10297: % These macros are used here to construct the name of a control
10298: % sequence to be defined.
10299: \def\UTFviiiTwoOctetsName#1#2{%
10300: \csname u8:#1\string #2\endcsname}%
10301: \def\UTFviiiThreeOctetsName#1#2#3{%
10302: \csname u8:#1\string #2\string #3\endcsname}%
10303: \def\UTFviiiFourOctetsName#1#2#3#4{%
10304: \csname u8:#1\string #2\string #3\string #4\endcsname}%
10305:
10306: % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10307: % provide a definition macro to replace a Unicode character;
10308: % this gets used by the @U command
10309: %
10310: \begingroup
10311: \catcode`\"=12
10312: \catcode`\<=12
10313: \catcode`\.=12
10314: \catcode`\,=12
10315: \catcode`\;=12
10316: \catcode`\!=12
10317: \catcode`\~=13
10318: \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10319: \countUTFz = "#1\relax
10320: \begingroup
10321: \parseXMLCharref
10322:
10323: % Give \u8:... its definition. The sequence of seven \expandafter's
10324: % expands after the \gdef three times, e.g.
10325: %
10326: % 1. \UTFviiTwoOctetsName B1 B2
10327: % 2. \csname u8:B1 \string B2 \endcsname
10328: % 3. \u8: B1 B2 (a single control sequence token)
10329: %
10330: \expandafter\expandafter
10331: \expandafter\expandafter
10332: \expandafter\expandafter
10333: \expandafter\gdef \UTFviiiTmp{#2}%
10334: %
10335: \expandafter\ifx\csname uni:#1\endcsname \relax \else
10336: \message{Internal error, already defined: #1}%
10337: \fi
10338: %
10339: % define an additional control sequence for this code point.
10340: \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10341: \endgroup}
10342: %
10343: % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10344: % to the corresponding UTF-8 sequence.
10345: \gdef\parseXMLCharref{%
1.5 ! snw 10346: \ifnum\countUTFz < "A0\relax
1.1 snw 10347: \errhelp = \EMsimple
1.5 ! snw 10348: \errmessage{Cannot define Unicode char value < 00A0}%
1.1 snw 10349: \else\ifnum\countUTFz < "800\relax
10350: \parseUTFviiiA,%
10351: \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10352: \else\ifnum\countUTFz < "10000\relax
10353: \parseUTFviiiA;%
10354: \parseUTFviiiA,%
10355: \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10356: \else
10357: \parseUTFviiiA;%
10358: \parseUTFviiiA,%
10359: \parseUTFviiiA!%
10360: \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10361: \fi\fi\fi
10362: }
10363:
10364: % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10365: % It must be a non-initial byte in the sequence.
10366: % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10367: % of the bytes.
10368: \gdef\parseUTFviiiA#1{%
10369: \countUTFx = \countUTFz
10370: \divide\countUTFz by 64
10371: \countUTFy = \countUTFz % Save to be the future value of \countUTFz.
10372: \multiply\countUTFz by 64
10373:
10374: % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract
10375: % in order to get the last five bits.
10376: \advance\countUTFx by -\countUTFz
10377:
10378: % Convert this to the byte in the UTF-8 sequence.
10379: \advance\countUTFx by 128
10380: \uccode `#1\countUTFx
10381: \countUTFz = \countUTFy}
10382:
10383: % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10384: % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10385: % sequence.
10386: % #2 is one of the \UTFviii*OctetsName macros.
10387: % #3 is always a full stop (.)
10388: % #4 is a template for the other bytes in the sequence. The values for these
10389: % bytes is substituted in here with \uppercase using the \uccode's.
10390: \gdef\parseUTFviiiB#1#2#3#4{%
10391: \advance\countUTFz by "#10\relax
10392: \uccode `#3\countUTFz
10393: \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10394: \endgroup
10395:
10396: % For native Unicode handling (XeTeX and LuaTeX),
10397: % provide a definition macro that sets a catcode to `other' non-globally
10398: %
10399: \def\DeclareUnicodeCharacterNativeOther#1#2{%
10400: \catcode"#1=\other
10401: }
10402:
10403: % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10404: % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10405: % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10406: % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10407: % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10408: %
10409: % Many of our renditions are less than wonderful, and all the missing
10410: % characters are available somewhere. Loading the necessary fonts
10411: % awaits user request. We can't truly support Unicode without
10412: % reimplementing everything that's been done in LaTeX for many years,
10413: % plus probably using luatex or xetex, and who knows what else.
10414: % We won't be doing that here in this simple file. But we can try to at
10415: % least make most of the characters not bomb out.
10416: %
10417: \def\unicodechardefs{%
10418: \DeclareUnicodeCharacter{00A0}{\tie}%
10419: \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10420: \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10421: \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10422: \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10423: \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10424: \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10425: \DeclareUnicodeCharacter{00A7}{\S}%
10426: \DeclareUnicodeCharacter{00A8}{\"{ }}%
10427: \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10428: \DeclareUnicodeCharacter{00AA}{\ordf}%
10429: \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10430: \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10431: \DeclareUnicodeCharacter{00AD}{\-}%
10432: \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10433: \DeclareUnicodeCharacter{00AF}{\={ }}%
10434: %
1.5 ! snw 10435: \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
1.1 snw 10436: \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10437: \DeclareUnicodeCharacter{00B2}{$^2$}%
10438: \DeclareUnicodeCharacter{00B3}{$^3$}%
10439: \DeclareUnicodeCharacter{00B4}{\'{ }}%
10440: \DeclareUnicodeCharacter{00B5}{$\mu$}%
10441: \DeclareUnicodeCharacter{00B6}{\P}%
10442: \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10443: \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10444: \DeclareUnicodeCharacter{00B9}{$^1$}%
10445: \DeclareUnicodeCharacter{00BA}{\ordm}%
10446: \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10447: \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10448: \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10449: \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10450: \DeclareUnicodeCharacter{00BF}{\questiondown}%
10451: %
10452: \DeclareUnicodeCharacter{00C0}{\`A}%
10453: \DeclareUnicodeCharacter{00C1}{\'A}%
10454: \DeclareUnicodeCharacter{00C2}{\^A}%
10455: \DeclareUnicodeCharacter{00C3}{\~A}%
10456: \DeclareUnicodeCharacter{00C4}{\"A}%
10457: \DeclareUnicodeCharacter{00C5}{\AA}%
10458: \DeclareUnicodeCharacter{00C6}{\AE}%
10459: \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10460: \DeclareUnicodeCharacter{00C8}{\`E}%
10461: \DeclareUnicodeCharacter{00C9}{\'E}%
10462: \DeclareUnicodeCharacter{00CA}{\^E}%
10463: \DeclareUnicodeCharacter{00CB}{\"E}%
10464: \DeclareUnicodeCharacter{00CC}{\`I}%
10465: \DeclareUnicodeCharacter{00CD}{\'I}%
10466: \DeclareUnicodeCharacter{00CE}{\^I}%
10467: \DeclareUnicodeCharacter{00CF}{\"I}%
10468: %
10469: \DeclareUnicodeCharacter{00D0}{\DH}%
10470: \DeclareUnicodeCharacter{00D1}{\~N}%
10471: \DeclareUnicodeCharacter{00D2}{\`O}%
10472: \DeclareUnicodeCharacter{00D3}{\'O}%
10473: \DeclareUnicodeCharacter{00D4}{\^O}%
10474: \DeclareUnicodeCharacter{00D5}{\~O}%
10475: \DeclareUnicodeCharacter{00D6}{\"O}%
10476: \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10477: \DeclareUnicodeCharacter{00D8}{\O}%
10478: \DeclareUnicodeCharacter{00D9}{\`U}%
10479: \DeclareUnicodeCharacter{00DA}{\'U}%
10480: \DeclareUnicodeCharacter{00DB}{\^U}%
10481: \DeclareUnicodeCharacter{00DC}{\"U}%
10482: \DeclareUnicodeCharacter{00DD}{\'Y}%
10483: \DeclareUnicodeCharacter{00DE}{\TH}%
10484: \DeclareUnicodeCharacter{00DF}{\ss}%
10485: %
10486: \DeclareUnicodeCharacter{00E0}{\`a}%
10487: \DeclareUnicodeCharacter{00E1}{\'a}%
10488: \DeclareUnicodeCharacter{00E2}{\^a}%
10489: \DeclareUnicodeCharacter{00E3}{\~a}%
10490: \DeclareUnicodeCharacter{00E4}{\"a}%
10491: \DeclareUnicodeCharacter{00E5}{\aa}%
10492: \DeclareUnicodeCharacter{00E6}{\ae}%
10493: \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10494: \DeclareUnicodeCharacter{00E8}{\`e}%
10495: \DeclareUnicodeCharacter{00E9}{\'e}%
10496: \DeclareUnicodeCharacter{00EA}{\^e}%
10497: \DeclareUnicodeCharacter{00EB}{\"e}%
10498: \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10499: \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10500: \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10501: \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10502: %
10503: \DeclareUnicodeCharacter{00F0}{\dh}%
10504: \DeclareUnicodeCharacter{00F1}{\~n}%
10505: \DeclareUnicodeCharacter{00F2}{\`o}%
10506: \DeclareUnicodeCharacter{00F3}{\'o}%
10507: \DeclareUnicodeCharacter{00F4}{\^o}%
10508: \DeclareUnicodeCharacter{00F5}{\~o}%
10509: \DeclareUnicodeCharacter{00F6}{\"o}%
10510: \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10511: \DeclareUnicodeCharacter{00F8}{\o}%
10512: \DeclareUnicodeCharacter{00F9}{\`u}%
10513: \DeclareUnicodeCharacter{00FA}{\'u}%
10514: \DeclareUnicodeCharacter{00FB}{\^u}%
10515: \DeclareUnicodeCharacter{00FC}{\"u}%
10516: \DeclareUnicodeCharacter{00FD}{\'y}%
10517: \DeclareUnicodeCharacter{00FE}{\th}%
10518: \DeclareUnicodeCharacter{00FF}{\"y}%
10519: %
10520: \DeclareUnicodeCharacter{0100}{\=A}%
10521: \DeclareUnicodeCharacter{0101}{\=a}%
10522: \DeclareUnicodeCharacter{0102}{\u{A}}%
10523: \DeclareUnicodeCharacter{0103}{\u{a}}%
10524: \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10525: \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10526: \DeclareUnicodeCharacter{0106}{\'C}%
10527: \DeclareUnicodeCharacter{0107}{\'c}%
10528: \DeclareUnicodeCharacter{0108}{\^C}%
10529: \DeclareUnicodeCharacter{0109}{\^c}%
10530: \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10531: \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10532: \DeclareUnicodeCharacter{010C}{\v{C}}%
10533: \DeclareUnicodeCharacter{010D}{\v{c}}%
10534: \DeclareUnicodeCharacter{010E}{\v{D}}%
10535: \DeclareUnicodeCharacter{010F}{d'}%
10536: %
10537: \DeclareUnicodeCharacter{0110}{\DH}%
10538: \DeclareUnicodeCharacter{0111}{\dh}%
10539: \DeclareUnicodeCharacter{0112}{\=E}%
10540: \DeclareUnicodeCharacter{0113}{\=e}%
10541: \DeclareUnicodeCharacter{0114}{\u{E}}%
10542: \DeclareUnicodeCharacter{0115}{\u{e}}%
10543: \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10544: \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10545: \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10546: \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10547: \DeclareUnicodeCharacter{011A}{\v{E}}%
10548: \DeclareUnicodeCharacter{011B}{\v{e}}%
10549: \DeclareUnicodeCharacter{011C}{\^G}%
10550: \DeclareUnicodeCharacter{011D}{\^g}%
10551: \DeclareUnicodeCharacter{011E}{\u{G}}%
10552: \DeclareUnicodeCharacter{011F}{\u{g}}%
10553: %
10554: \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10555: \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10556: \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10557: \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10558: \DeclareUnicodeCharacter{0124}{\^H}%
10559: \DeclareUnicodeCharacter{0125}{\^h}%
10560: \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10561: \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10562: \DeclareUnicodeCharacter{0128}{\~I}%
10563: \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10564: \DeclareUnicodeCharacter{012A}{\=I}%
10565: \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10566: \DeclareUnicodeCharacter{012C}{\u{I}}%
10567: \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10568: \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10569: \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10570: %
10571: \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10572: \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10573: \DeclareUnicodeCharacter{0132}{IJ}%
10574: \DeclareUnicodeCharacter{0133}{ij}%
10575: \DeclareUnicodeCharacter{0134}{\^J}%
10576: \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10577: \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10578: \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10579: \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10580: \DeclareUnicodeCharacter{0139}{\'L}%
10581: \DeclareUnicodeCharacter{013A}{\'l}%
10582: \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10583: \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10584: \DeclareUnicodeCharacter{013D}{L'}% should kern
10585: \DeclareUnicodeCharacter{013E}{l'}% should kern
10586: \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10587: %
10588: \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10589: \DeclareUnicodeCharacter{0141}{\L}%
10590: \DeclareUnicodeCharacter{0142}{\l}%
10591: \DeclareUnicodeCharacter{0143}{\'N}%
10592: \DeclareUnicodeCharacter{0144}{\'n}%
10593: \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10594: \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10595: \DeclareUnicodeCharacter{0147}{\v{N}}%
10596: \DeclareUnicodeCharacter{0148}{\v{n}}%
10597: \DeclareUnicodeCharacter{0149}{'n}%
10598: \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10599: \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10600: \DeclareUnicodeCharacter{014C}{\=O}%
10601: \DeclareUnicodeCharacter{014D}{\=o}%
10602: \DeclareUnicodeCharacter{014E}{\u{O}}%
10603: \DeclareUnicodeCharacter{014F}{\u{o}}%
10604: %
10605: \DeclareUnicodeCharacter{0150}{\H{O}}%
10606: \DeclareUnicodeCharacter{0151}{\H{o}}%
10607: \DeclareUnicodeCharacter{0152}{\OE}%
10608: \DeclareUnicodeCharacter{0153}{\oe}%
10609: \DeclareUnicodeCharacter{0154}{\'R}%
10610: \DeclareUnicodeCharacter{0155}{\'r}%
10611: \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10612: \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10613: \DeclareUnicodeCharacter{0158}{\v{R}}%
10614: \DeclareUnicodeCharacter{0159}{\v{r}}%
10615: \DeclareUnicodeCharacter{015A}{\'S}%
10616: \DeclareUnicodeCharacter{015B}{\'s}%
10617: \DeclareUnicodeCharacter{015C}{\^S}%
10618: \DeclareUnicodeCharacter{015D}{\^s}%
10619: \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10620: \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10621: %
10622: \DeclareUnicodeCharacter{0160}{\v{S}}%
10623: \DeclareUnicodeCharacter{0161}{\v{s}}%
10624: \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10625: \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10626: \DeclareUnicodeCharacter{0164}{\v{T}}%
10627: \DeclareUnicodeCharacter{0165}{\v{t}}%
10628: \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10629: \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10630: \DeclareUnicodeCharacter{0168}{\~U}%
10631: \DeclareUnicodeCharacter{0169}{\~u}%
10632: \DeclareUnicodeCharacter{016A}{\=U}%
10633: \DeclareUnicodeCharacter{016B}{\=u}%
10634: \DeclareUnicodeCharacter{016C}{\u{U}}%
10635: \DeclareUnicodeCharacter{016D}{\u{u}}%
10636: \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10637: \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10638: %
10639: \DeclareUnicodeCharacter{0170}{\H{U}}%
10640: \DeclareUnicodeCharacter{0171}{\H{u}}%
10641: \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10642: \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10643: \DeclareUnicodeCharacter{0174}{\^W}%
10644: \DeclareUnicodeCharacter{0175}{\^w}%
10645: \DeclareUnicodeCharacter{0176}{\^Y}%
10646: \DeclareUnicodeCharacter{0177}{\^y}%
10647: \DeclareUnicodeCharacter{0178}{\"Y}%
10648: \DeclareUnicodeCharacter{0179}{\'Z}%
10649: \DeclareUnicodeCharacter{017A}{\'z}%
10650: \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10651: \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10652: \DeclareUnicodeCharacter{017D}{\v{Z}}%
10653: \DeclareUnicodeCharacter{017E}{\v{z}}%
10654: \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10655: %
10656: \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10657: \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10658: \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10659: \DeclareUnicodeCharacter{01C7}{LJ}%
10660: \DeclareUnicodeCharacter{01C8}{Lj}%
10661: \DeclareUnicodeCharacter{01C9}{lj}%
10662: \DeclareUnicodeCharacter{01CA}{NJ}%
10663: \DeclareUnicodeCharacter{01CB}{Nj}%
10664: \DeclareUnicodeCharacter{01CC}{nj}%
10665: \DeclareUnicodeCharacter{01CD}{\v{A}}%
10666: \DeclareUnicodeCharacter{01CE}{\v{a}}%
10667: \DeclareUnicodeCharacter{01CF}{\v{I}}%
10668: %
10669: \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10670: \DeclareUnicodeCharacter{01D1}{\v{O}}%
10671: \DeclareUnicodeCharacter{01D2}{\v{o}}%
10672: \DeclareUnicodeCharacter{01D3}{\v{U}}%
10673: \DeclareUnicodeCharacter{01D4}{\v{u}}%
10674: %
10675: \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10676: \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10677: \DeclareUnicodeCharacter{01E6}{\v{G}}%
10678: \DeclareUnicodeCharacter{01E7}{\v{g}}%
10679: \DeclareUnicodeCharacter{01E8}{\v{K}}%
10680: \DeclareUnicodeCharacter{01E9}{\v{k}}%
10681: %
10682: \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10683: \DeclareUnicodeCharacter{01F1}{DZ}%
10684: \DeclareUnicodeCharacter{01F2}{Dz}%
10685: \DeclareUnicodeCharacter{01F3}{dz}%
10686: \DeclareUnicodeCharacter{01F4}{\'G}%
10687: \DeclareUnicodeCharacter{01F5}{\'g}%
10688: \DeclareUnicodeCharacter{01F8}{\`N}%
10689: \DeclareUnicodeCharacter{01F9}{\`n}%
10690: \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10691: \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10692: \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10693: \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10694: %
10695: \DeclareUnicodeCharacter{021E}{\v{H}}%
10696: \DeclareUnicodeCharacter{021F}{\v{h}}%
10697: %
10698: \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10699: \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10700: \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10701: \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10702: \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10703: \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10704: %
10705: \DeclareUnicodeCharacter{0232}{\=Y}%
10706: \DeclareUnicodeCharacter{0233}{\=y}%
10707: \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10708: %
10709: \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10710: %
10711: % Greek letters upper case
10712: \DeclareUnicodeCharacter{0391}{{\it A}}%
10713: \DeclareUnicodeCharacter{0392}{{\it B}}%
10714: \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10715: \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10716: \DeclareUnicodeCharacter{0395}{{\it E}}%
10717: \DeclareUnicodeCharacter{0396}{{\it Z}}%
10718: \DeclareUnicodeCharacter{0397}{{\it H}}%
10719: \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10720: \DeclareUnicodeCharacter{0399}{{\it I}}%
10721: \DeclareUnicodeCharacter{039A}{{\it K}}%
10722: \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10723: \DeclareUnicodeCharacter{039C}{{\it M}}%
10724: \DeclareUnicodeCharacter{039D}{{\it N}}%
10725: \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10726: \DeclareUnicodeCharacter{039F}{{\it O}}%
10727: \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10728: \DeclareUnicodeCharacter{03A1}{{\it P}}%
10729: %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10730: \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10731: \DeclareUnicodeCharacter{03A4}{{\it T}}%
10732: \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10733: \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10734: \DeclareUnicodeCharacter{03A7}{{\it X}}%
10735: \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10736: \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10737: %
10738: % Vowels with accents
10739: \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10740: \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10741: \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10742: \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10743: \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10744: \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10745: %
10746: % Standalone accent
10747: \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10748: %
10749: % Greek letters lower case
10750: \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10751: \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10752: \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10753: \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10754: \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10755: \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10756: \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10757: \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10758: \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10759: \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10760: \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10761: \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10762: \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10763: \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10764: \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10765: \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10766: \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10767: \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10768: \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10769: \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10770: \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10771: \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10772: \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10773: \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10774: \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10775: %
10776: % More Greek vowels with accents
10777: \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10778: \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10779: \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10780: \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10781: \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10782: %
10783: % Variant Greek letters
10784: \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10785: \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10786: \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10787: %
10788: \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10789: \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10790: \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10791: \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10792: \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10793: \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10794: \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10795: \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10796: \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10797: \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10798: \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10799: \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10800: %
10801: \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10802: \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10803: %
10804: \DeclareUnicodeCharacter{1E20}{\=G}%
10805: \DeclareUnicodeCharacter{1E21}{\=g}%
10806: \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10807: \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10808: \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10809: \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10810: \DeclareUnicodeCharacter{1E26}{\"H}%
10811: \DeclareUnicodeCharacter{1E27}{\"h}%
10812: %
10813: \DeclareUnicodeCharacter{1E30}{\'K}%
10814: \DeclareUnicodeCharacter{1E31}{\'k}%
10815: \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10816: \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10817: \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10818: \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10819: \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10820: \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10821: \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10822: \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10823: \DeclareUnicodeCharacter{1E3E}{\'M}%
10824: \DeclareUnicodeCharacter{1E3F}{\'m}%
10825: %
10826: \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10827: \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10828: \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10829: \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10830: \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10831: \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10832: \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10833: \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10834: \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10835: \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10836: %
10837: \DeclareUnicodeCharacter{1E54}{\'P}%
10838: \DeclareUnicodeCharacter{1E55}{\'p}%
10839: \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10840: \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10841: \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10842: \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10843: \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10844: \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10845: \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10846: \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10847: %
10848: \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10849: \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10850: \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10851: \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10852: \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10853: \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10854: \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10855: \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10856: \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10857: \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10858: %
10859: \DeclareUnicodeCharacter{1E7C}{\~V}%
10860: \DeclareUnicodeCharacter{1E7D}{\~v}%
10861: \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10862: \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10863: %
10864: \DeclareUnicodeCharacter{1E80}{\`W}%
10865: \DeclareUnicodeCharacter{1E81}{\`w}%
10866: \DeclareUnicodeCharacter{1E82}{\'W}%
10867: \DeclareUnicodeCharacter{1E83}{\'w}%
10868: \DeclareUnicodeCharacter{1E84}{\"W}%
10869: \DeclareUnicodeCharacter{1E85}{\"w}%
10870: \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10871: \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10872: \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10873: \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10874: \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10875: \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10876: \DeclareUnicodeCharacter{1E8C}{\"X}%
10877: \DeclareUnicodeCharacter{1E8D}{\"x}%
10878: \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10879: \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10880: %
10881: \DeclareUnicodeCharacter{1E90}{\^Z}%
10882: \DeclareUnicodeCharacter{1E91}{\^z}%
10883: \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10884: \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10885: \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10886: \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10887: \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10888: \DeclareUnicodeCharacter{1E97}{\"t}%
10889: \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10890: \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10891: %
10892: \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10893: \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10894: %
10895: \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10896: \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10897: \DeclareUnicodeCharacter{1EBC}{\~E}%
10898: \DeclareUnicodeCharacter{1EBD}{\~e}%
10899: %
10900: \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10901: \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10902: \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10903: \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10904: %
10905: \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10906: \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10907: %
10908: \DeclareUnicodeCharacter{1EF2}{\`Y}%
10909: \DeclareUnicodeCharacter{1EF3}{\`y}%
10910: \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10911: %
10912: \DeclareUnicodeCharacter{1EF8}{\~Y}%
10913: \DeclareUnicodeCharacter{1EF9}{\~y}%
10914: %
10915: % Punctuation
10916: \DeclareUnicodeCharacter{2013}{--}%
10917: \DeclareUnicodeCharacter{2014}{---}%
10918: \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10919: \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10920: \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10921: \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10922: \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10923: \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10924: \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10925: \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10926: \DeclareUnicodeCharacter{2022}{\bullet{}}%
10927: \DeclareUnicodeCharacter{202F}{\thinspace}%
10928: \DeclareUnicodeCharacter{2026}{\dots{}}%
10929: \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10930: \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10931: %
10932: \DeclareUnicodeCharacter{20AC}{\euro{}}%
10933: %
1.5 ! snw 10934: \DeclareUnicodeCharacter{2192}{\expansion{}}%
1.1 snw 10935: \DeclareUnicodeCharacter{21D2}{\result{}}%
10936: %
10937: % Mathematical symbols
10938: \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10939: \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10940: \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10941: \DeclareUnicodeCharacter{2212}{\minus{}}%
10942: \DeclareUnicodeCharacter{2217}{\ast}%
10943: \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10944: \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10945: \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10946: \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10947: \DeclareUnicodeCharacter{2261}{\equiv{}}%
10948: \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10949: \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10950: \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10951: \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10952: %
10953: \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10954: \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10955: \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10956: \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10957: \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10958: \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10959: \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10960: \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10961: \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10962: \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10963: \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10964: \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10965: \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10966: \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10967: \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10968: \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10969: \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10970: \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10971: \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10972: \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10973: \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10974: \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10975: \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10976: \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10977: \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10978: \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10979: \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10980: \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10981: \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10982: \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10983: \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10984: \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10985: \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10986: \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10987: \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10988: \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10989: \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10990: \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10991: \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10992: \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10993: \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10994: \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10995: \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10996: \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10997: \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10998: \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10999: \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11000: \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11001: \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11002: \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11003: \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11004: \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11005: \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11006: \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11007: \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11008: \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11009: \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11010: \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11011: \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11012: \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11013: \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11014: \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11015: \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11016: \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11017: \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11018: \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11019: \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11020: \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11021: \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11022: \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11023: \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11024: \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11025: \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11026: \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11027: \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11028: \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11029: \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11030: \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11031: \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11032: \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11033: \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11034: \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11035: \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11036: \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11037: \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11038: \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11039: \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11040: \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11041: \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11042: \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11043: \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11044: %
11045: \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11046: \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11047: \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11048: \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11049: \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11050: \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11051: \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11052: \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11053: \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11054: \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11055: \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11056: \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11057: \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11058: \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11059: \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11060: \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11061: \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11062: \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11063: \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11064: \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11065: \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11066: \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11067: \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11068: \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11069: \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11070: \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11071: \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11072: \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11073: \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11074: %
11075: \global\mathchardef\checkmark="1370% actually the square root sign
11076: \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11077: }% end of \unicodechardefs
11078:
11079: % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11080: % It makes the setting that replace UTF-8 byte sequence.
11081: \def\utfeightchardefs{%
11082: \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11083: \unicodechardefs
11084: }
11085:
11086: % Whether the active definitions of non-ASCII characters expand to
11087: % non-active tokens with the same character code. This is used to
11088: % write characters literally, instead of using active definitions for
11089: % printing the correct glyphs.
11090: \newif\ifpassthroughchars
11091: \passthroughcharsfalse
11092:
11093: % For native Unicode handling (XeTeX and LuaTeX),
11094: % provide a definition macro to replace/pass-through a Unicode character
11095: %
11096: \def\DeclareUnicodeCharacterNative#1#2{%
1.5 ! snw 11097: \catcode"#1=\active
! 11098: \def\dodeclareunicodecharacternative##1##2##3{%
1.1 snw 11099: \begingroup
1.5 ! snw 11100: \uccode`\~="##2\relax
! 11101: \uppercase{\gdef~}{%
! 11102: \ifpassthroughchars
! 11103: ##1%
! 11104: \else
! 11105: ##3%
! 11106: \fi
! 11107: }
1.1 snw 11108: \endgroup
1.5 ! snw 11109: }
! 11110: \begingroup
! 11111: \uccode`\.="#1\relax
! 11112: \uppercase{\def\UTFNativeTmp{.}}%
! 11113: \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
! 11114: \endgroup
1.1 snw 11115: }
11116:
11117: % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11118: % It activates the setting that replaces Unicode characters.
11119: \def\nativeunicodechardefs{%
11120: \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11121: \unicodechardefs
11122: }
11123:
11124: % For native Unicode handling (XeTeX and LuaTeX),
11125: % make the character token expand
11126: % to the sequences given in \unicodechardefs for printing.
11127: \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11128: \def\UTFAtUTmp{#2}
11129: \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11130: }
11131:
11132: % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11133: \def\nativeunicodechardefsatu{%
11134: \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11135: \unicodechardefs
11136: }
11137:
11138: % US-ASCII character definitions.
11139: \def\asciichardefs{% nothing need be done
11140: \relax
11141: }
11142:
1.5 ! snw 11143: % Define all Unicode characters we know about. This makes UTF-8 the default
! 11144: % input encoding and allows @U to work.
1.1 snw 11145: \iftxinativeunicodecapable
11146: \nativeunicodechardefsatu
11147: \else
11148: \utfeightchardefs
11149: \fi
11150:
11151: \message{formatting,}
11152:
11153: \newdimen\defaultparindent \defaultparindent = 15pt
11154:
11155: \chapheadingskip = 15pt plus 4pt minus 2pt
11156: \secheadingskip = 12pt plus 3pt minus 2pt
11157: \subsecheadingskip = 9pt plus 2pt minus 2pt
11158:
11159: % Prevent underfull vbox error messages.
11160: \vbadness = 10000
11161:
11162: % Don't be very finicky about underfull hboxes, either.
11163: \hbadness = 6666
11164:
11165: % Following George Bush, get rid of widows and orphans.
11166: \widowpenalty=10000
11167: \clubpenalty=10000
11168:
11169: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11170: % using an old version of TeX, don't do anything. We want the amount of
11171: % stretch added to depend on the line length, hence the dependence on
11172: % \hsize. We call this whenever the paper size is set.
11173: %
11174: \def\setemergencystretch{%
11175: \ifx\emergencystretch\thisisundefined
11176: % Allow us to assign to \emergencystretch anyway.
11177: \def\emergencystretch{\dimen0}%
11178: \else
11179: \emergencystretch = .15\hsize
11180: \fi
11181: }
11182:
11183: % Parameters in order: 1) textheight; 2) textwidth;
11184: % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11185: % 7) physical page height; 8) physical page width.
11186: %
11187: % We also call \setleading{\textleading}, so the caller should define
11188: % \textleading. The caller should also set \parskip.
11189: %
11190: \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11191: \voffset = #3\relax
11192: \topskip = #6\relax
11193: \splittopskip = \topskip
11194: %
11195: \vsize = #1\relax
11196: \advance\vsize by \topskip
1.5 ! snw 11197: \outervsize = \vsize
! 11198: \advance\outervsize by 2\topandbottommargin
1.1 snw 11199: \txipageheight = \vsize
11200: %
11201: \hsize = #2\relax
1.5 ! snw 11202: \outerhsize = \hsize
! 11203: \advance\outerhsize by 0.5in
1.1 snw 11204: \txipagewidth = \hsize
11205: %
11206: \normaloffset = #4\relax
11207: \bindingoffset = #5\relax
11208: %
11209: \ifpdf
11210: \pdfpageheight #7\relax
11211: \pdfpagewidth #8\relax
11212: % if we don't reset these, they will remain at "1 true in" of
11213: % whatever layout pdftex was dumped with.
11214: \pdfhorigin = 1 true in
11215: \pdfvorigin = 1 true in
11216: \else
11217: \ifx\XeTeXrevision\thisisundefined
11218: \special{papersize=#8,#7}%
11219: \else
11220: \pdfpageheight #7\relax
11221: \pdfpagewidth #8\relax
11222: % XeTeX does not have \pdfhorigin and \pdfvorigin.
11223: \fi
11224: \fi
11225: %
11226: \setleading{\textleading}
11227: %
11228: \parindent = \defaultparindent
11229: \setemergencystretch
11230: }
11231:
11232: % @letterpaper (the default).
11233: \def\letterpaper{{\globaldefs = 1
11234: \parskip = 3pt plus 2pt minus 1pt
11235: \textleading = 13.2pt
11236: %
11237: % If page is nothing but text, make it come out even.
11238: \internalpagesizes{607.2pt}{6in}% that's 46 lines
11239: {\voffset}{.25in}%
11240: {\bindingoffset}{36pt}%
11241: {11in}{8.5in}%
11242: }}
11243:
11244: % Use @smallbook to reset parameters for 7x9.25 trim size.
11245: \def\smallbook{{\globaldefs = 1
11246: \parskip = 2pt plus 1pt
11247: \textleading = 12pt
11248: %
11249: \internalpagesizes{7.5in}{5in}%
11250: {-.2in}{0in}%
11251: {\bindingoffset}{16pt}%
11252: {9.25in}{7in}%
11253: %
11254: \lispnarrowing = 0.3in
11255: \tolerance = 700
11256: \contentsrightmargin = 0pt
11257: \defbodyindent = .5cm
11258: }}
11259:
1.5 ! snw 11260: % Use @smallerbook to reset parameters for 6x9 trim size.
! 11261: % (Just testing, parameters still in flux.)
! 11262: \def\smallerbook{{\globaldefs = 1
! 11263: \parskip = 1.5pt plus 1pt
! 11264: \textleading = 12pt
! 11265: %
! 11266: \internalpagesizes{7.4in}{4.8in}%
! 11267: {-.2in}{-.4in}%
! 11268: {0pt}{14pt}%
! 11269: {9in}{6in}%
! 11270: %
! 11271: \lispnarrowing = 0.25in
! 11272: \tolerance = 700
! 11273: \contentsrightmargin = 0pt
! 11274: \defbodyindent = .4cm
! 11275: }}
! 11276:
1.1 snw 11277: % Use @afourpaper to print on European A4 paper.
11278: \def\afourpaper{{\globaldefs = 1
11279: \parskip = 3pt plus 2pt minus 1pt
11280: \textleading = 13.2pt
11281: %
11282: % Double-side printing via postscript on Laserjet 4050
11283: % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11284: % To change the settings for a different printer or situation, adjust
11285: % \normaloffset until the front-side and back-side texts align. Then
11286: % do the same for \bindingoffset. You can set these for testing in
11287: % your texinfo source file like this:
11288: % @tex
11289: % \global\normaloffset = -6mm
11290: % \global\bindingoffset = 10mm
11291: % @end tex
11292: \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11293: {\voffset}{\hoffset}%
11294: {\bindingoffset}{44pt}%
11295: {297mm}{210mm}%
11296: %
11297: \tolerance = 700
11298: \contentsrightmargin = 0pt
11299: \defbodyindent = 5mm
11300: }}
11301:
11302: % Use @afivepaper to print on European A5 paper.
11303: % From romildo@urano.iceb.ufop.br, 2 July 2000.
11304: % He also recommends making @example and @lisp be small.
11305: \def\afivepaper{{\globaldefs = 1
11306: \parskip = 2pt plus 1pt minus 0.1pt
11307: \textleading = 12.5pt
11308: %
11309: \internalpagesizes{160mm}{120mm}%
1.5 ! snw 11310: {\voffset}{\hoffset}%
1.1 snw 11311: {\bindingoffset}{8pt}%
11312: {210mm}{148mm}%
11313: %
11314: \lispnarrowing = 0.2in
11315: \tolerance = 800
11316: \contentsrightmargin = 0pt
11317: \defbodyindent = 2mm
11318: \tableindent = 12mm
11319: }}
11320:
11321: % A specific text layout, 24x15cm overall, intended for A4 paper.
11322: \def\afourlatex{{\globaldefs = 1
11323: \afourpaper
11324: \internalpagesizes{237mm}{150mm}%
11325: {\voffset}{4.6mm}%
11326: {\bindingoffset}{7mm}%
11327: {297mm}{210mm}%
11328: %
11329: % Must explicitly reset to 0 because we call \afourpaper.
11330: \globaldefs = 0
11331: }}
11332:
11333: % Use @afourwide to print on A4 paper in landscape format.
11334: \def\afourwide{{\globaldefs = 1
11335: \afourpaper
11336: \internalpagesizes{241mm}{165mm}%
11337: {\voffset}{-2.95mm}%
11338: {\bindingoffset}{7mm}%
11339: {297mm}{210mm}%
11340: \globaldefs = 0
11341: }}
11342:
11343: % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11344: % Perhaps we should allow setting the margins, \topskip, \parskip,
11345: % and/or leading, also. Or perhaps we should compute them somehow.
11346: %
11347: \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11348: \def\pagesizesyyy#1,#2,#3\finish{{%
11349: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11350: \globaldefs = 1
11351: %
11352: \parskip = 3pt plus 2pt minus 1pt
11353: \setleading{\textleading}%
11354: %
11355: \dimen0 = #1\relax
1.5 ! snw 11356: \advance\dimen0 by \voffset
! 11357: \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
1.1 snw 11358: %
11359: \dimen2 = \hsize
1.5 ! snw 11360: \advance\dimen2 by \normaloffset
! 11361: \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
1.1 snw 11362: %
11363: \internalpagesizes{#1}{\hsize}%
11364: {\voffset}{\normaloffset}%
11365: {\bindingoffset}{44pt}%
11366: {\dimen0}{\dimen2}%
11367: }}
11368:
11369: % Set default to letter.
11370: %
11371: \letterpaper
11372:
11373: % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11374: \hfuzz = 1pt
11375:
11376:
11377: \message{and turning on texinfo input format.}
11378:
11379: \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11380:
11381: % DEL is a comment character, in case @c does not suffice.
11382: \catcode`\^^? = 14
11383:
11384: % Define macros to output various characters with catcode for normal text.
11385: \catcode`\"=\other \def\normaldoublequote{"}
11386: \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11387: \catcode`\+=\other \def\normalplus{+}
11388: \catcode`\<=\other \def\normalless{<}
11389: \catcode`\>=\other \def\normalgreater{>}
11390: \catcode`\^=\other \def\normalcaret{^}
11391: \catcode`\_=\other \def\normalunderscore{_}
11392: \catcode`\|=\other \def\normalverticalbar{|}
11393: \catcode`\~=\other \def\normaltilde{~}
11394:
1.5 ! snw 11395: % This macro is used to make a character print one way in \tt
! 11396: % (where it can probably be output as-is), and another way in other fonts,
! 11397: % where something hairier probably needs to be done.
! 11398: %
! 11399: % #1 is what to print if we are indeed using \tt; #2 is what to print
! 11400: % otherwise. Since all the Computer Modern typewriter fonts have zero
! 11401: % interword stretch (and shrink), and it is reasonable to expect all
! 11402: % typewriter fonts to have this, we can check that font parameter.
! 11403: %
! 11404: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
! 11405:
! 11406: % Same as above, but check for italic font. Actually this also catches
! 11407: % non-italic slanted fonts since it is impossible to distinguish them from
! 11408: % italic fonts. But since this is only used by $ and it uses \sl anyway
! 11409: % this is not a problem.
! 11410: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
! 11411:
1.1 snw 11412: % Set catcodes for Texinfo file
11413:
11414: % Active characters for printing the wanted glyph.
11415: % Most of these we simply print from the \tt font, but for some, we can
11416: % use math or other variants that look better in normal text.
11417: %
11418: \catcode`\"=\active
11419: \def\activedoublequote{{\tt\char34}}
11420: \let"=\activedoublequote
11421: \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11422: \chardef\hatchar=`\^
11423: \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11424:
11425: \catcode`\_=\active
11426: \def_{\ifusingtt\normalunderscore\_}
11427: \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11428: \let\realunder=_
11429:
11430: \catcode`\|=\active \def|{{\tt\char124}}
11431:
11432: \chardef \less=`\<
11433: \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11434: \chardef \gtr=`\>
11435: \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11436: \catcode`\+=\active \def+{{\tt \char 43}}
11437: \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11438: \catcode`\-=\active \let-=\normaldash
11439:
11440:
11441: % used for headline/footline in the output routine, in case the page
11442: % breaks in the middle of an @tex block.
11443: \def\texinfochars{%
11444: \let< = \activeless
11445: \let> = \activegtr
11446: \let~ = \activetilde
11447: \let^ = \activehat
1.5 ! snw 11448: \markupsetuplqdefault \markupsetuprqdefault
1.1 snw 11449: \let\b = \strong
11450: \let\i = \smartitalic
11451: % in principle, all other definitions in \tex have to be undone too.
11452: }
11453:
11454: % Used sometimes to turn off (effectively) the active characters even after
11455: % parsing them.
11456: \def\turnoffactive{%
1.5 ! snw 11457: \normalturnoffactive
1.1 snw 11458: \otherbackslash
11459: }
11460:
1.5 ! snw 11461: \catcode`\@=0
1.1 snw 11462:
11463: % \backslashcurfont outputs one backslash character in current font,
11464: % as in \char`\\.
11465: \global\chardef\backslashcurfont=`\\
11466:
1.5 ! snw 11467: % \realbackslash is an actual character `\' with catcode other.
! 11468: {\catcode`\\=\other @gdef@realbackslash{\}}
! 11469:
! 11470: % In Texinfo, backslash is an active character; it prints the backslash
! 11471: % in fixed width font.
! 11472: \catcode`\\=\active % @ for escape char from now on.
! 11473:
1.1 snw 11474: % Print a typewriter backslash. For math mode, we can't simply use
11475: % \backslashcurfont: the story here is that in math mode, the \char
11476: % of \backslashcurfont ends up printing the roman \ from the math symbol
11477: % font (because \char in math mode uses the \mathcode, and plain.tex
11478: % sets \mathcode`\\="026E). Hence we use an explicit \mathchar,
11479: % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11480: % ignored family value; char position "5C). We can't use " for the
11481: % usual hex value because it has already been made active.
11482:
1.5 ! snw 11483: @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
! 11484: @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
1.3 snw 11485:
1.5 ! snw 11486: % \otherbackslash defines an active \ to be a literal `\' character with
! 11487: % catcode other.
! 11488: @gdef@otherbackslash{@let\=@realbackslash}
! 11489:
! 11490: % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
! 11491: % the literal character `\'.
! 11492: %
! 11493: {@catcode`- = @active
! 11494: @gdef@normalturnoffactive{%
! 11495: @passthroughcharstrue
! 11496: @let-=@normaldash
! 11497: @let"=@normaldoublequote
! 11498: @let$=@normaldollar %$ font-lock fix
! 11499: @let+=@normalplus
! 11500: @let<=@normalless
! 11501: @let>=@normalgreater
! 11502: @let^=@normalcaret
! 11503: @let_=@normalunderscore
! 11504: @let|=@normalverticalbar
! 11505: @let~=@normaltilde
! 11506: @let\=@ttbackslash
! 11507: @markupsetuplqdefault
! 11508: @markupsetuprqdefault
! 11509: @unsepspaces
! 11510: }
! 11511: }
! 11512:
! 11513: % If a .fmt file is being used, characters that might appear in a file
! 11514: % name cannot be active until we have parsed the command line.
! 11515: % So turn them off again, and have @fixbackslash turn them back on.
! 11516: @catcode`+=@other @catcode`@_=@other
! 11517:
! 11518: % \enablebackslashhack - allow file to begin `\input texinfo'
! 11519: %
! 11520: % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
! 11521: % That is what \eatinput is for; after that, the `\' should revert to printing
! 11522: % a backslash.
! 11523: % If the file did not have a `\input texinfo', then it is turned off after
! 11524: % the first line; otherwise the first `\' in the file would cause an error.
! 11525: % This is used on the very last line of this file, texinfo.tex.
! 11526: % We also use @c to call @fixbackslash, in case ends of lines are hidden.
! 11527: {
! 11528: @catcode`@^=7
! 11529: @catcode`@^^M=13@gdef@enablebackslashhack{%
! 11530: @global@let\ = @eatinput%
! 11531: @catcode`@^^M=13%
! 11532: @def@c{@fixbackslash@c}%
! 11533: % Definition for the newline at the end of this file.
! 11534: @def ^^M{@let^^M@secondlinenl}%
! 11535: % Definition for a newline in the main Texinfo file.
! 11536: @gdef @secondlinenl{@fixbackslash}%
! 11537: % In case the first line has a whole-line command on it
! 11538: @let@originalparsearg@parsearg
! 11539: @def@parsearg{@fixbackslash@originalparsearg}
1.1 snw 11540: }}
11541:
1.5 ! snw 11542: {@catcode`@^=7 @catcode`@^^M=13%
! 11543: @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
1.1 snw 11544:
11545: % Emergency active definition of newline, in case an active newline token
11546: % appears by mistake.
1.5 ! snw 11547: {@catcode`@^=7 @catcode13=13%
! 11548: @gdef@enableemergencynewline{%
! 11549: @gdef^^M{%
! 11550: @par%
! 11551: %<warning: active newline>@par%
1.1 snw 11552: }}}
11553:
11554:
1.5 ! snw 11555: @gdef@fixbackslash{%
! 11556: @ifx\@eatinput @let\ = @ttbackslash @fi
! 11557: @catcode13=5 % regular end of line
! 11558: @enableemergencynewline
! 11559: @let@c=@comment
! 11560: @let@parsearg@originalparsearg
1.1 snw 11561: % Also turn back on active characters that might appear in the input
11562: % file name, in case not using a pre-dumped format.
1.5 ! snw 11563: @catcode`+=@active
! 11564: @catcode`@_=@active
1.1 snw 11565: %
1.5 ! snw 11566: % If texinfo.cnf is present on the system, read it.
! 11567: % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets
! 11568: % called at the beginning of every Texinfo file. Not opening texinfo.cnf
! 11569: % directly in this file, texinfo.tex, makes it possible to make a format
! 11570: % file for Texinfo.
! 11571: %
! 11572: @openin 1 texinfo.cnf
! 11573: @ifeof 1 @else @input texinfo.cnf @fi
! 11574: @closein 1
1.1 snw 11575: }
11576:
11577:
11578: % Say @foo, not \foo, in error messages.
11579: @escapechar = `@@
11580:
1.5 ! snw 11581: % These (along with & and #) are made active for url-breaking, so need
! 11582: % active definitions as the normal characters.
! 11583: @def@normaldot{.}
! 11584: @def@normalquest{?}
! 11585: @def@normalslash{/}
! 11586:
1.1 snw 11587: % These look ok in all fonts, so just make them not special.
11588: % @hashchar{} gets its own user-level command, because of #line.
11589: @catcode`@& = @other @def@normalamp{&}
11590: @catcode`@# = @other @def@normalhash{#}
11591: @catcode`@% = @other @def@normalpercent{%}
11592:
11593: @let @hashchar = @normalhash
11594:
11595: @c Finally, make ` and ' active, so that txicodequoteundirected and
11596: @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
11597: @c don't make ` and ' active, @code will not get them as active chars.
11598: @c Do this last of all since we use ` in the previous @catcode assignments.
11599: @catcode`@'=@active
11600: @catcode`@`=@active
1.5 ! snw 11601: @markupsetuplqdefault
! 11602: @markupsetuprqdefault
1.1 snw 11603:
11604: @c Local variables:
1.5 ! snw 11605: @c eval: (add-hook 'before-save-hook 'time-stamp)
! 11606: @c page-delimiter: "^\\\\message\\|emacs-page"
! 11607: @c time-stamp-start: "def\\\\texinfoversion{"
! 11608: @c time-stamp-format: "%:y-%02m-%02d.%02H"
! 11609: @c time-stamp-end: "}"
1.1 snw 11610: @c End:
11611:
1.5 ! snw 11612: @c vim:sw=2:
! 11613:
! 11614: @enablebackslashhack
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>