]>
Commit | Line | Data |
---|---|---|
2eb45444 | 1 | % texinfo.tex -- TeX macros to handle Texinfo files. |
d667195c UD |
2 | % |
3 | % Load plain if necessary, i.e., if running under initex. | |
4 | \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi | |
5 | % | |
7f7dd1d3 | 6 | \def\texinfoversion{2016-09-18.18} |
2eb45444 | 7 | % |
0f8bbd69 | 8 | % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, |
c94f48d7 | 9 | % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
084e7d57 JM |
10 | % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
11 | % Free Software Foundation, Inc. | |
2eb45444 | 12 | % |
c94f48d7 | 13 | % This texinfo.tex file is free software: you can redistribute it and/or |
2eb45444 | 14 | % modify it under the terms of the GNU General Public License as |
c94f48d7 AJ |
15 | % published by the Free Software Foundation, either version 3 of the |
16 | % License, or (at your option) any later version. | |
2eb45444 UD |
17 | % |
18 | % This texinfo.tex file is distributed in the hope that it will be | |
19 | % useful, but WITHOUT ANY WARRANTY; without even the implied warranty | |
20 | % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | % General Public License for more details. | |
22 | % | |
23 | % You should have received a copy of the GNU General Public License | |
c94f48d7 | 24 | % along with this program. If not, see <http://www.gnu.org/licenses/>. |
2eb45444 | 25 | % |
82d5ce1d UD |
26 | % As a special exception, when this file is read by TeX when processing |
27 | % a Texinfo source document, you may use the result without | |
8fcb833a JM |
28 | % restriction. This Exception is an additional permission under section 7 |
29 | % of the GNU General Public License, version 3 ("GPLv3"). | |
2eb45444 UD |
30 | % |
31 | % Please try the latest version of texinfo.tex before submitting bug | |
32 | % reports; you can get the latest version from: | |
8fcb833a JM |
33 | % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or |
34 | % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or | |
35 | % http://www.gnu.org/software/texinfo/ (the Texinfo home page) | |
82d5ce1d | 36 | % The texinfo.tex in any given distribution could well be out |
0c2b5752 | 37 | % of date, so if that's what you're using, please check. |
7158eae4 | 38 | % |
407dc7a0 UD |
39 | % Send bug reports to bug-texinfo@gnu.org. Please include including a |
40 | % complete document in each bug report with which we can reproduce the | |
41 | % problem. Patches are, of course, greatly appreciated. | |
b710a6e2 | 42 | % |
40c0dc53 | 43 | % To process a Texinfo manual with TeX, it's most reliable to use the |
407dc7a0 UD |
44 | % texi2dvi shell script that comes with the distribution. For a simple |
45 | % manual foo.texi, however, you can get away with this: | |
40c0dc53 UD |
46 | % tex foo.texi |
47 | % texindex foo.?? | |
48 | % tex foo.texi | |
49 | % tex foo.texi | |
27692f89 | 50 | % dvips foo.dvi -o # or whatever; this makes foo.ps. |
7ed7ad59 | 51 | % The extra TeX runs get the cross-reference information correct. |
40c0dc53 UD |
52 | % Sometimes one run after texindex suffices, and sometimes you need more |
53 | % than two; texi2dvi does it as many times as necessary. | |
7158eae4 | 54 | % |
e0f86659 UD |
55 | % It is possible to adapt texinfo.tex for other languages, to some |
56 | % extent. You can get the existing language-specific files from the | |
57 | % full Texinfo distribution. | |
82d5ce1d UD |
58 | % |
59 | % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. | |
60 | ||
9e9f9cc2 | 61 | |
1e02536f | 62 | \message{Loading texinfo [version \texinfoversion]:} |
9e9f9cc2 KB |
63 | |
64 | % If in a .fmt file, print the version number | |
65 | % and turn on active characters that we couldn't do earlier because | |
66 | % they might have appeared in the input file name. | |
1e02536f | 67 | \everyjob{\message{[Texinfo version \texinfoversion]}% |
9e9f9cc2 KB |
68 | \catcode`+=\active \catcode`\_=\active} |
69 | ||
7f7dd1d3 JM |
70 | % LaTeX's \typeout. This ensures that the messages it is used for |
71 | % are identical in format to the corresponding ones from latex/pdflatex. | |
72 | \def\typeout{\immediate\write17}% | |
73 | ||
2f5b1124 UD |
74 | \chardef\other=12 |
75 | ||
7158eae4 | 76 | % We never want plain's \outer definition of \+ in Texinfo. |
2f5b1124 UD |
77 | % For @tex, we can use \tabalign. |
78 | \let\+ = \relax | |
79 | ||
7158eae4 | 80 | % Save some plain tex macros whose names we will redefine. |
9e9f9cc2 | 81 | \let\ptexb=\b |
359a1d0b | 82 | \let\ptexbullet=\bullet |
9e9f9cc2 | 83 | \let\ptexc=\c |
359a1d0b KB |
84 | \let\ptexcomma=\, |
85 | \let\ptexdot=\. | |
86 | \let\ptexdots=\dots | |
87 | \let\ptexend=\end | |
2eb45444 UD |
88 | \let\ptexequiv=\equiv |
89 | \let\ptexexclam=\! | |
82d5ce1d | 90 | \let\ptexfootnote=\footnote |
2f5b1124 UD |
91 | \let\ptexgtr=> |
92 | \let\ptexhat=^ | |
9e9f9cc2 | 93 | \let\ptexi=\i |
7158eae4 | 94 | \let\ptexindent=\indent |
82d5ce1d | 95 | \let\ptexinsert=\insert |
359a1d0b | 96 | \let\ptexlbrace=\{ |
2f5b1124 | 97 | \let\ptexless=< |
82d5ce1d UD |
98 | \let\ptexnewwrite\newwrite |
99 | \let\ptexnoindent=\noindent | |
2f5b1124 | 100 | \let\ptexplus=+ |
0f8bbd69 | 101 | \let\ptexraggedright=\raggedright |
359a1d0b | 102 | \let\ptexrbrace=\} |
7158eae4 | 103 | \let\ptexslash=\/ |
084e7d57 | 104 | \let\ptexsp=\sp |
359a1d0b | 105 | \let\ptexstar=\* |
084e7d57 | 106 | \let\ptexsup=\sup |
9e9f9cc2 | 107 | \let\ptext=\t |
0f8bbd69 JM |
108 | \let\ptextop=\top |
109 | {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode | |
9e9f9cc2 | 110 | |
9e9f9cc2 KB |
111 | % If this character appears in an error message or help string, it |
112 | % starts a new line in the output. | |
113 | \newlinechar = `^^J | |
114 | ||
82d5ce1d UD |
115 | % Use TeX 3.0's \inputlineno to get the line number, for better error |
116 | % messages, but if we're using an old version of TeX, don't do anything. | |
117 | % | |
118 | \ifx\inputlineno\thisisundefined | |
119 | \let\linenumber = \empty % Pre-3.0. | |
120 | \else | |
121 | \def\linenumber{l.\the\inputlineno:\space} | |
122 | \fi | |
123 | ||
f962d792 | 124 | % Set up fixed words for English if not already set. |
407dc7a0 | 125 | \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi |
b710a6e2 | 126 | \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi |
0f8bbd69 | 127 | \ifx\putworderror\undefined \gdef\putworderror{error}\fi |
b710a6e2 | 128 | \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi |
13632cfc | 129 | \ifx\putwordin\undefined \gdef\putwordin{in}\fi |
0f8bbd69 JM |
130 | \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi |
131 | \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi | |
b710a6e2 | 132 | \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi |
13632cfc | 133 | \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi |
b710a6e2 | 134 | \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi |
407dc7a0 UD |
135 | \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi |
136 | \ifx\putwordof\undefined \gdef\putwordof{of}\fi | |
b710a6e2 UD |
137 | \ifx\putwordon\undefined \gdef\putwordon{on}\fi |
138 | \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi | |
139 | \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi | |
140 | \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi | |
141 | \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi | |
142 | \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi | |
407dc7a0 UD |
143 | \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi |
144 | \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi | |
b710a6e2 UD |
145 | % |
146 | \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi | |
147 | \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi | |
148 | \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi | |
149 | \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi | |
407dc7a0 | 150 | \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi |
b710a6e2 UD |
151 | \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi |
152 | \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi | |
153 | \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi | |
154 | \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi | |
155 | \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi | |
156 | \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi | |
157 | \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi | |
158 | % | |
407dc7a0 UD |
159 | \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi |
160 | \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi | |
407dc7a0 UD |
161 | \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi |
162 | \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi | |
407dc7a0 | 163 | \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi |
9e9f9cc2 | 164 | |
084e7d57 JM |
165 | % Give the space character the catcode for a space. |
166 | \def\spaceisspace{\catcode`\ =10\relax} | |
9251c568 | 167 | |
9251c568 | 168 | \chardef\dashChar = `\- |
0f8bbd69 | 169 | \chardef\slashChar = `\/ |
a334319f | 170 | \chardef\underChar = `\_ |
0ecb606c | 171 | |
9e9f9cc2 KB |
172 | % Ignore a token. |
173 | % | |
174 | \def\gobble#1{} | |
175 | ||
82d5ce1d UD |
176 | % The following is used inside several \edef's. |
177 | \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} | |
2f5b1124 UD |
178 | |
179 | % Hyphenation fixes. | |
82d5ce1d UD |
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 | } | |
9e9f9cc2 | 190 | |
9e9f9cc2 KB |
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, | |
2f5b1124 UD |
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. | |
9e9f9cc2 KB |
196 | % |
197 | \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% | |
2f5b1124 UD |
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 | |
0f8bbd69 | 207 | \ifx\eTeXversion\thisisundefined\else % etex gives us more logging |
2f5b1124 UD |
208 | \tracingscantokens1 |
209 | \tracingifs1 | |
210 | \tracinggroups1 | |
211 | \tracingnesting2 | |
212 | \tracingassigns1 | |
213 | \fi | |
214 | \tracingcommands3 % 3 gives us more in etex | |
82d5ce1d | 215 | \errorcontextlines16 |
61027f30 | 216 | }% |
9e9f9cc2 | 217 | |
0f8bbd69 JM |
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 | ||
be1152ca UD |
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. | |
7158eae4 | 227 | % |
be1152ca UD |
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 | ||
084e7d57 JM |
235 | %\f 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 | ||
779ae82e | 244 | % Do @cropmarks to get crop marks. |
b710a6e2 | 245 | % |
779ae82e UD |
246 | \newif\ifcropmarks |
247 | \let\cropmarks = \cropmarkstrue | |
9e9f9cc2 | 248 | % |
779ae82e UD |
249 | % Dimensions to add cropmarks at corners. |
250 | % Added by P. A. MacKay, 12 Nov. 1986 | |
9e9f9cc2 | 251 | % |
0c2b5752 UD |
252 | \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines |
253 | \newdimen\cornerlong \cornerlong=1pc | |
254 | \newdimen\cornerthick \cornerthick=.3pt | |
255 | \newdimen\topandbottommargin \topandbottommargin=.75in | |
9e9f9cc2 | 256 | |
c94f48d7 AJ |
257 | % Output a mark which sets \thischapter, \thissection and \thiscolor. |
258 | % We dump everything together because we only have one kind of mark. | |
259 | % This works because we only use \botmark / \topmark, not \firstmark. | |
260 | % | |
261 | % A mark contains a subexpression of the \ifcase ... \fi construct. | |
262 | % \get*marks macros below extract the needed part using \ifcase. | |
263 | % | |
264 | % Another complication is to let the user choose whether \thischapter | |
265 | % (\thissection) refers to the chapter (section) in effect at the top | |
084e7d57 JM |
266 | % of a page, or that at the bottom of a page. |
267 | ||
268 | % \domark is called twice inside \chapmacro, to add one | |
269 | % mark before the section break, and one after. | |
270 | % In the second call \prevchapterdefs is the same as \lastchapterdefs, | |
271 | % and \prevsectiondefs is the same as \lastsectiondefs. | |
272 | % Then if the page is not broken at the mark, some of the previous | |
273 | % section appears on the page, and we can get the name of this section | |
274 | % from \firstmark for @everyheadingmarks top. | |
275 | % @everyheadingmarks bottom uses \botmark. | |
276 | % | |
277 | % See page 260 of The TeXbook. | |
c94f48d7 AJ |
278 | \def\domark{% |
279 | \toks0=\expandafter{\lastchapterdefs}% | |
280 | \toks2=\expandafter{\lastsectiondefs}% | |
281 | \toks4=\expandafter{\prevchapterdefs}% | |
282 | \toks6=\expandafter{\prevsectiondefs}% | |
283 | \toks8=\expandafter{\lastcolordefs}% | |
284 | \mark{% | |
084e7d57 JM |
285 | \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top |
286 | \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom | |
21fea2e2 | 287 | \noexpand\else \the\toks8 % 2: color marks |
c94f48d7 AJ |
288 | }% |
289 | } | |
084e7d57 JM |
290 | |
291 | % \gettopheadingmarks, \getbottomheadingmarks, | |
292 | % \getcolormarks - extract needed part of mark. | |
293 | % | |
c94f48d7 AJ |
294 | % \topmark doesn't work for the very first chapter (after the title |
295 | % page or the contents), so we use \firstmark there -- this gets us | |
296 | % the mark with the chapter defs, unless the user sneaks in, e.g., | |
297 | % @setcolor (or @url, or @link, etc.) between @contents and the very | |
298 | % first @chapter. | |
299 | \def\gettopheadingmarks{% | |
300 | \ifcase0\topmark\fi | |
301 | \ifx\thischapter\empty \ifcase0\firstmark\fi \fi | |
302 | } | |
303 | \def\getbottomheadingmarks{\ifcase1\botmark\fi} | |
304 | \def\getcolormarks{\ifcase2\topmark\fi} | |
305 | ||
306 | % Avoid "undefined control sequence" errors. | |
307 | \def\lastchapterdefs{} | |
308 | \def\lastsectiondefs{} | |
084e7d57 | 309 | \def\lastsection{} |
c94f48d7 AJ |
310 | \def\prevchapterdefs{} |
311 | \def\prevsectiondefs{} | |
312 | \def\lastcolordefs{} | |
313 | ||
084e7d57 JM |
314 | % Margin to add to right of even pages, to left of odd pages. |
315 | \newdimen\bindingoffset | |
316 | \newdimen\normaloffset | |
7f7dd1d3 | 317 | \newdimen\txipagewidth \newdimen\txipageheight |
084e7d57 | 318 | |
f5311448 | 319 | % Main output routine. |
084e7d57 | 320 | % |
f5311448 KB |
321 | \chardef\PAGE = 255 |
322 | \output = {\onepageout{\pagecontents\PAGE}} | |
323 | ||
779ae82e UD |
324 | \newbox\headlinebox |
325 | \newbox\footlinebox | |
f5311448 | 326 | |
084e7d57 JM |
327 | % \onepageout takes a vbox as an argument. |
328 | % \shipout a vbox for a single page, adding an optional header, footer, | |
329 | % cropmarks, and footnote. This also causes index entries for this page | |
330 | % to be written to the auxiliary files. | |
331 | % | |
359a1d0b | 332 | \def\onepageout#1{% |
51702635 | 333 | \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi |
779ae82e | 334 | % |
359a1d0b KB |
335 | \ifodd\pageno \advance\hoffset by \bindingoffset |
336 | \else \advance\hoffset by -\bindingoffset\fi | |
f5311448 | 337 | % |
084e7d57 | 338 | % Common context changes for both heading and footing. |
f5311448 KB |
339 | % Do this outside of the \shipout so @code etc. will be expanded in |
340 | % the headline as they should be, not taken literally (outputting ''code). | |
7f7dd1d3 | 341 | \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars} |
21fea2e2 | 342 | % |
084e7d57 JM |
343 | % Retrieve the information for the headings from the marks in the page, |
344 | % and call Plain TeX's \makeheadline and \makefootline, which use the | |
345 | % values in \headline and \footline. | |
346 | % | |
347 | % This is used to check if we are on the first page of a chapter. | |
348 | \ifcase1\topmark\fi | |
349 | \let\prevchaptername\thischaptername | |
350 | \ifcase0\firstmark\fi | |
351 | \let\curchaptername\thischaptername | |
21fea2e2 | 352 | % |
084e7d57 | 353 | \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi |
c94f48d7 | 354 | \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi |
084e7d57 JM |
355 | % |
356 | \ifx\curchaptername\prevchaptername | |
357 | \let\thischapterheading\thischapter | |
358 | \else | |
359 | % \thischapterheading is the same as \thischapter except it is blank | |
360 | % for the first page of a chapter. This is to prevent the chapter name | |
361 | % being shown twice. | |
362 | \def\thischapterheading{}% | |
363 | \fi | |
364 | % | |
365 | \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}% | |
21fea2e2 | 366 | \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}% |
f5311448 | 367 | % |
359a1d0b | 368 | {% |
084e7d57 | 369 | % Set context for writing to auxiliary files like index files. |
f5311448 KB |
370 | % Have to do this stuff outside the \shipout because we want it to |
371 | % take effect in \write's, yet the group defined by the \vbox ends | |
372 | % before the \shipout runs. | |
373 | % | |
23a01afe KB |
374 | \indexdummies % don't expand commands in the output. |
375 | \normalturnoffactive % \ in index entries must not stay \, e.g., if | |
9251c568 AJ |
376 | % the page break happens to be in the middle of an example. |
377 | % We don't want .vr (or whatever) entries like this: | |
084e7d57 | 378 | % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}} |
9251c568 | 379 | % "\acronym" won't work when it's read back in; |
0f8bbd69 | 380 | % it needs to be |
084e7d57 | 381 | % {\code {{\backslashcurfont }acronym} |
359a1d0b | 382 | \shipout\vbox{% |
3bc88c40 | 383 | % Do this early so pdf references go to the beginning of the page. |
82d5ce1d | 384 | \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi |
3bc88c40 | 385 | % |
51702635 UD |
386 | \ifcropmarks \vbox to \outervsize\bgroup |
387 | \hsize = \outerhsize | |
d667195c UD |
388 | \vskip-\topandbottommargin |
389 | \vtop to0pt{% | |
390 | \line{\ewtop\hfil\ewtop}% | |
391 | \nointerlineskip | |
392 | \line{% | |
393 | \vbox{\moveleft\cornerthick\nstop}% | |
394 | \hfill | |
395 | \vbox{\moveright\cornerthick\nstop}% | |
396 | }% | |
397 | \vss}% | |
51702635 UD |
398 | \vskip\topandbottommargin |
399 | \line\bgroup | |
400 | \hfil % center the page within the outer (page) hsize. | |
401 | \ifodd\pageno\hskip\bindingoffset\fi | |
402 | \vbox\bgroup | |
779ae82e UD |
403 | \fi |
404 | % | |
f5311448 | 405 | \unvbox\headlinebox |
359a1d0b | 406 | \pagebody{#1}% |
d705269e UD |
407 | \ifdim\ht\footlinebox > 0pt |
408 | % Only leave this space if the footline is nonempty. | |
9251c568 | 409 | % (We lessened \vsize for it in \oddfootingyyy.) |
d705269e | 410 | % The \baselineskip=24pt in plain's \makefootline has no effect. |
9251c568 | 411 | \vskip 24pt |
d705269e UD |
412 | \unvbox\footlinebox |
413 | \fi | |
779ae82e UD |
414 | % |
415 | \ifcropmarks | |
51702635 UD |
416 | \egroup % end of \vbox\bgroup |
417 | \hfil\egroup % end of (centering) \line\bgroup | |
418 | \vskip\topandbottommargin plus1fill minus1fill | |
419 | \boxmaxdepth = \cornerthick | |
d667195c UD |
420 | \vbox to0pt{\vss |
421 | \line{% | |
422 | \vbox{\moveleft\cornerthick\nsbot}% | |
423 | \hfill | |
424 | \vbox{\moveright\cornerthick\nsbot}% | |
425 | }% | |
426 | \nointerlineskip | |
427 | \line{\ewbot\hfil\ewbot}% | |
51702635 | 428 | }% |
51702635 | 429 | \egroup % \vbox from first cropmarks clause |
779ae82e | 430 | \fi |
51702635 | 431 | }% end of \shipout\vbox |
9251c568 | 432 | }% end of group with \indexdummies |
359a1d0b KB |
433 | \advancepageno |
434 | \ifnum\outputpenalty>-20000 \else\dosupereject\fi | |
435 | } | |
9e9f9cc2 | 436 | |
9e9f9cc2 KB |
437 | \newinsert\margin \dimen\margin=\maxdimen |
438 | ||
084e7d57 | 439 | % Main part of page, including any footnotes |
7f7dd1d3 | 440 | \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}} |
9e9f9cc2 KB |
441 | {\catcode`\@ =11 |
442 | \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi | |
443 | % marginal hacks, juha@viisa.uucp (Juha Takala) | |
444 | \ifvoid\margin\else % marginal info is present | |
445 | \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi | |
c94f48d7 | 446 | \dimen@=\dp#1\relax \unvbox#1\relax |
9e9f9cc2 KB |
447 | \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi |
448 | \ifr@ggedbottom \kern-\dimen@ \vfil \fi} | |
449 | } | |
450 | ||
9e9f9cc2 KB |
451 | % Here are the rules for the cropmarks. Note that they are |
452 | % offset so that the space between them is truly \outerhsize or \outervsize | |
453 | % (P. A. MacKay, 12 November, 1986) | |
454 | % | |
455 | \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} | |
456 | \def\nstop{\vbox | |
457 | {\hrule height\cornerthick depth\cornerlong width\cornerthick}} | |
458 | \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} | |
459 | \def\nsbot{\vbox | |
460 | {\hrule height\cornerlong depth\cornerthick width\cornerthick}} | |
461 | ||
084e7d57 JM |
462 | |
463 | % Argument parsing | |
464 | ||
9e9f9cc2 KB |
465 | % Parse an argument, then pass it to #1. The argument is the rest of |
466 | % the input line (except we remove a trailing comment). #1 should be a | |
467 | % macro which expects an ordinary undelimited TeX argument. | |
084e7d57 | 468 | % For example, \def\foo{\parsearg\fooxxx}. |
9e9f9cc2 | 469 | % |
82d5ce1d UD |
470 | \def\parsearg{\parseargusing{}} |
471 | \def\parseargusing#1#2{% | |
9251c568 | 472 | \def\argtorun{#2}% |
9e9f9cc2 KB |
473 | \begingroup |
474 | \obeylines | |
82d5ce1d UD |
475 | \spaceisspace |
476 | #1% | |
477 | \parseargline\empty% Insert the \empty token, see \finishparsearg below. | |
a334319f UD |
478 | } |
479 | ||
9e9f9cc2 KB |
480 | {\obeylines % |
481 | \gdef\parseargline#1^^M{% | |
482 | \endgroup % End of the group started in \parsearg. | |
82d5ce1d | 483 | \argremovecomment #1\comment\ArgTerm% |
9e9f9cc2 KB |
484 | }% |
485 | } | |
486 | ||
084e7d57 JM |
487 | % First remove any @comment, then any @c comment. Also remove a @texinfoc |
488 | % comment (see \scanmacro for details). Pass the result on to \argcheckspaces. | |
82d5ce1d | 489 | \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} |
084e7d57 JM |
490 | \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm} |
491 | \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} | |
9e9f9cc2 | 492 | |
0f8bbd69 | 493 | % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space. |
82d5ce1d UD |
494 | % |
495 | % \argremovec might leave us with trailing space, e.g., | |
9e9f9cc2 | 496 | % @end itemize @c foo |
82d5ce1d UD |
497 | % This space token undergoes the same procedure and is eventually removed |
498 | % by \finishparsearg. | |
499 | % | |
500 | \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} | |
501 | \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} | |
502 | \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% | |
503 | \def\temp{#3}% | |
504 | \ifx\temp\empty | |
9251c568 | 505 | % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: |
82d5ce1d UD |
506 | \let\temp\finishparsearg |
507 | \else | |
508 | \let\temp\argcheckspaces | |
509 | \fi | |
510 | % Put the space token in: | |
511 | \temp#1 #3\ArgTerm | |
9e9f9cc2 KB |
512 | } |
513 | ||
82d5ce1d UD |
514 | % If a _delimited_ argument is enclosed in braces, they get stripped; so |
515 | % to get _exactly_ the rest of the line, we had to prevent such situation. | |
516 | % We prepended an \empty token at the very beginning and we expand it now, | |
9251c568 | 517 | % just before passing the control to \argtorun. |
0f8bbd69 | 518 | % (Similarly, we have to think about #3 of \argcheckspacesY above: it is |
82d5ce1d UD |
519 | % either the null string, or it ends with \^^M---thus there is no danger |
520 | % that a pair of braces would be stripped. | |
9e9f9cc2 | 521 | % |
82d5ce1d UD |
522 | % But first, we have to remove the trailing space token. |
523 | % | |
9251c568 | 524 | \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} |
82d5ce1d | 525 | |
084e7d57 JM |
526 | |
527 | % \parseargdef - define a command taking an argument on the line | |
528 | % | |
82d5ce1d UD |
529 | % \parseargdef\foo{...} |
530 | % is roughly equivalent to | |
531 | % \def\foo{\parsearg\Xfoo} | |
532 | % \def\Xfoo#1{...} | |
82d5ce1d UD |
533 | \def\parseargdef#1{% |
534 | \expandafter \doparseargdef \csname\string#1\endcsname #1% | |
535 | } | |
536 | \def\doparseargdef#1#2{% | |
537 | \def#2{\parsearg#1}% | |
538 | \def#1##1% | |
539 | } | |
540 | ||
541 | % Several utility definitions with active space: | |
542 | { | |
9e9f9cc2 | 543 | \obeyspaces |
82d5ce1d UD |
544 | \gdef\obeyedspace{ } |
545 | ||
546 | % Make each space character in the input produce a normal interword | |
547 | % space in the output. Don't allow a line break at this space, as this | |
548 | % is used only in environments like @example, where each line of input | |
549 | % should produce a line of output anyway. | |
550 | % | |
551 | \gdef\sepspaces{\obeyspaces\let =\tie} | |
552 | ||
553 | % If an index command is used in an @example environment, any spaces | |
554 | % therein should become regular spaces in the raw index file, not the | |
555 | % expansion of \tie (\leavevmode \penalty \@M \ ). | |
556 | \gdef\unsepspaces{\let =\space} | |
557 | } | |
9e9f9cc2 KB |
558 | |
559 | ||
560 | \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} | |
561 | ||
82d5ce1d UD |
562 | % Define the framework for environments in texinfo.tex. It's used like this: |
563 | % | |
564 | % \envdef\foo{...} | |
565 | % \def\Efoo{...} | |
566 | % | |
567 | % It's the responsibility of \envdef to insert \begingroup before the | |
568 | % actual body; @end closes the group after calling \Efoo. \envdef also | |
569 | % defines \thisenv, so the current environment is known; @end checks | |
570 | % whether the environment name matches. The \checkenv macro can also be | |
571 | % used to check whether the current environment is the one expected. | |
572 | % | |
573 | % Non-false conditionals (@iftex, @ifset) don't fit into this, so they | |
0f8bbd69 | 574 | % are not treated as environments; they don't open a group. (The |
82d5ce1d UD |
575 | % implementation of @end takes care not to call \endgroup in this |
576 | % special case.) | |
9e9f9cc2 | 577 | |
9e9f9cc2 | 578 | |
0f8bbd69 | 579 | % At run-time, environments start with this: |
82d5ce1d UD |
580 | \def\startenvironment#1{\begingroup\def\thisenv{#1}} |
581 | % initialize | |
582 | \let\thisenv\empty | |
9e9f9cc2 | 583 | |
82d5ce1d UD |
584 | % ... but they get defined via ``\envdef\foo{...}'': |
585 | \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} | |
586 | \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} | |
9e9f9cc2 | 587 | |
82d5ce1d UD |
588 | % Check whether we're in the right environment: |
589 | \def\checkenv#1{% | |
590 | \def\temp{#1}% | |
591 | \ifx\thisenv\temp | |
9e9f9cc2 | 592 | \else |
82d5ce1d | 593 | \badenverr |
9e9f9cc2 KB |
594 | \fi |
595 | } | |
596 | ||
0f8bbd69 | 597 | % Environment mismatch, #1 expected: |
82d5ce1d | 598 | \def\badenverr{% |
9e9f9cc2 | 599 | \errhelp = \EMsimple |
82d5ce1d UD |
600 | \errmessage{This command can appear only \inenvironment\temp, |
601 | not \inenvironment\thisenv}% | |
602 | } | |
603 | \def\inenvironment#1{% | |
604 | \ifx#1\empty | |
0f8bbd69 | 605 | outside of any environment% |
82d5ce1d UD |
606 | \else |
607 | in environment \expandafter\string#1% | |
608 | \fi | |
9e9f9cc2 KB |
609 | } |
610 | ||
82d5ce1d UD |
611 | % @end foo executes the definition of \Efoo. |
612 | % But first, it executes a specialized version of \checkenv | |
9e9f9cc2 | 613 | % |
82d5ce1d UD |
614 | \parseargdef\end{% |
615 | \if 1\csname iscond.#1\endcsname | |
616 | \else | |
0f8bbd69 | 617 | % The general wording of \badenverr may not be ideal. |
82d5ce1d UD |
618 | \expandafter\checkenv\csname#1\endcsname |
619 | \csname E#1\endcsname | |
620 | \endgroup | |
621 | \fi | |
9e9f9cc2 KB |
622 | } |
623 | ||
82d5ce1d UD |
624 | \newhelp\EMsimple{Press RETURN to continue.} |
625 | ||
9e9f9cc2 | 626 | |
40c0dc53 UD |
627 | % Be sure we're in horizontal mode when doing a tie, since we make space |
628 | % equivalent to this in @example-like environments. Otherwise, a space | |
629 | % at the beginning of a line will start with \penalty -- and | |
630 | % since \penalty is valid in vertical mode, we'd end up putting the | |
631 | % penalty on the vertical list instead of in the new paragraph. | |
632 | {\catcode`@ = 11 | |
633 | % Avoid using \@M directly, because that causes trouble | |
634 | % if the definition is written into an index file. | |
635 | \global\let\tiepenalty = \@M | |
636 | \gdef\tie{\leavevmode\penalty\tiepenalty\ } | |
637 | } | |
638 | ||
9e9f9cc2 KB |
639 | % @: forces normal size whitespace following. |
640 | \def\:{\spacefactor=1000 } | |
641 | ||
642 | % @* forces a line break. | |
8fcb833a | 643 | \def\*{\unskip\hfil\break\hbox{}\ignorespaces} |
9e9f9cc2 | 644 | |
7158eae4 UD |
645 | % @/ allows a line break. |
646 | \let\/=\allowbreak | |
647 | ||
9e9f9cc2 | 648 | % @. is an end-of-sentence period. |
9251c568 | 649 | \def\.{.\spacefactor=\endofsentencespacefactor\space} |
9e9f9cc2 | 650 | |
9e9f9cc2 | 651 | % @! is an end-of-sentence bang. |
9251c568 | 652 | \def\!{!\spacefactor=\endofsentencespacefactor\space} |
9e9f9cc2 KB |
653 | |
654 | % @? is an end-of-sentence query. | |
9251c568 AJ |
655 | \def\?{?\spacefactor=\endofsentencespacefactor\space} |
656 | ||
657 | % @frenchspacing on|off says whether to put extra space after punctuation. | |
0f8bbd69 | 658 | % |
9251c568 AJ |
659 | \def\onword{on} |
660 | \def\offword{off} | |
661 | % | |
662 | \parseargdef\frenchspacing{% | |
663 | \def\temp{#1}% | |
664 | \ifx\temp\onword \plainfrenchspacing | |
665 | \else\ifx\temp\offword \plainnonfrenchspacing | |
666 | \else | |
667 | \errhelp = \EMsimple | |
0f8bbd69 | 668 | \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% |
9251c568 AJ |
669 | \fi\fi |
670 | } | |
9e9f9cc2 KB |
671 | |
672 | % @w prevents a word break. Without the \leavevmode, @w at the | |
673 | % beginning of a paragraph, when TeX is still in vertical mode, would | |
674 | % produce a whole line of output instead of starting the paragraph. | |
675 | \def\w#1{\leavevmode\hbox{#1}} | |
676 | ||
677 | % @group ... @end group forces ... to be all on one page, by enclosing | |
678 | % it in a TeX vbox. We use \vtop instead of \vbox to construct the box | |
679 | % to keep its height that of a normal line. According to the rules for | |
680 | % \topskip (p.114 of the TeXbook), the glue inserted is | |
681 | % max (\topskip - \ht (first item), 0). If that height is large, | |
682 | % therefore, no glue is inserted, and the space between the headline and | |
683 | % the text is small, which looks bad. | |
684 | % | |
e0f86659 UD |
685 | % Another complication is that the group might be very large. This can |
686 | % cause the glue on the previous page to be unduly stretched, because it | |
687 | % does not have much material. In this case, it's better to add an | |
688 | % explicit \vfill so that the extra space is at the bottom. The | |
689 | % threshold for doing this is if the group is more than \vfilllimit | |
690 | % percent of a page (\vfilllimit can be changed inside of @tex). | |
7158eae4 | 691 | % |
e0f86659 UD |
692 | \newbox\groupbox |
693 | \def\vfilllimit{0.7} | |
694 | % | |
82d5ce1d UD |
695 | \envdef\group{% |
696 | \ifnum\catcode`\^^M=\active \else | |
9e9f9cc2 KB |
697 | \errhelp = \groupinvalidhelp |
698 | \errmessage{@group invalid in context where filling is enabled}% | |
699 | \fi | |
82d5ce1d | 700 | \startsavinginserts |
9e9f9cc2 | 701 | % |
e0f86659 | 702 | \setbox\groupbox = \vtop\bgroup |
9e9f9cc2 KB |
703 | % Do @comment since we are called inside an environment such as |
704 | % @example, where each end-of-line in the input causes an | |
705 | % end-of-line in the output. We don't want the end-of-line after | |
706 | % the `@group' to put extra space in the output. Since @group | |
707 | % should appear on a line by itself (according to the Texinfo | |
708 | % manual), we don't worry about eating any user text. | |
709 | \comment | |
710 | } | |
711 | % | |
82d5ce1d UD |
712 | % The \vtop produces a box with normal height and large depth; thus, TeX puts |
713 | % \baselineskip glue before it, and (when the next line of text is done) | |
714 | % \lineskip glue after it. Thus, space below is not quite equal to space | |
715 | % above. But it's pretty close. | |
716 | \def\Egroup{% | |
717 | % To get correct interline space between the last line of the group | |
718 | % and the first line afterwards, we have to propagate \prevdepth. | |
719 | \endgraf % Not \par, as it may have been set to \lisppar. | |
720 | \global\dimen1 = \prevdepth | |
721 | \egroup % End the \vtop. | |
084e7d57 JM |
722 | \addgroupbox |
723 | \prevdepth = \dimen1 | |
724 | \checkinserts | |
725 | } | |
726 | ||
727 | \def\addgroupbox{ | |
82d5ce1d UD |
728 | % \dimen0 is the vertical size of the group's box. |
729 | \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox | |
730 | % \dimen2 is how much space is left on the page (more or less). | |
7f7dd1d3 | 731 | \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal |
82d5ce1d UD |
732 | % if the group doesn't fit on the current page, and it's a big big |
733 | % group, force a page break. | |
734 | \ifdim \dimen0 > \dimen2 | |
7f7dd1d3 | 735 | \ifdim \pagetotal < \vfilllimit\txipageheight |
82d5ce1d UD |
736 | \page |
737 | \fi | |
738 | \fi | |
739 | \box\groupbox | |
82d5ce1d | 740 | } |
084e7d57 | 741 | |
82d5ce1d | 742 | % |
9e9f9cc2 KB |
743 | % TeX puts in an \escapechar (i.e., `@') at the beginning of the help |
744 | % message, so this ends up printing `@group can only ...'. | |
745 | % | |
746 | \newhelp\groupinvalidhelp{% | |
747 | group can only be used in environments such as @example,^^J% | |
748 | where each line of input produces a line of output.} | |
749 | ||
750 | % @need space-in-mils | |
751 | % forces a page break if there is not space-in-mils remaining. | |
752 | ||
753 | \newdimen\mil \mil=0.001in | |
754 | ||
82d5ce1d | 755 | \parseargdef\need{% |
3b82ab1c | 756 | % Ensure vertical mode, so we don't make a big box in the middle of a |
9e9f9cc2 KB |
757 | % paragraph. |
758 | \par | |
759 | % | |
3b82ab1c UD |
760 | % If the @need value is less than one line space, it's useless. |
761 | \dimen0 = #1\mil | |
762 | \dimen2 = \ht\strutbox | |
763 | \advance\dimen2 by \dp\strutbox | |
764 | \ifdim\dimen0 > \dimen2 | |
765 | % | |
766 | % Do a \strut just to make the height of this box be normal, so the | |
767 | % normal leading is inserted relative to the preceding line. | |
768 | % And a page break here is fine. | |
769 | \vtop to #1\mil{\strut\vfil}% | |
770 | % | |
771 | % TeX does not even consider page breaks if a penalty added to the | |
772 | % main vertical list is 10000 or more. But in order to see if the | |
773 | % empty box we just added fits on the page, we must make it consider | |
774 | % page breaks. On the other hand, we don't want to actually break the | |
775 | % page after the empty box. So we use a penalty of 9999. | |
776 | % | |
777 | % There is an extremely small chance that TeX will actually break the | |
778 | % page at this \penalty, if there are no other feasible breakpoints in | |
779 | % sight. (If the user is using lots of big @group commands, which | |
780 | % almost-but-not-quite fill up a page, TeX will have a hard time doing | |
781 | % good page breaking, for example.) However, I could not construct an | |
782 | % example where a page broke at this \penalty; if it happens in a real | |
783 | % document, then we can reconsider our strategy. | |
784 | \penalty9999 | |
785 | % | |
786 | % Back up by the size of the box, whether we did a page break or not. | |
787 | \kern -#1\mil | |
788 | % | |
789 | % Do not allow a page break right after this kern. | |
790 | \nobreak | |
791 | \fi | |
9e9f9cc2 KB |
792 | } |
793 | ||
82d5ce1d | 794 | % @br forces paragraph break (and is undocumented). |
9e9f9cc2 KB |
795 | |
796 | \let\br = \par | |
797 | ||
7158eae4 | 798 | % @page forces the start of a new page. |
313a1174 | 799 | % |
9e9f9cc2 KB |
800 | \def\page{\par\vfill\supereject} |
801 | ||
802 | % @exdent text.... | |
803 | % outputs text on separate line in roman font, starting at standard page margin | |
804 | ||
805 | % This records the amount of indent in the innermost environment. | |
806 | % That's how much \exdent should take out. | |
807 | \newskip\exdentamount | |
808 | ||
809 | % This defn is used inside fill environments such as @defun. | |
82d5ce1d | 810 | \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} |
9e9f9cc2 KB |
811 | |
812 | % This defn is used inside nofill environments such as @example. | |
82d5ce1d UD |
813 | \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount |
814 | \leftline{\hskip\leftskip{\rm#1}}}} | |
9e9f9cc2 | 815 | |
366d6851 UD |
816 | % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current |
817 | % paragraph. For more general purposes, use the \margin insertion | |
0f8bbd69 | 818 | % class. WHICH is `l' or `r'. Not documented, written for gawk manual. |
366d6851 | 819 | % |
9e9f9cc2 KB |
820 | \newskip\inmarginspacing \inmarginspacing=1cm |
821 | \def\strutdepth{\dp\strutbox} | |
366d6851 UD |
822 | % |
823 | \def\doinmargin#1#2{\strut\vadjust{% | |
824 | \nobreak | |
825 | \kern-\strutdepth | |
826 | \vtop to \strutdepth{% | |
827 | \baselineskip=\strutdepth | |
828 | \vss | |
829 | % if you have multiple lines of stuff to put here, you'll need to | |
830 | % make the vbox yourself of the appropriate size. | |
831 | \ifx#1l% | |
832 | \llap{\ignorespaces #2\hskip\inmarginspacing}% | |
833 | \else | |
834 | \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% | |
835 | \fi | |
836 | \null | |
837 | }% | |
838 | }} | |
839 | \def\inleftmargin{\doinmargin l} | |
840 | \def\inrightmargin{\doinmargin r} | |
841 | % | |
842 | % @inmargin{TEXT [, RIGHT-TEXT]} | |
843 | % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; | |
844 | % else use TEXT for both). | |
7158eae4 | 845 | % |
366d6851 UD |
846 | \def\inmargin#1{\parseinmargin #1,,\finish} |
847 | \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. | |
7158eae4 | 848 | \setbox0 = \hbox{\ignorespaces #2}% |
366d6851 UD |
849 | \ifdim\wd0 > 0pt |
850 | \def\lefttext{#1}% have both texts | |
851 | \def\righttext{#2}% | |
852 | \else | |
853 | \def\lefttext{#1}% have only one text | |
854 | \def\righttext{#1}% | |
855 | \fi | |
856 | % | |
857 | \ifodd\pageno | |
be1152ca | 858 | \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin |
366d6851 | 859 | \else |
be1152ca | 860 | \def\temp{\inleftmargin\lefttext}% |
366d6851 UD |
861 | \fi |
862 | \temp | |
863 | } | |
9e9f9cc2 | 864 | |
0f8bbd69 | 865 | % @include FILE -- \input text of FILE. |
82d5ce1d UD |
866 | % |
867 | \def\include{\parseargusing\filenamecatcodes\includezzz} | |
868 | \def\includezzz#1{% | |
869 | \pushthisfilestack | |
870 | \def\thisfile{#1}% | |
871 | {% | |
0f8bbd69 JM |
872 | \makevalueexpandable % we want to expand any @value in FILE. |
873 | \turnoffactive % and allow special characters in the expansion | |
874 | \indexnofonts % Allow `@@' and other weird things in file names. | |
875 | \wlog{texinfo.tex: doing @include of #1^^J}% | |
876 | \edef\temp{\noexpand\input #1 }% | |
877 | % | |
878 | % This trickery is to read FILE outside of a group, in case it makes | |
879 | % definitions, etc. | |
82d5ce1d UD |
880 | \expandafter |
881 | }\temp | |
882 | \popthisfilestack | |
883 | } | |
884 | \def\filenamecatcodes{% | |
e0f86659 UD |
885 | \catcode`\\=\other |
886 | \catcode`~=\other | |
887 | \catcode`^=\other | |
888 | \catcode`_=\other | |
889 | \catcode`|=\other | |
890 | \catcode`<=\other | |
891 | \catcode`>=\other | |
892 | \catcode`+=\other | |
82d5ce1d | 893 | \catcode`-=\other |
0f8bbd69 JM |
894 | \catcode`\`=\other |
895 | \catcode`\'=\other | |
82d5ce1d UD |
896 | } |
897 | ||
898 | \def\pushthisfilestack{% | |
899 | \expandafter\pushthisfilestackX\popthisfilestack\StackTerm | |
900 | } | |
901 | \def\pushthisfilestackX{% | |
902 | \expandafter\pushthisfilestackY\thisfile\StackTerm | |
903 | } | |
904 | \def\pushthisfilestackY #1\StackTerm #2\StackTerm {% | |
905 | \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% | |
906 | } | |
907 | ||
908 | \def\popthisfilestack{\errthisfilestackempty} | |
909 | \def\errthisfilestackempty{\errmessage{Internal error: | |
910 | the stack of filenames is empty.}} | |
8fcb833a | 911 | % |
9e9f9cc2 KB |
912 | \def\thisfile{} |
913 | ||
e0f86659 UD |
914 | % @center line |
915 | % outputs that line, centered. | |
916 | % | |
82d5ce1d UD |
917 | \parseargdef\center{% |
918 | \ifhmode | |
8fcb833a | 919 | \let\centersub\centerH |
82d5ce1d | 920 | \else |
8fcb833a | 921 | \let\centersub\centerV |
82d5ce1d | 922 | \fi |
8fcb833a JM |
923 | \centersub{\hfil \ignorespaces#1\unskip \hfil}% |
924 | \let\centersub\relax % don't let the definition persist, just in case | |
82d5ce1d | 925 | } |
8fcb833a JM |
926 | \def\centerH#1{{% |
927 | \hfil\break | |
928 | \advance\hsize by -\leftskip | |
929 | \advance\hsize by -\rightskip | |
930 | \line{#1}% | |
931 | \break | |
932 | }} | |
933 | % | |
934 | \newcount\centerpenalty | |
935 | \def\centerV#1{% | |
936 | % The idea here is the same as in \startdefun, \cartouche, etc.: if | |
937 | % @center is the first thing after a section heading, we need to wipe | |
938 | % out the negative parskip inserted by \sectionheading, but still | |
939 | % prevent a page break here. | |
940 | \centerpenalty = \lastpenalty | |
941 | \ifnum\centerpenalty>10000 \vskip\parskip \fi | |
942 | \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi | |
943 | \line{\kern\leftskip #1\kern\rightskip}% | |
82d5ce1d | 944 | } |
9e9f9cc2 KB |
945 | |
946 | % @sp n outputs n lines of vertical space | |
8fcb833a | 947 | % |
82d5ce1d | 948 | \parseargdef\sp{\vskip #1\baselineskip} |
9e9f9cc2 KB |
949 | |
950 | % @comment ...line which is ignored... | |
951 | % @c is the same as @comment | |
952 | % @ignore ... @end ignore is another way to write a comment | |
8fcb833a | 953 | % |
084e7d57 JM |
954 | \def\comment{\begingroup \catcode`\^^M=\active% |
955 | \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}% | |
956 | ||
957 | {\catcode`\^^M=\active% | |
958 | \gdef\commentxxx#1^^M{\endgroup% | |
959 | \futurelet\nexttoken\commentxxxx}% | |
960 | \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}% | |
961 | } | |
962 | ||
963 | \def\c{\begingroup \catcode`\^^M=\active% | |
61027f30 | 964 | \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% |
084e7d57 JM |
965 | \cxxx} |
966 | {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}} | |
967 | % See comment in \scanmacro about why the definitions of @c and @comment differ | |
9e9f9cc2 | 968 | |
407dc7a0 UD |
969 | % @paragraphindent NCHARS |
970 | % We'll use ems for NCHARS, close enough. | |
7158eae4 UD |
971 | % NCHARS can also be the word `asis' or `none'. |
972 | % We cannot feasibly implement @paragraphindent asis, though. | |
973 | % | |
407dc7a0 UD |
974 | \def\asisword{asis} % no translation, these are keywords |
975 | \def\noneword{none} | |
9e9f9cc2 | 976 | % |
82d5ce1d | 977 | \parseargdef\paragraphindent{% |
407dc7a0 UD |
978 | \def\temp{#1}% |
979 | \ifx\temp\asisword | |
980 | \else | |
981 | \ifx\temp\noneword | |
982 | \defaultparindent = 0pt | |
983 | \else | |
984 | \defaultparindent = #1em | |
985 | \fi | |
986 | \fi | |
987 | \parindent = \defaultparindent | |
9e9f9cc2 KB |
988 | } |
989 | ||
13632cfc UD |
990 | % @exampleindent NCHARS |
991 | % We'll use ems for NCHARS like @paragraphindent. | |
992 | % It seems @exampleindent asis isn't necessary, but | |
993 | % I preserve it to make it similar to @paragraphindent. | |
82d5ce1d | 994 | \parseargdef\exampleindent{% |
13632cfc UD |
995 | \def\temp{#1}% |
996 | \ifx\temp\asisword | |
997 | \else | |
998 | \ifx\temp\noneword | |
999 | \lispnarrowing = 0pt | |
1000 | \else | |
1001 | \lispnarrowing = #1em | |
1002 | \fi | |
1003 | \fi | |
1004 | } | |
1005 | ||
7158eae4 UD |
1006 | % @firstparagraphindent WORD |
1007 | % If WORD is `none', then suppress indentation of the first paragraph | |
82d5ce1d | 1008 | % after a section heading. If WORD is `insert', then do indent at such |
7158eae4 UD |
1009 | % paragraphs. |
1010 | % | |
1011 | % The paragraph indentation is suppressed or not by calling | |
82d5ce1d UD |
1012 | % \suppressfirstparagraphindent, which the sectioning commands do. |
1013 | % We switch the definition of this back and forth according to WORD. | |
1014 | % By default, we suppress indentation. | |
7158eae4 UD |
1015 | % |
1016 | \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} | |
7158eae4 UD |
1017 | \def\insertword{insert} |
1018 | % | |
82d5ce1d | 1019 | \parseargdef\firstparagraphindent{% |
7158eae4 UD |
1020 | \def\temp{#1}% |
1021 | \ifx\temp\noneword | |
1022 | \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent | |
1023 | \else\ifx\temp\insertword | |
1024 | \let\suppressfirstparagraphindent = \relax | |
1025 | \else | |
1026 | \errhelp = \EMsimple | |
1027 | \errmessage{Unknown @firstparagraphindent option `\temp'}% | |
1028 | \fi\fi | |
1029 | } | |
1030 | ||
1031 | % Here is how we actually suppress indentation. Redefine \everypar to | |
1032 | % \kern backwards by \parindent, and then reset itself to empty. | |
1033 | % | |
1034 | % We also make \indent itself not actually do anything until the next | |
1035 | % paragraph. | |
1036 | % | |
1037 | \gdef\dosuppressfirstparagraphindent{% | |
084e7d57 JM |
1038 | \gdef\indent {\restorefirstparagraphindent \indent}% |
1039 | \gdef\noindent{\restorefirstparagraphindent \noindent}% | |
1040 | \global\everypar = {\kern -\parindent \restorefirstparagraphindent}% | |
82d5ce1d | 1041 | } |
084e7d57 | 1042 | % |
82d5ce1d | 1043 | \gdef\restorefirstparagraphindent{% |
084e7d57 JM |
1044 | \global\let\indent = \ptexindent |
1045 | \global\let\noindent = \ptexnoindent | |
1046 | \global\everypar = {}% | |
82d5ce1d | 1047 | } |
7158eae4 UD |
1048 | |
1049 | ||
407dc7a0 UD |
1050 | % @refill is a no-op. |
1051 | \let\refill=\relax | |
9e9f9cc2 | 1052 | |
084e7d57 JM |
1053 | % @setfilename INFO-FILENAME - ignored |
1054 | \let\setfilename=\comment | |
0c2b5752 | 1055 | |
d66b7b41 | 1056 | % @bye. |
9e9f9cc2 KB |
1057 | \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} |
1058 | ||
d66b7b41 | 1059 | |
13632cfc UD |
1060 | \message{pdf,} |
1061 | % adobe `portable' document format | |
13632cfc UD |
1062 | \newcount\tempnum |
1063 | \newcount\lnkcount | |
1064 | \newtoks\filename | |
1065 | \newcount\filenamelength | |
1066 | \newcount\pgn | |
3b82ab1c UD |
1067 | \newtoks\toksA |
1068 | \newtoks\toksB | |
1069 | \newtoks\toksC | |
1070 | \newtoks\toksD | |
1071 | \newbox\boxA | |
084e7d57 | 1072 | \newbox\boxB |
3b82ab1c UD |
1073 | \newcount\countA |
1074 | \newif\ifpdf | |
1075 | \newif\ifpdfmakepagedest | |
1076 | ||
7f7dd1d3 JM |
1077 | % |
1078 | % For LuaTeX | |
1079 | % | |
1080 | ||
1081 | \newif\iftxiuseunicodedestname | |
1082 | \txiuseunicodedestnamefalse % For pdfTeX etc. | |
1083 | ||
1084 | \ifx\luatexversion\thisisundefined | |
1085 | \else | |
1086 | % Use Unicode destination names | |
1087 | \txiuseunicodedestnametrue | |
1088 | % Escape PDF strings with converting UTF-16 from UTF-8 | |
1089 | \begingroup | |
1090 | \catcode`\%=12 | |
1091 | \directlua{ | |
1092 | function UTF16oct(str) | |
1093 | tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377') | |
1094 | for c in string.utfvalues(str) do | |
1095 | if c < 0x10000 then | |
1096 | tex.sprint( | |
1097 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. | |
1098 | string.char(0x5c) .. string.char(0x25) .. '03o', | |
1099 | (c / 256), (c % 256))) | |
1100 | else | |
1101 | c = c - 0x10000 | |
1102 | local c_hi = c / 1024 + 0xd800 | |
1103 | local c_lo = c % 1024 + 0xdc00 | |
1104 | tex.sprint( | |
1105 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. | |
1106 | string.char(0x5c) .. string.char(0x25) .. '03o' .. | |
1107 | string.char(0x5c) .. string.char(0x25) .. '03o' .. | |
1108 | string.char(0x5c) .. string.char(0x25) .. '03o', | |
1109 | (c_hi / 256), (c_hi % 256), | |
1110 | (c_lo / 256), (c_lo % 256))) | |
1111 | end | |
1112 | end | |
1113 | end | |
1114 | } | |
1115 | \endgroup | |
1116 | \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}} | |
1117 | % Escape PDF strings without converting | |
1118 | \begingroup | |
1119 | \directlua{ | |
1120 | function PDFescstr(str) | |
1121 | for c in string.bytes(str) do | |
1122 | if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then | |
1123 | tex.sprint( | |
1124 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o', | |
1125 | c)) | |
1126 | else | |
1127 | tex.sprint(string.char(c)) | |
1128 | end | |
1129 | end | |
1130 | end | |
1131 | } | |
1132 | \endgroup | |
1133 | \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}} | |
1134 | \ifnum\luatexversion>84 | |
1135 | % For LuaTeX >= 0.85 | |
1136 | \def\pdfdest{\pdfextension dest} | |
1137 | \let\pdfoutput\outputmode | |
1138 | \def\pdfliteral{\pdfextension literal} | |
1139 | \def\pdfcatalog{\pdfextension catalog} | |
1140 | \def\pdftexversion{\numexpr\pdffeedback version\relax} | |
1141 | \let\pdfximage\saveimageresource | |
1142 | \let\pdfrefximage\useimageresource | |
1143 | \let\pdflastximage\lastsavedimageresourceindex | |
1144 | \def\pdfendlink{\pdfextension endlink\relax} | |
1145 | \def\pdfoutline{\pdfextension outline} | |
1146 | \def\pdfstartlink{\pdfextension startlink} | |
1147 | \def\pdffontattr{\pdfextension fontattr} | |
1148 | \def\pdfobj{\pdfextension obj} | |
1149 | \def\pdflastobj{\numexpr\pdffeedback lastobj\relax} | |
1150 | \let\pdfpagewidth\pagewidth | |
1151 | \let\pdfpageheight\pageheight | |
1152 | \edef\pdfhorigin{\pdfvariable horigin} | |
1153 | \edef\pdfvorigin{\pdfvariable vorigin} | |
1154 | \fi | |
1155 | \fi | |
1156 | ||
82d5ce1d | 1157 | % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 |
0f8bbd69 JM |
1158 | % can be set). So we test for \relax and 0 as well as being undefined. |
1159 | \ifx\pdfoutput\thisisundefined | |
3b82ab1c | 1160 | \else |
82d5ce1d UD |
1161 | \ifx\pdfoutput\relax |
1162 | \else | |
1163 | \ifcase\pdfoutput | |
1164 | \else | |
1165 | \pdftrue | |
1166 | \fi | |
1167 | \fi | |
1168 | \fi | |
9251c568 AJ |
1169 | |
1170 | % PDF uses PostScript string constants for the names of xref targets, | |
1171 | % for display in the outlines, and in other places. Thus, we have to | |
1172 | % double any backslashes. Otherwise, a name like "\node" will be | |
1173 | % interpreted as a newline (\n), followed by o, d, e. Not good. | |
8fcb833a | 1174 | % |
0f8bbd69 JM |
1175 | % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and |
1176 | % related messages. The final outcome is that it is up to the TeX user | |
1177 | % to double the backslashes and otherwise make the string valid, so | |
1178 | % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to | |
1179 | % do this reliably, so we use it. | |
1180 | ||
1181 | % #1 is a control sequence in which to do the replacements, | |
1182 | % which we \xdef. | |
1183 | \def\txiescapepdf#1{% | |
8fcb833a | 1184 | \ifx\pdfescapestring\thisisundefined |
0f8bbd69 JM |
1185 | % No primitive available; should we give a warning or log? |
1186 | % Many times it won't matter. | |
7f7dd1d3 | 1187 | \xdef#1{#1}% |
0f8bbd69 JM |
1188 | \else |
1189 | % The expandable \pdfescapestring primitive escapes parentheses, | |
1190 | % backslashes, and other special chars. | |
1191 | \xdef#1{\pdfescapestring{#1}}% | |
1192 | \fi | |
9251c568 | 1193 | } |
7f7dd1d3 JM |
1194 | \def\txiescapepdfutfsixteen#1{% |
1195 | \ifx\pdfescapestrutfsixteen\thisisundefined | |
1196 | % No UTF-16 converting macro available. | |
1197 | \txiescapepdf{#1}% | |
1198 | \else | |
1199 | \xdef#1{\pdfescapestrutfsixteen{#1}}% | |
1200 | \fi | |
1201 | } | |
9251c568 AJ |
1202 | |
1203 | \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images | |
1204 | with PDF output, and none of those formats could be found. (.eps cannot | |
1205 | be supported due to the design of the PDF format; use regular TeX (DVI | |
1206 | output) for that.)} | |
1207 | ||
82d5ce1d | 1208 | \ifpdf |
c94f48d7 | 1209 | % |
e66a8203 | 1210 | % Color manipulation macros using ideas from pdfcolor.tex, |
0f8bbd69 JM |
1211 | % except using rgb instead of cmyk; the latter is said to render as a |
1212 | % very dark gray on-screen and a very dark halftone in print, instead | |
e66a8203 | 1213 | % of actual black. The dark red here is dark enough to print on paper as |
21fea2e2 JM |
1214 | % nearly black, but still distinguishable for online viewing. We use |
1215 | % black by default, though. | |
0f8bbd69 JM |
1216 | \def\rgbDarkRed{0.50 0.09 0.12} |
1217 | \def\rgbBlack{0 0 0} | |
1218 | % | |
084e7d57 JM |
1219 | % rg sets the color for filling (usual text, etc.); |
1220 | % RG sets the color for stroking (thin rules, e.g., normal _'s). | |
0f8bbd69 | 1221 | \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} |
c94f48d7 | 1222 | % |
c94f48d7 AJ |
1223 | % Set color, and create a mark which defines \thiscolor accordingly, |
1224 | % so that \makeheadline knows which color to restore. | |
1225 | \def\setcolor#1{% | |
1226 | \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% | |
1227 | \domark | |
1228 | \pdfsetcolor{#1}% | |
1229 | } | |
1230 | % | |
0f8bbd69 | 1231 | \def\maincolor{\rgbBlack} |
c94f48d7 AJ |
1232 | \pdfsetcolor{\maincolor} |
1233 | \edef\thiscolor{\maincolor} | |
1234 | \def\lastcolordefs{} | |
1235 | % | |
1236 | \def\makefootline{% | |
1237 | \baselineskip24pt | |
1238 | \line{\pdfsetcolor{\maincolor}\the\footline}% | |
1239 | } | |
1240 | % | |
1241 | \def\makeheadline{% | |
1242 | \vbox to 0pt{% | |
1243 | \vskip-22.5pt | |
1244 | \line{% | |
1245 | \vbox to8.5pt{}% | |
1246 | % Extract \thiscolor definition from the marks. | |
1247 | \getcolormarks | |
1248 | % Typeset the headline with \maincolor, then restore the color. | |
1249 | \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% | |
1250 | }% | |
1251 | \vss | |
1252 | }% | |
1253 | \nointerlineskip | |
1254 | } | |
1255 | % | |
1256 | % | |
1257 | \pdfcatalog{/PageMode /UseOutlines} | |
1258 | % | |
9251c568 | 1259 | % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). |
3b82ab1c | 1260 | \def\dopdfimage#1#2#3{% |
8fcb833a JM |
1261 | \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% |
1262 | \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% | |
9251c568 | 1263 | % |
0f8bbd69 JM |
1264 | % pdftex (and the PDF format) support .pdf, .png, .jpg (among |
1265 | % others). Let's try in that order, PDF first since if | |
1266 | % someone has a scalable image, presumably better to use that than a | |
1267 | % bitmap. | |
9251c568 AJ |
1268 | \let\pdfimgext=\empty |
1269 | \begingroup | |
0f8bbd69 JM |
1270 | \openin 1 #1.pdf \ifeof 1 |
1271 | \openin 1 #1.PDF \ifeof 1 | |
1272 | \openin 1 #1.png \ifeof 1 | |
1273 | \openin 1 #1.jpg \ifeof 1 | |
1274 | \openin 1 #1.jpeg \ifeof 1 | |
1275 | \openin 1 #1.JPG \ifeof 1 | |
1276 | \errhelp = \nopdfimagehelp | |
1277 | \errmessage{Could not find image file #1 for pdf}% | |
1278 | \else \gdef\pdfimgext{JPG}% | |
1279 | \fi | |
1280 | \else \gdef\pdfimgext{jpeg}% | |
9251c568 | 1281 | \fi |
0f8bbd69 | 1282 | \else \gdef\pdfimgext{jpg}% |
9251c568 | 1283 | \fi |
0f8bbd69 | 1284 | \else \gdef\pdfimgext{png}% |
9251c568 | 1285 | \fi |
0f8bbd69 | 1286 | \else \gdef\pdfimgext{PDF}% |
9251c568 | 1287 | \fi |
0f8bbd69 | 1288 | \else \gdef\pdfimgext{pdf}% |
9251c568 AJ |
1289 | \fi |
1290 | \closein 1 | |
1291 | \endgroup | |
1292 | % | |
0f8bbd69 | 1293 | % without \immediate, ancient pdftex seg faults when the same image is |
e23f8d20 | 1294 | % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) |
3b82ab1c | 1295 | \ifnum\pdftexversion < 14 |
e23f8d20 | 1296 | \immediate\pdfimage |
3b82ab1c | 1297 | \else |
e23f8d20 | 1298 | \immediate\pdfximage |
3b82ab1c | 1299 | \fi |
8fcb833a JM |
1300 | \ifdim \wd0 >0pt width \pdfimagewidth \fi |
1301 | \ifdim \wd2 >0pt height \pdfimageheight \fi | |
be1152ca | 1302 | \ifnum\pdftexversion<13 |
9251c568 | 1303 | #1.\pdfimgext |
be1152ca | 1304 | \else |
9251c568 | 1305 | {#1.\pdfimgext}% |
be1152ca | 1306 | \fi |
3b82ab1c UD |
1307 | \ifnum\pdftexversion < 14 \else |
1308 | \pdfrefximage \pdflastximage | |
1309 | \fi} | |
c94f48d7 | 1310 | % |
7f7dd1d3 | 1311 | \def\setpdfdestname#1{{% |
9251c568 AJ |
1312 | % We have to set dummies so commands such as @code, and characters |
1313 | % such as \, aren't expanded when present in a section title. | |
c94f48d7 | 1314 | \indexnofonts |
c94f48d7 | 1315 | \makevalueexpandable |
7f7dd1d3 JM |
1316 | \turnoffactive |
1317 | \iftxiuseunicodedestname | |
1318 | \ifx \declaredencoding \latone | |
1319 | % Pass through Latin-1 characters. | |
1320 | % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode. | |
1321 | \else | |
1322 | \ifx \declaredencoding \utfeight | |
1323 | % Pass through Unicode characters. | |
1324 | \else | |
1325 | % Use ASCII approximations in destination names. | |
1326 | \passthroughcharsfalse | |
1327 | \fi | |
1328 | \fi | |
1329 | \else | |
1330 | % Use ASCII approximations in destination names. | |
1331 | \passthroughcharsfalse | |
1332 | \fi | |
9251c568 | 1333 | \def\pdfdestname{#1}% |
0f8bbd69 | 1334 | \txiescapepdf\pdfdestname |
c94f48d7 | 1335 | }} |
9251c568 | 1336 | % |
7f7dd1d3 JM |
1337 | \def\setpdfoutlinetext#1{{% |
1338 | \indexnofonts | |
1339 | \makevalueexpandable | |
1340 | \turnoffactive | |
1341 | \ifx \declaredencoding \latone | |
1342 | % The PDF format can use an extended form of Latin-1 in bookmark | |
1343 | % strings. See Appendix D of the PDF Reference, Sixth Edition, for | |
1344 | % the "PDFDocEncoding". | |
1345 | \passthroughcharstrue | |
1346 | % Pass through Latin-1 characters. | |
1347 | % LuaTeX: Convert to Unicode | |
1348 | % pdfTeX: Use Latin-1 as PDFDocEncoding | |
1349 | \def\pdfoutlinetext{#1}% | |
1350 | \else | |
1351 | \ifx \declaredencoding \utfeight | |
1352 | \ifx\luatexversion\thisisundefined | |
1353 | % For pdfTeX with UTF-8. | |
1354 | % TODO: the PDF format can use UTF-16 in bookmark strings, | |
1355 | % but the code for this isn't done yet. | |
1356 | % Use ASCII approximations. | |
1357 | \passthroughcharsfalse | |
1358 | \def\pdfoutlinetext{#1}% | |
1359 | \else | |
1360 | % For LuaTeX with UTF-8. | |
1361 | % Pass through Unicode characters for title texts. | |
1362 | \passthroughcharstrue | |
1363 | \def\pdfoutlinetext{#1}% | |
1364 | \fi | |
1365 | \else | |
1366 | % For non-Latin-1 or non-UTF-8 encodings. | |
1367 | % Use ASCII approximations. | |
1368 | \passthroughcharsfalse | |
1369 | \def\pdfoutlinetext{#1}% | |
1370 | \fi | |
1371 | \fi | |
1372 | % LuaTeX: Convert to UTF-16 | |
1373 | % pdfTeX: Use Latin-1 as PDFDocEncoding | |
1374 | \txiescapepdfutfsixteen\pdfoutlinetext | |
1375 | }} | |
1376 | % | |
1377 | \def\pdfmkdest#1{% | |
1378 | \setpdfdestname{#1}% | |
1379 | \safewhatsit{\pdfdest name{\pdfdestname} xyz}% | |
1380 | } | |
1381 | % | |
9251c568 | 1382 | % used to mark target names; must be expandable. |
c94f48d7 AJ |
1383 | \def\pdfmkpgn#1{#1} |
1384 | % | |
21fea2e2 JM |
1385 | % by default, use black for everything. |
1386 | \def\urlcolor{\rgbBlack} | |
1387 | \def\linkcolor{\rgbBlack} | |
c94f48d7 | 1388 | \def\endlink{\setcolor{\maincolor}\pdfendlink} |
9251c568 | 1389 | % |
3b82ab1c UD |
1390 | % Adding outlines to PDF; macros for calculating structure of outlines |
1391 | % come from Petr Olsak | |
1392 | \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% | |
1393 | \else \csname#1\endcsname \fi} | |
1394 | \def\advancenumber#1{\tempnum=\expnumber{#1}\relax | |
82d5ce1d | 1395 | \advance\tempnum by 1 |
3b82ab1c | 1396 | \expandafter\xdef\csname#1\endcsname{\the\tempnum}} |
82d5ce1d | 1397 | % |
9251c568 AJ |
1398 | % #1 is the section text, which is what will be displayed in the |
1399 | % outline by the pdf viewer. #2 is the pdf expression for the number | |
1400 | % of subentries (or empty, for subsubsections). #3 is the node text, | |
1401 | % which might be empty if this toc entry had no corresponding node. | |
1402 | % #4 is the page number | |
82d5ce1d UD |
1403 | % |
1404 | \def\dopdfoutline#1#2#3#4{% | |
1405 | % Generate a link to the node text if that exists; else, use the | |
1406 | % page number. We could generate a destination for the section | |
1407 | % text in the case where a section has no node, but it doesn't | |
9251c568 | 1408 | % seem worth the trouble, since most documents are normally structured. |
7f7dd1d3 JM |
1409 | \setpdfoutlinetext{#1} |
1410 | \setpdfdestname{#3} | |
1411 | \ifx\pdfdestname\empty | |
1412 | \def\pdfdestname{#4}% | |
9251c568 AJ |
1413 | \fi |
1414 | % | |
7f7dd1d3 | 1415 | \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}% |
82d5ce1d UD |
1416 | } |
1417 | % | |
1418 | \def\pdfmakeoutlines{% | |
1419 | \begingroup | |
82d5ce1d | 1420 | % Read toc silently, to get counts of subentries for \pdfoutline. |
0f8bbd69 | 1421 | \def\partentry##1##2##3##4{}% ignore parts in the outlines |
82d5ce1d UD |
1422 | \def\numchapentry##1##2##3##4{% |
1423 | \def\thischapnum{##2}% | |
1424 | \def\thissecnum{0}% | |
1425 | \def\thissubsecnum{0}% | |
1426 | }% | |
1427 | \def\numsecentry##1##2##3##4{% | |
1428 | \advancenumber{chap\thischapnum}% | |
1429 | \def\thissecnum{##2}% | |
1430 | \def\thissubsecnum{0}% | |
1431 | }% | |
1432 | \def\numsubsecentry##1##2##3##4{% | |
1433 | \advancenumber{sec\thissecnum}% | |
1434 | \def\thissubsecnum{##2}% | |
1435 | }% | |
1436 | \def\numsubsubsecentry##1##2##3##4{% | |
1437 | \advancenumber{subsec\thissubsecnum}% | |
1438 | }% | |
1439 | \def\thischapnum{0}% | |
1440 | \def\thissecnum{0}% | |
1441 | \def\thissubsecnum{0}% | |
1442 | % | |
1443 | % use \def rather than \let here because we redefine \chapentry et | |
1444 | % al. a second time, below. | |
1445 | \def\appentry{\numchapentry}% | |
1446 | \def\appsecentry{\numsecentry}% | |
1447 | \def\appsubsecentry{\numsubsecentry}% | |
1448 | \def\appsubsubsecentry{\numsubsubsecentry}% | |
1449 | \def\unnchapentry{\numchapentry}% | |
1450 | \def\unnsecentry{\numsecentry}% | |
1451 | \def\unnsubsecentry{\numsubsecentry}% | |
1452 | \def\unnsubsubsecentry{\numsubsubsecentry}% | |
9251c568 | 1453 | \readdatafile{toc}% |
2f5b1124 | 1454 | % |
82d5ce1d UD |
1455 | % Read toc second time, this time actually producing the outlines. |
1456 | % The `-' means take the \expnumber as the absolute number of | |
1457 | % subentries, which we calculated on our first read of the .toc above. | |
1458 | % | |
1459 | % We use the node names as the destinations. | |
1460 | \def\numchapentry##1##2##3##4{% | |
1461 | \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% | |
1462 | \def\numsecentry##1##2##3##4{% | |
1463 | \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% | |
1464 | \def\numsubsecentry##1##2##3##4{% | |
1465 | \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% | |
1466 | \def\numsubsubsecentry##1##2##3##4{% count is always zero | |
1467 | \dopdfoutline{##1}{}{##3}{##4}}% | |
1468 | % | |
1469 | % PDF outlines are displayed using system fonts, instead of | |
1470 | % document fonts. Therefore we cannot use special characters, | |
1471 | % since the encoding is unknown. For example, the eogonek from | |
1472 | % Latin 2 (0xea) gets translated to a | character. Info from | |
1473 | % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. | |
7158eae4 | 1474 | % |
0f8bbd69 JM |
1475 | % TODO this right, we have to translate 8-bit characters to |
1476 | % their "best" equivalent, based on the @documentencoding. Too | |
1477 | % much work for too little return. Just use the ASCII equivalents | |
1478 | % we use for the index sort strings. | |
1479 | % | |
2f5b1124 | 1480 | \indexnofonts |
9251c568 | 1481 | \setupdatafile |
0f8bbd69 JM |
1482 | % We can have normal brace characters in the PDF outlines, unlike |
1483 | % Texinfo index files. So set that up. | |
1484 | \def\{{\lbracecharliteral}% | |
1485 | \def\}{\rbracecharliteral}% | |
9251c568 | 1486 | \catcode`\\=\active \otherbackslash |
c94f48d7 | 1487 | \input \tocreadfilename |
82d5ce1d UD |
1488 | \endgroup |
1489 | } | |
0f8bbd69 JM |
1490 | {\catcode`[=1 \catcode`]=2 |
1491 | \catcode`{=\other \catcode`}=\other | |
1492 | \gdef\lbracecharliteral[{]% | |
1493 | \gdef\rbracecharliteral[}]% | |
1494 | ] | |
82d5ce1d | 1495 | % |
3b82ab1c UD |
1496 | \def\skipspaces#1{\def\PP{#1}\def\D{|}% |
1497 | \ifx\PP\D\let\nextsp\relax | |
1498 | \else\let\nextsp\skipspaces | |
8fcb833a JM |
1499 | \addtokens{\filename}{\PP}% |
1500 | \advance\filenamelength by 1 | |
3b82ab1c UD |
1501 | \fi |
1502 | \nextsp} | |
8fcb833a JM |
1503 | \def\getfilename#1{% |
1504 | \filenamelength=0 | |
1505 | % If we don't expand the argument now, \skipspaces will get | |
1506 | % snagged on things like "@value{foo}". | |
1507 | \edef\temp{#1}% | |
1508 | \expandafter\skipspaces\temp|\relax | |
1509 | } | |
3b82ab1c UD |
1510 | \ifnum\pdftexversion < 14 |
1511 | \let \startlink \pdfannotlink | |
1512 | \else | |
1513 | \let \startlink \pdfstartlink | |
13632cfc | 1514 | \fi |
9251c568 | 1515 | % make a live url in pdf output. |
3b82ab1c UD |
1516 | \def\pdfurl#1{% |
1517 | \begingroup | |
9251c568 AJ |
1518 | % it seems we really need yet another set of dummies; have not |
1519 | % tried to figure out what each command should do in the context | |
1520 | % of @url. for now, just make @/ a no-op, that's the only one | |
1521 | % people have actually reported a problem with. | |
0f8bbd69 | 1522 | % |
9251c568 AJ |
1523 | \normalturnoffactive |
1524 | \def\@{@}% | |
1525 | \let\/=\empty | |
82d5ce1d | 1526 | \makevalueexpandable |
0f8bbd69 JM |
1527 | % do we want to go so far as to use \indexnofonts instead of just |
1528 | % special-casing \var here? | |
1529 | \def\var##1{##1}% | |
1530 | % | |
c94f48d7 | 1531 | \leavevmode\setcolor{\urlcolor}% |
3b82ab1c UD |
1532 | \startlink attr{/Border [0 0 0]}% |
1533 | user{/Subtype /Link /A << /S /URI /URI (#1) >>}% | |
3b82ab1c UD |
1534 | \endgroup} |
1535 | \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} | |
1536 | \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} | |
1537 | \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} | |
1538 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} | |
1539 | \def\maketoks{% | |
82d5ce1d | 1540 | \expandafter\poptoks\the\toksA|ENDTOKS|\relax |
3b82ab1c UD |
1541 | \ifx\first0\adn0 |
1542 | \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 | |
1543 | \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 | |
7158eae4 | 1544 | \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 |
3b82ab1c UD |
1545 | \else |
1546 | \ifnum0=\countA\else\makelink\fi | |
1547 | \ifx\first.\let\next=\done\else | |
1548 | \let\next=\maketoks | |
1549 | \addtokens{\toksB}{\the\toksD} | |
1550 | \ifx\first,\addtokens{\toksB}{\space}\fi | |
1551 | \fi | |
1552 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi | |
1553 | \next} | |
1554 | \def\makelink{\addtokens{\toksB}% | |
1555 | {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} | |
1556 | \def\pdflink#1{% | |
e23f8d20 | 1557 | \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} |
c94f48d7 | 1558 | \setcolor{\linkcolor}#1\endlink} |
3b82ab1c | 1559 | \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} |
82d5ce1d | 1560 | \else |
0f8bbd69 | 1561 | % non-pdf mode |
82d5ce1d UD |
1562 | \let\pdfmkdest = \gobble |
1563 | \let\pdfurl = \gobble | |
1564 | \let\endlink = \relax | |
c94f48d7 AJ |
1565 | \let\setcolor = \gobble |
1566 | \let\pdfsetcolor = \gobble | |
82d5ce1d UD |
1567 | \let\pdfmakeoutlines = \relax |
1568 | \fi % \ifx\pdfoutput | |
13632cfc | 1569 | |
82d5ce1d | 1570 | % |
7f7dd1d3 | 1571 | % For XeTeX |
82d5ce1d | 1572 | % |
7f7dd1d3 JM |
1573 | \ifx\XeTeXrevision\thisisundefined |
1574 | \else | |
1575 | % | |
1576 | % XeTeX version check | |
1577 | % | |
1578 | \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1 | |
1579 | % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307. | |
1580 | % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941). | |
1581 | % For avoiding PDF destination name replacement, we use this special | |
1582 | % instead of xdvipdfmx's command line option `-C 0x0010'. | |
1583 | \special{dvipdfmx:config C 0x0010} | |
1584 | % XeTeX 0.99995+ comes with xdvipdfmx 20160307+. | |
1585 | % It can handle Unicode destination names for PDF. | |
1586 | \txiuseunicodedestnametrue | |
1587 | \else | |
1588 | % XeTeX < 0.99996 (TeX Live < 2016) cannot use the | |
1589 | % `dvipdfmx:config' special. | |
1590 | % So for avoiding PDF destination name replacement, | |
1591 | % xdvipdfmx's command line option `-C 0x0010' is necessary. | |
1592 | % | |
1593 | % XeTeX < 0.99995 can not handle Unicode destination names for PDF | |
1594 | % because xdvipdfmx 20150315 has a UTF-16 conversion issue. | |
1595 | % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). | |
1596 | \txiuseunicodedestnamefalse | |
1597 | \fi | |
1598 | % | |
1599 | % Color support | |
1600 | % | |
1601 | \def\rgbDarkRed{0.50 0.09 0.12} | |
1602 | \def\rgbBlack{0 0 0} | |
1603 | % | |
1604 | \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} | |
1605 | % | |
1606 | % Set color, and create a mark which defines \thiscolor accordingly, | |
1607 | % so that \makeheadline knows which color to restore. | |
1608 | \def\setcolor#1{% | |
1609 | \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% | |
1610 | \domark | |
1611 | \pdfsetcolor{#1}% | |
1612 | } | |
1613 | % | |
1614 | \def\maincolor{\rgbBlack} | |
1615 | \pdfsetcolor{\maincolor} | |
1616 | \edef\thiscolor{\maincolor} | |
1617 | \def\lastcolordefs{} | |
1618 | % | |
1619 | \def\makefootline{% | |
1620 | \baselineskip24pt | |
1621 | \line{\pdfsetcolor{\maincolor}\the\footline}% | |
1622 | } | |
1623 | % | |
1624 | \def\makeheadline{% | |
1625 | \vbox to 0pt{% | |
1626 | \vskip-22.5pt | |
1627 | \line{% | |
1628 | \vbox to8.5pt{}% | |
1629 | % Extract \thiscolor definition from the marks. | |
1630 | \getcolormarks | |
1631 | % Typeset the headline with \maincolor, then restore the color. | |
1632 | \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% | |
1633 | }% | |
1634 | \vss | |
1635 | }% | |
1636 | \nointerlineskip | |
1637 | } | |
1638 | % | |
1639 | % PDF outline support | |
1640 | % | |
1641 | % Emulate pdfTeX primitive | |
1642 | \def\pdfdest name#1 xyz{% | |
1643 | \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}% | |
1644 | } | |
1645 | % | |
1646 | \def\setpdfdestname#1{{% | |
1647 | % We have to set dummies so commands such as @code, and characters | |
1648 | % such as \, aren't expanded when present in a section title. | |
1649 | \indexnofonts | |
1650 | \makevalueexpandable | |
1651 | \turnoffactive | |
1652 | \iftxiuseunicodedestname | |
1653 | % Pass through Unicode characters. | |
1654 | \else | |
1655 | % Use ASCII approximations in destination names. | |
1656 | \passthroughcharsfalse | |
1657 | \fi | |
1658 | \def\pdfdestname{#1}% | |
1659 | \txiescapepdf\pdfdestname | |
1660 | }} | |
1661 | % | |
1662 | \def\setpdfoutlinetext#1{{% | |
1663 | \turnoffactive | |
1664 | % Always use Unicode characters in title texts. | |
1665 | \def\pdfoutlinetext{#1}% | |
1666 | % For XeTeX, xdvipdfmx converts to UTF-16. | |
1667 | % So we do not convert. | |
1668 | \txiescapepdf\pdfoutlinetext | |
1669 | }} | |
1670 | % | |
1671 | \def\pdfmkdest#1{% | |
1672 | \setpdfdestname{#1}% | |
1673 | \safewhatsit{\pdfdest name{\pdfdestname} xyz}% | |
1674 | } | |
1675 | % | |
1676 | % by default, use black for everything. | |
1677 | \def\urlcolor{\rgbBlack} | |
1678 | \def\linkcolor{\rgbBlack} | |
1679 | \def\endlink{\setcolor{\maincolor}\pdfendlink} | |
1680 | % | |
1681 | \def\dopdfoutline#1#2#3#4{% | |
1682 | \setpdfoutlinetext{#1} | |
1683 | \setpdfdestname{#3} | |
1684 | \ifx\pdfdestname\empty | |
1685 | \def\pdfdestname{#4}% | |
1686 | \fi | |
1687 | % | |
1688 | \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A | |
1689 | << /S /GoTo /D (\pdfdestname) >> >> }% | |
1690 | } | |
1691 | % | |
1692 | \def\pdfmakeoutlines{% | |
1693 | \begingroup | |
1694 | % | |
1695 | % For XeTeX, counts of subentries are not necessary. | |
1696 | % Therefore, we read toc only once. | |
1697 | % | |
1698 | % We use node names as destinations. | |
1699 | \def\partentry##1##2##3##4{}% ignore parts in the outlines | |
1700 | \def\numchapentry##1##2##3##4{% | |
1701 | \dopdfoutline{##1}{1}{##3}{##4}}% | |
1702 | \def\numsecentry##1##2##3##4{% | |
1703 | \dopdfoutline{##1}{2}{##3}{##4}}% | |
1704 | \def\numsubsecentry##1##2##3##4{% | |
1705 | \dopdfoutline{##1}{3}{##3}{##4}}% | |
1706 | \def\numsubsubsecentry##1##2##3##4{% | |
1707 | \dopdfoutline{##1}{4}{##3}{##4}}% | |
1708 | % | |
1709 | \let\appentry\numchapentry% | |
1710 | \let\appsecentry\numsecentry% | |
1711 | \let\appsubsecentry\numsubsecentry% | |
1712 | \let\appsubsubsecentry\numsubsubsecentry% | |
1713 | \let\unnchapentry\numchapentry% | |
1714 | \let\unnsecentry\numsecentry% | |
1715 | \let\unnsubsecentry\numsubsecentry% | |
1716 | \let\unnsubsubsecentry\numsubsubsecentry% | |
1717 | % | |
1718 | % For XeTeX, xdvipdfmx converts strings to UTF-16. | |
1719 | % Therefore, the encoding and the language may not be considered. | |
1720 | % | |
1721 | \indexnofonts | |
1722 | \setupdatafile | |
1723 | % We can have normal brace characters in the PDF outlines, unlike | |
1724 | % Texinfo index files. So set that up. | |
1725 | \def\{{\lbracecharliteral}% | |
1726 | \def\}{\rbracecharliteral}% | |
1727 | \catcode`\\=\active \otherbackslash | |
1728 | \input \tocreadfilename | |
1729 | \endgroup | |
1730 | } | |
1731 | {\catcode`[=1 \catcode`]=2 | |
1732 | \catcode`{=\other \catcode`}=\other | |
1733 | \gdef\lbracecharliteral[{]% | |
1734 | \gdef\rbracecharliteral[}]% | |
1735 | ] | |
0f8bbd69 | 1736 | |
7f7dd1d3 JM |
1737 | \special{pdf:docview << /PageMode /UseOutlines >> } |
1738 | % ``\special{pdf:tounicode ...}'' is not necessary | |
1739 | % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it. | |
1740 | % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315, | |
1741 | % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings. | |
1742 | % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). | |
1743 | % | |
1744 | \def\skipspaces#1{\def\PP{#1}\def\D{|}% | |
1745 | \ifx\PP\D\let\nextsp\relax | |
1746 | \else\let\nextsp\skipspaces | |
1747 | \addtokens{\filename}{\PP}% | |
1748 | \advance\filenamelength by 1 | |
1749 | \fi | |
1750 | \nextsp} | |
1751 | \def\getfilename#1{% | |
1752 | \filenamelength=0 | |
1753 | % If we don't expand the argument now, \skipspaces will get | |
1754 | % snagged on things like "@value{foo}". | |
1755 | \edef\temp{#1}% | |
1756 | \expandafter\skipspaces\temp|\relax | |
1757 | } | |
1758 | % make a live url in pdf output. | |
1759 | \def\pdfurl#1{% | |
1760 | \begingroup | |
1761 | % it seems we really need yet another set of dummies; have not | |
1762 | % tried to figure out what each command should do in the context | |
1763 | % of @url. for now, just make @/ a no-op, that's the only one | |
1764 | % people have actually reported a problem with. | |
1765 | % | |
1766 | \normalturnoffactive | |
1767 | \def\@{@}% | |
1768 | \let\/=\empty | |
1769 | \makevalueexpandable | |
1770 | % do we want to go so far as to use \indexnofonts instead of just | |
1771 | % special-casing \var here? | |
1772 | \def\var##1{##1}% | |
1773 | % | |
1774 | \leavevmode\setcolor{\urlcolor}% | |
1775 | \special{pdf:bann << /Border [0 0 0] | |
1776 | /Subtype /Link /A << /S /URI /URI (#1) >> >>}% | |
1777 | \endgroup} | |
1778 | \def\endlink{\setcolor{\maincolor}\special{pdf:eann}} | |
1779 | \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} | |
1780 | \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} | |
1781 | \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} | |
1782 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} | |
1783 | \def\maketoks{% | |
1784 | \expandafter\poptoks\the\toksA|ENDTOKS|\relax | |
1785 | \ifx\first0\adn0 | |
1786 | \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 | |
1787 | \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 | |
1788 | \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 | |
1789 | \else | |
1790 | \ifnum0=\countA\else\makelink\fi | |
1791 | \ifx\first.\let\next=\done\else | |
1792 | \let\next=\maketoks | |
1793 | \addtokens{\toksB}{\the\toksD} | |
1794 | \ifx\first,\addtokens{\toksB}{\space}\fi | |
1795 | \fi | |
1796 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi | |
1797 | \next} | |
1798 | \def\makelink{\addtokens{\toksB}% | |
1799 | {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} | |
1800 | \def\pdflink#1{% | |
1801 | \special{pdf:bann << /Border [0 0 0] | |
1802 | /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}% | |
1803 | \setcolor{\linkcolor}#1\endlink} | |
1804 | \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} | |
1805 | % | |
1806 | % | |
1807 | % @image support | |
1808 | % | |
1809 | % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). | |
1810 | \def\doxeteximage#1#2#3{% | |
1811 | \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% | |
1812 | \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% | |
1813 | % | |
1814 | % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among | |
1815 | % others). Let's try in that order, PDF first since if | |
1816 | % someone has a scalable image, presumably better to use that than a | |
1817 | % bitmap. | |
1818 | \let\xeteximgext=\empty | |
1819 | \begingroup | |
1820 | \openin 1 #1.pdf \ifeof 1 | |
1821 | \openin 1 #1.PDF \ifeof 1 | |
1822 | \openin 1 #1.png \ifeof 1 | |
1823 | \openin 1 #1.jpg \ifeof 1 | |
1824 | \openin 1 #1.jpeg \ifeof 1 | |
1825 | \openin 1 #1.JPG \ifeof 1 | |
1826 | \errmessage{Could not find image file #1 for XeTeX}% | |
1827 | \else \gdef\xeteximgext{JPG}% | |
1828 | \fi | |
1829 | \else \gdef\xeteximgext{jpeg}% | |
1830 | \fi | |
1831 | \else \gdef\xeteximgext{jpg}% | |
1832 | \fi | |
1833 | \else \gdef\xeteximgext{png}% | |
1834 | \fi | |
1835 | \else \gdef\xeteximgext{PDF}% | |
1836 | \fi | |
1837 | \else \gdef\xeteximgext{pdf}% | |
1838 | \fi | |
1839 | \closein 1 | |
1840 | \endgroup | |
1841 | % | |
1842 | \def\xetexpdfext{pdf}% | |
1843 | \ifx\xeteximgext\xetexpdfext | |
1844 | \XeTeXpdffile "#1".\xeteximgext "" | |
1845 | \else | |
1846 | \def\xetexpdfext{PDF}% | |
1847 | \ifx\xeteximgext\xetexpdfext | |
1848 | \XeTeXpdffile "#1".\xeteximgext "" | |
1849 | \else | |
1850 | \XeTeXpicfile "#1".\xeteximgext "" | |
1851 | \fi | |
1852 | \fi | |
1853 | \ifdim \wd0 >0pt width \xeteximagewidth \fi | |
1854 | \ifdim \wd2 >0pt height \xeteximageheight \fi \relax | |
1855 | } | |
1856 | \fi | |
9e9f9cc2 | 1857 | |
9e9f9cc2 | 1858 | |
7f7dd1d3 JM |
1859 | % |
1860 | \message{fonts,} | |
9251c568 | 1861 | |
e23f8d20 UD |
1862 | % Set the baselineskip to #1, and the lineskip and strut size |
1863 | % correspondingly. There is no deep meaning behind these magic numbers | |
1864 | % used as factors; they just match (closely enough) what Knuth defined. | |
1865 | % | |
1866 | \def\lineskipfactor{.08333} | |
1867 | \def\strutheightpercent{.70833} | |
1868 | \def\strutdepthpercent {.29167} | |
1869 | % | |
c94f48d7 AJ |
1870 | % can get a sort of poor man's double spacing by redefining this. |
1871 | \def\baselinefactor{1} | |
1872 | % | |
8fcb833a | 1873 | \newdimen\textleading |
e23f8d20 | 1874 | \def\setleading#1{% |
c94f48d7 AJ |
1875 | \dimen0 = #1\relax |
1876 | \normalbaselineskip = \baselinefactor\dimen0 | |
e23f8d20 UD |
1877 | \normallineskip = \lineskipfactor\normalbaselineskip |
1878 | \normalbaselines | |
1879 | \setbox\strutbox =\hbox{% | |
1880 | \vrule width0pt height\strutheightpercent\baselineskip | |
1881 | depth \strutdepthpercent \baselineskip | |
1882 | }% | |
1883 | } | |
1884 | ||
c94f48d7 AJ |
1885 | % PDF CMaps. See also LaTeX's t1.cmap. |
1886 | % | |
0f8bbd69 JM |
1887 | % do nothing with this by default. |
1888 | \expandafter\let\csname cmapOT1\endcsname\gobble | |
1889 | \expandafter\let\csname cmapOT1IT\endcsname\gobble | |
1890 | \expandafter\let\csname cmapOT1TT\endcsname\gobble | |
1891 | ||
1892 | % if we are producing pdf, and we have \pdffontattr, then define cmaps. | |
1893 | % (\pdffontattr was introduced many years ago, but people still run | |
1894 | % older pdftex's; it's easy to conditionalize, so we do.) | |
1895 | \ifpdf \ifx\pdffontattr\thisisundefined \else | |
c94f48d7 AJ |
1896 | \begingroup |
1897 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. | |
1898 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap | |
1899 | %%DocumentNeededResources: ProcSet (CIDInit) | |
1900 | %%IncludeResource: ProcSet (CIDInit) | |
1901 | %%BeginResource: CMap (TeX-OT1-0) | |
1902 | %%Title: (TeX-OT1-0 TeX OT1 0) | |
1903 | %%Version: 1.000 | |
1904 | %%EndComments | |
1905 | /CIDInit /ProcSet findresource begin | |
1906 | 12 dict begin | |
1907 | begincmap | |
1908 | /CIDSystemInfo | |
1909 | << /Registry (TeX) | |
1910 | /Ordering (OT1) | |
1911 | /Supplement 0 | |
1912 | >> def | |
1913 | /CMapName /TeX-OT1-0 def | |
1914 | /CMapType 2 def | |
1915 | 1 begincodespacerange | |
1916 | <00> <7F> | |
1917 | endcodespacerange | |
1918 | 8 beginbfrange | |
1919 | <00> <01> <0393> | |
1920 | <09> <0A> <03A8> | |
1921 | <23> <26> <0023> | |
1922 | <28> <3B> <0028> | |
1923 | <3F> <5B> <003F> | |
1924 | <5D> <5E> <005D> | |
1925 | <61> <7A> <0061> | |
1926 | <7B> <7C> <2013> | |
1927 | endbfrange | |
1928 | 40 beginbfchar | |
1929 | <02> <0398> | |
1930 | <03> <039B> | |
1931 | <04> <039E> | |
1932 | <05> <03A0> | |
1933 | <06> <03A3> | |
1934 | <07> <03D2> | |
1935 | <08> <03A6> | |
1936 | <0B> <00660066> | |
1937 | <0C> <00660069> | |
1938 | <0D> <0066006C> | |
1939 | <0E> <006600660069> | |
1940 | <0F> <00660066006C> | |
1941 | <10> <0131> | |
1942 | <11> <0237> | |
1943 | <12> <0060> | |
1944 | <13> <00B4> | |
1945 | <14> <02C7> | |
1946 | <15> <02D8> | |
1947 | <16> <00AF> | |
1948 | <17> <02DA> | |
1949 | <18> <00B8> | |
1950 | <19> <00DF> | |
1951 | <1A> <00E6> | |
1952 | <1B> <0153> | |
1953 | <1C> <00F8> | |
1954 | <1D> <00C6> | |
1955 | <1E> <0152> | |
1956 | <1F> <00D8> | |
1957 | <21> <0021> | |
1958 | <22> <201D> | |
1959 | <27> <2019> | |
1960 | <3C> <00A1> | |
1961 | <3D> <003D> | |
1962 | <3E> <00BF> | |
1963 | <5C> <201C> | |
1964 | <5F> <02D9> | |
1965 | <60> <2018> | |
1966 | <7D> <02DD> | |
1967 | <7E> <007E> | |
1968 | <7F> <00A8> | |
1969 | endbfchar | |
1970 | endcmap | |
1971 | CMapName currentdict /CMap defineresource pop | |
1972 | end | |
1973 | end | |
1974 | %%EndResource | |
1975 | %%EOF | |
1976 | }\endgroup | |
1977 | \expandafter\edef\csname cmapOT1\endcsname#1{% | |
1978 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% | |
1979 | }% | |
1980 | % | |
1981 | % \cmapOT1IT | |
1982 | \begingroup | |
1983 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. | |
1984 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap | |
1985 | %%DocumentNeededResources: ProcSet (CIDInit) | |
1986 | %%IncludeResource: ProcSet (CIDInit) | |
1987 | %%BeginResource: CMap (TeX-OT1IT-0) | |
1988 | %%Title: (TeX-OT1IT-0 TeX OT1IT 0) | |
1989 | %%Version: 1.000 | |
1990 | %%EndComments | |
1991 | /CIDInit /ProcSet findresource begin | |
1992 | 12 dict begin | |
1993 | begincmap | |
1994 | /CIDSystemInfo | |
1995 | << /Registry (TeX) | |
1996 | /Ordering (OT1IT) | |
1997 | /Supplement 0 | |
1998 | >> def | |
1999 | /CMapName /TeX-OT1IT-0 def | |
2000 | /CMapType 2 def | |
2001 | 1 begincodespacerange | |
2002 | <00> <7F> | |
2003 | endcodespacerange | |
2004 | 8 beginbfrange | |
2005 | <00> <01> <0393> | |
2006 | <09> <0A> <03A8> | |
2007 | <25> <26> <0025> | |
2008 | <28> <3B> <0028> | |
2009 | <3F> <5B> <003F> | |
2010 | <5D> <5E> <005D> | |
2011 | <61> <7A> <0061> | |
2012 | <7B> <7C> <2013> | |
2013 | endbfrange | |
2014 | 42 beginbfchar | |
2015 | <02> <0398> | |
2016 | <03> <039B> | |
2017 | <04> <039E> | |
2018 | <05> <03A0> | |
2019 | <06> <03A3> | |
2020 | <07> <03D2> | |
2021 | <08> <03A6> | |
2022 | <0B> <00660066> | |
2023 | <0C> <00660069> | |
2024 | <0D> <0066006C> | |
2025 | <0E> <006600660069> | |
2026 | <0F> <00660066006C> | |
2027 | <10> <0131> | |
2028 | <11> <0237> | |
2029 | <12> <0060> | |
2030 | <13> <00B4> | |
2031 | <14> <02C7> | |
2032 | <15> <02D8> | |
2033 | <16> <00AF> | |
2034 | <17> <02DA> | |
2035 | <18> <00B8> | |
2036 | <19> <00DF> | |
2037 | <1A> <00E6> | |
2038 | <1B> <0153> | |
2039 | <1C> <00F8> | |
2040 | <1D> <00C6> | |
2041 | <1E> <0152> | |
2042 | <1F> <00D8> | |
2043 | <21> <0021> | |
2044 | <22> <201D> | |
2045 | <23> <0023> | |
2046 | <24> <00A3> | |
2047 | <27> <2019> | |
2048 | <3C> <00A1> | |
2049 | <3D> <003D> | |
2050 | <3E> <00BF> | |
2051 | <5C> <201C> | |
2052 | <5F> <02D9> | |
2053 | <60> <2018> | |
2054 | <7D> <02DD> | |
2055 | <7E> <007E> | |
2056 | <7F> <00A8> | |
2057 | endbfchar | |
2058 | endcmap | |
2059 | CMapName currentdict /CMap defineresource pop | |
2060 | end | |
2061 | end | |
2062 | %%EndResource | |
2063 | %%EOF | |
2064 | }\endgroup | |
2065 | \expandafter\edef\csname cmapOT1IT\endcsname#1{% | |
2066 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% | |
2067 | }% | |
2068 | % | |
2069 | % \cmapOT1TT | |
2070 | \begingroup | |
2071 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. | |
2072 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap | |
2073 | %%DocumentNeededResources: ProcSet (CIDInit) | |
2074 | %%IncludeResource: ProcSet (CIDInit) | |
2075 | %%BeginResource: CMap (TeX-OT1TT-0) | |
2076 | %%Title: (TeX-OT1TT-0 TeX OT1TT 0) | |
2077 | %%Version: 1.000 | |
2078 | %%EndComments | |
2079 | /CIDInit /ProcSet findresource begin | |
2080 | 12 dict begin | |
2081 | begincmap | |
2082 | /CIDSystemInfo | |
2083 | << /Registry (TeX) | |
2084 | /Ordering (OT1TT) | |
2085 | /Supplement 0 | |
2086 | >> def | |
2087 | /CMapName /TeX-OT1TT-0 def | |
2088 | /CMapType 2 def | |
2089 | 1 begincodespacerange | |
2090 | <00> <7F> | |
2091 | endcodespacerange | |
2092 | 5 beginbfrange | |
2093 | <00> <01> <0393> | |
2094 | <09> <0A> <03A8> | |
2095 | <21> <26> <0021> | |
2096 | <28> <5F> <0028> | |
2097 | <61> <7E> <0061> | |
2098 | endbfrange | |
2099 | 32 beginbfchar | |
2100 | <02> <0398> | |
2101 | <03> <039B> | |
2102 | <04> <039E> | |
2103 | <05> <03A0> | |
2104 | <06> <03A3> | |
2105 | <07> <03D2> | |
2106 | <08> <03A6> | |
2107 | <0B> <2191> | |
2108 | <0C> <2193> | |
2109 | <0D> <0027> | |
2110 | <0E> <00A1> | |
2111 | <0F> <00BF> | |
2112 | <10> <0131> | |
2113 | <11> <0237> | |
2114 | <12> <0060> | |
2115 | <13> <00B4> | |
2116 | <14> <02C7> | |
2117 | <15> <02D8> | |
2118 | <16> <00AF> | |
2119 | <17> <02DA> | |
2120 | <18> <00B8> | |
2121 | <19> <00DF> | |
2122 | <1A> <00E6> | |
2123 | <1B> <0153> | |
2124 | <1C> <00F8> | |
2125 | <1D> <00C6> | |
2126 | <1E> <0152> | |
2127 | <1F> <00D8> | |
2128 | <20> <2423> | |
2129 | <27> <2019> | |
2130 | <60> <2018> | |
2131 | <7F> <00A8> | |
2132 | endbfchar | |
2133 | endcmap | |
2134 | CMapName currentdict /CMap defineresource pop | |
2135 | end | |
2136 | end | |
2137 | %%EndResource | |
2138 | %%EOF | |
2139 | }\endgroup | |
2140 | \expandafter\edef\csname cmapOT1TT\endcsname#1{% | |
2141 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% | |
2142 | }% | |
0f8bbd69 | 2143 | \fi\fi |
c94f48d7 | 2144 | |
9251c568 | 2145 | |
8fcb833a | 2146 | % Set the font macro #1 to the font named \fontprefix#2. |
c94f48d7 | 2147 | % #3 is the font's design size, #4 is a scale factor, #5 is the CMap |
8fcb833a JM |
2148 | % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). |
2149 | % Example: | |
2150 | % #1 = \textrm | |
2151 | % #2 = \rmshape | |
2152 | % #3 = 10 | |
2153 | % #4 = \mainmagstep | |
2154 | % #5 = OT1 | |
2155 | % | |
c94f48d7 AJ |
2156 | \def\setfont#1#2#3#4#5{% |
2157 | \font#1=\fontprefix#2#3 scaled #4 | |
2158 | \csname cmap#5\endcsname#1% | |
2159 | } | |
2160 | % This is what gets called when #5 of \setfont is empty. | |
2161 | \let\cmap\gobble | |
8fcb833a JM |
2162 | % |
2163 | % (end of cmaps) | |
9251c568 | 2164 | |
9e9f9cc2 KB |
2165 | % Use cm as the default font prefix. |
2166 | % To specify the font prefix, you must define \fontprefix | |
2167 | % before you read in texinfo.tex. | |
0f8bbd69 | 2168 | \ifx\fontprefix\thisisundefined |
9e9f9cc2 KB |
2169 | \def\fontprefix{cm} |
2170 | \fi | |
2171 | % Support font families that don't use the same naming scheme as CM. | |
2172 | \def\rmshape{r} | |
8fcb833a | 2173 | \def\rmbshape{bx} % where the normal face is bold |
9e9f9cc2 KB |
2174 | \def\bfshape{b} |
2175 | \def\bxshape{bx} | |
2176 | \def\ttshape{tt} | |
2177 | \def\ttbshape{tt} | |
2178 | \def\ttslshape{sltt} | |
2179 | \def\itshape{ti} | |
2180 | \def\itbshape{bxti} | |
2181 | \def\slshape{sl} | |
2182 | \def\slbshape{bxsl} | |
2183 | \def\sfshape{ss} | |
2184 | \def\sfbshape{ss} | |
2185 | \def\scshape{csc} | |
2186 | \def\scbshape{csc} | |
2187 | ||
8fcb833a | 2188 | % Definitions for a main text size of 11pt. (The default in Texinfo.) |
0f8bbd69 | 2189 | % |
c94f48d7 | 2190 | \def\definetextfontsizexi{% |
82d5ce1d UD |
2191 | % Text fonts (11.2pt, magstep1). |
2192 | \def\textnominalsize{11pt} | |
2193 | \edef\mainmagstep{\magstephalf} | |
c94f48d7 AJ |
2194 | \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} |
2195 | \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} | |
2196 | \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} | |
2197 | \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} | |
2198 | \setfont\textsl\slshape{10}{\mainmagstep}{OT1} | |
2199 | \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} | |
2200 | \setfont\textsc\scshape{10}{\mainmagstep}{OT1} | |
2201 | \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} | |
9e9f9cc2 KB |
2202 | \font\texti=cmmi10 scaled \mainmagstep |
2203 | \font\textsy=cmsy10 scaled \mainmagstep | |
c94f48d7 | 2204 | \def\textecsize{1095} |
9e9f9cc2 | 2205 | |
82d5ce1d | 2206 | % A few fonts for @defun names and args. |
c94f48d7 AJ |
2207 | \setfont\defbf\bfshape{10}{\magstep1}{OT1} |
2208 | \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} | |
084e7d57 | 2209 | \setfont\defsl\slshape{10}{\magstep1}{OT1TT} |
c94f48d7 | 2210 | \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} |
7f7dd1d3 JM |
2211 | \def\df{\let\ttfont=\deftt \let\bffont = \defbf |
2212 | \let\ttslfont=\defttsl \let\slfont=\defsl \bf} | |
9e9f9cc2 | 2213 | |
3b82ab1c | 2214 | % Fonts for indices, footnotes, small examples (9pt). |
82d5ce1d | 2215 | \def\smallnominalsize{9pt} |
c94f48d7 AJ |
2216 | \setfont\smallrm\rmshape{9}{1000}{OT1} |
2217 | \setfont\smalltt\ttshape{9}{1000}{OT1TT} | |
2218 | \setfont\smallbf\bfshape{10}{900}{OT1} | |
2219 | \setfont\smallit\itshape{9}{1000}{OT1IT} | |
2220 | \setfont\smallsl\slshape{9}{1000}{OT1} | |
2221 | \setfont\smallsf\sfshape{9}{1000}{OT1} | |
2222 | \setfont\smallsc\scshape{10}{900}{OT1} | |
2223 | \setfont\smallttsl\ttslshape{10}{900}{OT1TT} | |
3b82ab1c UD |
2224 | \font\smalli=cmmi9 |
2225 | \font\smallsy=cmsy9 | |
c94f48d7 | 2226 | \def\smallecsize{0900} |
9e9f9cc2 | 2227 | |
be1152ca | 2228 | % Fonts for small examples (8pt). |
82d5ce1d | 2229 | \def\smallernominalsize{8pt} |
c94f48d7 AJ |
2230 | \setfont\smallerrm\rmshape{8}{1000}{OT1} |
2231 | \setfont\smallertt\ttshape{8}{1000}{OT1TT} | |
2232 | \setfont\smallerbf\bfshape{10}{800}{OT1} | |
2233 | \setfont\smallerit\itshape{8}{1000}{OT1IT} | |
2234 | \setfont\smallersl\slshape{8}{1000}{OT1} | |
2235 | \setfont\smallersf\sfshape{8}{1000}{OT1} | |
2236 | \setfont\smallersc\scshape{10}{800}{OT1} | |
2237 | \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} | |
be1152ca UD |
2238 | \font\smalleri=cmmi8 |
2239 | \font\smallersy=cmsy8 | |
c94f48d7 | 2240 | \def\smallerecsize{0800} |
be1152ca | 2241 | |
82d5ce1d UD |
2242 | % Fonts for title page (20.4pt): |
2243 | \def\titlenominalsize{20pt} | |
c94f48d7 AJ |
2244 | \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} |
2245 | \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} | |
2246 | \setfont\titlesl\slbshape{10}{\magstep4}{OT1} | |
2247 | \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} | |
2248 | \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} | |
2249 | \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} | |
9c2322bc | 2250 | \let\titlebf=\titlerm |
c94f48d7 | 2251 | \setfont\titlesc\scbshape{10}{\magstep4}{OT1} |
9c2322bc UD |
2252 | \font\titlei=cmmi12 scaled \magstep3 |
2253 | \font\titlesy=cmsy10 scaled \magstep4 | |
c94f48d7 | 2254 | \def\titleecsize{2074} |
9c2322bc | 2255 | |
cd4e176c | 2256 | % Chapter (and unnumbered) fonts (17.28pt). |
82d5ce1d | 2257 | \def\chapnominalsize{17pt} |
c94f48d7 AJ |
2258 | \setfont\chaprm\rmbshape{12}{\magstep2}{OT1} |
2259 | \setfont\chapit\itbshape{10}{\magstep3}{OT1IT} | |
2260 | \setfont\chapsl\slbshape{10}{\magstep3}{OT1} | |
2261 | \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} | |
2262 | \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} | |
2263 | \setfont\chapsf\sfbshape{17}{1000}{OT1} | |
9e9f9cc2 | 2264 | \let\chapbf=\chaprm |
c94f48d7 | 2265 | \setfont\chapsc\scbshape{10}{\magstep3}{OT1} |
9e9f9cc2 KB |
2266 | \font\chapi=cmmi12 scaled \magstep2 |
2267 | \font\chapsy=cmsy10 scaled \magstep3 | |
c94f48d7 | 2268 | \def\chapecsize{1728} |
9e9f9cc2 | 2269 | |
cd4e176c | 2270 | % Section fonts (14.4pt). |
82d5ce1d | 2271 | \def\secnominalsize{14pt} |
c94f48d7 | 2272 | \setfont\secrm\rmbshape{12}{\magstep1}{OT1} |
084e7d57 | 2273 | \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1} |
c94f48d7 AJ |
2274 | \setfont\secit\itbshape{10}{\magstep2}{OT1IT} |
2275 | \setfont\secsl\slbshape{10}{\magstep2}{OT1} | |
2276 | \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} | |
2277 | \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} | |
2278 | \setfont\secsf\sfbshape{12}{\magstep1}{OT1} | |
9e9f9cc2 | 2279 | \let\secbf\secrm |
c94f48d7 | 2280 | \setfont\secsc\scbshape{10}{\magstep2}{OT1} |
9e9f9cc2 KB |
2281 | \font\seci=cmmi12 scaled \magstep1 |
2282 | \font\secsy=cmsy10 scaled \magstep2 | |
c94f48d7 | 2283 | \def\sececsize{1440} |
9e9f9cc2 | 2284 | |
cd4e176c | 2285 | % Subsection fonts (13.15pt). |
82d5ce1d | 2286 | \def\ssecnominalsize{13pt} |
c94f48d7 AJ |
2287 | \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} |
2288 | \setfont\ssecit\itbshape{10}{1315}{OT1IT} | |
2289 | \setfont\ssecsl\slbshape{10}{1315}{OT1} | |
2290 | \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} | |
2291 | \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} | |
2292 | \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} | |
9e9f9cc2 | 2293 | \let\ssecbf\ssecrm |
c94f48d7 | 2294 | \setfont\ssecsc\scbshape{10}{1315}{OT1} |
9e9f9cc2 | 2295 | \font\sseci=cmmi12 scaled \magstephalf |
9c2322bc | 2296 | \font\ssecsy=cmsy10 scaled 1315 |
c94f48d7 | 2297 | \def\ssececsize{1200} |
82d5ce1d | 2298 | |
7f7dd1d3 | 2299 | % Reduced fonts for @acronym in text (10pt). |
82d5ce1d | 2300 | \def\reducednominalsize{10pt} |
c94f48d7 AJ |
2301 | \setfont\reducedrm\rmshape{10}{1000}{OT1} |
2302 | \setfont\reducedtt\ttshape{10}{1000}{OT1TT} | |
2303 | \setfont\reducedbf\bfshape{10}{1000}{OT1} | |
2304 | \setfont\reducedit\itshape{10}{1000}{OT1IT} | |
2305 | \setfont\reducedsl\slshape{10}{1000}{OT1} | |
2306 | \setfont\reducedsf\sfshape{10}{1000}{OT1} | |
2307 | \setfont\reducedsc\scshape{10}{1000}{OT1} | |
2308 | \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} | |
82d5ce1d UD |
2309 | \font\reducedi=cmmi10 |
2310 | \font\reducedsy=cmsy10 | |
c94f48d7 | 2311 | \def\reducedecsize{1000} |
9e9f9cc2 | 2312 | |
0f8bbd69 JM |
2313 | \textleading = 13.2pt % line spacing for 11pt CM |
2314 | \textfonts % reset the current fonts | |
9251c568 | 2315 | \rm |
8fcb833a | 2316 | } % end of 11pt text font size definitions, \definetextfontsizexi |
9251c568 AJ |
2317 | |
2318 | ||
2319 | % Definitions to make the main text be 10pt Computer Modern, with | |
2320 | % section, chapter, etc., sizes following suit. This is for the GNU | |
2321 | % Press printing of the Emacs 22 manual. Maybe other manuals in the | |
2322 | % future. Used with @smallbook, which sets the leading to 12pt. | |
0f8bbd69 | 2323 | % |
9251c568 AJ |
2324 | \def\definetextfontsizex{% |
2325 | % Text fonts (10pt). | |
2326 | \def\textnominalsize{10pt} | |
2327 | \edef\mainmagstep{1000} | |
c94f48d7 AJ |
2328 | \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} |
2329 | \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} | |
2330 | \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} | |
2331 | \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} | |
2332 | \setfont\textsl\slshape{10}{\mainmagstep}{OT1} | |
2333 | \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} | |
2334 | \setfont\textsc\scshape{10}{\mainmagstep}{OT1} | |
2335 | \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} | |
9251c568 AJ |
2336 | \font\texti=cmmi10 scaled \mainmagstep |
2337 | \font\textsy=cmsy10 scaled \mainmagstep | |
c94f48d7 | 2338 | \def\textecsize{1000} |
9251c568 AJ |
2339 | |
2340 | % A few fonts for @defun names and args. | |
c94f48d7 AJ |
2341 | \setfont\defbf\bfshape{10}{\magstephalf}{OT1} |
2342 | \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} | |
084e7d57 | 2343 | \setfont\defsl\slshape{10}{\magstephalf}{OT1TT} |
c94f48d7 | 2344 | \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} |
7f7dd1d3 JM |
2345 | \def\df{\let\ttfont=\deftt \let\bffont = \defbf |
2346 | \let\slfont=\defsl \let\ttslfont=\defttsl \bf} | |
9251c568 AJ |
2347 | |
2348 | % Fonts for indices, footnotes, small examples (9pt). | |
2349 | \def\smallnominalsize{9pt} | |
c94f48d7 AJ |
2350 | \setfont\smallrm\rmshape{9}{1000}{OT1} |
2351 | \setfont\smalltt\ttshape{9}{1000}{OT1TT} | |
2352 | \setfont\smallbf\bfshape{10}{900}{OT1} | |
2353 | \setfont\smallit\itshape{9}{1000}{OT1IT} | |
2354 | \setfont\smallsl\slshape{9}{1000}{OT1} | |
2355 | \setfont\smallsf\sfshape{9}{1000}{OT1} | |
2356 | \setfont\smallsc\scshape{10}{900}{OT1} | |
2357 | \setfont\smallttsl\ttslshape{10}{900}{OT1TT} | |
9251c568 AJ |
2358 | \font\smalli=cmmi9 |
2359 | \font\smallsy=cmsy9 | |
c94f48d7 | 2360 | \def\smallecsize{0900} |
9251c568 AJ |
2361 | |
2362 | % Fonts for small examples (8pt). | |
2363 | \def\smallernominalsize{8pt} | |
c94f48d7 AJ |
2364 | \setfont\smallerrm\rmshape{8}{1000}{OT1} |
2365 | \setfont\smallertt\ttshape{8}{1000}{OT1TT} | |
2366 | \setfont\smallerbf\bfshape{10}{800}{OT1} | |
2367 | \setfont\smallerit\itshape{8}{1000}{OT1IT} | |
2368 | \setfont\smallersl\slshape{8}{1000}{OT1} | |
2369 | \setfont\smallersf\sfshape{8}{1000}{OT1} | |
2370 | \setfont\smallersc\scshape{10}{800}{OT1} | |
2371 | \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} | |
9251c568 AJ |
2372 | \font\smalleri=cmmi8 |
2373 | \font\smallersy=cmsy8 | |
c94f48d7 | 2374 | \def\smallerecsize{0800} |
9251c568 AJ |
2375 | |
2376 | % Fonts for title page (20.4pt): | |
2377 | \def\titlenominalsize{20pt} | |
c94f48d7 AJ |
2378 | \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} |
2379 | \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} | |
2380 | \setfont\titlesl\slbshape{10}{\magstep4}{OT1} | |
2381 | \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} | |
2382 | \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} | |
2383 | \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} | |
9251c568 | 2384 | \let\titlebf=\titlerm |
c94f48d7 | 2385 | \setfont\titlesc\scbshape{10}{\magstep4}{OT1} |
9251c568 AJ |
2386 | \font\titlei=cmmi12 scaled \magstep3 |
2387 | \font\titlesy=cmsy10 scaled \magstep4 | |
c94f48d7 | 2388 | \def\titleecsize{2074} |
9251c568 AJ |
2389 | |
2390 | % Chapter fonts (14.4pt). | |
2391 | \def\chapnominalsize{14pt} | |
c94f48d7 AJ |
2392 | \setfont\chaprm\rmbshape{12}{\magstep1}{OT1} |
2393 | \setfont\chapit\itbshape{10}{\magstep2}{OT1IT} | |
2394 | \setfont\chapsl\slbshape{10}{\magstep2}{OT1} | |
2395 | \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} | |
2396 | \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} | |
2397 | \setfont\chapsf\sfbshape{12}{\magstep1}{OT1} | |
9251c568 | 2398 | \let\chapbf\chaprm |
c94f48d7 | 2399 | \setfont\chapsc\scbshape{10}{\magstep2}{OT1} |
9251c568 AJ |
2400 | \font\chapi=cmmi12 scaled \magstep1 |
2401 | \font\chapsy=cmsy10 scaled \magstep2 | |
c94f48d7 | 2402 | \def\chapecsize{1440} |
9251c568 AJ |
2403 | |
2404 | % Section fonts (12pt). | |
2405 | \def\secnominalsize{12pt} | |
c94f48d7 AJ |
2406 | \setfont\secrm\rmbshape{12}{1000}{OT1} |
2407 | \setfont\secit\itbshape{10}{\magstep1}{OT1IT} | |
2408 | \setfont\secsl\slbshape{10}{\magstep1}{OT1} | |
2409 | \setfont\sectt\ttbshape{12}{1000}{OT1TT} | |
2410 | \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} | |
2411 | \setfont\secsf\sfbshape{12}{1000}{OT1} | |
9251c568 | 2412 | \let\secbf\secrm |
c94f48d7 | 2413 | \setfont\secsc\scbshape{10}{\magstep1}{OT1} |
0f8bbd69 | 2414 | \font\seci=cmmi12 |
9251c568 | 2415 | \font\secsy=cmsy10 scaled \magstep1 |
c94f48d7 | 2416 | \def\sececsize{1200} |
9251c568 AJ |
2417 | |
2418 | % Subsection fonts (10pt). | |
2419 | \def\ssecnominalsize{10pt} | |
c94f48d7 AJ |
2420 | \setfont\ssecrm\rmbshape{10}{1000}{OT1} |
2421 | \setfont\ssecit\itbshape{10}{1000}{OT1IT} | |
2422 | \setfont\ssecsl\slbshape{10}{1000}{OT1} | |
2423 | \setfont\ssectt\ttbshape{10}{1000}{OT1TT} | |
2424 | \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} | |
2425 | \setfont\ssecsf\sfbshape{10}{1000}{OT1} | |
9251c568 | 2426 | \let\ssecbf\ssecrm |
c94f48d7 | 2427 | \setfont\ssecsc\scbshape{10}{1000}{OT1} |
9251c568 AJ |
2428 | \font\sseci=cmmi10 |
2429 | \font\ssecsy=cmsy10 | |
c94f48d7 | 2430 | \def\ssececsize{1000} |
9251c568 | 2431 | |
7f7dd1d3 | 2432 | % Reduced fonts for @acronym in text (9pt). |
9251c568 | 2433 | \def\reducednominalsize{9pt} |
c94f48d7 AJ |
2434 | \setfont\reducedrm\rmshape{9}{1000}{OT1} |
2435 | \setfont\reducedtt\ttshape{9}{1000}{OT1TT} | |
2436 | \setfont\reducedbf\bfshape{10}{900}{OT1} | |
2437 | \setfont\reducedit\itshape{9}{1000}{OT1IT} | |
2438 | \setfont\reducedsl\slshape{9}{1000}{OT1} | |
2439 | \setfont\reducedsf\sfshape{9}{1000}{OT1} | |
2440 | \setfont\reducedsc\scshape{10}{900}{OT1} | |
2441 | \setfont\reducedttsl\ttslshape{10}{900}{OT1TT} | |
9251c568 AJ |
2442 | \font\reducedi=cmmi9 |
2443 | \font\reducedsy=cmsy9 | |
c94f48d7 | 2444 | \def\reducedecsize{0900} |
9251c568 | 2445 | |
0f8bbd69 JM |
2446 | \divide\parskip by 2 % reduce space between paragraphs |
2447 | \textleading = 12pt % line spacing for 10pt CM | |
2448 | \textfonts % reset the current fonts | |
9251c568 | 2449 | \rm |
8fcb833a | 2450 | } % end of 10pt text font size definitions, \definetextfontsizex |
9251c568 | 2451 | |
7f7dd1d3 JM |
2452 | % Fonts for short table of contents. |
2453 | \setfont\shortcontrm\rmshape{12}{1000}{OT1} | |
2454 | \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 | |
2455 | \setfont\shortcontsl\slshape{12}{1000}{OT1} | |
2456 | \setfont\shortconttt\ttshape{12}{1000}{OT1TT} | |
2457 | ||
9251c568 AJ |
2458 | |
2459 | % We provide the user-level command | |
2460 | % @fonttextsize 10 | |
2461 | % (or 11) to redefine the text font size. pt is assumed. | |
0f8bbd69 | 2462 | % |
9251c568 | 2463 | \def\xiword{11} |
0f8bbd69 JM |
2464 | \def\xword{10} |
2465 | \def\xwordpt{10pt} | |
9251c568 AJ |
2466 | % |
2467 | \parseargdef\fonttextsize{% | |
2468 | \def\textsizearg{#1}% | |
0f8bbd69 | 2469 | %\wlog{doing @fonttextsize \textsizearg}% |
9251c568 AJ |
2470 | % |
2471 | % Set \globaldefs so that documents can use this inside @tex, since | |
2472 | % makeinfo 4.8 does not support it, but we need it nonetheless. | |
0f8bbd69 | 2473 | % |
9251c568 AJ |
2474 | \begingroup \globaldefs=1 |
2475 | \ifx\textsizearg\xword \definetextfontsizex | |
2476 | \else \ifx\textsizearg\xiword \definetextfontsizexi | |
2477 | \else | |
2478 | \errhelp=\EMsimple | |
2479 | \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} | |
2480 | \fi\fi | |
2481 | \endgroup | |
2482 | } | |
2483 | ||
7f7dd1d3 JM |
2484 | % |
2485 | % Change the current font style to #1, remembering it in \curfontstyle. | |
2486 | % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in | |
2487 | % italics, not bold italics. | |
2488 | % | |
2489 | \def\setfontstyle#1{% | |
2490 | \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. | |
2491 | \csname #1font\endcsname % change the current font | |
2492 | } | |
2493 | ||
2494 | \def\rm{\fam=0 \setfontstyle{rm}} | |
2495 | \def\it{\fam=\itfam \setfontstyle{it}} | |
2496 | \def\sl{\fam=\slfam \setfontstyle{sl}} | |
2497 | \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} | |
2498 | \def\tt{\fam=\ttfam \setfontstyle{tt}} | |
2499 | ||
2500 | % Texinfo sort of supports the sans serif font style, which plain TeX does not. | |
2501 | % So we set up a \sf. | |
2502 | \newfam\sffam | |
2503 | \def\sf{\fam=\sffam \setfontstyle{sf}} | |
2504 | ||
2505 | % We don't need math for this font style. | |
2506 | \def\ttsl{\setfontstyle{ttsl}} | |
2507 | ||
2508 | ||
9e9f9cc2 | 2509 | % In order for the font changes to affect most math symbols and letters, |
084e7d57 JM |
2510 | % we have to define the \textfont of the standard families. We don't |
2511 | % bother to reset \scriptfont and \scriptscriptfont; awaiting user need. | |
9e9f9cc2 KB |
2512 | % |
2513 | \def\resetmathfonts{% | |
7f7dd1d3 JM |
2514 | \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont |
2515 | \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont | |
2516 | \textfont\ttfam=\ttfont \textfont\sffam=\sffont | |
9e9f9cc2 KB |
2517 | } |
2518 | ||
7f7dd1d3 JM |
2519 | % |
2520 | ||
2521 | % The font-changing commands (all called \...fonts) redefine the meanings | |
2522 | % of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs | |
2523 | % to also set the current \fam for math mode. Our \STYLE (e.g., \rm) | |
2524 | % commands hardwire \STYLEfont to set the current font. | |
82d5ce1d UD |
2525 | % |
2526 | % Each font-changing command also sets the names \lsize (one size lower) | |
084e7d57 JM |
2527 | % and \lllsize (three sizes lower). These relative commands are used |
2528 | % in, e.g., the LaTeX logo and acronyms. | |
82d5ce1d UD |
2529 | % |
2530 | % This all needs generalizing, badly. | |
2531 | % | |
e0f86659 | 2532 | |
7f7dd1d3 JM |
2533 | \def\assignfonts#1{% |
2534 | \expandafter\let\expandafter\rmfont\csname #1rm\endcsname | |
2535 | \expandafter\let\expandafter\itfont\csname #1it\endcsname | |
2536 | \expandafter\let\expandafter\slfont\csname #1sl\endcsname | |
2537 | \expandafter\let\expandafter\bffont\csname #1bf\endcsname | |
2538 | \expandafter\let\expandafter\ttfont\csname #1tt\endcsname | |
2539 | \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname | |
2540 | \expandafter\let\expandafter\sffont \csname #1sf\endcsname | |
2541 | \expandafter\let\expandafter\ifont \csname #1i\endcsname | |
2542 | \expandafter\let\expandafter\syfont \csname #1sy\endcsname | |
2543 | \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname | |
2544 | } | |
2545 | ||
2546 | \newif\ifrmisbold | |
2547 | ||
2548 | % Select smaller font size with the current style. Used to change font size | |
2549 | % in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for | |
2550 | % normal roman text, also use bold fonts for roman text in the smaller size. | |
2551 | \def\switchtolllsize{% | |
2552 | \expandafter\assignfonts\expandafter{\lllsize}% | |
2553 | \ifrmisbold | |
2554 | \let\rmfont\bffont | |
2555 | \fi | |
2556 | \csname\curfontstyle\endcsname | |
2557 | }% | |
2558 | ||
2559 | \def\switchtolsize{% | |
2560 | \expandafter\assignfonts\expandafter{\lsize}% | |
2561 | \ifrmisbold | |
2562 | \let\rmfont\bffont | |
2563 | \fi | |
2564 | \csname\curfontstyle\endcsname | |
2565 | }% | |
2566 | ||
2567 | \def\definefontsetatsize#1#2#3#4#5{% | |
2568 | \expandafter\def\csname #1fonts\endcsname{% | |
2569 | \def\curfontsize{#1}% | |
2570 | \def\lsize{#2}\def\lllsize{#3}% | |
2571 | \csname rmisbold#5\endcsname | |
2572 | \assignfonts{#1}% | |
2573 | \resetmathfonts | |
2574 | \setleading{#4}% | |
2575 | }} | |
2576 | ||
2577 | \definefontsetatsize{text} {reduced}{smaller}{\textleading}{false} | |
2578 | \definefontsetatsize{title} {chap} {subsec} {27pt} {true} | |
2579 | \definefontsetatsize{chap} {sec} {text} {19pt} {true} | |
2580 | \definefontsetatsize{sec} {subsec} {reduced}{17pt} {true} | |
2581 | \definefontsetatsize{ssec} {text} {small} {15pt} {true} | |
2582 | \definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false} | |
2583 | \definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false} | |
2584 | \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false} | |
2585 | ||
2586 | \def\titlefont#1{{\titlefonts\rm #1}} | |
2587 | \let\subsecfonts = \ssecfonts | |
2588 | \let\subsubsecfonts = \ssecfonts | |
0f8bbd69 JM |
2589 | |
2590 | % Define these just so they can be easily changed for other fonts. | |
2591 | \def\angleleft{$\langle$} | |
2592 | \def\angleright{$\rangle$} | |
2593 | ||
e0f86659 UD |
2594 | % Set the fonts to use with the @small... environments. |
2595 | \let\smallexamplefonts = \smallfonts | |
2596 | ||
2597 | % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample | |
2598 | % can fit this many characters: | |
2599 | % 8.5x11=86 smallbook=72 a4=90 a5=69 | |
82d5ce1d | 2600 | % If we use \scriptfonts (8pt), then we can fit this many characters: |
e0f86659 UD |
2601 | % 8.5x11=90+ smallbook=80 a4=90+ a5=77 |
2602 | % For me, subjectively, the few extra characters that fit aren't worth | |
2603 | % the additional smallness of 8pt. So I'm making the default 9pt. | |
7158eae4 | 2604 | % |
e0f86659 UD |
2605 | % By the way, for comparison, here's what fits with @example (10pt): |
2606 | % 8.5x11=71 smallbook=60 a4=75 a5=58 | |
e0f86659 UD |
2607 | % --karl, 24jan03. |
2608 | ||
9e9f9cc2 KB |
2609 | % Set up the default fonts, so we can use them for creating boxes. |
2610 | % | |
9251c568 | 2611 | \definetextfontsizexi |
9e9f9cc2 | 2612 | |
2eb45444 | 2613 | |
0f8bbd69 | 2614 | \message{markup,} |
9e9f9cc2 | 2615 | |
0f8bbd69 JM |
2616 | % Check if we are currently using a typewriter font. Since all the |
2617 | % Computer Modern typewriter fonts have zero interword stretch (and | |
2618 | % shrink), and it is reasonable to expect all typewriter fonts to have | |
2619 | % this property, we can check that font parameter. | |
2620 | % | |
2621 | \def\ifmonospace{\ifdim\fontdimen3\font=0pt } | |
2622 | ||
2623 | % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will | |
2624 | % define and register \INITMACRO to be called on markup style changes. | |
2625 | % \INITMACRO can check \currentmarkupstyle for the innermost | |
2626 | % style and the set of \ifmarkupSTYLE switches for all styles | |
2627 | % currently in effect. | |
2628 | \newif\ifmarkupvar | |
2629 | \newif\ifmarkupsamp | |
2630 | \newif\ifmarkupkey | |
2631 | %\newif\ifmarkupfile % @file == @samp. | |
2632 | %\newif\ifmarkupoption % @option == @samp. | |
2633 | \newif\ifmarkupcode | |
2634 | \newif\ifmarkupkbd | |
2635 | %\newif\ifmarkupenv % @env == @code. | |
2636 | %\newif\ifmarkupcommand % @command == @code. | |
2637 | \newif\ifmarkuptex % @tex (and part of @math, for now). | |
2638 | \newif\ifmarkupexample | |
2639 | \newif\ifmarkupverb | |
2640 | \newif\ifmarkupverbatim | |
9e9f9cc2 | 2641 | |
0f8bbd69 | 2642 | \let\currentmarkupstyle\empty |
9e9f9cc2 | 2643 | |
0f8bbd69 JM |
2644 | \def\setupmarkupstyle#1{% |
2645 | \csname markup#1true\endcsname | |
2646 | \def\currentmarkupstyle{#1}% | |
2647 | \markupstylesetup | |
2648 | } | |
9e9f9cc2 | 2649 | |
0f8bbd69 JM |
2650 | \let\markupstylesetup\empty |
2651 | ||
2652 | \def\defmarkupstylesetup#1{% | |
2653 | \expandafter\def\expandafter\markupstylesetup | |
2654 | \expandafter{\markupstylesetup #1}% | |
2655 | \def#1% | |
2656 | } | |
2657 | ||
2658 | % Markup style setup for left and right quotes. | |
2659 | \defmarkupstylesetup\markupsetuplq{% | |
2660 | \expandafter\let\expandafter \temp | |
2661 | \csname markupsetuplq\currentmarkupstyle\endcsname | |
2662 | \ifx\temp\relax \markupsetuplqdefault \else \temp \fi | |
2663 | } | |
2664 | ||
2665 | \defmarkupstylesetup\markupsetuprq{% | |
2666 | \expandafter\let\expandafter \temp | |
2667 | \csname markupsetuprq\currentmarkupstyle\endcsname | |
2668 | \ifx\temp\relax \markupsetuprqdefault \else \temp \fi | |
2669 | } | |
2670 | ||
2671 | { | |
2672 | \catcode`\'=\active | |
2673 | \catcode`\`=\active | |
2674 | ||
2675 | \gdef\markupsetuplqdefault{\let`\lq} | |
2676 | \gdef\markupsetuprqdefault{\let'\rq} | |
2677 | ||
2678 | \gdef\markupsetcodequoteleft{\let`\codequoteleft} | |
2679 | \gdef\markupsetcodequoteright{\let'\codequoteright} | |
0f8bbd69 JM |
2680 | } |
2681 | ||
2682 | \let\markupsetuplqcode \markupsetcodequoteleft | |
2683 | \let\markupsetuprqcode \markupsetcodequoteright | |
2684 | % | |
2685 | \let\markupsetuplqexample \markupsetcodequoteleft | |
2686 | \let\markupsetuprqexample \markupsetcodequoteright | |
2687 | % | |
8fcb833a JM |
2688 | \let\markupsetuplqkbd \markupsetcodequoteleft |
2689 | \let\markupsetuprqkbd \markupsetcodequoteright | |
2690 | % | |
0f8bbd69 JM |
2691 | \let\markupsetuplqsamp \markupsetcodequoteleft |
2692 | \let\markupsetuprqsamp \markupsetcodequoteright | |
2693 | % | |
2694 | \let\markupsetuplqverb \markupsetcodequoteleft | |
2695 | \let\markupsetuprqverb \markupsetcodequoteright | |
2696 | % | |
2697 | \let\markupsetuplqverbatim \markupsetcodequoteleft | |
2698 | \let\markupsetuprqverbatim \markupsetcodequoteright | |
2699 | ||
0f8bbd69 JM |
2700 | % Allow an option to not use regular directed right quote/apostrophe |
2701 | % (char 0x27), but instead the undirected quote from cmtt (char 0x0d). | |
2702 | % The undirected quote is ugly, so don't make it the default, but it | |
2703 | % works for pasting with more pdf viewers (at least evince), the | |
2704 | % lilypond developers report. xpdf does work with the regular 0x27. | |
2705 | % | |
2706 | \def\codequoteright{% | |
2707 | \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax | |
2708 | \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax | |
2709 | '% | |
2710 | \else \char'15 \fi | |
2711 | \else \char'15 \fi | |
2712 | } | |
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. | |
2717 | % | |
2718 | \def\codequoteleft{% | |
2719 | \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax | |
2720 | \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax | |
2721 | % [Knuth] pp. 380,381,391 | |
2722 | % \relax disables Spanish ligatures ?` and !` of \tt font. | |
2723 | \relax`% | |
2724 | \else \char'22 \fi | |
2725 | \else \char'22 \fi | |
2726 | } | |
2727 | ||
2728 | % Commands to set the quote options. | |
2729 | % | |
2730 | \parseargdef\codequoteundirected{% | |
2731 | \def\temp{#1}% | |
2732 | \ifx\temp\onword | |
2733 | \expandafter\let\csname SETtxicodequoteundirected\endcsname | |
2734 | = t% | |
2735 | \else\ifx\temp\offword | |
2736 | \expandafter\let\csname SETtxicodequoteundirected\endcsname | |
2737 | = \relax | |
2738 | \else | |
2739 | \errhelp = \EMsimple | |
2740 | \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% | |
2741 | \fi\fi | |
2742 | } | |
2743 | % | |
2744 | \parseargdef\codequotebacktick{% | |
2745 | \def\temp{#1}% | |
2746 | \ifx\temp\onword | |
2747 | \expandafter\let\csname SETtxicodequotebacktick\endcsname | |
2748 | = t% | |
2749 | \else\ifx\temp\offword | |
2750 | \expandafter\let\csname SETtxicodequotebacktick\endcsname | |
2751 | = \relax | |
2752 | \else | |
2753 | \errhelp = \EMsimple | |
2754 | \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% | |
2755 | \fi\fi | |
2756 | } | |
2757 | ||
2758 | % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. | |
2759 | \def\noligaturesquoteleft{\relax\lq} | |
2760 | ||
2761 | % Count depth in font-changes, for error checks | |
2762 | \newcount\fontdepth \fontdepth=0 | |
2763 | ||
2764 | % Font commands. | |
2765 | ||
2766 | % #1 is the font command (\sl or \it), #2 is the text to slant. | |
2767 | % If we are in a monospaced environment, however, 1) always use \ttsl, | |
2768 | % and 2) do not add an italic correction. | |
2769 | \def\dosmartslant#1#2{% | |
2770 | \ifusingtt | |
2771 | {{\ttsl #2}\let\next=\relax}% | |
2772 | {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% | |
2773 | \next | |
2774 | } | |
2775 | \def\smartslanted{\dosmartslant\sl} | |
2776 | \def\smartitalic{\dosmartslant\it} | |
2777 | ||
2778 | % Output an italic correction unless \next (presumed to be the following | |
2779 | % character) is such as not to need one. | |
2780 | \def\smartitaliccorrection{% | |
2781 | \ifx\next,% | |
2782 | \else\ifx\next-% | |
2783 | \else\ifx\next.% | |
21fea2e2 JM |
2784 | \else\ifx\next\.% |
2785 | \else\ifx\next\comma% | |
0f8bbd69 | 2786 | \else\ptexslash |
21fea2e2 | 2787 | \fi\fi\fi\fi\fi |
0f8bbd69 JM |
2788 | \aftersmartic |
2789 | } | |
2790 | ||
8fcb833a | 2791 | % Unconditional use \ttsl, and no ic. @var is set to this for defuns. |
0f8bbd69 | 2792 | \def\ttslanted#1{{\ttsl #1}} |
82d5ce1d | 2793 | |
0f8bbd69 | 2794 | % @cite is like \smartslanted except unconditionally use \sl. We never want |
82d5ce1d | 2795 | % ttsl for book titles, do we? |
0f8bbd69 JM |
2796 | \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} |
2797 | ||
2798 | \def\aftersmartic{} | |
2799 | \def\var#1{% | |
2800 | \let\saveaftersmartic = \aftersmartic | |
2801 | \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% | |
2802 | \smartslanted{#1}% | |
2803 | } | |
82d5ce1d | 2804 | |
9e9f9cc2 | 2805 | \let\i=\smartitalic |
82d5ce1d | 2806 | \let\slanted=\smartslanted |
409dfcea | 2807 | \let\dfn=\smartslanted |
9e9f9cc2 | 2808 | \let\emph=\smartitalic |
9e9f9cc2 | 2809 | |
0f8bbd69 JM |
2810 | % Explicit font changes: @r, @sc, undocumented @ii. |
2811 | \def\r#1{{\rm #1}} % roman font | |
2812 | \def\sc#1{{\smallcaps#1}} % smallcaps font | |
2813 | \def\ii#1{{\it #1}} % italic font | |
2814 | ||
2815 | % @b, explicit bold. Also @strong. | |
9e9f9cc2 KB |
2816 | \def\b#1{{\bf #1}} |
2817 | \let\strong=\b | |
2818 | ||
82d5ce1d UD |
2819 | % @sansserif, explicit sans. |
2820 | \def\sansserif#1{{\sf #1}} | |
2821 | ||
9e9f9cc2 KB |
2822 | % We can't just use \exhyphenpenalty, because that only has effect at |
2823 | % the end of a paragraph. Restore normal hyphenation at the end of the | |
2824 | % group within which \nohyphenation is presumably called. | |
2825 | % | |
2826 | \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} | |
2827 | \def\restorehyphenation{\hyphenchar\font = `- } | |
2828 | ||
e0f86659 UD |
2829 | % Set sfcode to normal for the chars that usually have another value. |
2830 | % Can't use plain's \frenchspacing because it uses the `\x notation, and | |
2831 | % sometimes \x has an active definition that messes things up. | |
7158eae4 | 2832 | % |
e0f86659 | 2833 | \catcode`@=11 |
9251c568 | 2834 | \def\plainfrenchspacing{% |
084e7d57 JM |
2835 | \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m |
2836 | \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m | |
9251c568 AJ |
2837 | \def\endofsentencespacefactor{1000}% for @. and friends |
2838 | } | |
2839 | \def\plainnonfrenchspacing{% | |
2840 | \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 | |
2841 | \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 | |
2842 | \def\endofsentencespacefactor{3000}% for @. and friends | |
e0f86659 UD |
2843 | } |
2844 | \catcode`@=\other | |
9251c568 | 2845 | \def\endofsentencespacefactor{3000}% default |
e0f86659 | 2846 | |
0f8bbd69 | 2847 | % @t, explicit typewriter. |
9e9f9cc2 | 2848 | \def\t#1{% |
9251c568 | 2849 | {\tt \rawbackslash \plainfrenchspacing #1}% |
9e9f9cc2 KB |
2850 | \null |
2851 | } | |
0f8bbd69 JM |
2852 | |
2853 | % @samp. | |
2854 | \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} | |
2855 | ||
8fcb833a JM |
2856 | % @indicateurl is \samp, that is, with quotes. |
2857 | \let\indicateurl=\samp | |
9e9f9cc2 | 2858 | |
8fcb833a JM |
2859 | % @code (and similar) prints in typewriter, but with spaces the same |
2860 | % size as normal in the surrounding text, without hyphenation, etc. | |
2861 | % This is a subroutine for that. | |
9e9f9cc2 KB |
2862 | \def\tclose#1{% |
2863 | {% | |
2864 | % Change normal interword space to be same as for the current font. | |
2865 | \spaceskip = \fontdimen2\font | |
2866 | % | |
2867 | % Switch to typewriter. | |
2868 | \tt | |
2869 | % | |
2870 | % But `\ ' produces the large typewriter interword space. | |
2871 | \def\ {{\spaceskip = 0pt{} }}% | |
2872 | % | |
2873 | % Turn off hyphenation. | |
2874 | \nohyphenation | |
2875 | % | |
2876 | \rawbackslash | |
9251c568 | 2877 | \plainfrenchspacing |
9e9f9cc2 KB |
2878 | #1% |
2879 | }% | |
0f8bbd69 | 2880 | \null % reset spacefactor to 1000 |
9e9f9cc2 KB |
2881 | } |
2882 | ||
82d5ce1d | 2883 | % We *must* turn on hyphenation at `-' and `_' in @code. |
8fcb833a | 2884 | % (But see \codedashfinish below.) |
9e9f9cc2 KB |
2885 | % Otherwise, it is too hard to avoid overfull hboxes |
2886 | % in the Emacs manual, the Library manual, etc. | |
8fcb833a | 2887 | % |
9e9f9cc2 KB |
2888 | % Unfortunately, TeX uses one parameter (\hyphenchar) to control |
2889 | % both hyphenation at - and hyphenation within words. | |
2890 | % We must therefore turn them both off (\tclose does that) | |
8fcb833a | 2891 | % and arrange explicitly to hyphenate at a dash. -- rms. |
9e9f9cc2 | 2892 | { |
9251c568 AJ |
2893 | \catcode`\-=\active \catcode`\_=\active |
2894 | \catcode`\'=\active \catcode`\`=\active | |
0f8bbd69 | 2895 | \global\let'=\rq \global\let`=\lq % default definitions |
409dfcea UD |
2896 | % |
2897 | \global\def\code{\begingroup | |
0f8bbd69 JM |
2898 | \setupmarkupstyle{code}% |
2899 | % The following should really be moved into \setupmarkupstyle handlers. | |
9251c568 AJ |
2900 | \catcode\dashChar=\active \catcode\underChar=\active |
2901 | \ifallowcodebreaks | |
2902 | \let-\codedash | |
2903 | \let_\codeunder | |
2904 | \else | |
8fcb833a | 2905 | \let-\normaldash |
9251c568 AJ |
2906 | \let_\realunder |
2907 | \fi | |
8fcb833a JM |
2908 | % Given -foo (with a single dash), we do not want to allow a break |
2909 | % after the hyphen. | |
2910 | \global\let\codedashprev=\codedash | |
2911 | % | |
409dfcea UD |
2912 | \codex |
2913 | } | |
8fcb833a JM |
2914 | % |
2915 | \gdef\codedash{\futurelet\next\codedashfinish} | |
2916 | \gdef\codedashfinish{% | |
2917 | \normaldash % always output the dash character itself. | |
2918 | % | |
2919 | % Now, output a discretionary to allow a line break, unless | |
2920 | % (a) the next character is a -, or | |
2921 | % (b) the preceding character is a -. | |
2922 | % E.g., given --posix, we do not want to allow a break after either -. | |
2923 | % Given --foo-bar, we do want to allow a break between the - and the b. | |
2924 | \ifx\next\codedash \else | |
2925 | \ifx\codedashprev\codedash | |
2926 | \else \discretionary{}{}{}\fi | |
2927 | \fi | |
21fea2e2 JM |
2928 | % we need the space after the = for the case when \next itself is a |
2929 | % space token; it would get swallowed otherwise. As in @code{- a}. | |
2930 | \global\let\codedashprev= \next | |
8fcb833a | 2931 | } |
9e9f9cc2 | 2932 | } |
8fcb833a JM |
2933 | \def\normaldash{-} |
2934 | % | |
0f8bbd69 JM |
2935 | \def\codex #1{\tclose{#1}\endgroup} |
2936 | ||
27692f89 UD |
2937 | \def\codeunder{% |
2938 | % this is all so @math{@code{var_name}+1} can work. In math mode, _ | |
2939 | % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) | |
2940 | % will therefore expand the active definition of _, which is us | |
2941 | % (inside @code that is), therefore an endless loop. | |
2942 | \ifusingtt{\ifmmode | |
2943 | \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. | |
2944 | \else\normalunderscore \fi | |
2945 | \discretionary{}{}{}}% | |
2946 | {\_}% | |
2947 | } | |
9e9f9cc2 | 2948 | |
9251c568 | 2949 | % An additional complication: the above will allow breaks after, e.g., |
8fcb833a JM |
2950 | % each of the four underscores in __typeof__. This is bad. |
2951 | % @allowcodebreaks provides a document-level way to turn breaking at - | |
2952 | % and _ on and off. | |
0f8bbd69 | 2953 | % |
9251c568 AJ |
2954 | \newif\ifallowcodebreaks \allowcodebreakstrue |
2955 | ||
2956 | \def\keywordtrue{true} | |
2957 | \def\keywordfalse{false} | |
2958 | ||
2959 | \parseargdef\allowcodebreaks{% | |
2960 | \def\txiarg{#1}% | |
2961 | \ifx\txiarg\keywordtrue | |
2962 | \allowcodebreakstrue | |
2963 | \else\ifx\txiarg\keywordfalse | |
2964 | \allowcodebreaksfalse | |
2965 | \else | |
2966 | \errhelp = \EMsimple | |
0f8bbd69 | 2967 | \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% |
9251c568 AJ |
2968 | \fi\fi |
2969 | } | |
2970 | ||
8fcb833a JM |
2971 | % For @command, @env, @file, @option quotes seem unnecessary, |
2972 | % so use \code rather than \samp. | |
2973 | \let\command=\code | |
2974 | \let\env=\code | |
2975 | \let\file=\code | |
2976 | \let\option=\code | |
2977 | ||
e66a8203 JM |
2978 | % @uref (abbreviation for `urlref') aka @url takes an optional |
2979 | % (comma-separated) second argument specifying the text to display and | |
2980 | % an optional third arg as text to display instead of (rather than in | |
2981 | % addition to) the url itself. First (mandatory) arg is the url. | |
714a562f | 2982 | |
e66a8203 | 2983 | % TeX-only option to allow changing PDF output to show only the second |
21fea2e2 JM |
2984 | % arg (if given), and not the url (which is then just the link target). |
2985 | \newif\ifurefurlonlylink | |
2986 | ||
2987 | % The main macro is \urefbreak, which allows breaking at expected | |
2988 | % places within the url. (There used to be another version, which | |
2989 | % didn't support automatic breaking.) | |
0f8bbd69 JM |
2990 | \def\urefbreak{\begingroup \urefcatcodes \dourefbreak} |
2991 | \let\uref=\urefbreak | |
21fea2e2 | 2992 | % |
0f8bbd69 JM |
2993 | \def\dourefbreak#1{\urefbreakfinish #1,,,\finish} |
2994 | \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example | |
2995 | \unsepspaces | |
2996 | \pdfurl{#1}% | |
2997 | \setbox0 = \hbox{\ignorespaces #3}% | |
2998 | \ifdim\wd0 > 0pt | |
2999 | \unhbox0 % third arg given, show only that | |
3000 | \else | |
21fea2e2 | 3001 | \setbox0 = \hbox{\ignorespaces #2}% look for second arg |
0f8bbd69 JM |
3002 | \ifdim\wd0 > 0pt |
3003 | \ifpdf | |
7f7dd1d3 | 3004 | % For pdfTeX and LuaTeX |
21fea2e2 JM |
3005 | \ifurefurlonlylink |
3006 | % PDF plus option to not display url, show just arg | |
3007 | \unhbox0 | |
3008 | \else | |
3009 | % PDF, normally display both arg and url for consistency, | |
3010 | % visibility, if the pdf is eventually used to print, etc. | |
3011 | \unhbox0\ (\urefcode{#1})% | |
3012 | \fi | |
0f8bbd69 | 3013 | \else |
7f7dd1d3 JM |
3014 | \ifx\XeTeXrevision\thisisundefined |
3015 | \unhbox0\ (\urefcode{#1})% DVI, always show arg and url | |
3016 | \else | |
3017 | % For XeTeX | |
3018 | \ifurefurlonlylink | |
3019 | % PDF plus option to not display url, show just arg | |
3020 | \unhbox0 | |
3021 | \else | |
3022 | % PDF, normally display both arg and url for consistency, | |
3023 | % visibility, if the pdf is eventually used to print, etc. | |
3024 | \unhbox0\ (\urefcode{#1})% | |
3025 | \fi | |
3026 | \fi | |
0f8bbd69 JM |
3027 | \fi |
3028 | \else | |
3029 | \urefcode{#1}% only url given, so show it | |
3030 | \fi | |
3031 | \fi | |
3032 | \endlink | |
3033 | \endgroup} | |
3034 | ||
3035 | % Allow line breaks around only a few characters (only). | |
3036 | \def\urefcatcodes{% | |
084e7d57 JM |
3037 | \catcode`\&=\active \catcode`\.=\active |
3038 | \catcode`\#=\active \catcode`\?=\active | |
3039 | \catcode`\/=\active | |
0f8bbd69 JM |
3040 | } |
3041 | { | |
3042 | \urefcatcodes | |
3043 | % | |
3044 | \global\def\urefcode{\begingroup | |
3045 | \setupmarkupstyle{code}% | |
3046 | \urefcatcodes | |
3047 | \let&\urefcodeamp | |
3048 | \let.\urefcodedot | |
3049 | \let#\urefcodehash | |
3050 | \let?\urefcodequest | |
3051 | \let/\urefcodeslash | |
3052 | \codex | |
3053 | } | |
3054 | % | |
3055 | % By default, they are just regular characters. | |
3056 | \global\def&{\normalamp} | |
3057 | \global\def.{\normaldot} | |
3058 | \global\def#{\normalhash} | |
3059 | \global\def?{\normalquest} | |
3060 | \global\def/{\normalslash} | |
3061 | } | |
3062 | ||
3063 | % we put a little stretch before and after the breakable chars, to help | |
3064 | % line breaking of long url's. The unequal skips make look better in | |
3065 | % cmtt at least, especially for dots. | |
e66a8203 JM |
3066 | \def\urefprestretchamount{.13em} |
3067 | \def\urefpoststretchamount{.1em} | |
3068 | \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax} | |
3069 | \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax} | |
0f8bbd69 JM |
3070 | % |
3071 | \def\urefcodeamp{\urefprestretch \&\urefpoststretch} | |
3072 | \def\urefcodedot{\urefprestretch .\urefpoststretch} | |
3073 | \def\urefcodehash{\urefprestretch \#\urefpoststretch} | |
3074 | \def\urefcodequest{\urefprestretch ?\urefpoststretch} | |
3075 | \def\urefcodeslash{\futurelet\next\urefcodeslashfinish} | |
3076 | { | |
3077 | \catcode`\/=\active | |
3078 | \global\def\urefcodeslashfinish{% | |
3079 | \urefprestretch \slashChar | |
3080 | % Allow line break only after the final / in a sequence of | |
3081 | % slashes, to avoid line break between the slashes in http://. | |
3082 | \ifx\next/\else \urefpoststretch \fi | |
3083 | } | |
3084 | } | |
3085 | ||
3086 | % One more complication: by default we'll break after the special | |
3087 | % characters, but some people like to break before the special chars, so | |
3088 | % allow that. Also allow no breaking at all, for manual control. | |
3089 | % | |
3090 | \parseargdef\urefbreakstyle{% | |
3091 | \def\txiarg{#1}% | |
3092 | \ifx\txiarg\wordnone | |
3093 | \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} | |
3094 | \else\ifx\txiarg\wordbefore | |
3095 | \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} | |
3096 | \else\ifx\txiarg\wordafter | |
3097 | \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} | |
3098 | \else | |
3099 | \errhelp = \EMsimple | |
3100 | \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% | |
3101 | \fi\fi\fi | |
3102 | } | |
3103 | \def\wordafter{after} | |
3104 | \def\wordbefore{before} | |
3105 | \def\wordnone{none} | |
3106 | ||
3107 | \urefbreakstyle after | |
3108 | ||
82d5ce1d UD |
3109 | % @url synonym for @uref, since that's how everyone uses it. |
3110 | % | |
3111 | \let\url=\uref | |
3112 | ||
13632cfc UD |
3113 | % rms does not like angle brackets --karl, 17may97. |
3114 | % So now @email is just like @uref, unless we are pdf. | |
7158eae4 | 3115 | % |
2eb45444 | 3116 | %\def\email#1{\angleleft{\tt #1}\angleright} |
13632cfc UD |
3117 | \ifpdf |
3118 | \def\email#1{\doemail#1,,\finish} | |
3b82ab1c UD |
3119 | \def\doemail#1,#2,#3\finish{\begingroup |
3120 | \unsepspaces | |
3121 | \pdfurl{mailto:#1}% | |
13632cfc UD |
3122 | \setbox0 = \hbox{\ignorespaces #2}% |
3123 | \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi | |
3b82ab1c UD |
3124 | \endlink |
3125 | \endgroup} | |
13632cfc | 3126 | \else |
7f7dd1d3 JM |
3127 | \ifx\XeTeXrevision\thisisundefined |
3128 | \let\email=\uref | |
3129 | \else | |
3130 | \def\email#1{\doemail#1,,\finish} | |
3131 | \def\doemail#1,#2,#3\finish{\begingroup | |
3132 | \unsepspaces | |
3133 | \pdfurl{mailto:#1}% | |
3134 | \setbox0 = \hbox{\ignorespaces #2}% | |
3135 | \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi | |
3136 | \endlink | |
3137 | \endgroup} | |
3138 | \fi | |
13632cfc | 3139 | \fi |
3996f34b | 3140 | |
0f8bbd69 JM |
3141 | % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), |
3142 | % `example' (@kbd uses ttsl only inside of @example and friends), | |
3143 | % or `code' (@kbd uses normal tty font always). | |
3144 | \parseargdef\kbdinputstyle{% | |
3145 | \def\txiarg{#1}% | |
3146 | \ifx\txiarg\worddistinct | |
3147 | \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% | |
3148 | \else\ifx\txiarg\wordexample | |
3149 | \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% | |
3150 | \else\ifx\txiarg\wordcode | |
3151 | \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% | |
3152 | \else | |
3153 | \errhelp = \EMsimple | |
3154 | \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% | |
3155 | \fi\fi\fi | |
3156 | } | |
3157 | \def\worddistinct{distinct} | |
3158 | \def\wordexample{example} | |
3159 | \def\wordcode{code} | |
3160 | ||
3161 | % Default is `distinct'. | |
3162 | \kbdinputstyle distinct | |
3163 | ||
8fcb833a JM |
3164 | % @kbd is like @code, except that if the argument is just one @key command, |
3165 | % then @kbd has no effect. | |
3166 | \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} | |
3167 | ||
0f8bbd69 | 3168 | \def\xkey{\key} |
8fcb833a JM |
3169 | \def\kbdsub#1#2#3\par{% |
3170 | \def\one{#1}\def\three{#3}\def\threex{??}% | |
3171 | \ifx\one\xkey\ifx\threex\three \key{#2}% | |
3172 | \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi | |
3173 | \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi | |
3174 | } | |
0f8bbd69 | 3175 | |
8fcb833a JM |
3176 | % definition of @key that produces a lozenge. Doesn't adjust to text size. |
3177 | %\setfont\keyrm\rmshape{8}{1000}{OT1} | |
3178 | %\font\keysy=cmsy9 | |
3179 | %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% | |
3180 | % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% | |
3181 | % \vbox{\hrule\kern-0.4pt | |
3182 | % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% | |
3183 | % \kern-0.4pt\hrule}% | |
3184 | % \kern-.06em\raise0.4pt\hbox{\angleright}}}} | |
3185 | ||
3186 | % definition of @key with no lozenge. If the current font is already | |
3187 | % monospace, don't change it; that way, we respect @kbdinputstyle. But | |
3188 | % if it isn't monospace, then use \tt. | |
3189 | % | |
3190 | \def\key#1{{\setupmarkupstyle{key}% | |
3191 | \nohyphenation | |
3192 | \ifmonospace\else\tt\fi | |
3193 | #1}\null} | |
0f8bbd69 JM |
3194 | |
3195 | % @clicksequence{File @click{} Open ...} | |
3196 | \def\clicksequence#1{\begingroup #1\endgroup} | |
3197 | ||
3198 | % @clickstyle @arrow (by default) | |
3199 | \parseargdef\clickstyle{\def\click{#1}} | |
3200 | \def\click{\arrow} | |
3201 | ||
3202 | % Typeset a dimension, e.g., `in' or `pt'. The only reason for the | |
3203 | % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. | |
10dc2a90 | 3204 | % |
0f8bbd69 JM |
3205 | \def\dmn#1{\thinspace #1} |
3206 | ||
0f8bbd69 JM |
3207 | % @acronym for "FBI", "NATO", and the like. |
3208 | % We print this one point size smaller, since it's intended for | |
3209 | % all-uppercase. | |
3210 | % | |
3211 | \def\acronym#1{\doacronym #1,,\finish} | |
3212 | \def\doacronym#1,#2,#3\finish{% | |
7f7dd1d3 | 3213 | {\switchtolsize #1}% |
0f8bbd69 JM |
3214 | \def\temp{#2}% |
3215 | \ifx\temp\empty \else | |
3216 | \space ({\unsepspaces \ignorespaces \temp \unskip})% | |
3217 | \fi | |
3218 | \null % reset \spacefactor=1000 | |
3219 | } | |
3220 | ||
3221 | % @abbr for "Comput. J." and the like. | |
3222 | % No font change, but don't do end-of-sentence spacing. | |
3223 | % | |
3224 | \def\abbr#1{\doabbr #1,,\finish} | |
3225 | \def\doabbr#1,#2,#3\finish{% | |
3226 | {\plainfrenchspacing #1}% | |
3227 | \def\temp{#2}% | |
3228 | \ifx\temp\empty \else | |
3229 | \space ({\unsepspaces \ignorespaces \temp \unskip})% | |
3230 | \fi | |
3231 | \null % reset \spacefactor=1000 | |
3232 | } | |
3233 | ||
3234 | % @asis just yields its argument. Used with @table, for example. | |
3235 | % | |
3236 | \def\asis#1{#1} | |
3237 | ||
3238 | % @math outputs its argument in math mode. | |
3239 | % | |
3240 | % One complication: _ usually means subscripts, but it could also mean | |
3241 | % an actual _ character, as in @math{@var{some_variable} + 1}. So make | |
3242 | % _ active, and distinguish by seeing if the current family is \slfam, | |
3243 | % which is what @var uses. | |
3244 | { | |
3245 | \catcode`\_ = \active | |
3246 | \gdef\mathunderscore{% | |
3247 | \catcode`\_=\active | |
3248 | \def_{\ifnum\fam=\slfam \_\else\sb\fi}% | |
3249 | } | |
3250 | } | |
3251 | % Another complication: we want \\ (and @\) to output a math (or tt) \. | |
3252 | % FYI, plain.tex uses \\ as a temporary control sequence (for no | |
3253 | % particular reason), but this is not advertised and we don't care. | |
3254 | % | |
3255 | % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. | |
3256 | \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} | |
3257 | % | |
3258 | \def\math{% | |
084e7d57 JM |
3259 | \ifmmode\else % only go into math if not in math mode already |
3260 | \tex | |
3261 | \mathunderscore | |
3262 | \let\\ = \mathbackslash | |
3263 | \mathactive | |
3264 | % make the texinfo accent commands work in math mode | |
3265 | \let\"=\ddot | |
3266 | \let\'=\acute | |
3267 | \let\==\bar | |
3268 | \let\^=\hat | |
3269 | \let\`=\grave | |
3270 | \let\u=\breve | |
3271 | \let\v=\check | |
3272 | \let\~=\tilde | |
3273 | \let\dotaccent=\dot | |
3274 | % have to provide another name for sup operator | |
3275 | \let\mathopsup=\sup | |
3276 | $\expandafter\finishmath\fi | |
0f8bbd69 JM |
3277 | } |
3278 | \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. | |
3279 | ||
3280 | % Some active characters (such as <) are spaced differently in math. | |
3281 | % We have to reset their definitions in case the @math was an argument | |
3282 | % to a command which sets the catcodes (such as @item or @section). | |
3283 | % | |
3284 | { | |
3285 | \catcode`^ = \active | |
3286 | \catcode`< = \active | |
3287 | \catcode`> = \active | |
3288 | \catcode`+ = \active | |
3289 | \catcode`' = \active | |
3290 | \gdef\mathactive{% | |
3291 | \let^ = \ptexhat | |
3292 | \let< = \ptexless | |
3293 | \let> = \ptexgtr | |
3294 | \let+ = \ptexplus | |
3295 | \let' = \ptexquoteright | |
3296 | } | |
3297 | } | |
3298 | ||
084e7d57 JM |
3299 | % for @sub and @sup, if in math mode, just do a normal sub/superscript. |
3300 | % If in text, use math to place as sub/superscript, but switch | |
3301 | % into text mode, with smaller fonts. This is a different font than the | |
3302 | % one used for real math sub/superscripts (8pt vs. 7pt), but let's not | |
3303 | % fix it (significant additions to font machinery) until someone notices. | |
3304 | % | |
3305 | \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi} | |
7f7dd1d3 | 3306 | \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}% |
084e7d57 JM |
3307 | % |
3308 | \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi} | |
7f7dd1d3 | 3309 | \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}% |
8fcb833a | 3310 | |
0f8bbd69 JM |
3311 | % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. |
3312 | % Ignore unless FMTNAME == tex; then it is like @iftex and @tex, | |
3313 | % except specified as a normal braced arg, so no newlines to worry about. | |
3314 | % | |
3315 | \def\outfmtnametex{tex} | |
3316 | % | |
3317 | \long\def\inlinefmt#1{\doinlinefmt #1,\finish} | |
3318 | \long\def\doinlinefmt#1,#2,\finish{% | |
3319 | \def\inlinefmtname{#1}% | |
3320 | \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi | |
3321 | } | |
21fea2e2 JM |
3322 | % |
3323 | % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if | |
3324 | % FMTNAME is tex, else ELSE-TEXT. | |
3325 | \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish} | |
3326 | \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{% | |
3327 | \def\inlinefmtname{#1}% | |
3328 | \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi | |
3329 | } | |
3330 | % | |
0f8bbd69 JM |
3331 | % For raw, must switch into @tex before parsing the argument, to avoid |
3332 | % setting catcodes prematurely. Doing it this way means that, for | |
3333 | % example, @inlineraw{html, foo{bar} gets a parse error instead of being | |
3334 | % ignored. But this isn't important because if people want a literal | |
3335 | % *right* brace they would have to use a command anyway, so they may as | |
3336 | % well use a command to get a left brace too. We could re-use the | |
3337 | % delimiter character idea from \verb, but it seems like overkill. | |
3338 | % | |
3339 | \long\def\inlineraw{\tex \doinlineraw} | |
3340 | \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} | |
3341 | \def\doinlinerawtwo#1,#2,\finish{% | |
3342 | \def\inlinerawname{#1}% | |
3343 | \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi | |
3344 | \endgroup % close group opened by \tex. | |
3345 | } | |
3346 | ||
21fea2e2 JM |
3347 | % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set. |
3348 | % | |
3349 | \long\def\inlineifset#1{\doinlineifset #1,\finish} | |
3350 | \long\def\doinlineifset#1,#2,\finish{% | |
3351 | \def\inlinevarname{#1}% | |
3352 | \expandafter\ifx\csname SET\inlinevarname\endcsname\relax | |
3353 | \else\ignorespaces#2\fi | |
3354 | } | |
3355 | ||
3356 | % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set. | |
3357 | % | |
3358 | \long\def\inlineifclear#1{\doinlineifclear #1,\finish} | |
3359 | \long\def\doinlineifclear#1,#2,\finish{% | |
3360 | \def\inlinevarname{#1}% | |
3361 | \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi | |
3362 | } | |
3363 | ||
0f8bbd69 JM |
3364 | |
3365 | \message{glyphs,} | |
3366 | % and logos. | |
3367 | ||
3368 | % @@ prints an @, as does @atchar{}. | |
3369 | \def\@{\char64 } | |
3370 | \let\atchar=\@ | |
3371 | ||
3372 | % @{ @} @lbracechar{} @rbracechar{} all generate brace characters. | |
7f7dd1d3 JM |
3373 | \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}} |
3374 | \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}} | |
3375 | \let\{=\lbracechar | |
3376 | \let\}=\rbracechar | |
0f8bbd69 JM |
3377 | |
3378 | % @comma{} to avoid , parsing problems. | |
3379 | \let\comma = , | |
3380 | ||
3381 | % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent | |
3382 | % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. | |
3383 | \let\, = \ptexc | |
3384 | \let\dotaccent = \ptexdot | |
3385 | \def\ringaccent#1{{\accent23 #1}} | |
3386 | \let\tieaccent = \ptext | |
3387 | \let\ubaraccent = \ptexb | |
3388 | \let\udotaccent = \d | |
3389 | ||
3390 | % Other special characters: @questiondown @exclamdown @ordf @ordm | |
3391 | % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. | |
3392 | \def\questiondown{?`} | |
3393 | \def\exclamdown{!`} | |
7f7dd1d3 JM |
3394 | \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}} |
3395 | \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}} | |
0f8bbd69 JM |
3396 | |
3397 | % Dotless i and dotless j, used for accents. | |
3398 | \def\imacro{i} | |
3399 | \def\jmacro{j} | |
3400 | \def\dotless#1{% | |
3401 | \def\temp{#1}% | |
3402 | \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi | |
3403 | \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi | |
3404 | \else \errmessage{@dotless can be used only with i or j}% | |
3405 | \fi\fi | |
3406 | } | |
9e9f9cc2 | 3407 | |
0f8bbd69 JM |
3408 | % The \TeX{} logo, as in plain, but resetting the spacing so that a |
3409 | % period following counts as ending a sentence. (Idea found in latex.) | |
9e9f9cc2 | 3410 | % |
0f8bbd69 | 3411 | \edef\TeX{\TeX \spacefactor=1000 } |
9e9f9cc2 | 3412 | |
0f8bbd69 JM |
3413 | % @LaTeX{} logo. Not quite the same results as the definition in |
3414 | % latex.ltx, since we use a different font for the raised A; it's most | |
3415 | % convenient for us to use an explicitly smaller font, rather than using | |
3416 | % the \scriptstyle font (since we don't reset \scriptstyle and | |
3417 | % \scriptscriptstyle). | |
3418 | % | |
3419 | \def\LaTeX{% | |
3420 | L\kern-.36em | |
3421 | {\setbox0=\hbox{T}% | |
3422 | \vbox to \ht0{\hbox{% | |
3423 | \ifx\textnominalsize\xwordpt | |
7f7dd1d3 | 3424 | % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX. |
0f8bbd69 JM |
3425 | % Revert to plain's \scriptsize, which is 7pt. |
3426 | \count255=\the\fam $\fam\count255 \scriptstyle A$% | |
3427 | \else | |
3428 | % For 11pt, we can use our lllsize. | |
7f7dd1d3 | 3429 | \switchtolllsize A% |
0f8bbd69 JM |
3430 | \fi |
3431 | }% | |
3432 | \vss | |
3433 | }}% | |
3434 | \kern-.15em | |
3435 | \TeX | |
3436 | } | |
9e9f9cc2 | 3437 | |
084e7d57 JM |
3438 | % Some math mode symbols. Define \ensuremath to switch into math mode |
3439 | % unless we are already there. Expansion tricks may not be needed here, | |
3440 | % but safer, and can't hurt. | |
3441 | \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi} | |
3442 | \def\ensuredmath#1{$\relax#1$} | |
3443 | % | |
3444 | \def\bullet{\ensuremath\ptexbullet} | |
3445 | \def\geq{\ensuremath\ge} | |
3446 | \def\leq{\ensuremath\le} | |
3447 | \def\minus{\ensuremath-} | |
9e9f9cc2 | 3448 | |
0f8bbd69 JM |
3449 | % @dots{} outputs an ellipsis using the current font. |
3450 | % We do .5em per period so that it has the same spacing in the cm | |
3451 | % typewriter fonts as three actual period characters; on the other hand, | |
3452 | % in other typewriter fonts three periods are wider than 1.5em. So do | |
3453 | % whichever is larger. | |
3454 | % | |
3455 | \def\dots{% | |
3456 | \leavevmode | |
3457 | \setbox0=\hbox{...}% get width of three periods | |
3458 | \ifdim\wd0 > 1.5em | |
3459 | \dimen0 = \wd0 | |
3460 | \else | |
3461 | \dimen0 = 1.5em | |
82d5ce1d | 3462 | \fi |
0f8bbd69 JM |
3463 | \hbox to \dimen0{% |
3464 | \hskip 0pt plus.25fil | |
3465 | .\hskip 0pt plus1fil | |
3466 | .\hskip 0pt plus1fil | |
3467 | .\hskip 0pt plus.5fil | |
3468 | }% | |
82d5ce1d | 3469 | } |
0ecb606c | 3470 | |
0f8bbd69 JM |
3471 | % @enddots{} is an end-of-sentence ellipsis. |
3472 | % | |
3473 | \def\enddots{% | |
3474 | \dots | |
3475 | \spacefactor=\endofsentencespacefactor | |
82d5ce1d UD |
3476 | } |
3477 | ||
0f8bbd69 JM |
3478 | % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. |
3479 | % | |
3480 | % Since these characters are used in examples, they should be an even number of | |
3481 | % \tt widths. Each \tt character is 1en, so two makes it 1em. | |
3482 | % | |
3483 | \def\point{$\star$} | |
3484 | \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} | |
3485 | \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} | |
3486 | \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} | |
3487 | \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} | |
3488 | \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} | |
3489 | ||
3490 | % The @error{} command. | |
3491 | % Adapted from the TeXbook's \boxit. | |
3492 | % | |
3493 | \newbox\errorbox | |
3494 | % | |
7f7dd1d3 | 3495 | {\ttfont \global\dimen0 = 3em}% Width of the box. |
0f8bbd69 JM |
3496 | \dimen2 = .55pt % Thickness of rules |
3497 | % The text. (`r' is open on the right, `e' somewhat less so on the left.) | |
3498 | \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} | |
3499 | % | |
3500 | \setbox\errorbox=\hbox to \dimen0{\hfil | |
3501 | \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. | |
3502 | \advance\hsize by -2\dimen2 % Rules. | |
3503 | \vbox{% | |
3504 | \hrule height\dimen2 | |
3505 | \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. | |
3506 | \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. | |
3507 | \kern3pt\vrule width\dimen2}% Space to right. | |
3508 | \hrule height\dimen2} | |
3509 | \hfil} | |
3510 | % | |
3511 | \def\error{\leavevmode\lower.7ex\copy\errorbox} | |
3512 | ||
82d5ce1d UD |
3513 | % @pounds{} is a sterling sign, which Knuth put in the CM italic font. |
3514 | % | |
3515 | \def\pounds{{\it\$}} | |
3516 | ||
3517 | % @euro{} comes from a separate font, depending on the current style. | |
3518 | % We use the free feym* fonts from the eurosym package by Henrik | |
3519 | % Theiling, which support regular, slanted, bold and bold slanted (and | |
3520 | % "outlined" (blackboard board, sort of) versions, which we don't need). | |
3521 | % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. | |
0f8bbd69 | 3522 | % |
82d5ce1d UD |
3523 | % Although only regular is the truly official Euro symbol, we ignore |
3524 | % that. The Euro is designed to be slightly taller than the regular | |
3525 | % font height. | |
0f8bbd69 | 3526 | % |
82d5ce1d UD |
3527 | % feymr - regular |
3528 | % feymo - slanted | |
3529 | % feybr - bold | |
3530 | % feybo - bold slanted | |
0f8bbd69 | 3531 | % |
82d5ce1d UD |
3532 | % There is no good (free) typewriter version, to my knowledge. |
3533 | % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. | |
3534 | % Hmm. | |
0f8bbd69 | 3535 | % |
82d5ce1d UD |
3536 | % Also doesn't work in math. Do we need to do math with euro symbols? |
3537 | % Hope not. | |
0f8bbd69 JM |
3538 | % |
3539 | % | |
82d5ce1d UD |
3540 | \def\euro{{\eurofont e}} |
3541 | \def\eurofont{% | |
3542 | % We set the font at each command, rather than predefining it in | |
3543 | % \textfonts and the other font-switching commands, so that | |
9251c568 | 3544 | % installations which never need the symbol don't have to have the |
82d5ce1d | 3545 | % font installed. |
0f8bbd69 | 3546 | % |
82d5ce1d UD |
3547 | % There is only one designed size (nominal 10pt), so we always scale |
3548 | % that to the current nominal size. | |
0f8bbd69 | 3549 | % |
82d5ce1d UD |
3550 | % By the way, simply using "at 1em" works for cmr10 and the like, but |
3551 | % does not work for cmbx10 and other extended/shrunken fonts. | |
0f8bbd69 | 3552 | % |
82d5ce1d UD |
3553 | \def\eurosize{\csname\curfontsize nominalsize\endcsname}% |
3554 | % | |
0f8bbd69 | 3555 | \ifx\curfontstyle\bfstylename |
82d5ce1d UD |
3556 | % bold: |
3557 | \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize | |
0f8bbd69 | 3558 | \else |
82d5ce1d UD |
3559 | % regular: |
3560 | \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize | |
3561 | \fi | |
3562 | \thiseurofont | |
3563 | } | |
3564 | ||
0f8bbd69 JM |
3565 | % Glyphs from the EC fonts. We don't use \let for the aliases, because |
3566 | % sometimes we redefine the original macro, and the alias should reflect | |
3567 | % the redefinition. | |
3568 | % | |
3569 | % Use LaTeX names for the Icelandic letters. | |
3570 | \def\DH{{\ecfont \char"D0}} % Eth | |
3571 | \def\dh{{\ecfont \char"F0}} % eth | |
3572 | \def\TH{{\ecfont \char"DE}} % Thorn | |
3573 | \def\th{{\ecfont \char"FE}} % thorn | |
3574 | % | |
c94f48d7 AJ |
3575 | \def\guillemetleft{{\ecfont \char"13}} |
3576 | \def\guillemotleft{\guillemetleft} | |
3577 | \def\guillemetright{{\ecfont \char"14}} | |
3578 | \def\guillemotright{\guillemetright} | |
3579 | \def\guilsinglleft{{\ecfont \char"0E}} | |
3580 | \def\guilsinglright{{\ecfont \char"0F}} | |
3581 | \def\quotedblbase{{\ecfont \char"12}} | |
3582 | \def\quotesinglbase{{\ecfont \char"0D}} | |
3583 | % | |
0f8bbd69 JM |
3584 | % This positioning is not perfect (see the ogonek LaTeX package), but |
3585 | % we have the precomposed glyphs for the most common cases. We put the | |
3586 | % tests to use those glyphs in the single \ogonek macro so we have fewer | |
3587 | % dummy definitions to worry about for index entries, etc. | |
3588 | % | |
3589 | % ogonek is also used with other letters in Lithuanian (IOU), but using | |
3590 | % the precomposed glyphs for those is not so easy since they aren't in | |
3591 | % the same EC font. | |
3592 | \def\ogonek#1{{% | |
3593 | \def\temp{#1}% | |
3594 | \ifx\temp\macrocharA\Aogonek | |
3595 | \else\ifx\temp\macrochara\aogonek | |
3596 | \else\ifx\temp\macrocharE\Eogonek | |
3597 | \else\ifx\temp\macrochare\eogonek | |
3598 | \else | |
3599 | \ecfont \setbox0=\hbox{#1}% | |
3600 | \ifdim\ht0=1ex\accent"0C #1% | |
3601 | \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% | |
3602 | \fi | |
3603 | \fi\fi\fi\fi | |
3604 | }% | |
3605 | } | |
3606 | \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} | |
3607 | \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} | |
3608 | \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} | |
3609 | \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} | |
3610 | % | |
084e7d57 JM |
3611 | % Use the European Computer Modern fonts (cm-super in outline format) |
3612 | % for non-CM glyphs. That is ec* for regular text and tc* for the text | |
3613 | % companion symbols (LaTeX TS1 encoding). Both are part of the ec | |
3614 | % package and follow the same conventions. | |
3615 | % | |
3616 | \def\ecfont{\etcfont{e}} | |
3617 | \def\tcfont{\etcfont{t}} | |
3618 | % | |
3619 | \def\etcfont#1{% | |
0f8bbd69 | 3620 | % We can't distinguish serif/sans and italic/slanted, but this |
c94f48d7 AJ |
3621 | % is used for crude hacks anyway (like adding French and German |
3622 | % quotes to documents typeset with CM, where we lose kerning), so | |
3623 | % hopefully nobody will notice/care. | |
3624 | \edef\ecsize{\csname\curfontsize ecsize\endcsname}% | |
3625 | \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% | |
8fcb833a JM |
3626 | \ifmonospace |
3627 | % typewriter: | |
084e7d57 | 3628 | \font\thisecfont = #1ctt\ecsize \space at \nominalsize |
c94f48d7 | 3629 | \else |
8fcb833a JM |
3630 | \ifx\curfontstyle\bfstylename |
3631 | % bold: | |
084e7d57 | 3632 | \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize |
8fcb833a JM |
3633 | \else |
3634 | % regular: | |
084e7d57 | 3635 | \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize |
8fcb833a | 3636 | \fi |
c94f48d7 AJ |
3637 | \fi |
3638 | \thisecfont | |
3639 | } | |
3640 | ||
82d5ce1d UD |
3641 | % @registeredsymbol - R in a circle. The font for the R should really |
3642 | % be smaller yet, but lllsize is the best we can do for now. | |
7158eae4 UD |
3643 | % Adapted from the plain.tex definition of \copyright. |
3644 | % | |
3645 | \def\registeredsymbol{% | |
7f7dd1d3 | 3646 | $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}% |
82d5ce1d | 3647 | \hfil\crcr\Orb}}% |
7158eae4 UD |
3648 | }$% |
3649 | } | |
3650 | ||
9251c568 AJ |
3651 | % @textdegree - the normal degrees sign. |
3652 | % | |
3653 | \def\textdegree{$^\circ$} | |
3654 | ||
82d5ce1d UD |
3655 | % Laurent Siebenmann reports \Orb undefined with: |
3656 | % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 | |
3657 | % so we'll define it if necessary. | |
0f8bbd69 JM |
3658 | % |
3659 | \ifx\Orb\thisisundefined | |
82d5ce1d UD |
3660 | \def\Orb{\mathhexbox20D} |
3661 | \fi | |
3662 | ||
c94f48d7 AJ |
3663 | % Quotes. |
3664 | \chardef\quotedblleft="5C | |
3665 | \chardef\quotedblright=`\" | |
3666 | \chardef\quoteleft=`\` | |
3667 | \chardef\quoteright=`\' | |
474be527 | 3668 | |
0f8bbd69 | 3669 | |
9e9f9cc2 KB |
3670 | \message{page headings,} |
3671 | ||
3672 | \newskip\titlepagetopglue \titlepagetopglue = 1.5in | |
3673 | \newskip\titlepagebottomglue \titlepagebottomglue = 2pc | |
3674 | ||
3675 | % First the title page. Must do @settitle before @titlepage. | |
9e9f9cc2 KB |
3676 | \newif\ifseenauthor |
3677 | \newif\iffinishedtitlepage | |
3678 | ||
7f7dd1d3 JM |
3679 | % @setcontentsaftertitlepage used to do an implicit @contents or |
3680 | % @shortcontents after @end titlepage, but it is now obsolete. | |
3681 | \def\setcontentsaftertitlepage{% | |
3682 | \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo | |
3683 | command; move your @contents command if you want the contents | |
3684 | after the title page.}}% | |
3685 | \def\setshortcontentsaftertitlepage{% | |
3686 | \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo | |
3687 | command; move your @shortcontents and @contents commands if you | |
3688 | want the contents after the title page.}}% | |
313a1174 | 3689 | |
0f8bbd69 JM |
3690 | \parseargdef\shorttitlepage{% |
3691 | \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% | |
3692 | \endgroup\page\hbox{}\page} | |
9e9f9cc2 | 3693 | |
82d5ce1d UD |
3694 | \envdef\titlepage{% |
3695 | % Open one extra group, as we want to close it in the middle of \Etitlepage. | |
3696 | \begingroup | |
3697 | \parindent=0pt \textfonts | |
3698 | % Leave some space at the very top of the page. | |
3699 | \vglue\titlepagetopglue | |
3700 | % No rule at page bottom unless we print one at the top with @title. | |
3701 | \finishedtitlepagetrue | |
3702 | % | |
3703 | % Most title ``pages'' are actually two pages long, with space | |
3704 | % at the top of the second. We don't want the ragged left on the second. | |
3705 | \let\oldpage = \page | |
3706 | \def\page{% | |
9e9f9cc2 | 3707 | \iffinishedtitlepage\else |
82d5ce1d | 3708 | \finishtitlepage |
9e9f9cc2 | 3709 | \fi |
9e9f9cc2 | 3710 | \let\page = \oldpage |
82d5ce1d UD |
3711 | \page |
3712 | \null | |
3713 | }% | |
9e9f9cc2 KB |
3714 | } |
3715 | ||
3716 | \def\Etitlepage{% | |
82d5ce1d UD |
3717 | \iffinishedtitlepage\else |
3718 | \finishtitlepage | |
3719 | \fi | |
3720 | % It is important to do the page break before ending the group, | |
3721 | % because the headline and footline are only empty inside the group. | |
3722 | % If we use the new definition of \page, we always get a blank page | |
3723 | % after the title page, which we certainly don't want. | |
3724 | \oldpage | |
3725 | \endgroup | |
3726 | % | |
3727 | % Need this before the \...aftertitlepage checks so that if they are | |
3728 | % in effect the toc pages will come out with page numbers. | |
3729 | \HEADINGSon | |
9e9f9cc2 KB |
3730 | } |
3731 | ||
3732 | \def\finishtitlepage{% | |
82d5ce1d UD |
3733 | \vskip4pt \hrule height 2pt width \hsize |
3734 | \vskip\titlepagebottomglue | |
3735 | \finishedtitlepagetrue | |
0ecb606c JJ |
3736 | } |
3737 | ||
8fcb833a JM |
3738 | % Settings used for typesetting titles: no hyphenation, no indentation, |
3739 | % don't worry much about spacing, ragged right. This should be used | |
7f7dd1d3 JM |
3740 | % inside a \vbox, and fonts need to be set appropriately first. \par should |
3741 | % be specified before the end of the \vbox, since a vbox is a group. | |
8fcb833a JM |
3742 | % |
3743 | \def\raggedtitlesettings{% | |
7f7dd1d3 | 3744 | \rm |
8fcb833a JM |
3745 | \hyphenpenalty=10000 |
3746 | \parindent=0pt | |
3747 | \tolerance=5000 | |
3748 | \ptexraggedright | |
3749 | } | |
3750 | ||
0f8bbd69 | 3751 | % Macros to be used within @titlepage: |
82d5ce1d | 3752 | |
7f7dd1d3 | 3753 | \let\subtitlerm=\rmfont |
82d5ce1d UD |
3754 | \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} |
3755 | ||
82d5ce1d UD |
3756 | \parseargdef\title{% |
3757 | \checkenv\titlepage | |
8fcb833a | 3758 | \vbox{\titlefonts \raggedtitlesettings #1\par}% |
82d5ce1d UD |
3759 | % print a rule at the page bottom also. |
3760 | \finishedtitlepagefalse | |
3761 | \vskip4pt \hrule height 4pt width \hsize \vskip4pt | |
3762 | } | |
3763 | ||
3764 | \parseargdef\subtitle{% | |
3765 | \checkenv\titlepage | |
3766 | {\subtitlefont \rightline{#1}}% | |
3767 | } | |
3768 | ||
3769 | % @author should come last, but may come many times. | |
3770 | % It can also be used inside @quotation. | |
3771 | % | |
3772 | \parseargdef\author{% | |
3773 | \def\temp{\quotation}% | |
3774 | \ifx\thisenv\temp | |
3775 | \def\quotationauthor{#1}% printed in \Equotation. | |
3776 | \else | |
3777 | \checkenv\titlepage | |
3778 | \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi | |
7f7dd1d3 | 3779 | {\secfonts\rm \leftline{#1}}% |
82d5ce1d UD |
3780 | \fi |
3781 | } | |
3782 | ||
3783 | ||
0f8bbd69 | 3784 | % Set up page headings and footings. |
9e9f9cc2 KB |
3785 | |
3786 | \let\thispage=\folio | |
3787 | ||
313a1174 UD |
3788 | \newtoks\evenheadline % headline on even pages |
3789 | \newtoks\oddheadline % headline on odd pages | |
3790 | \newtoks\evenfootline % footline on even pages | |
3791 | \newtoks\oddfootline % footline on odd pages | |
9e9f9cc2 | 3792 | |
084e7d57 | 3793 | % Now make \makeheadline and \makefootline in Plain TeX use those variables |
9e9f9cc2 KB |
3794 | \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline |
3795 | \else \the\evenheadline \fi}} | |
3796 | \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline | |
3797 | \else \the\evenfootline \fi}\HEADINGShook} | |
3798 | \let\HEADINGShook=\relax | |
3799 | ||
3800 | % Commands to set those variables. | |
3801 | % For example, this is what @headings on does | |
3802 | % @evenheading @thistitle|@thispage|@thischapter | |
3803 | % @oddheading @thischapter|@thispage|@thistitle | |
3804 | % @evenfooting @thisfile|| | |
3805 | % @oddfooting ||@thisfile | |
3806 | ||
a334319f | 3807 | |
82d5ce1d UD |
3808 | \def\evenheading{\parsearg\evenheadingxxx} |
3809 | \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} | |
3810 | \def\evenheadingyyy #1\|#2\|#3\|#4\finish{% | |
9e9f9cc2 KB |
3811 | \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} |
3812 | ||
82d5ce1d UD |
3813 | \def\oddheading{\parsearg\oddheadingxxx} |
3814 | \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} | |
3815 | \def\oddheadingyyy #1\|#2\|#3\|#4\finish{% | |
9e9f9cc2 KB |
3816 | \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} |
3817 | ||
82d5ce1d | 3818 | \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% |
9e9f9cc2 | 3819 | |
82d5ce1d UD |
3820 | \def\evenfooting{\parsearg\evenfootingxxx} |
3821 | \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} | |
3822 | \def\evenfootingyyy #1\|#2\|#3\|#4\finish{% | |
9e9f9cc2 KB |
3823 | \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} |
3824 | ||
82d5ce1d UD |
3825 | \def\oddfooting{\parsearg\oddfootingxxx} |
3826 | \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} | |
3827 | \def\oddfootingyyy #1\|#2\|#3\|#4\finish{% | |
d705269e UD |
3828 | \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% |
3829 | % | |
3830 | % Leave some space for the footline. Hopefully ok to assume | |
3831 | % @evenfooting will not be used by itself. | |
7f7dd1d3 | 3832 | \global\advance\txipageheight by -12pt |
9251c568 | 3833 | \global\advance\vsize by -12pt |
d705269e | 3834 | } |
9e9f9cc2 | 3835 | |
82d5ce1d UD |
3836 | \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} |
3837 | ||
c94f48d7 AJ |
3838 | % @evenheadingmarks top \thischapter <- chapter at the top of a page |
3839 | % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page | |
3840 | % | |
3841 | % The same set of arguments for: | |
3842 | % | |
3843 | % @oddheadingmarks | |
3844 | % @evenfootingmarks | |
3845 | % @oddfootingmarks | |
3846 | % @everyheadingmarks | |
3847 | % @everyfootingmarks | |
3848 | ||
084e7d57 JM |
3849 | % These define \getoddheadingmarks, \getevenheadingmarks, |
3850 | % \getoddfootingmarks, and \getevenfootingmarks, each to one of | |
3851 | % \gettopheadingmarks, \getbottomheadingmarks. | |
3852 | % | |
c94f48d7 AJ |
3853 | \def\evenheadingmarks{\headingmarks{even}{heading}} |
3854 | \def\oddheadingmarks{\headingmarks{odd}{heading}} | |
3855 | \def\evenfootingmarks{\headingmarks{even}{footing}} | |
3856 | \def\oddfootingmarks{\headingmarks{odd}{footing}} | |
7f7dd1d3 | 3857 | \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1} |
c94f48d7 | 3858 | \headingmarks{odd}{heading}{#1} } |
7f7dd1d3 | 3859 | \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1} |
c94f48d7 AJ |
3860 | \headingmarks{odd}{footing}{#1} } |
3861 | % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. | |
3862 | \def\headingmarks#1#2#3 {% | |
3863 | \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname | |
3864 | \global\expandafter\let\csname get#1#2marks\endcsname \temp | |
3865 | } | |
3866 | ||
3867 | \everyheadingmarks bottom | |
3868 | \everyfootingmarks bottom | |
9e9f9cc2 | 3869 | |
2d07133b KB |
3870 | % @headings double turns headings on for double-sided printing. |
3871 | % @headings single turns headings on for single-sided printing. | |
3872 | % @headings off turns them off. | |
3873 | % @headings on same as @headings double, retained for compatibility. | |
3874 | % @headings after turns on double-sided headings after this page. | |
3875 | % @headings doubleafter turns on double-sided headings after this page. | |
9e9f9cc2 | 3876 | % @headings singleafter turns on single-sided headings after this page. |
793fde8a KB |
3877 | % By default, they are off at the start of a document, |
3878 | % and turned `on' after @end titlepage. | |
9e9f9cc2 | 3879 | |
7f7dd1d3 | 3880 | \parseargdef\headings{\csname HEADINGS#1\endcsname} |
9e9f9cc2 | 3881 | |
0f8bbd69 JM |
3882 | \def\headingsoff{% non-global headings elimination |
3883 | \evenheadline={\hfil}\evenfootline={\hfil}% | |
3884 | \oddheadline={\hfil}\oddfootline={\hfil}% | |
3885 | } | |
3886 | ||
3887 | \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting | |
3888 | \HEADINGSoff % it's the default | |
3889 | ||
9e9f9cc2 KB |
3890 | % When we turn headings on, set the page number to 1. |
3891 | % For double-sided printing, put current file name in lower left corner, | |
3892 | % chapter name on inside top of right hand pages, document | |
3893 | % title on inside top of left hand pages, and page numbers on outside top | |
3894 | % edge of all pages. | |
82d5ce1d | 3895 | \def\HEADINGSdouble{% |
9e9f9cc2 KB |
3896 | \global\pageno=1 |
3897 | \global\evenfootline={\hfil} | |
3898 | \global\oddfootline={\hfil} | |
3899 | \global\evenheadline={\line{\folio\hfil\thistitle}} | |
084e7d57 | 3900 | \global\oddheadline={\line{\thischapterheading\hfil\folio}} |
793fde8a | 3901 | \global\let\contentsalignmacro = \chapoddpage |
9e9f9cc2 | 3902 | } |
793fde8a KB |
3903 | \let\contentsalignmacro = \chappager |
3904 | ||
9e9f9cc2 KB |
3905 | % For single-sided printing, chapter title goes across top left of page, |
3906 | % page number on top right. | |
82d5ce1d | 3907 | \def\HEADINGSsingle{% |
9e9f9cc2 KB |
3908 | \global\pageno=1 |
3909 | \global\evenfootline={\hfil} | |
3910 | \global\oddfootline={\hfil} | |
084e7d57 JM |
3911 | \global\evenheadline={\line{\thischapterheading\hfil\folio}} |
3912 | \global\oddheadline={\line{\thischapterheading\hfil\folio}} | |
793fde8a | 3913 | \global\let\contentsalignmacro = \chappager |
9e9f9cc2 KB |
3914 | } |
3915 | \def\HEADINGSon{\HEADINGSdouble} | |
3916 | ||
3917 | \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} | |
3918 | \let\HEADINGSdoubleafter=\HEADINGSafter | |
3919 | \def\HEADINGSdoublex{% | |
3920 | \global\evenfootline={\hfil} | |
3921 | \global\oddfootline={\hfil} | |
3922 | \global\evenheadline={\line{\folio\hfil\thistitle}} | |
084e7d57 | 3923 | \global\oddheadline={\line{\thischapterheading\hfil\folio}} |
793fde8a | 3924 | \global\let\contentsalignmacro = \chapoddpage |
9e9f9cc2 KB |
3925 | } |
3926 | ||
3927 | \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} | |
3928 | \def\HEADINGSsinglex{% | |
3929 | \global\evenfootline={\hfil} | |
3930 | \global\oddfootline={\hfil} | |
084e7d57 JM |
3931 | \global\evenheadline={\line{\thischapterheading\hfil\folio}} |
3932 | \global\oddheadline={\line{\thischapterheading\hfil\folio}} | |
793fde8a | 3933 | \global\let\contentsalignmacro = \chappager |
9e9f9cc2 KB |
3934 | } |
3935 | ||
3936 | % Subroutines used in generating headings | |
3bc88c40 AJ |
3937 | % This produces Day Month Year style of output. |
3938 | % Only define if not already defined, in case a txi-??.tex file has set | |
3939 | % up a different format (e.g., txi-cs.tex does this). | |
0f8bbd69 | 3940 | \ifx\today\thisisundefined |
b710a6e2 UD |
3941 | \def\today{% |
3942 | \number\day\space | |
3943 | \ifcase\month | |
3944 | \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr | |
3945 | \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug | |
3946 | \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec | |
3947 | \fi | |
3948 | \space\number\year} | |
3bc88c40 | 3949 | \fi |
b710a6e2 UD |
3950 | |
3951 | % @settitle line... specifies the title of the document, for headings. | |
3952 | % It generates no output of its own. | |
3953 | \def\thistitle{\putwordNoTitle} | |
82d5ce1d | 3954 | \def\settitle{\parsearg{\gdef\thistitle}} |
9e9f9cc2 | 3955 | |
d66b7b41 | 3956 | |
9e9f9cc2 | 3957 | \message{tables,} |
82d5ce1d | 3958 | % Tables -- @table, @ftable, @vtable, @item(x). |
9e9f9cc2 KB |
3959 | |
3960 | % default indentation of table text | |
3961 | \newdimen\tableindent \tableindent=.8in | |
3962 | % default indentation of @itemize and @enumerate text | |
3963 | \newdimen\itemindent \itemindent=.3in | |
3964 | % margin between end of table item and start of table text. | |
3965 | \newdimen\itemmargin \itemmargin=.1in | |
3966 | ||
3967 | % used internally for \itemindent minus \itemmargin | |
3968 | \newdimen\itemmax | |
3969 | ||
82d5ce1d | 3970 | % Note @table, @ftable, and @vtable define @item, @itemx, etc., with |
9e9f9cc2 KB |
3971 | % these defs. |
3972 | % They also define \itemindex | |
3973 | % to index the item name in whatever manner is desired (perhaps none). | |
3974 | ||
3975 | \newif\ifitemxneedsnegativevskip | |
3976 | ||
3977 | \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} | |
3978 | ||
3979 | \def\internalBitem{\smallbreak \parsearg\itemzzz} | |
3980 | \def\internalBitemx{\itemxpar \parsearg\itemzzz} | |
3981 | ||
9e9f9cc2 KB |
3982 | \def\itemzzz #1{\begingroup % |
3983 | \advance\hsize by -\rightskip | |
3984 | \advance\hsize by -\tableindent | |
82d5ce1d | 3985 | \setbox0=\hbox{\itemindicate{#1}}% |
9e9f9cc2 KB |
3986 | \itemindex{#1}% |
3987 | \nobreak % This prevents a break before @itemx. | |
3988 | % | |
9e9f9cc2 KB |
3989 | % If the item text does not fit in the space we have, put it on a line |
3990 | % by itself, and do not allow a page break either before or after that | |
3991 | % line. We do not start a paragraph here because then if the next | |
3992 | % command is, e.g., @kindex, the whatsit would get put into the | |
3993 | % horizontal list on a line by itself, resulting in extra blank space. | |
3994 | \ifdim \wd0>\itemmax | |
3995 | % | |
3996 | % Make this a paragraph so we get the \parskip glue and wrapping, | |
3997 | % but leave it ragged-right. | |
3998 | \begingroup | |
3999 | \advance\leftskip by-\tableindent | |
4000 | \advance\hsize by\tableindent | |
0f8bbd69 | 4001 | \advance\rightskip by0pt plus1fil\relax |
9e9f9cc2 KB |
4002 | \leavevmode\unhbox0\par |
4003 | \endgroup | |
4004 | % | |
4005 | % We're going to be starting a paragraph, but we don't want the | |
4006 | % \parskip glue -- logically it's part of the @item we just started. | |
4007 | \nobreak \vskip-\parskip | |
4008 | % | |
82d5ce1d UD |
4009 | % Stop a page break at the \parskip glue coming up. However, if |
4010 | % what follows is an environment such as @example, there will be no | |
4011 | % \parskip glue; then the negative vskip we just inserted would | |
4012 | % cause the example and the item to crash together. So we use this | |
4013 | % bizarre value of 10001 as a signal to \aboveenvbreak to insert | |
4014 | % \parskip glue after all. Section titles are handled this way also. | |
0f8bbd69 | 4015 | % |
2f5b1124 | 4016 | \penalty 10001 |
9e9f9cc2 KB |
4017 | \endgroup |
4018 | \itemxneedsnegativevskipfalse | |
4019 | \else | |
4020 | % The item text fits into the space. Start a paragraph, so that the | |
b710a6e2 | 4021 | % following text (if any) will end up on the same line. |
9e9f9cc2 | 4022 | \noindent |
61027f30 UD |
4023 | % Do this with kerns and \unhbox so that if there is a footnote in |
4024 | % the item text, it can migrate to the main vertical list and | |
4025 | % eventually be printed. | |
4026 | \nobreak\kern-\tableindent | |
85c165be | 4027 | \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 |
61027f30 UD |
4028 | \unhbox0 |
4029 | \nobreak\kern\dimen0 | |
4030 | \endgroup | |
4031 | \itemxneedsnegativevskiptrue | |
9e9f9cc2 KB |
4032 | \fi |
4033 | } | |
4034 | ||
82d5ce1d UD |
4035 | \def\item{\errmessage{@item while not in a list environment}} |
4036 | \def\itemx{\errmessage{@itemx while not in a list environment}} | |
9e9f9cc2 | 4037 | |
61027f30 | 4038 | % @table, @ftable, @vtable. |
82d5ce1d UD |
4039 | \envdef\table{% |
4040 | \let\itemindex\gobble | |
4041 | \tablecheck{table}% | |
4042 | } | |
4043 | \envdef\ftable{% | |
4044 | \def\itemindex ##1{\doind {fn}{\code{##1}}}% | |
4045 | \tablecheck{ftable}% | |
4046 | } | |
4047 | \envdef\vtable{% | |
4048 | \def\itemindex ##1{\doind {vr}{\code{##1}}}% | |
4049 | \tablecheck{vtable}% | |
0ecb606c | 4050 | } |
82d5ce1d UD |
4051 | \def\tablecheck#1{% |
4052 | \ifnum \the\catcode`\^^M=\active | |
4053 | \endgroup | |
4054 | \errmessage{This command won't work in this context; perhaps the problem is | |
4055 | that we are \inenvironment\thisenv}% | |
4056 | \def\next{\doignore{#1}}% | |
4057 | \else | |
4058 | \let\next\tablex | |
4059 | \fi | |
4060 | \next | |
4061 | } | |
4062 | \def\tablex#1{% | |
4063 | \def\itemindicate{#1}% | |
4064 | \parsearg\tabley | |
4065 | } | |
4066 | \def\tabley#1{% | |
4067 | {% | |
4068 | \makevalueexpandable | |
4069 | \edef\temp{\noexpand\tablez #1\space\space\space}% | |
4070 | \expandafter | |
4071 | }\temp \endtablez | |
4072 | } | |
4073 | \def\tablez #1 #2 #3 #4\endtablez{% | |
4074 | \aboveenvbreak | |
4075 | \ifnum 0#1>0 \advance \leftskip by #1\mil \fi | |
4076 | \ifnum 0#2>0 \tableindent=#2\mil \fi | |
4077 | \ifnum 0#3>0 \advance \rightskip by #3\mil \fi | |
4078 | \itemmax=\tableindent | |
4079 | \advance \itemmax by -\itemmargin | |
4080 | \advance \leftskip by \tableindent | |
4081 | \exdentamount=\tableindent | |
4082 | \parindent = 0pt | |
4083 | \parskip = \smallskipamount | |
4084 | \ifdim \parskip=0pt \parskip=2pt \fi | |
4085 | \let\item = \internalBitem | |
4086 | \let\itemx = \internalBitemx | |
4087 | } | |
4088 | \def\Etable{\endgraf\afterenvbreak} | |
4089 | \let\Eftable\Etable | |
4090 | \let\Evtable\Etable | |
4091 | \let\Eitemize\Etable | |
4092 | \let\Eenumerate\Etable | |
9e9f9cc2 KB |
4093 | |
4094 | % This is the counter used by @enumerate, which is really @itemize | |
4095 | ||
4096 | \newcount \itemno | |
4097 | ||
82d5ce1d | 4098 | \envdef\itemize{\parsearg\doitemize} |
9e9f9cc2 | 4099 | |
82d5ce1d | 4100 | \def\doitemize#1{% |
7158eae4 UD |
4101 | \aboveenvbreak |
4102 | \itemmax=\itemindent | |
4103 | \advance\itemmax by -\itemmargin | |
4104 | \advance\leftskip by \itemindent | |
4105 | \exdentamount=\itemindent | |
4106 | \parindent=0pt | |
4107 | \parskip=\smallskipamount | |
4108 | \ifdim\parskip=0pt \parskip=2pt \fi | |
0f8bbd69 | 4109 | % |
21fea2e2 | 4110 | % Try typesetting the item mark so that if the document erroneously says |
0f8bbd69 JM |
4111 | % something like @itemize @samp (intending @table), there's an error |
4112 | % right away at the @itemize. It's not the best error message in the | |
4113 | % world, but it's better than leaving it to the @item. This means if | |
4114 | % the user wants an empty mark, they have to say @w{} not just @w. | |
7158eae4 | 4115 | \def\itemcontents{#1}% |
0f8bbd69 JM |
4116 | \setbox0 = \hbox{\itemcontents}% |
4117 | % | |
7158eae4 UD |
4118 | % @itemize with no arg is equivalent to @itemize @bullet. |
4119 | \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi | |
0f8bbd69 | 4120 | % |
7158eae4 UD |
4121 | \let\item=\itemizeitem |
4122 | } | |
9e9f9cc2 | 4123 | |
82d5ce1d UD |
4124 | % Definition of @item while inside @itemize and @enumerate. |
4125 | % | |
4126 | \def\itemizeitem{% | |
4127 | \advance\itemno by 1 % for enumerations | |
4128 | {\let\par=\endgraf \smallbreak}% reasonable place to break | |
4129 | {% | |
4130 | % If the document has an @itemize directly after a section title, a | |
4131 | % \nobreak will be last on the list, and \sectionheading will have | |
4132 | % done a \vskip-\parskip. In that case, we don't want to zero | |
4133 | % parskip, or the item text will crash with the heading. On the | |
4134 | % other hand, when there is normal text preceding the item (as there | |
4135 | % usually is), we do want to zero parskip, or there would be too much | |
4136 | % space. In that case, we won't have a \nobreak before. At least | |
4137 | % that's the theory. | |
4138 | \ifnum\lastpenalty<10000 \parskip=0in \fi | |
4139 | \noindent | |
4140 | \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% | |
0f8bbd69 | 4141 | % |
084e7d57 JM |
4142 | \ifinner\else |
4143 | \vadjust{\penalty 1200}% not good to break after first line of item. | |
4144 | \fi | |
4145 | % We can be in inner vertical mode in a footnote, although an | |
4146 | % @itemize looks awful there. | |
4147 | }% | |
82d5ce1d UD |
4148 | \flushcr |
4149 | } | |
4150 | ||
9e9f9cc2 KB |
4151 | % \splitoff TOKENS\endmark defines \first to be the first token in |
4152 | % TOKENS, and \rest to be the remainder. | |
4153 | % | |
4154 | \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% | |
4155 | ||
4156 | % Allow an optional argument of an uppercase letter, lowercase letter, | |
4157 | % or number, to specify the first label in the enumerated list. No | |
4158 | % argument is the same as `1'. | |
4159 | % | |
82d5ce1d | 4160 | \envparseargdef\enumerate{\enumeratey #1 \endenumeratey} |
9e9f9cc2 | 4161 | \def\enumeratey #1 #2\endenumeratey{% |
9e9f9cc2 KB |
4162 | % If we were given no argument, pretend we were given `1'. |
4163 | \def\thearg{#1}% | |
4164 | \ifx\thearg\empty \def\thearg{1}\fi | |
4165 | % | |
4166 | % Detect if the argument is a single token. If so, it might be a | |
4167 | % letter. Otherwise, the only valid thing it can be is a number. | |
4168 | % (We will always have one token, because of the test we just made. | |
4169 | % This is a good thing, since \splitoff doesn't work given nothing at | |
4170 | % all -- the first parameter is undelimited.) | |
4171 | \expandafter\splitoff\thearg\endmark | |
4172 | \ifx\rest\empty | |
4173 | % Only one token in the argument. It could still be anything. | |
4174 | % A ``lowercase letter'' is one whose \lccode is nonzero. | |
4175 | % An ``uppercase letter'' is one whose \lccode is both nonzero, and | |
4176 | % not equal to itself. | |
4177 | % Otherwise, we assume it's a number. | |
4178 | % | |
4179 | % We need the \relax at the end of the \ifnum lines to stop TeX from | |
4180 | % continuing to look for a <number>. | |
4181 | % | |
4182 | \ifnum\lccode\expandafter`\thearg=0\relax | |
4183 | \numericenumerate % a number (we hope) | |
4184 | \else | |
4185 | % It's a letter. | |
4186 | \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax | |
4187 | \lowercaseenumerate % lowercase letter | |
4188 | \else | |
4189 | \uppercaseenumerate % uppercase letter | |
4190 | \fi | |
4191 | \fi | |
4192 | \else | |
4193 | % Multiple tokens in the argument. We hope it's a number. | |
4194 | \numericenumerate | |
4195 | \fi | |
4196 | } | |
4197 | ||
4198 | % An @enumerate whose labels are integers. The starting integer is | |
4199 | % given in \thearg. | |
4200 | % | |
4201 | \def\numericenumerate{% | |
4202 | \itemno = \thearg | |
4203 | \startenumeration{\the\itemno}% | |
4204 | } | |
4205 | ||
4206 | % The starting (lowercase) letter is in \thearg. | |
4207 | \def\lowercaseenumerate{% | |
4208 | \itemno = \expandafter`\thearg | |
4209 | \startenumeration{% | |
4210 | % Be sure we're not beyond the end of the alphabet. | |
4211 | \ifnum\itemno=0 | |
4212 | \errmessage{No more lowercase letters in @enumerate; get a bigger | |
4213 | alphabet}% | |
4214 | \fi | |
4215 | \char\lccode\itemno | |
4216 | }% | |
4217 | } | |
4218 | ||
4219 | % The starting (uppercase) letter is in \thearg. | |
4220 | \def\uppercaseenumerate{% | |
4221 | \itemno = \expandafter`\thearg | |
4222 | \startenumeration{% | |
4223 | % Be sure we're not beyond the end of the alphabet. | |
4224 | \ifnum\itemno=0 | |
4225 | \errmessage{No more uppercase letters in @enumerate; get a bigger | |
4226 | alphabet} | |
4227 | \fi | |
4228 | \char\uccode\itemno | |
4229 | }% | |
4230 | } | |
4231 | ||
82d5ce1d | 4232 | % Call \doitemize, adding a period to the first argument and supplying the |
9e9f9cc2 KB |
4233 | % common last two arguments. Also subtract one from the initial value in |
4234 | % \itemno, since @item increments \itemno. | |
4235 | % | |
4236 | \def\startenumeration#1{% | |
4237 | \advance\itemno by -1 | |
82d5ce1d | 4238 | \doitemize{#1.}\flushcr |
9e9f9cc2 KB |
4239 | } |
4240 | ||
4241 | % @alphaenumerate and @capsenumerate are abbreviations for giving an arg | |
4242 | % to @enumerate. | |
4243 | % | |
4244 | \def\alphaenumerate{\enumerate{a}} | |
4245 | \def\capsenumerate{\enumerate{A}} | |
4246 | \def\Ealphaenumerate{\Eenumerate} | |
4247 | \def\Ecapsenumerate{\Eenumerate} | |
4248 | ||
9e9f9cc2 KB |
4249 | |
4250 | % @multitable macros | |
4251 | % Amy Hendrickson, 8/18/94, 3/6/96 | |
4252 | % | |
4253 | % @multitable ... @end multitable will make as many columns as desired. | |
4254 | % Contents of each column will wrap at width given in preamble. Width | |
4255 | % can be specified either with sample text given in a template line, | |
4256 | % or in percent of \hsize, the current width of text on page. | |
4257 | ||
4258 | % Table can continue over pages but will only break between lines. | |
4259 | ||
4260 | % To make preamble: | |
4261 | % | |
10dc2a90 | 4262 | % Either define widths of columns in terms of percent of \hsize: |
9e9f9cc2 KB |
4263 | % @multitable @columnfractions .25 .3 .45 |
4264 | % @item ... | |
4265 | % | |
4266 | % Numbers following @columnfractions are the percent of the total | |
4267 | % current hsize to be used for each column. You may use as many | |
4268 | % columns as desired. | |
4269 | ||
d66b7b41 | 4270 | |
9e9f9cc2 KB |
4271 | % Or use a template: |
4272 | % @multitable {Column 1 template} {Column 2 template} {Column 3 template} | |
4273 | % @item ... | |
4274 | % using the widest term desired in each column. | |
9e9f9cc2 | 4275 | |
10dc2a90 | 4276 | % Each new table line starts with @item, each subsequent new column |
9e9f9cc2 KB |
4277 | % starts with @tab. Empty columns may be produced by supplying @tab's |
4278 | % with nothing between them for as many times as empty columns are needed, | |
4279 | % ie, @tab@tab@tab will produce two empty columns. | |
4280 | ||
82d5ce1d UD |
4281 | % @item, @tab do not need to be on their own lines, but it will not hurt |
4282 | % if they are. | |
9e9f9cc2 KB |
4283 | |
4284 | % Sample multitable: | |
4285 | ||
4286 | % @multitable {Column 1 template} {Column 2 template} {Column 3 template} | |
4287 | % @item first col stuff @tab second col stuff @tab third col | |
10dc2a90 UD |
4288 | % @item |
4289 | % first col stuff | |
4290 | % @tab | |
4291 | % second col stuff | |
4292 | % @tab | |
4293 | % third col | |
4294 | % @item first col stuff @tab second col stuff | |
9e9f9cc2 | 4295 | % @tab Many paragraphs of text may be used in any column. |
10dc2a90 | 4296 | % |
9e9f9cc2 KB |
4297 | % They will wrap at the width determined by the template. |
4298 | % @item@tab@tab This will be in third column. | |
4299 | % @end multitable | |
4300 | ||
4301 | % Default dimensions may be reset by user. | |
4302 | % @multitableparskip is vertical space between paragraphs in table. | |
4303 | % @multitableparindent is paragraph indent in table. | |
4304 | % @multitablecolmargin is horizontal space to be left between columns. | |
4305 | % @multitablelinespace is space to leave between table items, baseline | |
4306 | % to baseline. | |
4307 | % 0pt means it depends on current normal line spacing. | |
2eb45444 | 4308 | % |
9e9f9cc2 KB |
4309 | \newskip\multitableparskip |
4310 | \newskip\multitableparindent | |
4311 | \newdimen\multitablecolspace | |
4312 | \newskip\multitablelinespace | |
4313 | \multitableparskip=0pt | |
4314 | \multitableparindent=6pt | |
4315 | \multitablecolspace=12pt | |
4316 | \multitablelinespace=0pt | |
4317 | ||
407dc7a0 UD |
4318 | % Macros used to set up halign preamble: |
4319 | % | |
4320 | \let\endsetuptable\relax | |
4321 | \def\xendsetuptable{\endsetuptable} | |
4322 | \let\columnfractions\relax | |
4323 | \def\xcolumnfractions{\columnfractions} | |
4324 | \newif\ifsetpercent | |
4325 | ||
82d5ce1d UD |
4326 | % #1 is the @columnfraction, usually a decimal number like .5, but might |
4327 | % be just 1. We just use it, whatever it is. | |
4328 | % | |
4329 | \def\pickupwholefraction#1 {% | |
407dc7a0 | 4330 | \global\advance\colcount by 1 |
82d5ce1d | 4331 | \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% |
407dc7a0 UD |
4332 | \setuptable |
4333 | } | |
4334 | ||
4335 | \newcount\colcount | |
4336 | \def\setuptable#1{% | |
4337 | \def\firstarg{#1}% | |
4338 | \ifx\firstarg\xendsetuptable | |
4339 | \let\go = \relax | |
4340 | \else | |
4341 | \ifx\firstarg\xcolumnfractions | |
4342 | \global\setpercenttrue | |
4343 | \else | |
4344 | \ifsetpercent | |
4345 | \let\go\pickupwholefraction | |
4346 | \else | |
4347 | \global\advance\colcount by 1 | |
e0f86659 UD |
4348 | \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a |
4349 | % separator; typically that is always in the input, anyway. | |
407dc7a0 UD |
4350 | \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% |
4351 | \fi | |
4352 | \fi | |
4353 | \ifx\go\pickupwholefraction | |
4354 | % Put the argument back for the \pickupwholefraction call, so | |
4355 | % we'll always have a period there to be parsed. | |
4356 | \def\go{\pickupwholefraction#1}% | |
4357 | \else | |
4358 | \let\go = \setuptable | |
4359 | \fi% | |
4360 | \fi | |
4361 | \go | |
4362 | } | |
4363 | ||
82d5ce1d UD |
4364 | % multitable-only commands. |
4365 | % | |
e66a8203 JM |
4366 | % @headitem starts a heading row, which we typeset in bold. Assignments |
4367 | % have to be global since we are inside the implicit group of an | |
4368 | % alignment entry. \everycr below resets \everytab so we don't have to | |
0f8bbd69 JM |
4369 | % undo it ourselves. |
4370 | \def\headitemfont{\b}% for people to use in the template row; not changeable | |
4371 | \def\headitem{% | |
4372 | \checkenv\multitable | |
4373 | \crcr | |
e66a8203 | 4374 | \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings |
0f8bbd69 JM |
4375 | \global\everytab={\bf}% can't use \headitemfont since the parsing differs |
4376 | \the\everytab % for the first item | |
4377 | }% | |
82d5ce1d | 4378 | % |
e66a8203 JM |
4379 | % default for tables with no headings. |
4380 | \let\headitemcrhook=\relax | |
4381 | % | |
82d5ce1d UD |
4382 | % A \tab used to include \hskip1sp. But then the space in a template |
4383 | % line is not enough. That is bad. So let's go back to just `&' until | |
0f8bbd69 | 4384 | % we again encounter the problem the 1sp was intended to solve. |
82d5ce1d UD |
4385 | % --karl, nathan@acm.org, 20apr99. |
4386 | \def\tab{\checkenv\multitable &\the\everytab}% | |
4387 | ||
407dc7a0 UD |
4388 | % @multitable ... @end multitable definitions: |
4389 | % | |
82d5ce1d UD |
4390 | \newtoks\everytab % insert after every tab. |
4391 | % | |
4392 | \envdef\multitable{% | |
407dc7a0 | 4393 | \vskip\parskip |
82d5ce1d UD |
4394 | \startsavinginserts |
4395 | % | |
4396 | % @item within a multitable starts a normal row. | |
4397 | % We use \def instead of \let so that if one of the multitable entries | |
4398 | % contains an @itemize, we don't choke on the \item (seen as \crcr aka | |
4399 | % \endtemplate) expanding \doitemize. | |
4400 | \def\item{\crcr}% | |
4401 | % | |
407dc7a0 UD |
4402 | \tolerance=9500 |
4403 | \hbadness=9500 | |
4404 | \setmultitablespacing | |
4405 | \parskip=\multitableparskip | |
4406 | \parindent=\multitableparindent | |
4407 | \overfullrule=0pt | |
4408 | \global\colcount=0 | |
82d5ce1d UD |
4409 | % |
4410 | \everycr = {% | |
4411 | \noalign{% | |
e66a8203 | 4412 | \global\everytab={}% Reset from possible headitem. |
82d5ce1d | 4413 | \global\colcount=0 % Reset the column counter. |
e66a8203 JM |
4414 | % |
4415 | % Check for saved footnotes, etc.: | |
82d5ce1d | 4416 | \checkinserts |
e66a8203 JM |
4417 | % |
4418 | % Perhaps a \nobreak, then reset: | |
4419 | \headitemcrhook | |
4420 | \global\let\headitemcrhook=\relax | |
82d5ce1d | 4421 | }% |
e0f86659 | 4422 | }% |
407dc7a0 | 4423 | % |
82d5ce1d UD |
4424 | \parsearg\domultitable |
4425 | } | |
4426 | \def\domultitable#1{% | |
407dc7a0 UD |
4427 | % To parse everything between @multitable and @item: |
4428 | \setuptable#1 \endsetuptable | |
4429 | % | |
407dc7a0 UD |
4430 | % This preamble sets up a generic column definition, which will |
4431 | % be used as many times as user calls for columns. | |
4432 | % \vtop will set a single line and will also let text wrap and | |
4433 | % continue for many paragraphs if desired. | |
82d5ce1d UD |
4434 | \halign\bgroup &% |
4435 | \global\advance\colcount by 1 | |
4436 | \multistrut | |
4437 | \vtop{% | |
4438 | % Use the current \colcount to find the correct column width: | |
4439 | \hsize=\expandafter\csname col\the\colcount\endcsname | |
4440 | % | |
4441 | % In order to keep entries from bumping into each other | |
4442 | % we will add a \leftskip of \multitablecolspace to all columns after | |
4443 | % the first one. | |
4444 | % | |
4445 | % If a template has been used, we will add \multitablecolspace | |
4446 | % to the width of each template entry. | |
4447 | % | |
4448 | % If the user has set preamble in terms of percent of \hsize we will | |
4449 | % use that dimension as the width of the column, and the \leftskip | |
4450 | % will keep entries from bumping into each other. Table will start at | |
4451 | % left margin and final column will justify at right margin. | |
4452 | % | |
4453 | % Make sure we don't inherit \rightskip from the outer environment. | |
4454 | \rightskip=0pt | |
4455 | \ifnum\colcount=1 | |
4456 | % The first column will be indented with the surrounding text. | |
4457 | \advance\hsize by\leftskip | |
4458 | \else | |
4459 | \ifsetpercent \else | |
4460 | % If user has not set preamble in terms of percent of \hsize | |
4461 | % we will advance \hsize by \multitablecolspace. | |
4462 | \advance\hsize by \multitablecolspace | |
4463 | \fi | |
4464 | % In either case we will make \leftskip=\multitablecolspace: | |
4465 | \leftskip=\multitablecolspace | |
4466 | \fi | |
4467 | % Ignoring space at the beginning and end avoids an occasional spurious | |
4468 | % blank line, when TeX decides to break the line at the space before the | |
4469 | % box from the multistrut, so the strut ends up on a line by itself. | |
4470 | % For example: | |
4471 | % @multitable @columnfractions .11 .89 | |
4472 | % @item @code{#} | |
4473 | % @tab Legal holiday which is valid in major parts of the whole country. | |
4474 | % Is automatically provided with highlighting sequences respectively | |
4475 | % marking characters. | |
4476 | \noindent\ignorespaces##\unskip\multistrut | |
4477 | }\cr | |
4478 | } | |
4479 | \def\Emultitable{% | |
4480 | \crcr | |
4481 | \egroup % end the \halign | |
4482 | \global\setpercentfalse | |
4483 | } | |
4484 | ||
4485 | \def\setmultitablespacing{% | |
4486 | \def\multistrut{\strut}% just use the standard line spacing | |
4487 | % | |
4488 | % Compute \multitablelinespace (if not defined by user) for use in | |
4489 | % \multitableparskip calculation. We used define \multistrut based on | |
4490 | % this, but (ironically) that caused the spacing to be off. | |
4491 | % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. | |
407dc7a0 | 4492 | \ifdim\multitablelinespace=0pt |
3b82ab1c UD |
4493 | \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip |
4494 | \global\advance\multitablelinespace by-\ht0 | |
82d5ce1d | 4495 | \fi |
0f8bbd69 JM |
4496 | % Test to see if parskip is larger than space between lines of |
4497 | % table. If not, do nothing. | |
4498 | % If so, set to same dimension as multitablelinespace. | |
407dc7a0 UD |
4499 | \ifdim\multitableparskip>\multitablelinespace |
4500 | \global\multitableparskip=\multitablelinespace | |
0f8bbd69 JM |
4501 | \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller |
4502 | % than skip between lines in the table. | |
407dc7a0 UD |
4503 | \fi% |
4504 | \ifdim\multitableparskip=0pt | |
4505 | \global\multitableparskip=\multitablelinespace | |
0f8bbd69 JM |
4506 | \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller |
4507 | % than skip between lines in the table. | |
407dc7a0 UD |
4508 | \fi} |
4509 | ||
4510 | ||
4511 | \message{conditionals,} | |
82d5ce1d UD |
4512 | |
4513 | % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, | |
4514 | % @ifnotxml always succeed. They currently do nothing; we don't | |
4515 | % attempt to check whether the conditionals are properly nested. But we | |
4516 | % have to remember that they are conditionals, so that @end doesn't | |
4517 | % attempt to close an environment group. | |
4518 | % | |
4519 | \def\makecond#1{% | |
4520 | \expandafter\let\csname #1\endcsname = \relax | |
4521 | \expandafter\let\csname iscond.#1\endcsname = 1 | |
407dc7a0 | 4522 | } |
82d5ce1d UD |
4523 | \makecond{iftex} |
4524 | \makecond{ifnotdocbook} | |
4525 | \makecond{ifnothtml} | |
4526 | \makecond{ifnotinfo} | |
4527 | \makecond{ifnotplaintext} | |
4528 | \makecond{ifnotxml} | |
407dc7a0 | 4529 | |
2f5b1124 | 4530 | % Ignore @ignore, @ifhtml, @ifinfo, and the like. |
407dc7a0 | 4531 | % |
2f5b1124 | 4532 | \def\direntry{\doignore{direntry}} |
2f5b1124 | 4533 | \def\documentdescription{\doignore{documentdescription}} |
82d5ce1d | 4534 | \def\docbook{\doignore{docbook}} |
2f5b1124 | 4535 | \def\html{\doignore{html}} |
82d5ce1d | 4536 | \def\ifdocbook{\doignore{ifdocbook}} |
407dc7a0 | 4537 | \def\ifhtml{\doignore{ifhtml}} |
27692f89 | 4538 | \def\ifinfo{\doignore{ifinfo}} |
407dc7a0 | 4539 | \def\ifnottex{\doignore{ifnottex}} |
2f5b1124 UD |
4540 | \def\ifplaintext{\doignore{ifplaintext}} |
4541 | \def\ifxml{\doignore{ifxml}} | |
4542 | \def\ignore{\doignore{ignore}} | |
407dc7a0 | 4543 | \def\menu{\doignore{menu}} |
2f5b1124 | 4544 | \def\xml{\doignore{xml}} |
407dc7a0 | 4545 | |
82d5ce1d | 4546 | % Ignore text until a line `@end #1', keeping track of nested conditionals. |
a334319f | 4547 | % |
82d5ce1d UD |
4548 | % A count to remember the depth of nesting. |
4549 | \newcount\doignorecount | |
4550 | ||
407dc7a0 | 4551 | \def\doignore#1{\begingroup |
82d5ce1d | 4552 | % Scan in ``verbatim'' mode: |
9251c568 | 4553 | \obeylines |
82d5ce1d UD |
4554 | \catcode`\@ = \other |
4555 | \catcode`\{ = \other | |
4556 | \catcode`\} = \other | |
407dc7a0 UD |
4557 | % |
4558 | % Make sure that spaces turn into tokens that match what \doignoretext wants. | |
82d5ce1d | 4559 | \spaceisspace |
407dc7a0 | 4560 | % |
82d5ce1d UD |
4561 | % Count number of #1's that we've seen. |
4562 | \doignorecount = 0 | |
407dc7a0 | 4563 | % |
82d5ce1d UD |
4564 | % Swallow text until we reach the matching `@end #1'. |
4565 | \dodoignore{#1}% | |
0ecb606c JJ |
4566 | } |
4567 | ||
82d5ce1d UD |
4568 | { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. |
4569 | \obeylines % | |
a334319f | 4570 | % |
82d5ce1d UD |
4571 | \gdef\dodoignore#1{% |
4572 | % #1 contains the command name as a string, e.g., `ifinfo'. | |
a334319f | 4573 | % |
9251c568 AJ |
4574 | % Define a command to find the next `@end #1'. |
4575 | \long\def\doignoretext##1^^M@end #1{% | |
4576 | \doignoretextyyy##1^^M@#1\_STOP_}% | |
4577 | % | |
82d5ce1d UD |
4578 | % And this command to find another #1 command, at the beginning of a |
4579 | % line. (Otherwise, we would consider a line `@c @ifset', for | |
4580 | % example, to count as an @ifset for nesting.) | |
4581 | \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% | |
a334319f | 4582 | % |
82d5ce1d | 4583 | % And now expand that command. |
82d5ce1d UD |
4584 | \doignoretext ^^M% |
4585 | }% | |
4586 | } | |
4587 | ||
4588 | \def\doignoreyyy#1{% | |
4589 | \def\temp{#1}% | |
4590 | \ifx\temp\empty % Nothing found. | |
4591 | \let\next\doignoretextzzz | |
4592 | \else % Found a nested condition, ... | |
4593 | \advance\doignorecount by 1 | |
4594 | \let\next\doignoretextyyy % ..., look for another. | |
4595 | % If we're here, #1 ends with ^^M\ifinfo (for example). | |
4596 | \fi | |
4597 | \next #1% the token \_STOP_ is present just after this macro. | |
4598 | } | |
4599 | ||
4600 | % We have to swallow the remaining "\_STOP_". | |
4601 | % | |
4602 | \def\doignoretextzzz#1{% | |
4603 | \ifnum\doignorecount = 0 % We have just found the outermost @end. | |
4604 | \let\next\enddoignore | |
4605 | \else % Still inside a nested condition. | |
4606 | \advance\doignorecount by -1 | |
4607 | \let\next\doignoretext % Look for the next @end. | |
4608 | \fi | |
4609 | \next | |
407dc7a0 UD |
4610 | } |
4611 | ||
82d5ce1d | 4612 | % Finish off ignored text. |
9251c568 AJ |
4613 | { \obeylines% |
4614 | % Ignore anything after the last `@end #1'; this matters in verbatim | |
4615 | % environments, where otherwise the newline after an ignored conditional | |
4616 | % would result in a blank line in the output. | |
4617 | \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% | |
4618 | } | |
82d5ce1d UD |
4619 | |
4620 | ||
407dc7a0 UD |
4621 | % @set VAR sets the variable VAR to an empty value. |
4622 | % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. | |
4623 | % | |
4624 | % Since we want to separate VAR from REST-OF-LINE (which might be | |
4625 | % empty), we can't just use \parsearg; we have to insert a space of our | |
4626 | % own to delimit the rest of the line, and then take it out again if we | |
82d5ce1d UD |
4627 | % didn't need it. |
4628 | % We rely on the fact that \parsearg sets \catcode`\ =10. | |
407dc7a0 | 4629 | % |
82d5ce1d | 4630 | \parseargdef\set{\setyyy#1 \endsetyyy} |
407dc7a0 | 4631 | \def\setyyy#1 #2\endsetyyy{% |
82d5ce1d UD |
4632 | {% |
4633 | \makevalueexpandable | |
4634 | \def\temp{#2}% | |
4635 | \edef\next{\gdef\makecsname{SET#1}}% | |
4636 | \ifx\temp\empty | |
4637 | \next{}% | |
4638 | \else | |
4639 | \setzzz#2\endsetzzz | |
4640 | \fi | |
4641 | }% | |
407dc7a0 | 4642 | } |
82d5ce1d UD |
4643 | % Remove the trailing space \setxxx inserted. |
4644 | \def\setzzz#1 \endsetzzz{\next{#1}} | |
407dc7a0 UD |
4645 | |
4646 | % @clear VAR clears (i.e., unsets) the variable VAR. | |
b710a6e2 | 4647 | % |
82d5ce1d UD |
4648 | \parseargdef\clear{% |
4649 | {% | |
4650 | \makevalueexpandable | |
4651 | \global\expandafter\let\csname SET#1\endcsname=\relax | |
4652 | }% | |
4653 | } | |
9e9f9cc2 | 4654 | |
407dc7a0 | 4655 | % @value{foo} gets the text saved in variable foo. |
82d5ce1d UD |
4656 | \def\value{\begingroup\makevalueexpandable\valuexxx} |
4657 | \def\valuexxx#1{\expandablevalue{#1}\endgroup} | |
407dc7a0 | 4658 | { |
21fea2e2 | 4659 | \catcode`\-=\active \catcode`\_=\active |
407dc7a0 | 4660 | % |
82d5ce1d UD |
4661 | \gdef\makevalueexpandable{% |
4662 | \let\value = \expandablevalue | |
4663 | % We don't want these characters active, ... | |
e0f86659 | 4664 | \catcode`\-=\other \catcode`\_=\other |
82d5ce1d UD |
4665 | % ..., but we might end up with active ones in the argument if |
4666 | % we're called from @code, as @code{@value{foo-bar_}}, though. | |
4667 | % So \let them to their normal equivalents. | |
8fcb833a | 4668 | \let-\normaldash \let_\normalunderscore |
82d5ce1d | 4669 | } |
b710a6e2 | 4670 | } |
9e9f9cc2 | 4671 | |
407dc7a0 | 4672 | % We have this subroutine so that we can handle at least some @value's |
82d5ce1d UD |
4673 | % properly in indexes (we call \makevalueexpandable in \indexdummies). |
4674 | % The command has to be fully expandable (if the variable is set), since | |
4675 | % the result winds up in the index file. This means that if the | |
4676 | % variable's value contains other Texinfo commands, it's almost certain | |
4677 | % it will fail (although perhaps we could fix that with sufficient work | |
4678 | % to do a one-level expansion on the result, instead of complete). | |
407dc7a0 | 4679 | % |
21fea2e2 JM |
4680 | % Unfortunately, this has the consequence that when _ is in the *value* |
4681 | % of an @set, it does not print properly in the roman fonts (get the cmr | |
4682 | % dot accent at position 126 instead). No fix comes to mind, and it's | |
4683 | % been this way since 2003 or earlier, so just ignore it. | |
4684 | % | |
407dc7a0 UD |
4685 | \def\expandablevalue#1{% |
4686 | \expandafter\ifx\csname SET#1\endcsname\relax | |
4687 | {[No value for ``#1'']}% | |
e0f86659 | 4688 | \message{Variable `#1', used in @value, is not set.}% |
9e9f9cc2 | 4689 | \else |
407dc7a0 | 4690 | \csname SET#1\endcsname |
b710a6e2 | 4691 | \fi |
b710a6e2 | 4692 | } |
9e9f9cc2 | 4693 | |
7f7dd1d3 JM |
4694 | % Like \expandablevalue, but completely expandable (the \message in the |
4695 | % definition above operates at the execution level of TeX). Used when | |
4696 | % writing to auxiliary files, due to the expansion that \write does. | |
4697 | % If flag is undefined, pass through an unexpanded @value command: maybe it | |
4698 | % will be set by the time it is read back in. | |
4699 | % | |
4700 | % NB flag names containing - or _ may not work here. | |
4701 | \def\dummyvalue#1{% | |
4702 | \expandafter\ifx\csname SET#1\endcsname\relax | |
4703 | \noexpand\value{#1}% | |
4704 | \else | |
4705 | \csname SET#1\endcsname | |
4706 | \fi | |
4707 | } | |
4708 | ||
4709 | % Used for @value's in index entries to form the sort key: expand the @value | |
4710 | % if possible, otherwise sort late. | |
4711 | \def\indexnofontsvalue#1{% | |
4712 | \expandafter\ifx\csname SET#1\endcsname\relax | |
4713 | ZZZZZZZ | |
4714 | \else | |
4715 | \csname SET#1\endcsname | |
4716 | \fi | |
4717 | } | |
4718 | ||
407dc7a0 UD |
4719 | % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined |
4720 | % with @set. | |
4721 | % | |
8fcb833a JM |
4722 | % To get the special treatment we need for `@end ifset,' we call |
4723 | % \makecond and then redefine. | |
82d5ce1d UD |
4724 | % |
4725 | \makecond{ifset} | |
4726 | \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} | |
4727 | \def\doifset#1#2{% | |
4728 | {% | |
4729 | \makevalueexpandable | |
4730 | \let\next=\empty | |
4731 | \expandafter\ifx\csname SET#2\endcsname\relax | |
4732 | #1% If not set, redefine \next. | |
4733 | \fi | |
4734 | \expandafter | |
4735 | }\next | |
407dc7a0 | 4736 | } |
82d5ce1d | 4737 | \def\ifsetfail{\doignore{ifset}} |
9e9f9cc2 | 4738 | |
8fcb833a | 4739 | % @ifclear VAR ... @end executes the `...' iff VAR has never been |
407dc7a0 | 4740 | % defined with @set, or has been undefined with @clear. |
b710a6e2 | 4741 | % |
82d5ce1d UD |
4742 | % The `\else' inside the `\doifset' parameter is a trick to reuse the |
4743 | % above code: if the variable is not set, do nothing, if it is set, | |
4744 | % then redefine \next to \ifclearfail. | |
407dc7a0 | 4745 | % |
82d5ce1d UD |
4746 | \makecond{ifclear} |
4747 | \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} | |
4748 | \def\ifclearfail{\doignore{ifclear}} | |
407dc7a0 | 4749 | |
8fcb833a JM |
4750 | % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written |
4751 | % without the @) is in fact defined. We can only feasibly check at the | |
4752 | % TeX level, so something like `mathcode' is going to considered | |
4753 | % defined even though it is not a Texinfo command. | |
4754 | % | |
4755 | \makecond{ifcommanddefined} | |
4756 | \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} | |
4757 | % | |
4758 | \def\doifcmddefined#1#2{{% | |
4759 | \makevalueexpandable | |
4760 | \let\next=\empty | |
4761 | \expandafter\ifx\csname #2\endcsname\relax | |
4762 | #1% If not defined, \let\next as above. | |
4763 | \fi | |
4764 | \expandafter | |
4765 | }\next | |
4766 | } | |
4767 | \def\ifcmddefinedfail{\doignore{ifcommanddefined}} | |
4768 | ||
4769 | % @ifcommandnotdefined CMD ... handled similar to @ifclear above. | |
4770 | \makecond{ifcommandnotdefined} | |
4771 | \def\ifcommandnotdefined{% | |
4772 | \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} | |
4773 | \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} | |
4774 | ||
4775 | % Set the `txicommandconditionals' variable, so documents have a way to | |
4776 | % test if the @ifcommand...defined conditionals are available. | |
4777 | \set txicommandconditionals | |
4778 | ||
82d5ce1d UD |
4779 | % @dircategory CATEGORY -- specify a category of the dir file |
4780 | % which this file should belong to. Ignore this in TeX. | |
4781 | \let\dircategory=\comment | |
407dc7a0 UD |
4782 | |
4783 | % @defininfoenclose. | |
4784 | \let\definfoenclose=\comment | |
d66b7b41 KB |
4785 | |
4786 | ||
9e9f9cc2 KB |
4787 | \message{indexing,} |
4788 | % Index generation facilities | |
4789 | ||
4790 | % Define \newwrite to be identical to plain tex's \newwrite | |
82d5ce1d UD |
4791 | % except not \outer, so it can be used within macros and \if's. |
4792 | \edef\newwrite{\makecsname{ptexnewwrite}} | |
9e9f9cc2 | 4793 | |
084e7d57 JM |
4794 | % \newindex {foo} defines an index named IX. |
4795 | % It automatically defines \IXindex such that | |
4796 | % \IXindex ...rest of line... puts an entry in the index IX. | |
4797 | % It also defines \IXindfile to be the number of the output channel for | |
4798 | % the file that accumulates this index. The file's extension is IX. | |
9e9f9cc2 KB |
4799 | % The name of an index should be no more than 2 characters long |
4800 | % for the sake of vms. | |
f962d792 UD |
4801 | % |
4802 | \def\newindex#1{% | |
084e7d57 | 4803 | \expandafter\chardef\csname#1indfile\endcsname=0 |
f962d792 UD |
4804 | \expandafter\xdef\csname#1index\endcsname{% % Define @#1index |
4805 | \noexpand\doindex{#1}} | |
9e9f9cc2 KB |
4806 | } |
4807 | ||
4808 | % @defindex foo == \newindex{foo} | |
366d6851 | 4809 | % |
9e9f9cc2 KB |
4810 | \def\defindex{\parsearg\newindex} |
4811 | ||
4812 | % Define @defcodeindex, like @defindex except put all entries in @code. | |
366d6851 UD |
4813 | % |
4814 | \def\defcodeindex{\parsearg\newcodeindex} | |
4815 | % | |
f962d792 | 4816 | \def\newcodeindex#1{% |
084e7d57 | 4817 | \expandafter\chardef\csname#1indfile\endcsname=0 |
f962d792 | 4818 | \expandafter\xdef\csname#1index\endcsname{% |
366d6851 | 4819 | \noexpand\docodeindex{#1}}% |
9e9f9cc2 KB |
4820 | } |
4821 | ||
084e7d57 JM |
4822 | % The default indices: |
4823 | \newindex{cp}% concepts, | |
4824 | \newcodeindex{fn}% functions, | |
4825 | \newcodeindex{vr}% variables, | |
4826 | \newcodeindex{tp}% types, | |
4827 | \newcodeindex{ky}% keys | |
4828 | \newcodeindex{pg}% and programs. | |
4829 | ||
9e9f9cc2 KB |
4830 | |
4831 | % @synindex foo bar makes index foo feed into index bar. | |
4832 | % Do this instead of @defindex foo if you don't want it as a separate index. | |
7158eae4 | 4833 | % |
9e9f9cc2 KB |
4834 | % @syncodeindex foo bar similar, but put all entries made for index foo |
4835 | % inside @code. | |
7158eae4 | 4836 | % |
366d6851 UD |
4837 | \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} |
4838 | \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} | |
4839 | ||
4840 | % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), | |
4841 | % #3 the target index (bar). | |
4842 | \def\dosynindex#1#2#3{% | |
7f7dd1d3 | 4843 | \requireopenindexfile{#3}% |
366d6851 UD |
4844 | % redefine \fooindfile: |
4845 | \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname | |
4846 | \expandafter\let\csname#2indfile\endcsname=\temp | |
4847 | % redefine \fooindex: | |
4848 | \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% | |
9e9f9cc2 KB |
4849 | } |
4850 | ||
084e7d57 | 4851 | % Define \doindex, the driver for all index macros. |
9e9f9cc2 | 4852 | % Argument #1 is generated by the calling \fooindex macro, |
7f7dd1d3 | 4853 | % and it is the two-letter name of the index. |
9e9f9cc2 | 4854 | |
084e7d57 JM |
4855 | \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx} |
4856 | \def\doindexxxx #1{\doind{\indexname}{#1}} | |
9e9f9cc2 KB |
4857 | |
4858 | % like the previous two, but they put @code around the argument. | |
084e7d57 JM |
4859 | \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx} |
4860 | \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}} | |
9e9f9cc2 | 4861 | |
7f7dd1d3 JM |
4862 | \f |
4863 | % Used when writing an index entry out to an index file to prevent | |
084e7d57 | 4864 | % expansion of Texinfo commands that can appear in an index entry. |
7158eae4 | 4865 | % |
9e9f9cc2 | 4866 | \def\indexdummies{% |
9251c568 | 4867 | \escapechar = `\\ % use backslash in output files. |
7f7dd1d3 JM |
4868 | \definedummyletter\@% |
4869 | \definedummyletter\ % | |
4870 | % | |
4871 | % For texindex which always views { and } as separators. | |
4872 | \def\{{\lbracechar{}}% | |
4873 | \def\}{\rbracechar{}}% | |
e0f86659 | 4874 | % |
e0f86659 | 4875 | % Do the redefinitions. |
7f7dd1d3 | 4876 | \definedummies |
e0f86659 UD |
4877 | } |
4878 | ||
7f7dd1d3 | 4879 | % Used for the aux and toc files, where @ is the escape character. |
7158eae4 | 4880 | % |
e0f86659 | 4881 | \def\atdummies{% |
7f7dd1d3 JM |
4882 | \definedummyletter\@% |
4883 | \definedummyletter\ % | |
4884 | \definedummyletter\{% | |
4885 | \definedummyletter\}% | |
e0f86659 | 4886 | % |
e0f86659 | 4887 | % Do the redefinitions. |
7f7dd1d3 | 4888 | \definedummies |
9251c568 | 4889 | \otherbackslash |
e0f86659 UD |
4890 | } |
4891 | ||
7f7dd1d3 JM |
4892 | % \definedummyword defines \#1 as \string\#1\space, thus effectively |
4893 | % preventing its expansion. This is used only for control words, | |
4894 | % not control letters, because the \space would be incorrect for | |
4895 | % control characters, but is needed to separate the control word | |
4896 | % from whatever follows. | |
7158eae4 | 4897 | % |
7f7dd1d3 JM |
4898 | % These can be used both for control words that take an argument and |
4899 | % those that do not. If it is followed by {arg} in the input, then | |
4900 | % that will dutifully get written to the index (or wherever). | |
4901 | % | |
4902 | % For control letters, we have \definedummyletter, which omits the | |
4903 | % space. | |
4904 | % | |
4905 | \def\definedummyword #1{\def#1{\string#1\space}}% | |
4906 | \def\definedummyletter#1{\def#1{\string#1}}% | |
4907 | \let\definedummyaccent\definedummyletter | |
4908 | ||
4909 | % Called from \indexdummies and \atdummies, to effectively prevent | |
4910 | % the expansion of commands. | |
4911 | % | |
4912 | \def\definedummies{% | |
e0f86659 | 4913 | % |
7f7dd1d3 JM |
4914 | \let\commondummyword\definedummyword |
4915 | \let\commondummyletter\definedummyletter | |
4916 | \let\commondummyaccent\definedummyaccent | |
82d5ce1d UD |
4917 | \commondummiesnofonts |
4918 | % | |
9251c568 | 4919 | \definedummyletter\_% |
0f8bbd69 | 4920 | \definedummyletter\-% |
82d5ce1d UD |
4921 | % |
4922 | % Non-English letters. | |
9251c568 AJ |
4923 | \definedummyword\AA |
4924 | \definedummyword\AE | |
0f8bbd69 | 4925 | \definedummyword\DH |
9251c568 | 4926 | \definedummyword\L |
9251c568 | 4927 | \definedummyword\O |
0f8bbd69 JM |
4928 | \definedummyword\OE |
4929 | \definedummyword\TH | |
9251c568 AJ |
4930 | \definedummyword\aa |
4931 | \definedummyword\ae | |
0f8bbd69 JM |
4932 | \definedummyword\dh |
4933 | \definedummyword\exclamdown | |
9251c568 | 4934 | \definedummyword\l |
9251c568 | 4935 | \definedummyword\o |
0f8bbd69 | 4936 | \definedummyword\oe |
9251c568 AJ |
4937 | \definedummyword\ordf |
4938 | \definedummyword\ordm | |
0f8bbd69 JM |
4939 | \definedummyword\questiondown |
4940 | \definedummyword\ss | |
4941 | \definedummyword\th | |
e0f86659 UD |
4942 | % |
4943 | % Although these internal commands shouldn't show up, sometimes they do. | |
9251c568 AJ |
4944 | \definedummyword\bf |
4945 | \definedummyword\gtr | |
4946 | \definedummyword\hat | |
4947 | \definedummyword\less | |
4948 | \definedummyword\sf | |
4949 | \definedummyword\sl | |
4950 | \definedummyword\tclose | |
4951 | \definedummyword\tt | |
4952 | % | |
4953 | \definedummyword\LaTeX | |
4954 | \definedummyword\TeX | |
e0f86659 UD |
4955 | % |
4956 | % Assorted special characters. | |
7f7dd1d3 | 4957 | \definedummyword\atchar |
0f8bbd69 | 4958 | \definedummyword\arrow |
9251c568 AJ |
4959 | \definedummyword\bullet |
4960 | \definedummyword\comma | |
4961 | \definedummyword\copyright | |
4962 | \definedummyword\registeredsymbol | |
4963 | \definedummyword\dots | |
4964 | \definedummyword\enddots | |
0f8bbd69 | 4965 | \definedummyword\entrybreak |
9251c568 AJ |
4966 | \definedummyword\equiv |
4967 | \definedummyword\error | |
4968 | \definedummyword\euro | |
0f8bbd69 JM |
4969 | \definedummyword\expansion |
4970 | \definedummyword\geq | |
c94f48d7 AJ |
4971 | \definedummyword\guillemetleft |
4972 | \definedummyword\guillemetright | |
4973 | \definedummyword\guilsinglleft | |
4974 | \definedummyword\guilsinglright | |
8fcb833a | 4975 | \definedummyword\lbracechar |
0f8bbd69 | 4976 | \definedummyword\leq |
084e7d57 | 4977 | \definedummyword\mathopsup |
9251c568 | 4978 | \definedummyword\minus |
0f8bbd69 | 4979 | \definedummyword\ogonek |
9251c568 AJ |
4980 | \definedummyword\pounds |
4981 | \definedummyword\point | |
4982 | \definedummyword\print | |
c94f48d7 AJ |
4983 | \definedummyword\quotedblbase |
4984 | \definedummyword\quotedblleft | |
4985 | \definedummyword\quotedblright | |
4986 | \definedummyword\quoteleft | |
4987 | \definedummyword\quoteright | |
4988 | \definedummyword\quotesinglbase | |
8fcb833a | 4989 | \definedummyword\rbracechar |
9251c568 | 4990 | \definedummyword\result |
084e7d57 JM |
4991 | \definedummyword\sub |
4992 | \definedummyword\sup | |
9251c568 AJ |
4993 | \definedummyword\textdegree |
4994 | % | |
4995 | % We want to disable all macros so that they are not expanded by \write. | |
4996 | \macrolist | |
7f7dd1d3 | 4997 | \let\value\dummyvalue |
9251c568 AJ |
4998 | % |
4999 | \normalturnoffactive | |
9e9f9cc2 KB |
5000 | } |
5001 | ||
7f7dd1d3 JM |
5002 | % \commondummiesnofonts: common to \definedummies and \indexnofonts. |
5003 | % Define \commondummyletter, \commondummyaccent and \commondummyword before | |
5004 | % using. Used for accents, font commands, and various control letters. | |
82d5ce1d | 5005 | % |
9251c568 AJ |
5006 | \def\commondummiesnofonts{% |
5007 | % Control letters and accents. | |
7f7dd1d3 JM |
5008 | \commondummyletter\!% |
5009 | \commondummyaccent\"% | |
5010 | \commondummyaccent\'% | |
5011 | \commondummyletter\*% | |
5012 | \commondummyaccent\,% | |
5013 | \commondummyletter\.% | |
5014 | \commondummyletter\/% | |
5015 | \commondummyletter\:% | |
5016 | \commondummyaccent\=% | |
5017 | \commondummyletter\?% | |
5018 | \commondummyaccent\^% | |
5019 | \commondummyaccent\`% | |
5020 | \commondummyaccent\~% | |
5021 | \commondummyword\u | |
5022 | \commondummyword\v | |
5023 | \commondummyword\H | |
5024 | \commondummyword\dotaccent | |
5025 | \commondummyword\ogonek | |
5026 | \commondummyword\ringaccent | |
5027 | \commondummyword\tieaccent | |
5028 | \commondummyword\ubaraccent | |
5029 | \commondummyword\udotaccent | |
5030 | \commondummyword\dotless | |
9251c568 AJ |
5031 | % |
5032 | % Texinfo font commands. | |
7f7dd1d3 JM |
5033 | \commondummyword\b |
5034 | \commondummyword\i | |
5035 | \commondummyword\r | |
5036 | \commondummyword\sansserif | |
5037 | \commondummyword\sc | |
5038 | \commondummyword\slanted | |
5039 | \commondummyword\t | |
9251c568 AJ |
5040 | % |
5041 | % Commands that take arguments. | |
7f7dd1d3 JM |
5042 | \commondummyword\abbr |
5043 | \commondummyword\acronym | |
5044 | \commondummyword\anchor | |
5045 | \commondummyword\cite | |
5046 | \commondummyword\code | |
5047 | \commondummyword\command | |
5048 | \commondummyword\dfn | |
5049 | \commondummyword\dmn | |
5050 | \commondummyword\email | |
5051 | \commondummyword\emph | |
5052 | \commondummyword\env | |
5053 | \commondummyword\file | |
5054 | \commondummyword\image | |
5055 | \commondummyword\indicateurl | |
5056 | \commondummyword\inforef | |
5057 | \commondummyword\kbd | |
5058 | \commondummyword\key | |
5059 | \commondummyword\math | |
5060 | \commondummyword\option | |
5061 | \commondummyword\pxref | |
5062 | \commondummyword\ref | |
5063 | \commondummyword\samp | |
5064 | \commondummyword\strong | |
5065 | \commondummyword\tie | |
5066 | \commondummyword\U | |
5067 | \commondummyword\uref | |
5068 | \commondummyword\url | |
5069 | \commondummyword\var | |
5070 | \commondummyword\verb | |
5071 | \commondummyword\w | |
5072 | \commondummyword\xref | |
82d5ce1d | 5073 | } |
e0f86659 | 5074 | |
e66a8203 JM |
5075 | % For testing: output @{ and @} in index sort strings as \{ and \}. |
5076 | \newif\ifusebracesinindexes | |
5077 | ||
084e7d57 JM |
5078 | \let\indexlbrace\relax |
5079 | \let\indexrbrace\relax | |
5080 | ||
5081 | {\catcode`\@=0 | |
5082 | \catcode`\\=13 | |
5083 | @gdef@backslashdisappear{@def\{}} | |
5084 | } | |
5085 | ||
5086 | { | |
5087 | \catcode`\<=13 | |
5088 | \catcode`\-=13 | |
5089 | \catcode`\`=13 | |
5090 | \gdef\indexnonalnumdisappear{% | |
5091 | \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else | |
5092 | % @set txiindexlquoteignore makes us ignore left quotes in the sort term. | |
5093 | % (Introduced for FSFS 2nd ed.) | |
5094 | \let`=\empty | |
5095 | \fi | |
5096 | % | |
5097 | \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else | |
5098 | \backslashdisappear | |
5099 | \fi | |
5100 | % | |
5101 | \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else | |
5102 | \def-{}% | |
5103 | \fi | |
5104 | \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else | |
5105 | \def<{}% | |
5106 | \fi | |
5107 | \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else | |
5108 | \def\@{}% | |
5109 | \fi | |
5110 | } | |
5111 | ||
5112 | \gdef\indexnonalnumreappear{% | |
5113 | \useindexbackslash | |
5114 | \let-\normaldash | |
5115 | \let<\normalless | |
5116 | \def\@{@}% | |
5117 | } | |
5118 | } | |
5119 | ||
5120 | ||
e0f86659 UD |
5121 | % \indexnofonts is used when outputting the strings to sort the index |
5122 | % by, and when constructing control sequence names. It eliminates all | |
5123 | % control sequences and just writes whatever the best ASCII sort string | |
5124 | % would be for a given command (usually its argument). | |
5125 | % | |
9e9f9cc2 | 5126 | \def\indexnofonts{% |
82d5ce1d | 5127 | % Accent commands should become @asis. |
7f7dd1d3 | 5128 | \def\commondummyaccent##1{\let##1\asis}% |
82d5ce1d | 5129 | % We can just ignore other control letters. |
7f7dd1d3 | 5130 | \def\commondummyletter##1{\let##1\empty}% |
0f8bbd69 | 5131 | % All control words become @asis by default; overrides below. |
7f7dd1d3 | 5132 | \let\commondummyword\commondummyaccent |
82d5ce1d UD |
5133 | \commondummiesnofonts |
5134 | % | |
5135 | % Don't no-op \tt, since it isn't a user-level command | |
5136 | % and is used in the definitions of the active chars like <, >, |, etc. | |
5137 | % Likewise with the other plain tex font commands. | |
5138 | %\let\tt=\asis | |
5139 | % | |
e0f86659 UD |
5140 | \def\ { }% |
5141 | \def\@{@}% | |
e0f86659 | 5142 | \def\_{\normalunderscore}% |
0f8bbd69 JM |
5143 | \def\-{}% @- shouldn't affect sorting |
5144 | % | |
7f7dd1d3 JM |
5145 | \uccode`\1=`\{ \uppercase{\def\{{1}}% |
5146 | \uccode`\1=`\} \uppercase{\def\}{1}}% | |
5147 | \let\lbracechar\{% | |
5148 | \let\rbracechar\}% | |
e0f86659 | 5149 | % |
82d5ce1d | 5150 | % Non-English letters. |
e0f86659 UD |
5151 | \def\AA{AA}% |
5152 | \def\AE{AE}% | |
0f8bbd69 | 5153 | \def\DH{DZZ}% |
e0f86659 UD |
5154 | \def\L{L}% |
5155 | \def\OE{OE}% | |
5156 | \def\O{O}% | |
084e7d57 | 5157 | \def\TH{TH}% |
e0f86659 UD |
5158 | \def\aa{aa}% |
5159 | \def\ae{ae}% | |
0f8bbd69 JM |
5160 | \def\dh{dzz}% |
5161 | \def\exclamdown{!}% | |
e0f86659 UD |
5162 | \def\l{l}% |
5163 | \def\oe{oe}% | |
82d5ce1d UD |
5164 | \def\ordf{a}% |
5165 | \def\ordm{o}% | |
0f8bbd69 JM |
5166 | \def\o{o}% |
5167 | \def\questiondown{?}% | |
5168 | \def\ss{ss}% | |
084e7d57 | 5169 | \def\th{th}% |
e0f86659 | 5170 | % |
82d5ce1d UD |
5171 | \def\LaTeX{LaTeX}% |
5172 | \def\TeX{TeX}% | |
e0f86659 | 5173 | % |
7f7dd1d3 JM |
5174 | % Assorted special characters. \defglyph gives the control sequence a |
5175 | % definition that removes the {} that follows its use. | |
5176 | \defglyph\atchar{@}% | |
5177 | \defglyph\arrow{->}% | |
5178 | \defglyph\bullet{bullet}% | |
5179 | \defglyph\comma{,}% | |
5180 | \defglyph\copyright{copyright}% | |
5181 | \defglyph\dots{...}% | |
5182 | \defglyph\enddots{...}% | |
5183 | \defglyph\equiv{==}% | |
5184 | \defglyph\error{error}% | |
5185 | \defglyph\euro{euro}% | |
5186 | \defglyph\expansion{==>}% | |
5187 | \defglyph\geq{>=}% | |
5188 | \defglyph\guillemetleft{<<}% | |
5189 | \defglyph\guillemetright{>>}% | |
5190 | \defglyph\guilsinglleft{<}% | |
5191 | \defglyph\guilsinglright{>}% | |
5192 | \defglyph\leq{<=}% | |
5193 | \defglyph\lbracechar{\{}% | |
5194 | \defglyph\minus{-}% | |
5195 | \defglyph\point{.}% | |
5196 | \defglyph\pounds{pounds}% | |
5197 | \defglyph\print{-|}% | |
5198 | \defglyph\quotedblbase{"}% | |
5199 | \defglyph\quotedblleft{"}% | |
5200 | \defglyph\quotedblright{"}% | |
5201 | \defglyph\quoteleft{`}% | |
5202 | \defglyph\quoteright{'}% | |
5203 | \defglyph\quotesinglbase{,}% | |
5204 | \defglyph\rbracechar{\}}% | |
5205 | \defglyph\registeredsymbol{R}% | |
5206 | \defglyph\result{=>}% | |
5207 | \defglyph\textdegree{o}% | |
0f8bbd69 | 5208 | % |
9251c568 AJ |
5209 | % We need to get rid of all macros, leaving only the arguments (if present). |
5210 | % Of course this is not nearly correct, but it is the best we can do for now. | |
5211 | % makeinfo does not expand macros in the argument to @deffn, which ends up | |
5212 | % writing an index entry, and texindex isn't prepared for an index sort entry | |
5213 | % that starts with \. | |
0f8bbd69 | 5214 | % |
9251c568 AJ |
5215 | % Since macro invocations are followed by braces, we can just redefine them |
5216 | % to take a single TeX argument. The case of a macro invocation that | |
5217 | % goes to end-of-line is not handled. | |
0f8bbd69 | 5218 | % |
9251c568 | 5219 | \macrolist |
7f7dd1d3 | 5220 | \let\value\indexnofontsvalue |
e0f86659 | 5221 | } |
7f7dd1d3 JM |
5222 | \def\defglyph#1#2{\def#1##1{#2}} % see above |
5223 | ||
5224 | \f | |
9e9f9cc2 | 5225 | |
0f8bbd69 | 5226 | |
f962d792 UD |
5227 | \let\SETmarginindex=\relax % put index entries in margin (undocumented)? |
5228 | ||
f962d792 | 5229 | % Most index entries go through here, but \dosubind is the general case. |
82d5ce1d UD |
5230 | % #1 is the index name, #2 is the entry text. |
5231 | \def\doind#1#2{\dosubind{#1}{#2}{}} | |
f962d792 | 5232 | |
084e7d57 JM |
5233 | % There is also \dosubind {index}{topic}{subtopic} |
5234 | % which makes an entry in a two-level index such as the operation index. | |
5235 | % TODO: Two-level index? Operation index? | |
5236 | ||
5237 | % Workhorse for all indexes. | |
f962d792 | 5238 | % #1 is name of index, #2 is stuff to put there, #3 is subentry -- |
82d5ce1d UD |
5239 | % empty if called from \doind, as we usually are (the main exception |
5240 | % is with most defuns, which call us directly). | |
b710a6e2 | 5241 | % |
f962d792 | 5242 | \def\dosubind#1#2#3{% |
82d5ce1d UD |
5243 | \iflinks |
5244 | {% | |
084e7d57 | 5245 | \requireopenindexfile{#1}% |
82d5ce1d UD |
5246 | % Store the main index entry text (including the third arg). |
5247 | \toks0 = {#2}% | |
5248 | % If third arg is present, precede it with a space. | |
5249 | \def\thirdarg{#3}% | |
5250 | \ifx\thirdarg\empty \else | |
5251 | \toks0 = \expandafter{\the\toks0 \space #3}% | |
5252 | \fi | |
5253 | % | |
5254 | \edef\writeto{\csname#1indfile\endcsname}% | |
5255 | % | |
c94f48d7 | 5256 | \safewhatsit\dosubindwrite |
82d5ce1d UD |
5257 | }% |
5258 | \fi | |
5259 | } | |
5260 | ||
084e7d57 JM |
5261 | % Check if an index file has been opened, and if not, open it. |
5262 | \def\requireopenindexfile#1{% | |
5263 | \ifnum\csname #1indfile\endcsname=0 | |
5264 | \expandafter\newwrite \csname#1indfile\endcsname | |
5265 | \edef\suffix{#1}% | |
5266 | % A .fls suffix would conflict with the file extension for the output | |
5267 | % of -recorder, so use .f1s instead. | |
5268 | \ifx\suffix\indexisfl\def\suffix{f1}\fi | |
5269 | % Open the file | |
5270 | \immediate\openout\csname#1indfile\endcsname \jobname.\suffix | |
7f7dd1d3 JM |
5271 | % Using \immediate above here prevents an object entering into the current |
5272 | % box, which could confound checks such as those in \safewhatsit for | |
5273 | % preceding skips. | |
5274 | \typeout{Writing index file \jobname.\suffix}% | |
084e7d57 JM |
5275 | \fi} |
5276 | \def\indexisfl{fl} | |
5277 | ||
5278 | % Output \ as {\indexbackslash}, because \ is an escape character in | |
5279 | % the index files. | |
5280 | \let\indexbackslash=\relax | |
5281 | {\catcode`\@=0 \catcode`\\=\active | |
5282 | @gdef@useindexbackslash{@def\{{@indexbackslash}}} | |
5283 | } | |
5284 | ||
5285 | % Definition for writing index entry text. | |
5286 | \def\sortas#1{\ignorespaces}% | |
5287 | ||
5288 | % Definition for writing index entry sort key. Should occur at the at | |
5289 | % the beginning of the index entry, like | |
5290 | % @cindex @sortas{september} \september | |
5291 | % The \ignorespaces takes care of following space, but there's no way | |
5292 | % to remove space before it. | |
5293 | { | |
5294 | \catcode`\-=13 | |
5295 | \gdef\indexwritesortas{% | |
5296 | \begingroup | |
5297 | \indexnonalnumreappear | |
5298 | \indexwritesortasxxx} | |
5299 | \gdef\indexwritesortasxxx#1{% | |
5300 | \xdef\indexsortkey{#1}\endgroup} | |
5301 | } | |
5302 | ||
5303 | ||
5304 | % Write the entry in \toks0 to the index file. | |
82d5ce1d UD |
5305 | % |
5306 | \def\dosubindwrite{% | |
359a1d0b KB |
5307 | % Put the index entry in the margin if desired. |
5308 | \ifx\SETmarginindex\relax\else | |
82d5ce1d | 5309 | \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% |
359a1d0b | 5310 | \fi |
82d5ce1d UD |
5311 | % |
5312 | % Remember, we are within a group. | |
5313 | \indexdummies % Must do this here, since \bf, etc expand at this stage | |
084e7d57 JM |
5314 | \useindexbackslash % \indexbackslash isn't defined now so it will be output |
5315 | % as is; and it will print as backslash. | |
7f7dd1d3 JM |
5316 | % The braces around \indexbrace are recognized by texindex. |
5317 | % | |
084e7d57 JM |
5318 | % Get the string to sort by, by processing the index entry with all |
5319 | % font commands turned off. | |
82d5ce1d | 5320 | {\indexnofonts |
7f7dd1d3 JM |
5321 | \def\lbracechar{{\indexlbrace}}% |
5322 | \def\rbracechar{{\indexrbrace}}% | |
5323 | \let\{=\lbracechar | |
5324 | \let\}=\rbracechar | |
084e7d57 JM |
5325 | \indexnonalnumdisappear |
5326 | \xdef\indexsortkey{}% | |
5327 | \let\sortas=\indexwritesortas | |
5328 | \edef\temp{\the\toks0}% | |
5329 | \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas | |
5330 | \ifx\indexsortkey\empty | |
5331 | \xdef\indexsortkey{\temp}% | |
5332 | \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi | |
5333 | \fi | |
82d5ce1d UD |
5334 | }% |
5335 | % | |
5336 | % Set up the complete index entry, with both the sort key and | |
5337 | % the original text, including any font commands. We write | |
5338 | % three arguments to \entry to the .?? file (four in the | |
5339 | % subentry case), texindex reduces to two when writing the .??s | |
5340 | % sorted result. | |
5341 | \edef\temp{% | |
5342 | \write\writeto{% | |
084e7d57 | 5343 | \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}% |
359a1d0b | 5344 | }% |
82d5ce1d | 5345 | \temp |
0ecb606c | 5346 | } |
084e7d57 | 5347 | \newbox\dummybox % used above |
0ecb606c | 5348 | |
c94f48d7 | 5349 | % Take care of unwanted page breaks/skips around a whatsit: |
82d5ce1d UD |
5350 | % |
5351 | % If a skip is the last thing on the list now, preserve it | |
5352 | % by backing up by \lastskip, doing the \write, then inserting | |
5353 | % the skip again. Otherwise, the whatsit generated by the | |
c94f48d7 AJ |
5354 | % \write or \pdfdest will make \lastskip zero. The result is that |
5355 | % sequences like this: | |
82d5ce1d UD |
5356 | % @end defun |
5357 | % @tindex whatever | |
5358 | % @defun ... | |
5359 | % will have extra space inserted, because the \medbreak in the | |
5360 | % start of the @defun won't see the skip inserted by the @end of | |
5361 | % the previous defun. | |
5362 | % | |
5363 | % But don't do any of this if we're not in vertical mode. We | |
5364 | % don't want to do a \vskip and prematurely end a paragraph. | |
5365 | % | |
5366 | % Avoid page breaks due to these extra skips, too. | |
5367 | % | |
5368 | % But wait, there is a catch there: | |
5369 | % We'll have to check whether \lastskip is zero skip. \ifdim is not | |
5370 | % sufficient for this purpose, as it ignores stretch and shrink parts | |
5371 | % of the skip. The only way seems to be to check the textual | |
5372 | % representation of the skip. | |
5373 | % | |
5374 | % The following is almost like \def\zeroskipmacro{0.0pt} except that | |
5375 | % the ``p'' and ``t'' characters have catcode \other, not 11 (letter). | |
5376 | % | |
5377 | \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} | |
5378 | % | |
c94f48d7 AJ |
5379 | \newskip\whatsitskip |
5380 | \newcount\whatsitpenalty | |
5381 | % | |
82d5ce1d UD |
5382 | % ..., ready, GO: |
5383 | % | |
8fcb833a | 5384 | \def\safewhatsit#1{\ifhmode |
c94f48d7 | 5385 | #1% |
8fcb833a | 5386 | \else |
82d5ce1d | 5387 | % \lastskip and \lastpenalty cannot both be nonzero simultaneously. |
c94f48d7 | 5388 | \whatsitskip = \lastskip |
82d5ce1d | 5389 | \edef\lastskipmacro{\the\lastskip}% |
c94f48d7 | 5390 | \whatsitpenalty = \lastpenalty |
82d5ce1d UD |
5391 | % |
5392 | % If \lastskip is nonzero, that means the last item was a | |
5393 | % skip. And since a skip is discardable, that means this | |
c94f48d7 | 5394 | % -\whatsitskip glue we're inserting is preceded by a |
82d5ce1d UD |
5395 | % non-discardable item, therefore it is not a potential |
5396 | % breakpoint, therefore no \nobreak needed. | |
5397 | \ifx\lastskipmacro\zeroskipmacro | |
5398 | \else | |
c94f48d7 | 5399 | \vskip-\whatsitskip |
82d5ce1d UD |
5400 | \fi |
5401 | % | |
c94f48d7 | 5402 | #1% |
82d5ce1d UD |
5403 | % |
5404 | \ifx\lastskipmacro\zeroskipmacro | |
5405 | % If \lastskip was zero, perhaps the last item was a penalty, and | |
5406 | % perhaps it was >=10000, e.g., a \nobreak. In that case, we want | |
5407 | % to re-insert the same penalty (values >10000 are used for various | |
5408 | % signals); since we just inserted a non-discardable item, any | |
5409 | % following glue (such as a \parskip) would be a breakpoint. For example: | |
82d5ce1d UD |
5410 | % @deffn deffn-whatever |
5411 | % @vindex index-whatever | |
5412 | % Description. | |
5413 | % would allow a break between the index-whatever whatsit | |
5414 | % and the "Description." paragraph. | |
c94f48d7 | 5415 | \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi |
82d5ce1d UD |
5416 | \else |
5417 | % On the other hand, if we had a nonzero \lastskip, | |
5418 | % this make-up glue would be preceded by a non-discardable item | |
5419 | % (the whatsit from the \write), so we must insert a \nobreak. | |
c94f48d7 | 5420 | \nobreak\vskip\whatsitskip |
82d5ce1d | 5421 | \fi |
8fcb833a | 5422 | \fi} |
82d5ce1d UD |
5423 | |
5424 | % The index entry written in the file actually looks like | |
5425 | % \entry {sortstring}{page}{topic} | |
5426 | % or | |
5427 | % \entry {sortstring}{page}{topic}{subtopic} | |
9e9f9cc2 KB |
5428 | % The texindex program reads in these files and writes files |
5429 | % containing these kinds of lines: | |
5430 | % \initial {c} | |
5431 | % before the first topic whose initial is c | |
5432 | % \entry {topic}{pagelist} | |
5433 | % for a topic that is used without subtopics | |
5434 | % \primary {topic} | |
5435 | % for the beginning of a topic that is used with subtopics | |
5436 | % \secondary {subtopic}{pagelist} | |
5437 | % for each subtopic. | |
5438 | ||
5439 | % Define the user-accessible indexing commands | |
5440 | % @findex, @vindex, @kindex, @cindex. | |
5441 | ||
5442 | \def\findex {\fnindex} | |
5443 | \def\kindex {\kyindex} | |
5444 | \def\cindex {\cpindex} | |
5445 | \def\vindex {\vrindex} | |
5446 | \def\tindex {\tpindex} | |
5447 | \def\pindex {\pgindex} | |
5448 | ||
5449 | \def\cindexsub {\begingroup\obeylines\cindexsub} | |
5450 | {\obeylines % | |
5451 | \gdef\cindexsub "#1" #2^^M{\endgroup % | |
5452 | \dosubind{cp}{#2}{#1}}} | |
5453 | ||
5454 | % Define the macros used in formatting output of the sorted index material. | |
5455 | ||
51702635 UD |
5456 | % @printindex causes a particular index (the ??s file) to get printed. |
5457 | % It does not print any chapter heading (usually an @unnumbered). | |
5458 | % | |
82d5ce1d | 5459 | \parseargdef\printindex{\begingroup |
ea6631a2 | 5460 | \dobreak \chapheadingskip{10000}% |
9e9f9cc2 | 5461 | % |
3b82ab1c | 5462 | \smallfonts \rm |
ea6631a2 | 5463 | \tolerance = 9500 |
c94f48d7 | 5464 | \plainfrenchspacing |
7158eae4 | 5465 | \everypar = {}% don't want the \kern\-parindent from indentation suppression. |
9e9f9cc2 KB |
5466 | % |
5467 | % See if the index file exists and is nonempty. | |
2eb45444 UD |
5468 | % Change catcode of @ here so that if the index file contains |
5469 | % \initial {@} | |
5470 | % as its first line, TeX doesn't complain about mismatched braces | |
5471 | % (because it thinks @} is a control sequence). | |
7f7dd1d3 | 5472 | \catcode`\@ = 12 |
084e7d57 JM |
5473 | % See comment in \requireopenindexfile. |
5474 | \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi | |
5475 | \openin 1 \jobname.\indexname s | |
9e9f9cc2 KB |
5476 | \ifeof 1 |
5477 | % \enddoublecolumns gets confused if there is no text in the index, | |
5478 | % and it loses the chapter title and the aux file entries for the | |
5479 | % index. The easiest way to prevent this problem is to make sure | |
5480 | % there is some text. | |
b710a6e2 | 5481 | \putwordIndexNonexistent |
7f7dd1d3 | 5482 | \typeout{No file \jobname.\indexname s.}% |
ea6631a2 | 5483 | \else |
084e7d57 | 5484 | \catcode`\\ = 0 |
9e9f9cc2 KB |
5485 | % |
5486 | % If the index file exists but is empty, then \openin leaves \ifeof | |
5487 | % false. We have to make TeX try to read something from the file, so | |
5488 | % it can discover if there is anything in it. | |
084e7d57 | 5489 | \read 1 to \thisline |
9e9f9cc2 | 5490 | \ifeof 1 |
b710a6e2 | 5491 | \putwordIndexIsEmpty |
9e9f9cc2 | 5492 | \else |
51702635 UD |
5493 | % Index files are almost Texinfo source, but we use \ as the escape |
5494 | % character. It would be better to use @, but that's too big a change | |
5495 | % to make right now. | |
084e7d57 JM |
5496 | \def\indexbackslash{\ttbackslash}% |
5497 | \let\indexlbrace\{ % Likewise, set these sequences for braces | |
5498 | \let\indexrbrace\} % used in the sort key. | |
51702635 | 5499 | \begindoublecolumns |
7f7dd1d3 | 5500 | \let\entrywidowpenalty=\indexwidowpenalty |
084e7d57 JM |
5501 | % |
5502 | % Read input from the index file line by line. | |
5503 | \loopdo | |
5504 | \ifeof1 | |
5505 | \let\firsttoken\relax | |
5506 | \else | |
5507 | \read 1 to \nextline | |
5508 | \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}% | |
5509 | \act | |
5510 | \fi | |
5511 | \thisline | |
5512 | % | |
5513 | \ifeof1\else | |
5514 | \let\thisline\nextline | |
5515 | \repeat | |
5516 | %% | |
51702635 | 5517 | \enddoublecolumns |
9e9f9cc2 KB |
5518 | \fi |
5519 | \fi | |
5520 | \closein 1 | |
ea6631a2 | 5521 | \endgroup} |
9e9f9cc2 | 5522 | |
084e7d57 JM |
5523 | \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken} |
5524 | \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1} | |
5525 | ||
5526 | \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx} | |
5527 | \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next} | |
5528 | ||
9e9f9cc2 KB |
5529 | % These macros are used by the sorted index file itself. |
5530 | % Change them to control the appearance of the index. | |
5531 | ||
084e7d57 JM |
5532 | {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13 |
5533 | \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13 | |
5534 | \catcode`\$=3 | |
5535 | \gdef\initialglyphs{% | |
5536 | % Some changes for non-alphabetic characters. Using the glyphs from the | |
5537 | % math fonts looks more consistent than the typewriter font used elsewhere | |
5538 | % for these characters. | |
5539 | \def\indexbackslash{\math{\backslash}}% | |
5540 | \let\\=\indexbackslash | |
5541 | % | |
5542 | % Can't get bold backslash so don't use bold forward slash | |
5543 | \catcode`\/=13 | |
5544 | \def/{{\secrmnotbold \normalslash}}% | |
5545 | \def-{{\normaldash\normaldash}}% en dash `--' | |
5546 | \def^{{\chapbf \normalcaret}}% | |
5547 | \def~{{\chapbf \normaltilde}}% | |
5548 | \def\_{% | |
5549 | \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }% | |
5550 | \def|{$\vert$}% | |
5551 | \def<{$\less$}% | |
5552 | \def>{$\gtr$}% | |
5553 | \def+{$\normalplus$}% | |
5554 | }} | |
5555 | ||
5556 | \def\initial{% | |
5557 | \bgroup | |
5558 | \initialglyphs | |
5559 | \initialx | |
5560 | } | |
5561 | ||
5562 | \def\initialx#1{% | |
313a1174 UD |
5563 | % Remove any glue we may have, we'll be inserting our own. |
5564 | \removelastskip | |
b710a6e2 | 5565 | % |
313a1174 | 5566 | % We like breaks before the index initials, so insert a bonus. |
084e7d57 JM |
5567 | % The glue before the bonus allows a little bit of space at the |
5568 | % bottom of a column to reduce an increase in inter-line spacing. | |
82d5ce1d | 5569 | \nobreak |
084e7d57 JM |
5570 | \vskip 0pt plus 5\baselineskip |
5571 | \penalty -300 | |
5572 | \vskip 0pt plus -5\baselineskip | |
313a1174 UD |
5573 | % |
5574 | % Typeset the initial. Making this add up to a whole number of | |
5575 | % baselineskips increases the chance of the dots lining up from column | |
5576 | % to column. It still won't often be perfect, because of the stretch | |
5577 | % we need before each entry, but it's better. | |
b710a6e2 | 5578 | % |
313a1174 | 5579 | % No shrink because it confuses \balancecolumns. |
084e7d57 JM |
5580 | \vskip 1.67\baselineskip plus 1\baselineskip |
5581 | \leftline{\secfonts \kern-0.05em \secbf #1}% | |
5582 | % \secfonts is inside the argument of \leftline so that the change of | |
5583 | % \baselineskip will not affect any glue inserted before the vbox that | |
5584 | % \leftline creates. | |
313a1174 UD |
5585 | % Do our best not to break after the initial. |
5586 | \nobreak | |
82d5ce1d | 5587 | \vskip .33\baselineskip plus .1\baselineskip |
084e7d57 JM |
5588 | \egroup % \initialglyphs |
5589 | } | |
5590 | ||
5591 | \newdimen\entryrightmargin | |
5592 | \entryrightmargin=0pt | |
9e9f9cc2 | 5593 | |
82d5ce1d UD |
5594 | % \entry typesets a paragraph consisting of the text (#1), dot leaders, and |
5595 | % then page number (#2) flushed to the right margin. It is used for index | |
5596 | % and table of contents entries. The paragraph is indented by \leftskip. | |
9e9f9cc2 | 5597 | % |
82d5ce1d UD |
5598 | \def\entry{% |
5599 | \begingroup | |
7f7dd1d3 JM |
5600 | % |
5601 | % For pdfTeX and XeTeX. | |
5602 | % The redefinition of \domark stops marks being added in \pdflink to | |
5603 | % preserve coloured links across page boundaries. Otherwise the marks | |
5604 | % would get in the way of \lastbox in \insertindexentrybox. | |
5605 | \let\domark\relax | |
82d5ce1d UD |
5606 | % |
5607 | % Start a new paragraph if necessary, so our assignments below can't | |
5608 | % affect previous text. | |
5609 | \par | |
5610 | % | |
82d5ce1d UD |
5611 | % No extra space above this paragraph. |
5612 | \parskip = 0in | |
5613 | % | |
0f8bbd69 JM |
5614 | % When reading the text of entry, convert explicit line breaks |
5615 | % from @* into spaces. The user might give these in long section | |
5616 | % titles, for instance. | |
5617 | \def\*{\unskip\space\ignorespaces}% | |
084e7d57 JM |
5618 | \def\entrybreak{\hfil\break}% An undocumented command |
5619 | % | |
82d5ce1d UD |
5620 | % Swallow the left brace of the text (first parameter): |
5621 | \afterassignment\doentry | |
5622 | \let\temp = | |
5623 | } | |
0f8bbd69 | 5624 | \def\entrybreak{\unskip\space\ignorespaces}% |
82d5ce1d | 5625 | \def\doentry{% |
084e7d57 JM |
5626 | % Save the text of the entry |
5627 | \global\setbox\boxA=\hbox\bgroup | |
82d5ce1d UD |
5628 | \bgroup % Instead of the swallowed brace. |
5629 | \noindent | |
5630 | \aftergroup\finishentry | |
5631 | % And now comes the text of the entry. | |
084e7d57 JM |
5632 | % Not absorbing as a macro argument reduces the chance of problems |
5633 | % with catcodes occurring. | |
82d5ce1d | 5634 | } |
084e7d57 JM |
5635 | {\catcode`\@=11 |
5636 | \gdef\finishentry#1{% | |
5637 | \egroup % end box A | |
5638 | \dimen@ = \wd\boxA % Length of text of entry | |
5639 | \global\setbox\boxA=\hbox\bgroup\unhbox\boxA | |
82d5ce1d UD |
5640 | % #1 is the page number. |
5641 | % | |
084e7d57 JM |
5642 | % Get the width of the page numbers, and only use |
5643 | % leaders if they are present. | |
5644 | \global\setbox\boxB = \hbox{#1}% | |
5645 | \ifdim\wd\boxB = 0pt | |
5646 | \null\nobreak\hfill\ % | |
3b82ab1c | 5647 | \else |
82d5ce1d | 5648 | % |
82d5ce1d UD |
5649 | \null\nobreak\indexdotfill % Have leaders before the page number. |
5650 | % | |
82d5ce1d | 5651 | \ifpdf |
084e7d57 | 5652 | \pdfgettoks#1.% |
7f7dd1d3 | 5653 | \hskip\skip\thinshrinkable\the\toksA |
82d5ce1d | 5654 | \else |
7f7dd1d3 JM |
5655 | \ifx\XeTeXrevision\thisisundefined |
5656 | \hskip\skip\thinshrinkable #1% | |
5657 | \else | |
5658 | \pdfgettoks#1.% | |
5659 | \hskip\skip\thinshrinkable\the\toksA | |
5660 | \fi | |
82d5ce1d | 5661 | \fi |
3b82ab1c | 5662 | \fi |
084e7d57 JM |
5663 | \egroup % end \boxA |
5664 | \ifdim\wd\boxB = 0pt | |
5665 | \global\setbox\entryindexbox=\vbox{\unhbox\boxA}% | |
5666 | \else | |
5667 | \global\setbox\entryindexbox=\vbox\bgroup | |
084e7d57 JM |
5668 | % We want the text of the entries to be aligned to the left, and the |
5669 | % page numbers to be aligned to the right. | |
5670 | % | |
7f7dd1d3 | 5671 | \parindent = 0pt |
084e7d57 JM |
5672 | \advance\leftskip by 0pt plus 1fil |
5673 | \advance\leftskip by 0pt plus -1fill | |
5674 | \rightskip = 0pt plus -1fil | |
5675 | \advance\rightskip by 0pt plus 1fill | |
5676 | % Cause last line, which could consist of page numbers on their own | |
5677 | % if the list of page numbers is long, to be aligned to the right. | |
5678 | \parfillskip=0pt plus -1fill | |
5679 | % | |
084e7d57 JM |
5680 | \advance\rightskip by \entryrightmargin |
5681 | % Determine how far we can stretch into the margin. | |
5682 | % This allows, e.g., "Appendix H GNU Free Documentation License" to | |
5683 | % fit on one line in @letterpaper format. | |
5684 | \ifdim\entryrightmargin>2.1em | |
5685 | \dimen@i=2.1em | |
5686 | \else | |
5687 | \dimen@i=0em | |
5688 | \fi | |
5689 | \advance \parfillskip by 0pt minus 1\dimen@i | |
5690 | % | |
5691 | \dimen@ii = \hsize | |
5692 | \advance\dimen@ii by -1\leftskip | |
5693 | \advance\dimen@ii by -1\entryrightmargin | |
5694 | \advance\dimen@ii by 1\dimen@i | |
5695 | \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line | |
5696 | \ifdim\dimen@ > 0.8\dimen@ii % due to long index text | |
5697 | \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly | |
5698 | \dimen@ii = \hsize | |
084e7d57 JM |
5699 | \ifnum\dimen@>\dimen@ii |
5700 | % If the entry is too long, use the whole line | |
5701 | \dimen@ = \dimen@ii | |
5702 | \fi | |
5703 | \advance\leftskip by 0pt plus 1fill % ragged right | |
5704 | \advance \dimen@ by 1\rightskip | |
7f7dd1d3 JM |
5705 | \parshape = 2 0pt \dimen@ 0em \dimen@ii |
5706 | % Ideally we'd add a finite glue at the end of the first line only, | |
5707 | % instead of using \parshape with explicit line lengths, but TeX | |
5708 | % doesn't seem to provide a way to do such a thing. | |
5709 | % | |
5710 | \leftskip = 1em | |
5711 | \parindent = -1em | |
084e7d57 | 5712 | \fi\fi |
7f7dd1d3 | 5713 | \indent % start paragraph |
084e7d57 JM |
5714 | \unhbox\boxA |
5715 | % | |
5716 | % Do not prefer a separate line ending with a hyphen to fewer lines. | |
5717 | \finalhyphendemerits = 0 | |
5718 | % | |
5719 | % Word spacing - no stretch | |
5720 | \spaceskip=\fontdimen2\font minus \fontdimen4\font | |
5721 | % | |
5722 | \linepenalty=1000 % Discourage line breaks. | |
5723 | \hyphenpenalty=5000 % Discourage hyphenation. | |
5724 | % | |
5725 | \par % format the paragraph | |
5726 | \egroup % The \vbox | |
5727 | \fi | |
82d5ce1d | 5728 | \endgroup |
084e7d57 JM |
5729 | % delay text of entry until after penalty |
5730 | \bgroup\aftergroup\insertindexentrybox | |
7f7dd1d3 | 5731 | \entrywidowpenalty |
084e7d57 JM |
5732 | }} |
5733 | ||
5734 | \newskip\thinshrinkable | |
5735 | \skip\thinshrinkable=.15em minus .15em | |
5736 | ||
5737 | \newbox\entryindexbox | |
5738 | \def\insertindexentrybox{% | |
7f7dd1d3 JM |
5739 | \ourunvbox\entryindexbox |
5740 | } | |
5741 | ||
5742 | % Use \lastbox to take apart vbox box by box, and add each sub-box | |
5743 | % to the current vertical list. | |
5744 | \def\ourunvbox#1{% | |
5745 | \bgroup % for local binding of \delayedbox | |
5746 | % Remove the last box from box #1 | |
5747 | \global\setbox#1=\vbox{% | |
5748 | \unvbox#1% | |
5749 | \unskip % remove any glue | |
5750 | \unpenalty | |
5751 | \global\setbox\interbox=\lastbox | |
084e7d57 | 5752 | }% |
7f7dd1d3 JM |
5753 | \setbox\delayedbox=\box\interbox |
5754 | \ifdim\ht#1=0pt\else | |
5755 | \ourunvbox#1 % Repeat on what's left of the box | |
5756 | \nobreak | |
5757 | \fi | |
5758 | \box\delayedbox | |
5759 | \egroup | |
084e7d57 | 5760 | } |
7f7dd1d3 JM |
5761 | \newbox\delayedbox |
5762 | \newbox\interbox | |
084e7d57 JM |
5763 | |
5764 | % Default is no penalty | |
7f7dd1d3 | 5765 | \let\entrywidowpenalty\egroup |
084e7d57 JM |
5766 | |
5767 | % Used from \printindex. \firsttoken should be the first token | |
5768 | % after the \entry. If it's not another \entry, we are at the last | |
5769 | % line of a group of index entries, so insert a penalty to discourage | |
7f7dd1d3 JM |
5770 | % widowed index entries. |
5771 | \long\def\indexwidowpenalty{% | |
084e7d57 JM |
5772 | \def\isentry{\entry}% |
5773 | \ifx\firsttoken\isentry | |
5774 | \else | |
7f7dd1d3 | 5775 | \penalty 9000 |
084e7d57 JM |
5776 | \fi |
5777 | \egroup % now comes the box added with \aftergroup | |
82d5ce1d | 5778 | } |
9e9f9cc2 | 5779 | |
9251c568 | 5780 | % Like plain.tex's \dotfill, except uses up at least 1 em. |
084e7d57 JM |
5781 | % The filll stretch here overpowers both the fil and fill stretch to push |
5782 | % the page number to the right. | |
9e9f9cc2 | 5783 | \def\indexdotfill{\cleaders |
084e7d57 JM |
5784 | \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} |
5785 | ||
9e9f9cc2 KB |
5786 | |
5787 | \def\primary #1{\line{#1\hfil}} | |
5788 | ||
5789 | \newskip\secondaryindent \secondaryindent=0.5cm | |
be1152ca UD |
5790 | \def\secondary#1#2{{% |
5791 | \parfillskip=0in | |
5792 | \parskip=0in | |
5793 | \hangindent=1in | |
5794 | \hangafter=1 | |
5795 | \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill | |
5796 | \ifpdf | |
5797 | \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. | |
5798 | \else | |
7f7dd1d3 JM |
5799 | \ifx\XeTeXrevision\thisisundefined |
5800 | #2 | |
5801 | \else | |
5802 | \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. | |
5803 | \fi | |
be1152ca UD |
5804 | \fi |
5805 | \par | |
9e9f9cc2 KB |
5806 | }} |
5807 | ||
359a1d0b KB |
5808 | % Define two-column mode, which we use to typeset indexes. |
5809 | % Adapted from the TeXbook, page 416, which is to say, | |
5810 | % the manmac.tex format used to print the TeXbook itself. | |
084e7d57 | 5811 | \catcode`\@=11 % private names |
9e9f9cc2 KB |
5812 | |
5813 | \newbox\partialpage | |
9e9f9cc2 | 5814 | \newdimen\doublecolumnhsize |
084e7d57 JM |
5815 | |
5816 | % Use inside an output routine to save \topmark and \firstmark | |
5817 | \def\savemarks{% | |
5818 | \global\savedtopmark=\expandafter{\topmark }% | |
5819 | \global\savedfirstmark=\expandafter{\firstmark }% | |
5820 | } | |
5821 | \newtoks\savedtopmark | |
5822 | \newtoks\savedfirstmark | |
5823 | ||
5824 | % Set \topmark and \firstmark for next time \output runs. | |
5825 | % Can't be run from withinside \output (because any material | |
5826 | % added while an output routine is active, including | |
5827 | % penalties, is saved for after it finishes). The page so far | |
5828 | % should be empty, otherwise what's on it will be thrown away. | |
5829 | \def\restoremarks{% | |
5830 | \mark{\the\savedtopmark}% | |
5831 | \bgroup\output = {% | |
5832 | \setbox\dummybox=\box\PAGE | |
5833 | }abc\eject\egroup | |
5834 | % "abc" because output routine doesn't fire for a completely empty page. | |
5835 | \mark{\the\savedfirstmark}% | |
5836 | } | |
9e9f9cc2 | 5837 | |
359a1d0b | 5838 | \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns |
084e7d57 JM |
5839 | % If not much space left on page, start a new page. |
5840 | \ifdim\pagetotal>0.8\vsize\vfill\eject\fi | |
5841 | % | |
9e9f9cc2 | 5842 | % Grab any single-column material above us. |
b710a6e2 UD |
5843 | \output = {% |
5844 | % | |
51702635 UD |
5845 | % Here is a possibility not foreseen in manmac: if we accumulate a |
5846 | % whole lot of material, we might end up calling this \output | |
5847 | % routine twice in a row (see the doublecol-lose test, which is | |
5848 | % essentially a couple of indexes with @setchapternewpage off). In | |
b710a6e2 UD |
5849 | % that case we just ship out what is in \partialpage with the normal |
5850 | % output routine. Generally, \partialpage will be empty when this | |
5851 | % runs and this will be a no-op. See the indexspread.tex test case. | |
5852 | \ifvoid\partialpage \else | |
5853 | \onepageout{\pagecontents\partialpage}% | |
5854 | \fi | |
51702635 | 5855 | % |
b710a6e2 UD |
5856 | \global\setbox\partialpage = \vbox{% |
5857 | % Unvbox the main output page. | |
5858 | \unvbox\PAGE | |
5859 | \kern-\topskip \kern\baselineskip | |
5860 | }% | |
084e7d57 | 5861 | \savemarks |
b710a6e2 UD |
5862 | }% |
5863 | \eject % run that output routine to set \partialpage | |
084e7d57 JM |
5864 | \restoremarks |
5865 | % | |
5866 | % We recover the two marks that the last output routine saved in order | |
5867 | % to propagate the information in marks added around a chapter heading, | |
5868 | % which could be otherwise be lost by the time the final page is output. | |
5869 | % | |
9e9f9cc2 | 5870 | % |
51702635 UD |
5871 | % Use the double-column output routine for subsequent pages. |
5872 | \output = {\doublecolumnout}% | |
9e9f9cc2 KB |
5873 | % |
5874 | % Change the page size parameters. We could do this once outside this | |
5875 | % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 | |
5876 | % format, but then we repeat the same computation. Repeating a couple | |
5877 | % of assignments once per index is clearly meaningless for the | |
51702635 | 5878 | % execution time, so we may as well do it in one place. |
9e9f9cc2 KB |
5879 | % |
5880 | % First we halve the line length, less a little for the gutter between | |
5881 | % the columns. We compute the gutter based on the line length, so it | |
5882 | % changes automatically with the paper format. The magic constant | |
51702635 UD |
5883 | % below is chosen so that the gutter has the same value (well, +-<1pt) |
5884 | % as it did when we hard-coded it. | |
9e9f9cc2 KB |
5885 | % |
5886 | % We put the result in a separate register, \doublecolumhsize, so we | |
5887 | % can restore it in \pagesofar, after \hsize itself has (potentially) | |
5888 | % been clobbered. | |
5889 | % | |
5890 | \doublecolumnhsize = \hsize | |
5891 | \advance\doublecolumnhsize by -.04154\hsize | |
5892 | \divide\doublecolumnhsize by 2 | |
5893 | \hsize = \doublecolumnhsize | |
5894 | % | |
5895 | % Double the \vsize as well. (We don't need a separate register here, | |
5896 | % since nobody clobbers \vsize.) | |
5897 | \vsize = 2\vsize | |
7f7dd1d3 JM |
5898 | % |
5899 | % For the benefit of balancing columns | |
5900 | \advance\baselineskip by 0pt plus 0.5pt | |
9e9f9cc2 | 5901 | } |
313a1174 UD |
5902 | |
5903 | % The double-column output routine for all double-column pages except | |
084e7d57 | 5904 | % the last, which is done by \balancecolumns. |
b710a6e2 | 5905 | % |
9e9f9cc2 | 5906 | \def\doublecolumnout{% |
084e7d57 | 5907 | % |
359a1d0b KB |
5908 | \splittopskip=\topskip \splitmaxdepth=\maxdepth |
5909 | % Get the available space for the double columns -- the normal | |
5910 | % (undoubled) page height minus any material left over from the | |
5911 | % previous page. | |
313a1174 UD |
5912 | \dimen@ = \vsize |
5913 | \divide\dimen@ by 2 | |
366d6851 | 5914 | \advance\dimen@ by -\ht\partialpage |
313a1174 | 5915 | % |
51702635 | 5916 | % box0 will be the left-hand column, box2 the right. |
359a1d0b KB |
5917 | \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ |
5918 | \onepageout\pagesofar | |
51702635 UD |
5919 | \unvbox255 |
5920 | \penalty\outputpenalty | |
359a1d0b | 5921 | } |
366d6851 UD |
5922 | % |
5923 | % Re-output the contents of the output page -- any previous material, | |
5924 | % followed by the two boxes we just split, in box0 and box2. | |
359a1d0b | 5925 | \def\pagesofar{% |
359a1d0b | 5926 | \unvbox\partialpage |
313a1174 | 5927 | % |
359a1d0b | 5928 | \hsize = \doublecolumnhsize |
313a1174 | 5929 | \wd0=\hsize \wd2=\hsize |
7f7dd1d3 | 5930 | \hbox to\txipagewidth{\box0\hfil\box2}% |
359a1d0b | 5931 | } |
084e7d57 JM |
5932 | |
5933 | ||
5934 | % Finished with with double columns. | |
359a1d0b | 5935 | \def\enddoublecolumns{% |
c94f48d7 AJ |
5936 | % The following penalty ensures that the page builder is exercised |
5937 | % _before_ we change the output routine. This is necessary in the | |
5938 | % following situation: | |
5939 | % | |
5940 | % The last section of the index consists only of a single entry. | |
5941 | % Before this section, \pagetotal is less than \pagegoal, so no | |
5942 | % break occurs before the last section starts. However, the last | |
5943 | % section, consisting of \initial and the single \entry, does not | |
5944 | % fit on the page and has to be broken off. Without the following | |
5945 | % penalty the page builder will not be exercised until \eject | |
5946 | % below, and by that time we'll already have changed the output | |
5947 | % routine to the \balancecolumns version, so the next-to-last | |
5948 | % double-column page will be processed with \balancecolumns, which | |
5949 | % is wrong: The two columns will go to the main vertical list, with | |
5950 | % the broken-off section in the recent contributions. As soon as | |
5951 | % the output routine finishes, TeX starts reconsidering the page | |
5952 | % break. The two columns and the broken-off section both fit on the | |
5953 | % page, because the two columns now take up only half of the page | |
5954 | % goal. When TeX sees \eject from below which follows the final | |
5955 | % section, it invokes the new output routine that we've set after | |
5956 | % \balancecolumns below; \onepageout will try to fit the two columns | |
7f7dd1d3 | 5957 | % and the final section into the vbox of \txipageheight (see |
c94f48d7 AJ |
5958 | % \pagebody), causing an overfull box. |
5959 | % | |
5960 | % Note that glue won't work here, because glue does not exercise the | |
5961 | % page builder, unlike penalties (see The TeXbook, pp. 280-281). | |
5962 | \penalty0 | |
5963 | % | |
313a1174 | 5964 | \output = {% |
084e7d57 JM |
5965 | % Split the last of the double-column material. |
5966 | \savemarks | |
313a1174 UD |
5967 | \balancecolumns |
5968 | % | |
084e7d57 | 5969 | % Having called \balancecolumns once, we do not |
313a1174 | 5970 | % want to call it again. Therefore, reset \output to its normal |
084e7d57 | 5971 | % definition right away. |
313a1174 | 5972 | \global\output = {\onepageout{\pagecontents\PAGE}}% |
313a1174 UD |
5973 | }% |
5974 | \eject | |
51702635 | 5975 | \endgroup % started in \begindoublecolumns |
084e7d57 JM |
5976 | \restoremarks |
5977 | % Leave the double-column material on the current page, no automatic | |
5978 | % page break. | |
5979 | \box\balancedcolumns | |
b710a6e2 UD |
5980 | % |
5981 | % \pagegoal was set to the doubled \vsize above, since we restarted | |
5982 | % the current page. We're now back to normal single-column | |
5983 | % typesetting, so reset \pagegoal to the normal \vsize (after the | |
5984 | % \endgroup where \vsize got restored). | |
5985 | \pagegoal = \vsize | |
359a1d0b | 5986 | } |
084e7d57 JM |
5987 | \newbox\balancedcolumns |
5988 | \setbox\balancedcolumns=\vbox{shouldnt see this}% | |
366d6851 | 5989 | % |
084e7d57 JM |
5990 | % Only called for the last of the double column material. \doublecolumnout |
5991 | % does the others. | |
359a1d0b | 5992 | \def\balancecolumns{% |
313a1174 | 5993 | \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. |
359a1d0b KB |
5994 | \dimen@ = \ht0 |
5995 | \advance\dimen@ by \topskip | |
5996 | \advance\dimen@ by-\baselineskip | |
7f7dd1d3 | 5997 | \ifdim\dimen@<5\baselineskip |
084e7d57 JM |
5998 | % Don't split a short final column in two. |
5999 | \setbox2=\vbox{}% | |
6000 | \else | |
6001 | \divide\dimen@ by 2 % target to split to | |
6002 | \dimen@ii = \dimen@ | |
6003 | \splittopskip = \topskip | |
7f7dd1d3 | 6004 | % Loop until left column is at least as high as the right column. |
084e7d57 JM |
6005 | {% |
6006 | \vbadness = 10000 | |
6007 | \loop | |
6008 | \global\setbox3 = \copy0 | |
6009 | \global\setbox1 = \vsplit3 to \dimen@ | |
7f7dd1d3 | 6010 | \ifdim\ht1<\ht3 |
084e7d57 JM |
6011 | \global\advance\dimen@ by 1pt |
6012 | \repeat | |
6013 | }% | |
7f7dd1d3 JM |
6014 | % Now the left column is in box 1, and the right column in box 3. |
6015 | % Check whether the left column has come out higher than the page itself. | |
6016 | % (Note that we have doubled \vsize for the double columns, so | |
6017 | % the actual height of the page is 0.5\vsize). | |
6018 | \ifdim2\ht1>\vsize | |
6019 | % Just split the last of the double column material roughly in half. | |
6020 | \setbox2=\box0 | |
6021 | \setbox0 = \vsplit2 to \dimen@ii | |
6022 | \setbox0=\vbox to \dimen@ii {\unvbox0\vfill}% | |
6023 | \setbox2=\vbox to \dimen@ii {\unvbox2\vfill}% | |
084e7d57 | 6024 | \else |
7f7dd1d3 JM |
6025 | % Compare the heights of the two columns. |
6026 | \ifdim4\ht1>5\ht3 | |
6027 | % Column heights are too different, so don't make their bottoms | |
6028 | % flush with each other. | |
6029 | \setbox2=\vbox to \ht1 {\unvbox3\vfill}% | |
6030 | \setbox0=\vbox to \ht1 {\unvbox1\vfill}% | |
6031 | \else | |
6032 | % Make column bottoms flush with each other. | |
6033 | \setbox2=\vbox to\ht1{\unvbox3\unskip}% | |
6034 | \setbox0=\vbox to\ht1{\unvbox1\unskip}% | |
6035 | \fi | |
084e7d57 JM |
6036 | \fi |
6037 | \fi | |
313a1174 | 6038 | % |
084e7d57 | 6039 | \global\setbox\balancedcolumns=\vbox{\pagesofar}% |
9e9f9cc2 | 6040 | } |
51702635 | 6041 | \catcode`\@ = \other |
d66b7b41 KB |
6042 | |
6043 | ||
9e9f9cc2 | 6044 | \message{sectioning,} |
13632cfc | 6045 | % Chapters, sections, etc. |
9e9f9cc2 | 6046 | |
0f8bbd69 JM |
6047 | % Let's start with @part. |
6048 | \outer\parseargdef\part{\partzzz{#1}} | |
6049 | \def\partzzz#1{% | |
6050 | \chapoddpage | |
6051 | \null | |
6052 | \vskip.3\vsize % move it down on the page a bit | |
6053 | \begingroup | |
7f7dd1d3 | 6054 | \noindent \titlefonts\rm #1\par % the text |
0f8bbd69 JM |
6055 | \let\lastnode=\empty % no node to associate with |
6056 | \writetocentry{part}{#1}{}% but put it in the toc | |
6057 | \headingsoff % no headline or footline on the part page | |
084e7d57 JM |
6058 | % This outputs a mark at the end of the page that clears \thischapter |
6059 | % and \thissection, as is done in \startcontents. | |
6060 | \let\pchapsepmacro\relax | |
6061 | \chapmacro{}{Yomitfromtoc}{}% | |
0f8bbd69 JM |
6062 | \chapoddpage |
6063 | \endgroup | |
6064 | } | |
6065 | ||
6066 | % \unnumberedno is an oxymoron. But we count the unnumbered | |
82d5ce1d UD |
6067 | % sections so that we can refer to them unambiguously in the pdf |
6068 | % outlines by their "section number". We avoid collisions with chapter | |
6069 | % numbers by starting them at 10000. (If a document ever has 10000 | |
6070 | % chapters, we're in trouble anyway, I'm sure.) | |
6071 | \newcount\unnumberedno \unnumberedno = 10000 | |
51702635 UD |
6072 | \newcount\chapno |
6073 | \newcount\secno \secno=0 | |
6074 | \newcount\subsecno \subsecno=0 | |
6075 | \newcount\subsubsecno \subsubsecno=0 | |
9e9f9cc2 KB |
6076 | |
6077 | % This counter is funny since it counts through charcodes of letters A, B, ... | |
51702635 | 6078 | \newcount\appendixno \appendixno = `\@ |
82d5ce1d | 6079 | % |
3b82ab1c | 6080 | % \def\appendixletter{\char\the\appendixno} |
82d5ce1d UD |
6081 | % We do the following ugly conditional instead of the above simple |
6082 | % construct for the sake of pdftex, which needs the actual | |
3b82ab1c | 6083 | % letter in the expansion, not just typeset. |
82d5ce1d | 6084 | % |
3b82ab1c UD |
6085 | \def\appendixletter{% |
6086 | \ifnum\appendixno=`A A% | |
6087 | \else\ifnum\appendixno=`B B% | |
6088 | \else\ifnum\appendixno=`C C% | |
6089 | \else\ifnum\appendixno=`D D% | |
6090 | \else\ifnum\appendixno=`E E% | |
6091 | \else\ifnum\appendixno=`F F% | |
6092 | \else\ifnum\appendixno=`G G% | |
6093 | \else\ifnum\appendixno=`H H% | |
6094 | \else\ifnum\appendixno=`I I% | |
6095 | \else\ifnum\appendixno=`J J% | |
6096 | \else\ifnum\appendixno=`K K% | |
6097 | \else\ifnum\appendixno=`L L% | |
6098 | \else\ifnum\appendixno=`M M% | |
6099 | \else\ifnum\appendixno=`N N% | |
6100 | \else\ifnum\appendixno=`O O% | |
6101 | \else\ifnum\appendixno=`P P% | |
6102 | \else\ifnum\appendixno=`Q Q% | |
6103 | \else\ifnum\appendixno=`R R% | |
6104 | \else\ifnum\appendixno=`S S% | |
6105 | \else\ifnum\appendixno=`T T% | |
6106 | \else\ifnum\appendixno=`U U% | |
6107 | \else\ifnum\appendixno=`V V% | |
6108 | \else\ifnum\appendixno=`W W% | |
6109 | \else\ifnum\appendixno=`X X% | |
6110 | \else\ifnum\appendixno=`Y Y% | |
6111 | \else\ifnum\appendixno=`Z Z% | |
6112 | % The \the is necessary, despite appearances, because \appendixletter is | |
6113 | % expanded while writing the .toc file. \char\appendixno is not | |
6114 | % expandable, thus it is written literally, thus all appendixes come out | |
6115 | % with the same letter (or @) in the toc without it. | |
6116 | \else\char\the\appendixno | |
6117 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi | |
6118 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} | |
9e9f9cc2 | 6119 | |
c94f48d7 AJ |
6120 | % Each @chapter defines these (using marks) as the number+name, number |
6121 | % and name of the chapter. Page headings and footings can use | |
6122 | % these. @section does likewise. | |
313a1174 | 6123 | \def\thischapter{} |
c94f48d7 AJ |
6124 | \def\thischapternum{} |
6125 | \def\thischaptername{} | |
313a1174 | 6126 | \def\thissection{} |
c94f48d7 AJ |
6127 | \def\thissectionnum{} |
6128 | \def\thissectionname{} | |
9e9f9cc2 KB |
6129 | |
6130 | \newcount\absseclevel % used to calculate proper heading level | |
82d5ce1d | 6131 | \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count |
9e9f9cc2 KB |
6132 | |
6133 | % @raisesections: treat @section as chapter, @subsection as section, etc. | |
6134 | \def\raisesections{\global\advance\secbase by -1} | |
6135 | \let\up=\raisesections % original BFox name | |
6136 | ||
6137 | % @lowersections: treat @chapter as section, @section as subsection, etc. | |
6138 | \def\lowersections{\global\advance\secbase by 1} | |
6139 | \let\down=\lowersections % original BFox name | |
6140 | ||
82d5ce1d UD |
6141 | % we only have subsub. |
6142 | \chardef\maxseclevel = 3 | |
6143 | % | |
6144 | % A numbered section within an unnumbered changes to unnumbered too. | |
0f8bbd69 JM |
6145 | % To achieve this, remember the "biggest" unnum. sec. we are currently in: |
6146 | \chardef\unnlevel = \maxseclevel | |
82d5ce1d UD |
6147 | % |
6148 | % Trace whether the current chapter is an appendix or not: | |
6149 | % \chapheadtype is "N" or "A", unnumbered chapters are ignored. | |
6150 | \def\chapheadtype{N} | |
6151 | ||
6152 | % Choose a heading macro | |
6153 | % #1 is heading type | |
6154 | % #2 is heading level | |
6155 | % #3 is text for heading | |
6156 | \def\genhead#1#2#3{% | |
6157 | % Compute the abs. sec. level: | |
6158 | \absseclevel=#2 | |
6159 | \advance\absseclevel by \secbase | |
6160 | % Make sure \absseclevel doesn't fall outside the range: | |
6161 | \ifnum \absseclevel < 0 | |
6162 | \absseclevel = 0 | |
9e9f9cc2 | 6163 | \else |
82d5ce1d UD |
6164 | \ifnum \absseclevel > 3 |
6165 | \absseclevel = 3 | |
6166 | \fi | |
9e9f9cc2 | 6167 | \fi |
82d5ce1d UD |
6168 | % The heading type: |
6169 | \def\headtype{#1}% | |
6170 | \if \headtype U% | |
0f8bbd69 JM |
6171 | \ifnum \absseclevel < \unnlevel |
6172 | \chardef\unnlevel = \absseclevel | |
82d5ce1d | 6173 | \fi |
9e9f9cc2 | 6174 | \else |
82d5ce1d UD |
6175 | % Check for appendix sections: |
6176 | \ifnum \absseclevel = 0 | |
6177 | \edef\chapheadtype{\headtype}% | |
6178 | \else | |
6179 | \if \headtype A\if \chapheadtype N% | |
6180 | \errmessage{@appendix... within a non-appendix chapter}% | |
6181 | \fi\fi | |
6182 | \fi | |
6183 | % Check for numbered within unnumbered: | |
0f8bbd69 | 6184 | \ifnum \absseclevel > \unnlevel |
82d5ce1d UD |
6185 | \def\headtype{U}% |
6186 | \else | |
0f8bbd69 | 6187 | \chardef\unnlevel = 3 |
82d5ce1d | 6188 | \fi |
9e9f9cc2 | 6189 | \fi |
82d5ce1d UD |
6190 | % Now print the heading: |
6191 | \if \headtype U% | |
6192 | \ifcase\absseclevel | |
6193 | \unnumberedzzz{#3}% | |
6194 | \or \unnumberedseczzz{#3}% | |
6195 | \or \unnumberedsubseczzz{#3}% | |
6196 | \or \unnumberedsubsubseczzz{#3}% | |
6197 | \fi | |
9e9f9cc2 | 6198 | \else |
82d5ce1d UD |
6199 | \if \headtype A% |
6200 | \ifcase\absseclevel | |
6201 | \appendixzzz{#3}% | |
6202 | \or \appendixsectionzzz{#3}% | |
6203 | \or \appendixsubseczzz{#3}% | |
6204 | \or \appendixsubsubseczzz{#3}% | |
6205 | \fi | |
6206 | \else | |
6207 | \ifcase\absseclevel | |
6208 | \chapterzzz{#3}% | |
6209 | \or \seczzz{#3}% | |
6210 | \or \numberedsubseczzz{#3}% | |
6211 | \or \numberedsubsubseczzz{#3}% | |
6212 | \fi | |
6213 | \fi | |
9e9f9cc2 | 6214 | \fi |
82d5ce1d UD |
6215 | \suppressfirstparagraphindent |
6216 | } | |
6217 | ||
6218 | % an interface: | |
6219 | \def\numhead{\genhead N} | |
6220 | \def\apphead{\genhead A} | |
6221 | \def\unnmhead{\genhead U} | |
6222 | ||
6223 | % @chapter, @appendix, @unnumbered. Increment top-level counter, reset | |
6224 | % all lower-level sectioning counters to zero. | |
6225 | % | |
6226 | % Also set \chaplevelprefix, which we prepend to @float sequence numbers | |
6227 | % (e.g., figures), q.v. By default (before any chapter), that is empty. | |
6228 | \let\chaplevelprefix = \empty | |
6229 | % | |
6230 | \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz | |
6231 | \def\chapterzzz#1{% | |
6232 | % section resetting is \global in case the chapter is in a group, such | |
6233 | % as an @include file. | |
6234 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 | |
6235 | \global\advance\chapno by 1 | |
6236 | % | |
6237 | % Used for \float. | |
6238 | \gdef\chaplevelprefix{\the\chapno.}% | |
6239 | \resetallfloatnos | |
6240 | % | |
0f8bbd69 JM |
6241 | % \putwordChapter can contain complex things in translations. |
6242 | \toks0=\expandafter{\putwordChapter}% | |
6243 | \message{\the\toks0 \space \the\chapno}% | |
82d5ce1d UD |
6244 | % |
6245 | % Write the actual heading. | |
6246 | \chapmacro{#1}{Ynumbered}{\the\chapno}% | |
6247 | % | |
6248 | % So @section and the like are numbered underneath this chapter. | |
e0f86659 UD |
6249 | \global\let\section = \numberedsec |
6250 | \global\let\subsection = \numberedsubsec | |
6251 | \global\let\subsubsection = \numberedsubsubsec | |
313a1174 | 6252 | } |
9e9f9cc2 | 6253 | |
0f8bbd69 JM |
6254 | \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz |
6255 | % | |
82d5ce1d UD |
6256 | \def\appendixzzz#1{% |
6257 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 | |
6258 | \global\advance\appendixno by 1 | |
6259 | \gdef\chaplevelprefix{\appendixletter.}% | |
6260 | \resetallfloatnos | |
6261 | % | |
0f8bbd69 JM |
6262 | % \putwordAppendix can contain complex things in translations. |
6263 | \toks0=\expandafter{\putwordAppendix}% | |
6264 | \message{\the\toks0 \space \appendixletter}% | |
82d5ce1d UD |
6265 | % |
6266 | \chapmacro{#1}{Yappendix}{\appendixletter}% | |
6267 | % | |
e0f86659 UD |
6268 | \global\let\section = \appendixsec |
6269 | \global\let\subsection = \appendixsubsec | |
6270 | \global\let\subsubsection = \appendixsubsubsec | |
313a1174 | 6271 | } |
9e9f9cc2 | 6272 | |
0f8bbd69 JM |
6273 | % normally unnmhead0 calls unnumberedzzz: |
6274 | \outer\parseargdef\unnumbered{\unnmhead0{#1}} | |
82d5ce1d UD |
6275 | \def\unnumberedzzz#1{% |
6276 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 | |
6277 | \global\advance\unnumberedno by 1 | |
6278 | % | |
6279 | % Since an unnumbered has no number, no prefix for figures. | |
6280 | \global\let\chaplevelprefix = \empty | |
6281 | \resetallfloatnos | |
e0f86659 UD |
6282 | % |
6283 | % This used to be simply \message{#1}, but TeX fully expands the | |
6284 | % argument to \message. Therefore, if #1 contained @-commands, TeX | |
6285 | % expanded them. For example, in `@unnumbered The @cite{Book}', TeX | |
6286 | % expanded @cite (which turns out to cause errors because \cite is meant | |
6287 | % to be executed, not expanded). | |
6288 | % | |
6289 | % Anyway, we don't want the fully-expanded definition of @cite to appear | |
6290 | % as a result of the \message, we just want `@cite' itself. We use | |
6291 | % \the<toks register> to achieve this: TeX expands \the<toks> only once, | |
6292 | % simply yielding the contents of <toks register>. (We also do this for | |
6293 | % the toc entries.) | |
82d5ce1d UD |
6294 | \toks0 = {#1}% |
6295 | \message{(\the\toks0)}% | |
6296 | % | |
6297 | \chapmacro{#1}{Ynothing}{\the\unnumberedno}% | |
e0f86659 | 6298 | % |
e0f86659 UD |
6299 | \global\let\section = \unnumberedsec |
6300 | \global\let\subsection = \unnumberedsubsec | |
6301 | \global\let\subsubsection = \unnumberedsubsubsec | |
313a1174 | 6302 | } |
9e9f9cc2 | 6303 | |
82d5ce1d UD |
6304 | % @centerchap is like @unnumbered, but the heading is centered. |
6305 | \outer\parseargdef\centerchap{% | |
82d5ce1d UD |
6306 | \let\centerparametersmaybe = \centerparameters |
6307 | \unnmhead0{#1}% | |
6308 | \let\centerparametersmaybe = \relax | |
6309 | } | |
6310 | ||
6311 | % @top is like @unnumbered. | |
6312 | \let\top\unnumbered | |
6313 | ||
313a1174 | 6314 | % Sections. |
0f8bbd69 | 6315 | % |
82d5ce1d UD |
6316 | \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz |
6317 | \def\seczzz#1{% | |
6318 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 | |
6319 | \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% | |
313a1174 | 6320 | } |
9e9f9cc2 | 6321 | |
0f8bbd69 JM |
6322 | % normally calls appendixsectionzzz: |
6323 | \outer\parseargdef\appendixsection{\apphead1{#1}} | |
82d5ce1d UD |
6324 | \def\appendixsectionzzz#1{% |
6325 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 | |
6326 | \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% | |
313a1174 | 6327 | } |
82d5ce1d | 6328 | \let\appendixsec\appendixsection |
9e9f9cc2 | 6329 | |
0f8bbd69 JM |
6330 | % normally calls unnumberedseczzz: |
6331 | \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} | |
82d5ce1d UD |
6332 | \def\unnumberedseczzz#1{% |
6333 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 | |
6334 | \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% | |
313a1174 | 6335 | } |
9e9f9cc2 | 6336 | |
313a1174 | 6337 | % Subsections. |
0f8bbd69 JM |
6338 | % |
6339 | % normally calls numberedsubseczzz: | |
6340 | \outer\parseargdef\numberedsubsec{\numhead2{#1}} | |
82d5ce1d UD |
6341 | \def\numberedsubseczzz#1{% |
6342 | \global\subsubsecno=0 \global\advance\subsecno by 1 | |
6343 | \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% | |
313a1174 | 6344 | } |
9e9f9cc2 | 6345 | |
0f8bbd69 JM |
6346 | % normally calls appendixsubseczzz: |
6347 | \outer\parseargdef\appendixsubsec{\apphead2{#1}} | |
82d5ce1d UD |
6348 | \def\appendixsubseczzz#1{% |
6349 | \global\subsubsecno=0 \global\advance\subsecno by 1 | |
6350 | \sectionheading{#1}{subsec}{Yappendix}% | |
6351 | {\appendixletter.\the\secno.\the\subsecno}% | |
313a1174 | 6352 | } |
9e9f9cc2 | 6353 | |
0f8bbd69 JM |
6354 | % normally calls unnumberedsubseczzz: |
6355 | \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} | |
82d5ce1d UD |
6356 | \def\unnumberedsubseczzz#1{% |
6357 | \global\subsubsecno=0 \global\advance\subsecno by 1 | |
6358 | \sectionheading{#1}{subsec}{Ynothing}% | |
6359 | {\the\unnumberedno.\the\secno.\the\subsecno}% | |
313a1174 | 6360 | } |
9e9f9cc2 | 6361 | |
313a1174 | 6362 | % Subsubsections. |
0f8bbd69 JM |
6363 | % |
6364 | % normally numberedsubsubseczzz: | |
6365 | \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} | |
82d5ce1d UD |
6366 | \def\numberedsubsubseczzz#1{% |
6367 | \global\advance\subsubsecno by 1 | |
6368 | \sectionheading{#1}{subsubsec}{Ynumbered}% | |
6369 | {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% | |
313a1174 | 6370 | } |
9e9f9cc2 | 6371 | |
0f8bbd69 JM |
6372 | % normally appendixsubsubseczzz: |
6373 | \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} | |
82d5ce1d UD |
6374 | \def\appendixsubsubseczzz#1{% |
6375 | \global\advance\subsubsecno by 1 | |
6376 | \sectionheading{#1}{subsubsec}{Yappendix}% | |
6377 | {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% | |
313a1174 | 6378 | } |
9e9f9cc2 | 6379 | |
0f8bbd69 JM |
6380 | % normally unnumberedsubsubseczzz: |
6381 | \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} | |
82d5ce1d UD |
6382 | \def\unnumberedsubsubseczzz#1{% |
6383 | \global\advance\subsubsecno by 1 | |
6384 | \sectionheading{#1}{subsubsec}{Ynothing}% | |
6385 | {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% | |
313a1174 | 6386 | } |
9e9f9cc2 | 6387 | |
9e9f9cc2 KB |
6388 | % These macros control what the section commands do, according |
6389 | % to what kind of chapter we are in (ordinary, appendix, or unnumbered). | |
6390 | % Define them by default for a numbered chapter. | |
82d5ce1d UD |
6391 | \let\section = \numberedsec |
6392 | \let\subsection = \numberedsubsec | |
6393 | \let\subsubsection = \numberedsubsubsec | |
9e9f9cc2 KB |
6394 | |
6395 | % Define @majorheading, @heading and @subheading | |
6396 | ||
82d5ce1d | 6397 | \def\majorheading{% |
e0f86659 | 6398 | {\advance\chapheadingskip by 10pt \chapbreak }% |
82d5ce1d UD |
6399 | \parsearg\chapheadingzzz |
6400 | } | |
9e9f9cc2 | 6401 | |
82d5ce1d UD |
6402 | \def\chapheading{\chapbreak \parsearg\chapheadingzzz} |
6403 | \def\chapheadingzzz#1{% | |
8fcb833a JM |
6404 | \vbox{\chapfonts \raggedtitlesettings #1\par}% |
6405 | \nobreak\bigskip \nobreak | |
82d5ce1d UD |
6406 | \suppressfirstparagraphindent |
6407 | } | |
9e9f9cc2 | 6408 | |
f2fec269 | 6409 | % @heading, @subheading, @subsubheading. |
82d5ce1d UD |
6410 | \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} |
6411 | \suppressfirstparagraphindent} | |
6412 | \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} | |
6413 | \suppressfirstparagraphindent} | |
6414 | \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} | |
6415 | \suppressfirstparagraphindent} | |
9e9f9cc2 KB |
6416 | |
6417 | % These macros generate a chapter, section, etc. heading only | |
6418 | % (including whitespace, linebreaking, etc. around it), | |
6419 | % given all the information in convenient, parsed form. | |
6420 | ||
0f8bbd69 | 6421 | % Args are the skip and penalty (usually negative) |
9e9f9cc2 KB |
6422 | \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} |
6423 | ||
9e9f9cc2 | 6424 | % Parameter controlling skip before chapter headings (if needed) |
474be527 | 6425 | \newskip\chapheadingskip |
9e9f9cc2 | 6426 | |
0f8bbd69 | 6427 | % Define plain chapter starts, and page on/off switching for it. |
9e9f9cc2 | 6428 | \def\chapbreak{\dobreak \chapheadingskip {-4000}} |
084e7d57 JM |
6429 | |
6430 | % Start a new page | |
9e9f9cc2 | 6431 | \def\chappager{\par\vfill\supereject} |
084e7d57 JM |
6432 | |
6433 | % \chapoddpage - start on an odd page for a new chapter | |
c94f48d7 AJ |
6434 | % Because \domark is called before \chapoddpage, the filler page will |
6435 | % get the headings for the next chapter, which is wrong. But we don't | |
6436 | % care -- we just disable all headings on the filler page. | |
6437 | \def\chapoddpage{% | |
6438 | \chappager | |
6439 | \ifodd\pageno \else | |
6440 | \begingroup | |
0f8bbd69 JM |
6441 | \headingsoff |
6442 | \null | |
c94f48d7 AJ |
6443 | \chappager |
6444 | \endgroup | |
6445 | \fi | |
6446 | } | |
9e9f9cc2 | 6447 | |
7f7dd1d3 | 6448 | \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname} |
9e9f9cc2 | 6449 | |
313a1174 | 6450 | \def\CHAPPAGoff{% |
793fde8a | 6451 | \global\let\contentsalignmacro = \chappager |
9e9f9cc2 KB |
6452 | \global\let\pchapsepmacro=\chapbreak |
6453 | \global\let\pagealignmacro=\chappager} | |
6454 | ||
313a1174 | 6455 | \def\CHAPPAGon{% |
793fde8a | 6456 | \global\let\contentsalignmacro = \chappager |
9e9f9cc2 KB |
6457 | \global\let\pchapsepmacro=\chappager |
6458 | \global\let\pagealignmacro=\chappager | |
6459 | \global\def\HEADINGSon{\HEADINGSsingle}} | |
6460 | ||
82d5ce1d | 6461 | \def\CHAPPAGodd{% |
793fde8a | 6462 | \global\let\contentsalignmacro = \chapoddpage |
9e9f9cc2 KB |
6463 | \global\let\pchapsepmacro=\chapoddpage |
6464 | \global\let\pagealignmacro=\chapoddpage | |
6465 | \global\def\HEADINGSon{\HEADINGSdouble}} | |
6466 | ||
6467 | \CHAPPAGon | |
6468 | ||
084e7d57 | 6469 | % \chapmacro - Chapter opening. |
82d5ce1d UD |
6470 | % |
6471 | % #1 is the text, #2 is the section type (Ynumbered, Ynothing, | |
6472 | % Yappendix, Yomitfromtoc), #3 the chapter number. | |
084e7d57 | 6473 | % Not used for @heading series. |
82d5ce1d UD |
6474 | % |
6475 | % To test against our argument. | |
6476 | \def\Ynothingkeyword{Ynothing} | |
82d5ce1d | 6477 | \def\Yappendixkeyword{Yappendix} |
084e7d57 | 6478 | \def\Yomitfromtockeyword{Yomitfromtoc} |
82d5ce1d UD |
6479 | % |
6480 | \def\chapmacro#1#2#3{% | |
7f7dd1d3 JM |
6481 | \expandafter\ifx\thisenv\titlepage\else |
6482 | \checkenv{}% chapters, etc., should not start inside an environment. | |
6483 | \fi | |
6484 | % FIXME: \chapmacro is currently called from inside \titlepage when | |
6485 | % \setcontentsaftertitlepage to print the "Table of Contents" heading, but | |
6486 | % this should probably be done by \sectionheading with an option to print | |
6487 | % in chapter size. | |
084e7d57 | 6488 | % |
c94f48d7 AJ |
6489 | % Insert the first mark before the heading break (see notes for \domark). |
6490 | \let\prevchapterdefs=\lastchapterdefs | |
6491 | \let\prevsectiondefs=\lastsectiondefs | |
6492 | \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% | |
6493 | \gdef\thissection{}}% | |
6494 | % | |
6495 | \def\temptype{#2}% | |
6496 | \ifx\temptype\Ynothingkeyword | |
6497 | \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% | |
6498 | \gdef\thischapter{\thischaptername}}% | |
6499 | \else\ifx\temptype\Yomitfromtockeyword | |
6500 | \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% | |
6501 | \gdef\thischapter{}}% | |
6502 | \else\ifx\temptype\Yappendixkeyword | |
6503 | \toks0={#1}% | |
6504 | \xdef\lastchapterdefs{% | |
6505 | \gdef\noexpand\thischaptername{\the\toks0}% | |
6506 | \gdef\noexpand\thischapternum{\appendixletter}% | |
0f8bbd69 JM |
6507 | % \noexpand\putwordAppendix avoids expanding indigestible |
6508 | % commands in some of the translations. | |
6509 | \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} | |
6510 | \noexpand\thischapternum: | |
c94f48d7 AJ |
6511 | \noexpand\thischaptername}% |
6512 | }% | |
6513 | \else | |
6514 | \toks0={#1}% | |
6515 | \xdef\lastchapterdefs{% | |
6516 | \gdef\noexpand\thischaptername{\the\toks0}% | |
6517 | \gdef\noexpand\thischapternum{\the\chapno}% | |
0f8bbd69 JM |
6518 | % \noexpand\putwordChapter avoids expanding indigestible |
6519 | % commands in some of the translations. | |
6520 | \gdef\noexpand\thischapter{\noexpand\putwordChapter{} | |
6521 | \noexpand\thischapternum: | |
c94f48d7 AJ |
6522 | \noexpand\thischaptername}% |
6523 | }% | |
6524 | \fi\fi\fi | |
6525 | % | |
6526 | % Output the mark. Pass it through \safewhatsit, to take care of | |
6527 | % the preceding space. | |
6528 | \safewhatsit\domark | |
6529 | % | |
6530 | % Insert the chapter heading break. | |
9e9f9cc2 | 6531 | \pchapsepmacro |
c94f48d7 AJ |
6532 | % |
6533 | % Now the second mark, after the heading break. No break points | |
6534 | % between here and the heading. | |
6535 | \let\prevchapterdefs=\lastchapterdefs | |
6536 | \let\prevsectiondefs=\lastsectiondefs | |
6537 | \domark | |
6538 | % | |
9e9f9cc2 | 6539 | {% |
7f7dd1d3 | 6540 | \chapfonts \rm |
084e7d57 | 6541 | \let\footnote=\errfootnoteheading % give better error message |
82d5ce1d | 6542 | % |
c94f48d7 | 6543 | % Have to define \lastsection before calling \donoderef, because the |
82d5ce1d UD |
6544 | % xref code eventually uses it. On the other hand, it has to be called |
6545 | % after \pchapsepmacro, or the headline will change too soon. | |
c94f48d7 | 6546 | \gdef\lastsection{#1}% |
82d5ce1d UD |
6547 | % |
6548 | % Only insert the separating space if we have a chapter/appendix | |
6549 | % number, and don't print the unnumbered ``number''. | |
82d5ce1d UD |
6550 | \ifx\temptype\Ynothingkeyword |
6551 | \setbox0 = \hbox{}% | |
6552 | \def\toctype{unnchap}% | |
82d5ce1d UD |
6553 | \else\ifx\temptype\Yomitfromtockeyword |
6554 | \setbox0 = \hbox{}% contents like unnumbered, but no toc entry | |
6555 | \def\toctype{omit}% | |
82d5ce1d UD |
6556 | \else\ifx\temptype\Yappendixkeyword |
6557 | \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% | |
6558 | \def\toctype{app}% | |
82d5ce1d UD |
6559 | \else |
6560 | \setbox0 = \hbox{#3\enspace}% | |
6561 | \def\toctype{numchap}% | |
82d5ce1d UD |
6562 | \fi\fi\fi |
6563 | % | |
6564 | % Write the toc entry for this chapter. Must come before the | |
6565 | % \donoderef, because we include the current node name in the toc | |
6566 | % entry, and \donoderef resets it to empty. | |
6567 | \writetocentry{\toctype}{#1}{#3}% | |
6568 | % | |
6569 | % For pdftex, we have to write out the node definition (aka, make | |
6570 | % the pdfdest) after any page break, but before the actual text has | |
6571 | % been typeset. If the destination for the pdf outline is after the | |
6572 | % text, then jumping from the outline may wind up with the text not | |
6573 | % being visible, for instance under high magnification. | |
6574 | \donoderef{#2}% | |
6575 | % | |
6576 | % Typeset the actual heading. | |
c94f48d7 | 6577 | \nobreak % Avoid page breaks at the interline glue. |
8fcb833a | 6578 | \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe |
843be0d3 | 6579 | \unhbox0 #1\par}% |
9e9f9cc2 | 6580 | }% |
cd4e176c KB |
6581 | \nobreak\bigskip % no page break after a chapter title |
6582 | \nobreak | |
9e9f9cc2 KB |
6583 | } |
6584 | ||
843be0d3 KB |
6585 | % @centerchap -- centered and unnumbered. |
6586 | \let\centerparametersmaybe = \relax | |
82d5ce1d UD |
6587 | \def\centerparameters{% |
6588 | \advance\rightskip by 3\rightskip | |
6589 | \leftskip = \rightskip | |
6590 | \parfillskip = 0pt | |
6591 | } | |
9e9f9cc2 | 6592 | |
9e9f9cc2 | 6593 | |
82d5ce1d UD |
6594 | % Section titles. These macros combine the section number parts and |
6595 | % call the generic \sectionheading to do the printing. | |
6596 | % | |
474be527 | 6597 | \newskip\secheadingskip |
82d5ce1d | 6598 | \def\secheadingbreak{\dobreak \secheadingskip{-1000}} |
cd4e176c KB |
6599 | |
6600 | % Subsection titles. | |
82d5ce1d UD |
6601 | \newskip\subsecheadingskip |
6602 | \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} | |
9e9f9cc2 | 6603 | |
cd4e176c | 6604 | % Subsubsection titles. |
82d5ce1d UD |
6605 | \def\subsubsecheadingskip{\subsecheadingskip} |
6606 | \def\subsubsecheadingbreak{\subsecheadingbreak} | |
9e9f9cc2 | 6607 | |
9e9f9cc2 | 6608 | |
82d5ce1d | 6609 | % Print any size, any type, section title. |
0ecb606c | 6610 | % |
084e7d57 JM |
6611 | % #1 is the text of the title, |
6612 | % #2 is the section level (sec/subsec/subsubsec), | |
6613 | % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc), | |
6614 | % #4 is the section number. | |
82d5ce1d | 6615 | % |
c94f48d7 AJ |
6616 | \def\seckeyword{sec} |
6617 | % | |
82d5ce1d | 6618 | \def\sectionheading#1#2#3#4{% |
cd4e176c | 6619 | {% |
084e7d57 JM |
6620 | \def\sectionlevel{#2}% |
6621 | \def\temptype{#3}% | |
6622 | % | |
6623 | % It is ok for the @heading series commands to appear inside an | |
6624 | % environment (it's been historically allowed, though the logic is | |
6625 | % dubious), but not the others. | |
6626 | \ifx\temptype\Yomitfromtockeyword\else | |
6627 | \checkenv{}% non-@*heading should not be in an environment. | |
6628 | \fi | |
6629 | \let\footnote=\errfootnoteheading | |
0f8bbd69 | 6630 | % |
843be0d3 | 6631 | % Switch to the right set of fonts. |
7f7dd1d3 | 6632 | \csname #2fonts\endcsname \rm |
82d5ce1d | 6633 | % |
c94f48d7 AJ |
6634 | % Insert first mark before the heading break (see notes for \domark). |
6635 | \let\prevsectiondefs=\lastsectiondefs | |
6636 | \ifx\temptype\Ynothingkeyword | |
6637 | \ifx\sectionlevel\seckeyword | |
6638 | \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% | |
6639 | \gdef\thissection{\thissectionname}}% | |
6640 | \fi | |
6641 | \else\ifx\temptype\Yomitfromtockeyword | |
6642 | % Don't redefine \thissection. | |
6643 | \else\ifx\temptype\Yappendixkeyword | |
6644 | \ifx\sectionlevel\seckeyword | |
6645 | \toks0={#1}% | |
6646 | \xdef\lastsectiondefs{% | |
6647 | \gdef\noexpand\thissectionname{\the\toks0}% | |
6648 | \gdef\noexpand\thissectionnum{#4}% | |
0f8bbd69 JM |
6649 | % \noexpand\putwordSection avoids expanding indigestible |
6650 | % commands in some of the translations. | |
6651 | \gdef\noexpand\thissection{\noexpand\putwordSection{} | |
6652 | \noexpand\thissectionnum: | |
c94f48d7 AJ |
6653 | \noexpand\thissectionname}% |
6654 | }% | |
6655 | \fi | |
6656 | \else | |
6657 | \ifx\sectionlevel\seckeyword | |
6658 | \toks0={#1}% | |
6659 | \xdef\lastsectiondefs{% | |
6660 | \gdef\noexpand\thissectionname{\the\toks0}% | |
6661 | \gdef\noexpand\thissectionnum{#4}% | |
0f8bbd69 JM |
6662 | % \noexpand\putwordSection avoids expanding indigestible |
6663 | % commands in some of the translations. | |
6664 | \gdef\noexpand\thissection{\noexpand\putwordSection{} | |
6665 | \noexpand\thissectionnum: | |
c94f48d7 AJ |
6666 | \noexpand\thissectionname}% |
6667 | }% | |
6668 | \fi | |
6669 | \fi\fi\fi | |
6670 | % | |
0f8bbd69 JM |
6671 | % Go into vertical mode. Usually we'll already be there, but we |
6672 | % don't want the following whatsit to end up in a preceding paragraph | |
6673 | % if the document didn't happen to have a blank line. | |
6674 | \par | |
6675 | % | |
c94f48d7 AJ |
6676 | % Output the mark. Pass it through \safewhatsit, to take care of |
6677 | % the preceding space. | |
6678 | \safewhatsit\domark | |
6679 | % | |
82d5ce1d UD |
6680 | % Insert space above the heading. |
6681 | \csname #2headingbreak\endcsname | |
6682 | % | |
c94f48d7 AJ |
6683 | % Now the second mark, after the heading break. No break points |
6684 | % between here and the heading. | |
21fea2e2 | 6685 | \global\let\prevsectiondefs=\lastsectiondefs |
c94f48d7 | 6686 | \domark |
82d5ce1d | 6687 | % |
c94f48d7 | 6688 | % Only insert the space after the number if we have a section number. |
82d5ce1d UD |
6689 | \ifx\temptype\Ynothingkeyword |
6690 | \setbox0 = \hbox{}% | |
6691 | \def\toctype{unn}% | |
c94f48d7 | 6692 | \gdef\lastsection{#1}% |
82d5ce1d UD |
6693 | \else\ifx\temptype\Yomitfromtockeyword |
6694 | % for @headings -- no section number, don't include in toc, | |
c94f48d7 | 6695 | % and don't redefine \lastsection. |
82d5ce1d UD |
6696 | \setbox0 = \hbox{}% |
6697 | \def\toctype{omit}% | |
6698 | \let\sectionlevel=\empty | |
6699 | \else\ifx\temptype\Yappendixkeyword | |
6700 | \setbox0 = \hbox{#4\enspace}% | |
6701 | \def\toctype{app}% | |
c94f48d7 | 6702 | \gdef\lastsection{#1}% |
82d5ce1d UD |
6703 | \else |
6704 | \setbox0 = \hbox{#4\enspace}% | |
6705 | \def\toctype{num}% | |
c94f48d7 | 6706 | \gdef\lastsection{#1}% |
82d5ce1d | 6707 | \fi\fi\fi |
0ecb606c | 6708 | % |
9251c568 | 6709 | % Write the toc entry (before \donoderef). See comments in \chapmacro. |
82d5ce1d | 6710 | \writetocentry{\toctype\sectionlevel}{#1}{#4}% |
0ecb606c | 6711 | % |
82d5ce1d | 6712 | % Write the node reference (= pdf destination for pdftex). |
9251c568 | 6713 | % Again, see comments in \chapmacro. |
82d5ce1d UD |
6714 | \donoderef{#3}% |
6715 | % | |
9251c568 AJ |
6716 | % Interline glue will be inserted when the vbox is completed. |
6717 | % That glue will be a valid breakpoint for the page, since it'll be | |
6718 | % preceded by a whatsit (usually from the \donoderef, or from the | |
6719 | % \writetocentry if there was no node). We don't want to allow that | |
6720 | % break, since then the whatsits could end up on page n while the | |
6721 | % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. | |
6722 | \nobreak | |
6723 | % | |
82d5ce1d | 6724 | % Output the actual section heading. |
0f8bbd69 | 6725 | \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright |
82d5ce1d UD |
6726 | \hangindent=\wd0 % zero if no section number |
6727 | \unhbox0 #1}% | |
cd4e176c | 6728 | }% |
82d5ce1d UD |
6729 | % Add extra space after the heading -- half of whatever came above it. |
6730 | % Don't allow stretch, though. | |
6731 | \kern .5 \csname #2headingskip\endcsname | |
6732 | % | |
6733 | % Do not let the kern be a potential breakpoint, as it would be if it | |
6734 | % was followed by glue. | |
2f5b1124 | 6735 | \nobreak |
82d5ce1d UD |
6736 | % |
6737 | % We'll almost certainly start a paragraph next, so don't let that | |
6738 | % glue accumulate. (Not a breakpoint because it's preceded by a | |
8fcb833a JM |
6739 | % discardable item.) However, when a paragraph is not started next |
6740 | % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out | |
6741 | % or the negative glue will cause weirdly wrong output, typically | |
6742 | % obscuring the section heading with something else. | |
82d5ce1d | 6743 | \vskip-\parskip |
0f8bbd69 | 6744 | % |
8fcb833a JM |
6745 | % This is so the last item on the main vertical list is a known |
6746 | % \penalty > 10000, so \startdefun, etc., can recognize the situation | |
6747 | % and do the needful. | |
82d5ce1d | 6748 | \penalty 10001 |
cd4e176c | 6749 | } |
9e9f9cc2 KB |
6750 | |
6751 | ||
313a1174 | 6752 | \message{toc,} |
13632cfc | 6753 | % Table of contents. |
313a1174 UD |
6754 | \newwrite\tocfile |
6755 | ||
6756 | % Write an entry to the toc file, opening it if necessary. | |
82d5ce1d UD |
6757 | % Called from @chapter, etc. |
6758 | % | |
6759 | % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} | |
6760 | % We append the current node name (if any) and page number as additional | |
6761 | % arguments for the \{chap,sec,...}entry macros which will eventually | |
6762 | % read this. The node name is used in the pdf outlines as the | |
6763 | % destination to jump to. | |
b710a6e2 | 6764 | % |
e0f86659 UD |
6765 | % We open the .toc file for writing here instead of at @setfilename (or |
6766 | % any other fixed time) so that @contents can be anywhere in the document. | |
82d5ce1d UD |
6767 | % But if #1 is `omit', then we don't do anything. This is used for the |
6768 | % table of contents chapter openings themselves. | |
b710a6e2 | 6769 | % |
313a1174 | 6770 | \newif\iftocfileopened |
82d5ce1d UD |
6771 | \def\omitkeyword{omit}% |
6772 | % | |
e0f86659 | 6773 | \def\writetocentry#1#2#3{% |
82d5ce1d UD |
6774 | \edef\writetoctype{#1}% |
6775 | \ifx\writetoctype\omitkeyword \else | |
6776 | \iftocfileopened\else | |
6777 | \immediate\openout\tocfile = \jobname.toc | |
6778 | \global\tocfileopenedtrue | |
6779 | \fi | |
6780 | % | |
6781 | \iflinks | |
9251c568 AJ |
6782 | {\atdummies |
6783 | \edef\temp{% | |
6784 | \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% | |
6785 | \temp | |
6786 | }% | |
82d5ce1d | 6787 | \fi |
e0f86659 | 6788 | \fi |
27692f89 | 6789 | % |
82d5ce1d UD |
6790 | % Tell \shipout to create a pdf destination on each page, if we're |
6791 | % writing pdf. These are used in the table of contents. We can't | |
6792 | % just write one on every page because the title pages are numbered | |
6793 | % 1 and 2 (the page numbers aren't printed), and so are the first | |
6794 | % two pages of the document. Thus, we'd have two destinations named | |
6795 | % `1', and two named `2'. | |
7f7dd1d3 JM |
6796 | \ifpdf |
6797 | \global\pdfmakepagedesttrue | |
6798 | \else | |
6799 | \ifx\XeTeXrevision\thisisundefined | |
6800 | \else | |
6801 | \global\pdfmakepagedesttrue | |
6802 | \fi | |
6803 | \fi | |
313a1174 UD |
6804 | } |
6805 | ||
9251c568 AJ |
6806 | |
6807 | % These characters do not print properly in the Computer Modern roman | |
6808 | % fonts, so we must take special care. This is more or less redundant | |
6809 | % with the Texinfo input format setup at the end of this file. | |
0f8bbd69 | 6810 | % |
9251c568 AJ |
6811 | \def\activecatcodes{% |
6812 | \catcode`\"=\active | |
6813 | \catcode`\$=\active | |
6814 | \catcode`\<=\active | |
6815 | \catcode`\>=\active | |
6816 | \catcode`\\=\active | |
6817 | \catcode`\^=\active | |
6818 | \catcode`\_=\active | |
6819 | \catcode`\|=\active | |
6820 | \catcode`\~=\active | |
6821 | } | |
6822 | ||
6823 | ||
6824 | % Read the toc file, which is essentially Texinfo input. | |
6825 | \def\readtocfile{% | |
6826 | \setupdatafile | |
6827 | \activecatcodes | |
c94f48d7 | 6828 | \input \tocreadfilename |
9251c568 AJ |
6829 | } |
6830 | ||
61027f30 UD |
6831 | \newskip\contentsrightmargin \contentsrightmargin=1in |
6832 | \newcount\savepageno | |
6833 | \newcount\lastnegativepageno \lastnegativepageno = -1 | |
6834 | ||
82d5ce1d | 6835 | % Prepare to read what we've written to \tocfile. |
b710a6e2 | 6836 | % |
9e9f9cc2 | 6837 | \def\startcontents#1{% |
82d5ce1d UD |
6838 | % If @setchapternewpage on, and @headings double, the contents should |
6839 | % start on an odd page, unlike chapters. Thus, we maintain | |
6840 | % \contentsalignmacro in parallel with \pagealignmacro. | |
6841 | % From: Torbjorn Granlund <tege@matematik.su.se> | |
6842 | \contentsalignmacro | |
6843 | \immediate\closeout\tocfile | |
6844 | % | |
6845 | % Don't need to put `Contents' or `Short Contents' in the headline. | |
6846 | % It is abundantly clear what they are. | |
82d5ce1d UD |
6847 | \chapmacro{#1}{Yomitfromtoc}{}% |
6848 | % | |
6849 | \savepageno = \pageno | |
6850 | \begingroup % Set up to handle contents files properly. | |
9251c568 | 6851 | \raggedbottom % Worry more about breakpoints than the bottom. |
084e7d57 | 6852 | \entryrightmargin=\contentsrightmargin % Don't use the full line length. |
82d5ce1d UD |
6853 | % |
6854 | % Roman numerals for page numbers. | |
6855 | \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi | |
9e9f9cc2 KB |
6856 | } |
6857 | ||
c94f48d7 AJ |
6858 | % redefined for the two-volume lispref. We always output on |
6859 | % \jobname.toc even if this is redefined. | |
0f8bbd69 | 6860 | % |
c94f48d7 | 6861 | \def\tocreadfilename{\jobname.toc} |
9e9f9cc2 KB |
6862 | |
6863 | % Normal (long) toc. | |
c94f48d7 | 6864 | % |
313a1174 | 6865 | \def\contents{% |
82d5ce1d | 6866 | \startcontents{\putwordTOC}% |
c94f48d7 | 6867 | \openin 1 \tocreadfilename\space |
82d5ce1d | 6868 | \ifeof 1 \else |
9251c568 | 6869 | \readtocfile |
82d5ce1d UD |
6870 | \fi |
6871 | \vfill \eject | |
6872 | \contentsalignmacro % in case @setchapternewpage odd is in effect | |
6873 | \ifeof 1 \else | |
6874 | \pdfmakeoutlines | |
6875 | \fi | |
6876 | \closein 1 | |
6877 | \endgroup | |
6878 | \lastnegativepageno = \pageno | |
6879 | \global\pageno = \savepageno | |
9e9f9cc2 KB |
6880 | } |
6881 | ||
6882 | % And just the chapters. | |
313a1174 | 6883 | \def\summarycontents{% |
82d5ce1d UD |
6884 | \startcontents{\putwordShortTOC}% |
6885 | % | |
0f8bbd69 | 6886 | \let\partentry = \shortpartentry |
82d5ce1d UD |
6887 | \let\numchapentry = \shortchapentry |
6888 | \let\appentry = \shortchapentry | |
6889 | \let\unnchapentry = \shortunnchapentry | |
6890 | % We want a true roman here for the page numbers. | |
6891 | \secfonts | |
6892 | \let\rm=\shortcontrm \let\bf=\shortcontbf | |
6893 | \let\sl=\shortcontsl \let\tt=\shortconttt | |
6894 | \rm | |
6895 | \hyphenpenalty = 10000 | |
6896 | \advance\baselineskip by 1pt % Open it up a little. | |
6897 | \def\numsecentry##1##2##3##4{} | |
6898 | \let\appsecentry = \numsecentry | |
6899 | \let\unnsecentry = \numsecentry | |
6900 | \let\numsubsecentry = \numsecentry | |
6901 | \let\appsubsecentry = \numsecentry | |
6902 | \let\unnsubsecentry = \numsecentry | |
6903 | \let\numsubsubsecentry = \numsecentry | |
6904 | \let\appsubsubsecentry = \numsecentry | |
6905 | \let\unnsubsubsecentry = \numsecentry | |
c94f48d7 | 6906 | \openin 1 \tocreadfilename\space |
82d5ce1d | 6907 | \ifeof 1 \else |
9251c568 | 6908 | \readtocfile |
82d5ce1d UD |
6909 | \fi |
6910 | \closein 1 | |
6911 | \vfill \eject | |
6912 | \contentsalignmacro % in case @setchapternewpage odd is in effect | |
6913 | \endgroup | |
6914 | \lastnegativepageno = \pageno | |
6915 | \global\pageno = \savepageno | |
9e9f9cc2 KB |
6916 | } |
6917 | \let\shortcontents = \summarycontents | |
6918 | ||
82d5ce1d UD |
6919 | % Typeset the label for a chapter or appendix for the short contents. |
6920 | % The arg is, e.g., `A' for an appendix, or `3' for a chapter. | |
6921 | % | |
6922 | \def\shortchaplabel#1{% | |
6923 | % This space should be enough, since a single number is .5em, and the | |
6924 | % widest letter (M) is 1em, at least in the Computer Modern fonts. | |
6925 | % But use \hss just in case. | |
6926 | % (This space doesn't include the extra space that gets added after | |
6927 | % the label; that gets put in by \shortchapentry above.) | |
6928 | % | |
6929 | % We'd like to right-justify chapter numbers, but that looks strange | |
6930 | % with appendix letters. And right-justifying numbers and | |
6931 | % left-justifying letters looks strange when there is less than 10 | |
6932 | % chapters. Have to read the whole toc once to know how many chapters | |
6933 | % there are before deciding ... | |
6934 | \hbox to 1em{#1\hss}% | |
6935 | } | |
13632cfc | 6936 | |
9e9f9cc2 KB |
6937 | % These macros generate individual entries in the table of contents. |
6938 | % The first argument is the chapter or section name. | |
6939 | % The last argument is the page number. | |
6940 | % The arguments in between are the chapter number, section number, ... | |
6941 | ||
0f8bbd69 JM |
6942 | % Parts, in the main contents. Replace the part number, which doesn't |
6943 | % exist, with an empty box. Let's hope all the numbers have the same width. | |
6944 | % Also ignore the page number, which is conventionally not printed. | |
6945 | \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} | |
6946 | \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} | |
6947 | % | |
6948 | % Parts, in the short toc. | |
6949 | \def\shortpartentry#1#2#3#4{% | |
6950 | \penalty-300 | |
6951 | \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip | |
6952 | \shortchapentry{{\bf #1}}{\numeralbox}{}{}% | |
6953 | } | |
6954 | ||
7ed7ad59 | 6955 | % Chapters, in the main contents. |
82d5ce1d | 6956 | \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} |
084e7d57 | 6957 | |
7ed7ad59 UD |
6958 | % Chapters, in the short toc. |
6959 | % See comments in \dochapentry re vbox and related settings. | |
82d5ce1d UD |
6960 | \def\shortchapentry#1#2#3#4{% |
6961 | \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% | |
9e9f9cc2 KB |
6962 | } |
6963 | ||
7ed7ad59 | 6964 | % Appendices, in the main contents. |
82d5ce1d | 6965 | % Need the word Appendix, and a fixed-size box. |
3b82ab1c | 6966 | % |
82d5ce1d UD |
6967 | \def\appendixbox#1{% |
6968 | % We use M since it's probably the widest letter. | |
6969 | \setbox0 = \hbox{\putwordAppendix{} M}% | |
6970 | \hbox to \wd0{\putwordAppendix{} #1\hss}} | |
a334319f | 6971 | % |
084e7d57 | 6972 | \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}} |
9e9f9cc2 | 6973 | |
7ed7ad59 | 6974 | % Unnumbered chapters. |
82d5ce1d UD |
6975 | \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} |
6976 | \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} | |
9e9f9cc2 KB |
6977 | |
6978 | % Sections. | |
82d5ce1d UD |
6979 | \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} |
6980 | \let\appsecentry=\numsecentry | |
6981 | \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} | |
9e9f9cc2 KB |
6982 | |
6983 | % Subsections. | |
82d5ce1d UD |
6984 | \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} |
6985 | \let\appsubsecentry=\numsubsecentry | |
6986 | \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} | |
9e9f9cc2 KB |
6987 | |
6988 | % And subsubsections. | |
82d5ce1d UD |
6989 | \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} |
6990 | \let\appsubsubsecentry=\numsubsubsecentry | |
6991 | \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} | |
9e9f9cc2 | 6992 | |
9e9f9cc2 | 6993 | % This parameter controls the indentation of the various levels. |
82d5ce1d UD |
6994 | % Same as \defaultparindent. |
6995 | \newdimen\tocindent \tocindent = 15pt | |
9e9f9cc2 KB |
6996 | |
6997 | % Now for the actual typesetting. In all these, #1 is the text and #2 is the | |
6998 | % page number. | |
6999 | % | |
359a1d0b | 7000 | % If the toc has to be broken over pages, we want it to be at chapters |
9e9f9cc2 KB |
7001 | % if at all possible; hence the \penalty. |
7002 | \def\dochapentry#1#2{% | |
359a1d0b | 7003 | \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip |
9e9f9cc2 | 7004 | \begingroup |
084e7d57 JM |
7005 | % Move the page numbers slightly to the right |
7006 | \advance\entryrightmargin by -0.05em | |
9e9f9cc2 | 7007 | \chapentryfonts |
3b82ab1c | 7008 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
9e9f9cc2 | 7009 | \endgroup |
359a1d0b | 7010 | \nobreak\vskip .25\baselineskip plus.1\baselineskip |
9e9f9cc2 KB |
7011 | } |
7012 | ||
7013 | \def\dosecentry#1#2{\begingroup | |
7014 | \secentryfonts \leftskip=\tocindent | |
3b82ab1c | 7015 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
9e9f9cc2 KB |
7016 | \endgroup} |
7017 | ||
7018 | \def\dosubsecentry#1#2{\begingroup | |
7019 | \subsecentryfonts \leftskip=2\tocindent | |
3b82ab1c | 7020 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
9e9f9cc2 KB |
7021 | \endgroup} |
7022 | ||
7023 | \def\dosubsubsecentry#1#2{\begingroup | |
7024 | \subsubsecentryfonts \leftskip=3\tocindent | |
3b82ab1c | 7025 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
0f8bbd69 JM |
7026 | \endgroup} |
7027 | ||
7028 | % We use the same \entry macro as for the index entries. | |
7029 | \let\tocentry = \entry | |
7030 | ||
7031 | % Space between chapter (or whatever) number and the title. | |
7032 | \def\labelspace{\hskip1em \relax} | |
7033 | ||
7034 | \def\dopageno#1{{\rm #1}} | |
7035 | \def\doshortpageno#1{{\rm #1}} | |
7036 | ||
7037 | \def\chapentryfonts{\secfonts \rm} | |
7038 | \def\secentryfonts{\textfonts} | |
7039 | \def\subsecentryfonts{\textfonts} | |
7040 | \def\subsubsecentryfonts{\textfonts} | |
7041 | ||
9e9f9cc2 | 7042 | |
0f8bbd69 JM |
7043 | \message{environments,} |
7044 | % @foo ... @end foo. | |
7045 | ||
7046 | % @tex ... @end tex escapes into raw TeX temporarily. | |
9e9f9cc2 | 7047 | % One exception: @ is still an escape character, so that @end tex works. |
0f8bbd69 | 7048 | % But \@ or @@ will get a plain @ character. |
9e9f9cc2 | 7049 | |
82d5ce1d | 7050 | \envdef\tex{% |
0f8bbd69 | 7051 | \setupmarkupstyle{tex}% |
2eb45444 UD |
7052 | \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 |
7053 | \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 | |
e0f86659 | 7054 | \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie |
2eb45444 | 7055 | \catcode `\%=14 |
e0f86659 UD |
7056 | \catcode `\+=\other |
7057 | \catcode `\"=\other | |
e0f86659 UD |
7058 | \catcode `\|=\other |
7059 | \catcode `\<=\other | |
7060 | \catcode `\>=\other | |
21fea2e2 JM |
7061 | \catcode `\`=\other |
7062 | \catcode `\'=\other | |
2eb45444 | 7063 | % |
0f8bbd69 JM |
7064 | % ' is active in math mode (mathcode"8000). So reset it, and all our |
7065 | % other math active characters (just in case), to plain's definitions. | |
7066 | \mathactive | |
7067 | % | |
084e7d57 | 7068 | % Inverse of the list at the beginning of the file. |
2eb45444 UD |
7069 | \let\b=\ptexb |
7070 | \let\bullet=\ptexbullet | |
7071 | \let\c=\ptexc | |
7072 | \let\,=\ptexcomma | |
7073 | \let\.=\ptexdot | |
7074 | \let\dots=\ptexdots | |
7075 | \let\equiv=\ptexequiv | |
7076 | \let\!=\ptexexclam | |
7077 | \let\i=\ptexi | |
7158eae4 | 7078 | \let\indent=\ptexindent |
82d5ce1d | 7079 | \let\noindent=\ptexnoindent |
2eb45444 | 7080 | \let\{=\ptexlbrace |
40c0dc53 | 7081 | \let\+=\tabalign |
2eb45444 | 7082 | \let\}=\ptexrbrace |
7158eae4 | 7083 | \let\/=\ptexslash |
084e7d57 | 7084 | \let\sp=\ptexsp |
2eb45444 | 7085 | \let\*=\ptexstar |
084e7d57 | 7086 | %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode |
2eb45444 | 7087 | \let\t=\ptext |
21fea2e2 | 7088 | \expandafter \let\csname top\endcsname=\ptextop % we've made it outer |
9251c568 | 7089 | \let\frenchspacing=\plainfrenchspacing |
2eb45444 UD |
7090 | % |
7091 | \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% | |
7092 | \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% | |
7093 | \def\@{@}% | |
82d5ce1d UD |
7094 | } |
7095 | % There is no need to define \Etex. | |
9e9f9cc2 | 7096 | |
27692f89 | 7097 | % Define @lisp ... @end lisp. |
82d5ce1d | 7098 | % @lisp environment forms a group so it can rebind things, |
27692f89 | 7099 | % including the definition of @end lisp (which normally is erroneous). |
9e9f9cc2 KB |
7100 | |
7101 | % Amount to narrow the margins by for @lisp. | |
7102 | \newskip\lispnarrowing \lispnarrowing=0.4in | |
7103 | ||
7104 | % This is the definition that ^^M gets inside @lisp, @example, and other | |
7105 | % such environments. \null is better than a space, since it doesn't | |
7106 | % have any width. | |
7107 | \def\lisppar{\null\endgraf} | |
7108 | ||
9e9f9cc2 KB |
7109 | % This space is always present above and below environments. |
7110 | \newskip\envskipamount \envskipamount = 0pt | |
7111 | ||
7112 | % Make spacing and below environment symmetrical. We use \parskip here | |
7113 | % to help in doing that, since in @example-like environments \parskip | |
7114 | % is reset to zero; thus the \afterenvbreak inserts no space -- but the | |
2f5b1124 | 7115 | % start of the next paragraph will insert \parskip. |
9e9f9cc2 | 7116 | % |
be1152ca | 7117 | \def\aboveenvbreak{{% |
084e7d57 JM |
7118 | % =10000 instead of <10000 because of a special case in \itemzzz and |
7119 | % \sectionheading, q.v. | |
7120 | \ifnum \lastpenalty=10000 \else | |
7121 | \advance\envskipamount by \parskip | |
7122 | \endgraf | |
7123 | \ifdim\lastskip<\envskipamount | |
7124 | \removelastskip | |
7125 | \ifnum\lastpenalty<10000 | |
7126 | % Penalize breaking before the environment, because preceding text | |
7127 | % often leads into it. | |
7128 | \penalty100 | |
7129 | \fi | |
7130 | \vskip\envskipamount | |
7131 | \fi | |
7132 | \fi | |
7133 | }} | |
7134 | ||
7135 | \def\afterenvbreak{{% | |
82d5ce1d UD |
7136 | % =10000 instead of <10000 because of a special case in \itemzzz and |
7137 | % \sectionheading, q.v. | |
2f5b1124 | 7138 | \ifnum \lastpenalty=10000 \else |
be1152ca UD |
7139 | \advance\envskipamount by \parskip |
7140 | \endgraf | |
7141 | \ifdim\lastskip<\envskipamount | |
7142 | \removelastskip | |
2f5b1124 UD |
7143 | % it's not a good place to break if the last penalty was \nobreak |
7144 | % or better ... | |
82d5ce1d | 7145 | \ifnum\lastpenalty<10000 \penalty-50 \fi |
be1152ca UD |
7146 | \vskip\envskipamount |
7147 | \fi | |
7148 | \fi | |
7149 | }} | |
9e9f9cc2 | 7150 | |
9251c568 AJ |
7151 | % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will |
7152 | % also clear it, so that its embedded environments do the narrowing again. | |
9e9f9cc2 KB |
7153 | \let\nonarrowing=\relax |
7154 | ||
40c0dc53 UD |
7155 | % @cartouche ... @end cartouche: draw rectangle w/rounded corners around |
7156 | % environment contents. | |
9e9f9cc2 KB |
7157 | \font\circle=lcircle10 |
7158 | \newdimen\circthick | |
7159 | \newdimen\cartouter\newdimen\cartinner | |
7160 | \newskip\normbskip\newskip\normpskip\newskip\normlskip | |
7161 | \circthick=\fontdimen8\circle | |
7162 | % | |
7163 | \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth | |
7164 | \def\ctr{{\hskip 6pt\circle\char'010}} | |
7165 | \def\cbl{{\circle\char'012\hskip -6pt}} | |
7166 | \def\cbr{{\hskip 6pt\circle\char'011}} | |
7167 | \def\carttop{\hbox to \cartouter{\hskip\lskip | |
2d07133b KB |
7168 | \ctl\leaders\hrule height\circthick\hfil\ctr |
7169 | \hskip\rskip}} | |
9e9f9cc2 | 7170 | \def\cartbot{\hbox to \cartouter{\hskip\lskip |
2d07133b KB |
7171 | \cbl\leaders\hrule height\circthick\hfil\cbr |
7172 | \hskip\rskip}} | |
9e9f9cc2 KB |
7173 | % |
7174 | \newskip\lskip\newskip\rskip | |
7175 | ||
82d5ce1d UD |
7176 | \envdef\cartouche{% |
7177 | \ifhmode\par\fi % can't be in the midst of a paragraph. | |
7178 | \startsavinginserts | |
7179 | \lskip=\leftskip \rskip=\rightskip | |
7180 | \leftskip=0pt\rightskip=0pt % we want these *outside*. | |
7181 | \cartinner=\hsize \advance\cartinner by-\lskip | |
7182 | \advance\cartinner by-\rskip | |
7183 | \cartouter=\hsize | |
7184 | \advance\cartouter by 18.4pt % allow for 3pt kerns on either | |
7185 | % side, and for 6pt waste from | |
7186 | % each corner char, and rule thickness | |
7187 | \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip | |
0f8bbd69 JM |
7188 | % |
7189 | % If this cartouche directly follows a sectioning command, we need the | |
7190 | % \parskip glue (backspaced over by default) or the cartouche can | |
7191 | % collide with the section heading. | |
8fcb833a | 7192 | \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi |
0f8bbd69 | 7193 | % |
084e7d57 | 7194 | \setbox\groupbox=\vbox\bgroup |
82d5ce1d UD |
7195 | \baselineskip=0pt\parskip=0pt\lineskip=0pt |
7196 | \carttop | |
7197 | \hbox\bgroup | |
7198 | \hskip\lskip | |
7199 | \vrule\kern3pt | |
7200 | \vbox\bgroup | |
7201 | \kern3pt | |
7202 | \hsize=\cartinner | |
7203 | \baselineskip=\normbskip | |
7204 | \lineskip=\normlskip | |
7205 | \parskip=\normpskip | |
7206 | \vskip -\parskip | |
0f8bbd69 | 7207 | \comment % For explanation, see the end of def\group. |
82d5ce1d | 7208 | } |
9e9f9cc2 | 7209 | \def\Ecartouche{% |
82d5ce1d UD |
7210 | \ifhmode\par\fi |
7211 | \kern3pt | |
7212 | \egroup | |
7213 | \kern3pt\vrule | |
7214 | \hskip\rskip | |
7215 | \egroup | |
7216 | \cartbot | |
7217 | \egroup | |
084e7d57 | 7218 | \addgroupbox |
82d5ce1d UD |
7219 | \checkinserts |
7220 | } | |
9e9f9cc2 KB |
7221 | |
7222 | ||
7223 | % This macro is called at the beginning of all the @example variants, | |
7224 | % inside a group. | |
0f8bbd69 | 7225 | \newdimen\nonfillparindent |
9e9f9cc2 KB |
7226 | \def\nonfillstart{% |
7227 | \aboveenvbreak | |
8fcb833a | 7228 | \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy |
9e9f9cc2 | 7229 | \sepspaces % Make spaces be word-separators rather than space tokens. |
9e9f9cc2 KB |
7230 | \let\par = \lisppar % don't ignore blank lines |
7231 | \obeylines % each line of input is a line of output | |
7232 | \parskip = 0pt | |
0f8bbd69 JM |
7233 | % Turn off paragraph indentation but redefine \indent to emulate |
7234 | % the normal \indent. | |
7235 | \nonfillparindent=\parindent | |
9e9f9cc2 | 7236 | \parindent = 0pt |
0f8bbd69 JM |
7237 | \let\indent\nonfillindent |
7238 | % | |
9e9f9cc2 | 7239 | \emergencystretch = 0pt % don't try to avoid overfull boxes |
9e9f9cc2 KB |
7240 | \ifx\nonarrowing\relax |
7241 | \advance \leftskip by \lispnarrowing | |
7242 | \exdentamount=\lispnarrowing | |
9251c568 AJ |
7243 | \else |
7244 | \let\nonarrowing = \relax | |
9e9f9cc2 | 7245 | \fi |
82d5ce1d | 7246 | \let\exdent=\nofillexdent |
9e9f9cc2 KB |
7247 | } |
7248 | ||
0f8bbd69 JM |
7249 | \begingroup |
7250 | \obeyspaces | |
7251 | % We want to swallow spaces (but not other tokens) after the fake | |
7252 | % @indent in our nonfill-environments, where spaces are normally | |
7253 | % active and set to @tie, resulting in them not being ignored after | |
7254 | % @indent. | |
7255 | \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% | |
7256 | \gdef\nonfillindentcheck{% | |
7257 | \ifx\temp % | |
7258 | \expandafter\nonfillindentgobble% | |
7259 | \else% | |
7260 | \leavevmode\nonfillindentbox% | |
7261 | \fi% | |
7262 | }% | |
7263 | \endgroup | |
7264 | \def\nonfillindentgobble#1{\nonfillindent} | |
7265 | \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} | |
7266 | ||
82d5ce1d UD |
7267 | % If you want all examples etc. small: @set dispenvsize small. |
7268 | % If you want even small examples the full size: @set dispenvsize nosmall. | |
7269 | % This affects the following displayed environments: | |
7270 | % @example, @display, @format, @lisp | |
a334319f | 7271 | % |
82d5ce1d UD |
7272 | \def\smallword{small} |
7273 | \def\nosmallword{nosmall} | |
7274 | \let\SETdispenvsize\relax | |
7275 | \def\setnormaldispenv{% | |
7276 | \ifx\SETdispenvsize\smallword | |
c94f48d7 AJ |
7277 | % end paragraph for sake of leading, in case document has no blank |
7278 | % line. This is redundant with what happens in \aboveenvbreak, but | |
7279 | % we need to do it before changing the fonts, and it's inconvenient | |
7280 | % to change the fonts afterward. | |
7281 | \ifnum \lastpenalty=10000 \else \endgraf \fi | |
82d5ce1d UD |
7282 | \smallexamplefonts \rm |
7283 | \fi | |
7284 | } | |
7285 | \def\setsmalldispenv{% | |
7286 | \ifx\SETdispenvsize\nosmallword | |
7287 | \else | |
c94f48d7 | 7288 | \ifnum \lastpenalty=10000 \else \endgraf \fi |
82d5ce1d UD |
7289 | \smallexamplefonts \rm |
7290 | \fi | |
7291 | } | |
9e9f9cc2 | 7292 | |
82d5ce1d | 7293 | % We often define two environments, @foo and @smallfoo. |
0f8bbd69 JM |
7294 | % Let's do it in one command. #1 is the env name, #2 the definition. |
7295 | \def\makedispenvdef#1#2{% | |
7296 | \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% | |
7297 | \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% | |
82d5ce1d UD |
7298 | \expandafter\let\csname E#1\endcsname \afterenvbreak |
7299 | \expandafter\let\csname Esmall#1\endcsname \afterenvbreak | |
9e9f9cc2 KB |
7300 | } |
7301 | ||
0f8bbd69 JM |
7302 | % Define two environment synonyms (#1 and #2) for an environment. |
7303 | \def\maketwodispenvdef#1#2#3{% | |
7304 | \makedispenvdef{#1}{#3}% | |
7305 | \makedispenvdef{#2}{#3}% | |
82d5ce1d | 7306 | } |
0f8bbd69 JM |
7307 | % |
7308 | % @lisp: indented, narrowed, typewriter font; | |
7309 | % @example: same as @lisp. | |
82d5ce1d | 7310 | % |
e0f86659 | 7311 | % @smallexample and @smalllisp: use smaller fonts. |
0c2b5752 | 7312 | % Originally contributed by Pavel@xerox. |
82d5ce1d | 7313 | % |
0f8bbd69 | 7314 | \maketwodispenvdef{lisp}{example}{% |
82d5ce1d | 7315 | \nonfillstart |
0f8bbd69 | 7316 | \tt\setupmarkupstyle{example}% |
82d5ce1d | 7317 | \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. |
0f8bbd69 | 7318 | \gobble % eat return |
9e9f9cc2 | 7319 | } |
82d5ce1d | 7320 | % @display/@smalldisplay: same as @lisp except keep current font. |
9e9f9cc2 | 7321 | % |
0f8bbd69 | 7322 | \makedispenvdef{display}{% |
9e9f9cc2 | 7323 | \nonfillstart |
9e9f9cc2 KB |
7324 | \gobble |
7325 | } | |
0c2b5752 | 7326 | |
82d5ce1d | 7327 | % @format/@smallformat: same as @display except don't narrow margins. |
a334319f | 7328 | % |
0f8bbd69 | 7329 | \makedispenvdef{format}{% |
82d5ce1d | 7330 | \let\nonarrowing = t% |
0ecb606c JJ |
7331 | \nonfillstart |
7332 | \gobble | |
7333 | } | |
a334319f | 7334 | |
82d5ce1d UD |
7335 | % @flushleft: same as @format, but doesn't obey \SETdispenvsize. |
7336 | \envdef\flushleft{% | |
7337 | \let\nonarrowing = t% | |
7338 | \nonfillstart | |
7339 | \gobble | |
7340 | } | |
7341 | \let\Eflushleft = \afterenvbreak | |
0c2b5752 UD |
7342 | |
7343 | % @flushright. | |
b710a6e2 | 7344 | % |
82d5ce1d UD |
7345 | \envdef\flushright{% |
7346 | \let\nonarrowing = t% | |
9e9f9cc2 | 7347 | \nonfillstart |
0f8bbd69 | 7348 | \advance\leftskip by 0pt plus 1fill\relax |
0c2b5752 UD |
7349 | \gobble |
7350 | } | |
82d5ce1d | 7351 | \let\Eflushright = \afterenvbreak |
9e9f9cc2 | 7352 | |
366d6851 | 7353 | |
0f8bbd69 | 7354 | % @raggedright does more-or-less normal line breaking but no right |
e66a8203 JM |
7355 | % justification. From plain.tex. Don't stretch around special |
7356 | % characters in urls in this environment, since the stretch at the right | |
7357 | % should be enough. | |
0f8bbd69 | 7358 | \envdef\raggedright{% |
e66a8203 JM |
7359 | \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax |
7360 | \def\urefprestretchamount{0pt}% | |
7361 | \def\urefpoststretchamount{0pt}% | |
0f8bbd69 JM |
7362 | } |
7363 | \let\Eraggedright\par | |
7364 | ||
7365 | \envdef\raggedleft{% | |
7366 | \parindent=0pt \leftskip0pt plus2em | |
7367 | \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt | |
7368 | \hbadness=10000 % Last line will usually be underfull, so turn off | |
7369 | % badness reporting. | |
7370 | } | |
7371 | \let\Eraggedleft\par | |
7372 | ||
7373 | \envdef\raggedcenter{% | |
7374 | \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em | |
7375 | \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt | |
7376 | \hbadness=10000 % Last line will usually be underfull, so turn off | |
7377 | % badness reporting. | |
7378 | } | |
7379 | \let\Eraggedcenter\par | |
7380 | ||
7381 | ||
9e9f9cc2 | 7382 | % @quotation does normal linebreaking (hence we can't use \nonfillstart) |
82d5ce1d UD |
7383 | % and narrows the margins. We keep \parskip nonzero in general, since |
7384 | % we're doing normal filling. So, when using \aboveenvbreak and | |
7385 | % \afterenvbreak, temporarily make \parskip 0. | |
9e9f9cc2 | 7386 | % |
0f8bbd69 JM |
7387 | \makedispenvdef{quotation}{\quotationstart} |
7388 | % | |
7389 | \def\quotationstart{% | |
8fcb833a | 7390 | \indentedblockstart % same as \indentedblock, but increase right margin too. |
9e9f9cc2 | 7391 | \ifx\nonarrowing\relax |
9e9f9cc2 | 7392 | \advance\rightskip by \lispnarrowing |
9e9f9cc2 | 7393 | \fi |
82d5ce1d UD |
7394 | \parsearg\quotationlabel |
7395 | } | |
7396 | ||
7397 | % We have retained a nonzero parskip for the environment, since we're | |
7398 | % doing normal filling. | |
7399 | % | |
7400 | \def\Equotation{% | |
7401 | \par | |
0f8bbd69 | 7402 | \ifx\quotationauthor\thisisundefined\else |
82d5ce1d UD |
7403 | % indent a bit. |
7404 | \leftline{\kern 2\leftskip \sl ---\quotationauthor}% | |
7405 | \fi | |
7406 | {\parskip=0pt \afterenvbreak}% | |
7407 | } | |
0f8bbd69 | 7408 | \def\Esmallquotation{\Equotation} |
82d5ce1d UD |
7409 | |
7410 | % If we're given an argument, typeset it in bold with a colon after. | |
7411 | \def\quotationlabel#1{% | |
7412 | \def\temp{#1}% | |
7413 | \ifx\temp\empty \else | |
7414 | {\bf #1: }% | |
7415 | \fi | |
9e9f9cc2 KB |
7416 | } |
7417 | ||
8fcb833a JM |
7418 | % @indentedblock is like @quotation, but indents only on the left and |
7419 | % has no optional argument. | |
7420 | % | |
7421 | \makedispenvdef{indentedblock}{\indentedblockstart} | |
7422 | % | |
7423 | \def\indentedblockstart{% | |
7424 | {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip | |
7425 | \parindent=0pt | |
7426 | % | |
7427 | % @cartouche defines \nonarrowing to inhibit narrowing at next level down. | |
7428 | \ifx\nonarrowing\relax | |
7429 | \advance\leftskip by \lispnarrowing | |
7430 | \exdentamount = \lispnarrowing | |
7431 | \else | |
7432 | \let\nonarrowing = \relax | |
7433 | \fi | |
7434 | } | |
7435 | ||
7436 | % Keep a nonzero parskip for the environment, since we're doing normal filling. | |
7437 | % | |
7438 | \def\Eindentedblock{% | |
7439 | \par | |
7440 | {\parskip=0pt \afterenvbreak}% | |
7441 | } | |
7442 | \def\Esmallindentedblock{\Eindentedblock} | |
7443 | ||
0c2b5752 | 7444 | |
366d6851 | 7445 | % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>} |
7158eae4 | 7446 | % If we want to allow any <char> as delimiter, |
366d6851 UD |
7447 | % we need the curly braces so that makeinfo sees the @verb command, eg: |
7448 | % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org | |
7449 | % | |
7450 | % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. | |
7451 | % | |
2f5b1124 UD |
7452 | % [Knuth] p.344; only we need to do the other characters Texinfo sets |
7453 | % active too. Otherwise, they get lost as the first character on a | |
7454 | % verbatim line. | |
366d6851 | 7455 | \def\dospecials{% |
2f5b1124 UD |
7456 | \do\ \do\\\do\{\do\}\do\$\do\&% |
7457 | \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% | |
7458 | \do\<\do\>\do\|\do\@\do+\do\"% | |
0f8bbd69 JM |
7459 | % Don't do the quotes -- if we do, @set txicodequoteundirected and |
7460 | % @set txicodequotebacktick will not have effect on @verb and | |
7461 | % @verbatim, and ?` and !` ligatures won't get disabled. | |
7462 | %\do\`\do\'% | |
2f5b1124 | 7463 | } |
366d6851 UD |
7464 | % |
7465 | % [Knuth] p. 380 | |
7466 | \def\uncatcodespecials{% | |
82d5ce1d | 7467 | \def\do##1{\catcode`##1=\other}\dospecials} |
366d6851 | 7468 | % |
366d6851 UD |
7469 | % Setup for the @verb command. |
7470 | % | |
7471 | % Eight spaces for a tab | |
7472 | \begingroup | |
7473 | \catcode`\^^I=\active | |
7474 | \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} | |
7475 | \endgroup | |
7476 | % | |
7477 | \def\setupverb{% | |
7478 | \tt % easiest (and conventionally used) font for verbatim | |
7479 | \def\par{\leavevmode\endgraf}% | |
0f8bbd69 | 7480 | \setupmarkupstyle{verb}% |
366d6851 UD |
7481 | \tabeightspaces |
7482 | % Respect line breaks, | |
7483 | % print special symbols as themselves, and | |
7484 | % make each space count | |
7485 | % must do in this order: | |
7486 | \obeylines \uncatcodespecials \sepspaces | |
7487 | } | |
7488 | ||
7489 | % Setup for the @verbatim environment | |
7490 | % | |
0f8bbd69 | 7491 | % Real tab expansion. |
366d6851 UD |
7492 | \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount |
7493 | % | |
0f8bbd69 JM |
7494 | % We typeset each line of the verbatim in an \hbox, so we can handle |
7495 | % tabs. The \global is in case the verbatim line starts with an accent, | |
7496 | % or some other command that starts with a begin-group. Otherwise, the | |
7497 | % entire \verbbox would disappear at the corresponding end-group, before | |
7498 | % it is typeset. Meanwhile, we can't have nested verbatim commands | |
7499 | % (can we?), so the \global won't be overwriting itself. | |
7500 | \newbox\verbbox | |
7501 | \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} | |
9251c568 | 7502 | % |
366d6851 UD |
7503 | \begingroup |
7504 | \catcode`\^^I=\active | |
7505 | \gdef\tabexpand{% | |
7506 | \catcode`\^^I=\active | |
7507 | \def^^I{\leavevmode\egroup | |
0f8bbd69 JM |
7508 | \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab |
7509 | \divide\dimen\verbbox by\tabw | |
7510 | \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw | |
7511 | \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw | |
7512 | \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox | |
366d6851 UD |
7513 | }% |
7514 | } | |
7515 | \endgroup | |
9251c568 AJ |
7516 | |
7517 | % start the verbatim environment. | |
366d6851 | 7518 | \def\setupverbatim{% |
9251c568 | 7519 | \let\nonarrowing = t% |
82d5ce1d | 7520 | \nonfillstart |
0f8bbd69 JM |
7521 | \tt % easiest (and conventionally used) font for verbatim |
7522 | % The \leavevmode here is for blank lines. Otherwise, we would | |
7523 | % never \starttabox and the \egroup would end verbatim mode. | |
7524 | \def\par{\leavevmode\egroup\box\verbbox\endgraf}% | |
366d6851 | 7525 | \tabexpand |
0f8bbd69 | 7526 | \setupmarkupstyle{verbatim}% |
366d6851 UD |
7527 | % Respect line breaks, |
7528 | % print special symbols as themselves, and | |
0f8bbd69 JM |
7529 | % make each space count. |
7530 | % Must do in this order: | |
366d6851 UD |
7531 | \obeylines \uncatcodespecials \sepspaces |
7532 | \everypar{\starttabbox}% | |
7533 | } | |
7534 | ||
7158eae4 UD |
7535 | % Do the @verb magic: verbatim text is quoted by unique |
7536 | % delimiter characters. Before first delimiter expect a | |
366d6851 UD |
7537 | % right brace, after last delimiter expect closing brace: |
7538 | % | |
7539 | % \def\doverb'{'<char>#1<char>'}'{#1} | |
7540 | % | |
7541 | % [Knuth] p. 382; only eat outer {} | |
7542 | \begingroup | |
82d5ce1d | 7543 | \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other |
366d6851 UD |
7544 | \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] |
7545 | \endgroup | |
7546 | % | |
7547 | \def\verb{\begingroup\setupverb\doverb} | |
7548 | % | |
7549 | % | |
7550 | % Do the @verbatim magic: define the macro \doverbatim so that | |
7551 | % the (first) argument ends when '@end verbatim' is reached, ie: | |
7552 | % | |
7553 | % \def\doverbatim#1@end verbatim{#1} | |
7554 | % | |
7158eae4 | 7555 | % For Texinfo it's a lot easier than for LaTeX, |
366d6851 | 7556 | % because texinfo's \verbatim doesn't stop at '\end{verbatim}': |
2f5b1124 | 7557 | % we need not redefine '\', '{' and '}'. |
366d6851 UD |
7558 | % |
7559 | % Inspired by LaTeX's verbatim command set [latex.ltx] | |
2f5b1124 | 7560 | % |
366d6851 UD |
7561 | \begingroup |
7562 | \catcode`\ =\active | |
2f5b1124 UD |
7563 | \obeylines % |
7564 | % ignore everything up to the first ^^M, that's the newline at the end | |
7565 | % of the @verbatim input line itself. Otherwise we get an extra blank | |
7566 | % line in the output. | |
82d5ce1d UD |
7567 | \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% |
7568 | % We really want {...\end verbatim} in the body of the macro, but | |
7569 | % without the active space; thus we have to use \xdef and \gobble. | |
366d6851 UD |
7570 | \endgroup |
7571 | % | |
82d5ce1d UD |
7572 | \envdef\verbatim{% |
7573 | \setupverbatim\doverbatim | |
366d6851 | 7574 | } |
82d5ce1d UD |
7575 | \let\Everbatim = \afterenvbreak |
7576 | ||
366d6851 UD |
7577 | |
7578 | % @verbatiminclude FILE - insert text of file in verbatim environment. | |
7579 | % | |
82d5ce1d | 7580 | \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} |
366d6851 UD |
7581 | % |
7582 | \def\doverbatiminclude#1{% | |
82d5ce1d UD |
7583 | {% |
7584 | \makevalueexpandable | |
7585 | \setupverbatim | |
0f8bbd69 JM |
7586 | \indexnofonts % Allow `@@' and other weird things in file names. |
7587 | \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% | |
82d5ce1d UD |
7588 | \input #1 |
7589 | \afterenvbreak | |
7590 | }% | |
366d6851 UD |
7591 | } |
7592 | ||
27692f89 | 7593 | % @copying ... @end copying. |
82d5ce1d | 7594 | % Save the text away for @insertcopying later. |
7158eae4 | 7595 | % |
2f5b1124 UD |
7596 | % We save the uninterpreted tokens, rather than creating a box. |
7597 | % Saving the text in a box would be much easier, but then all the | |
7598 | % typesetting commands (@smallbook, font changes, etc.) have to be done | |
7599 | % beforehand -- and a) we want @copying to be done first in the source | |
7600 | % file; b) letting users define the frontmatter in as flexible order as | |
084e7d57 | 7601 | % possible is desirable. |
7158eae4 | 7602 | % |
82d5ce1d UD |
7603 | \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} |
7604 | \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} | |
7605 | % | |
7606 | \def\insertcopying{% | |
7607 | \begingroup | |
7608 | \parindent = 0pt % paragraph indentation looks wrong on title page | |
7609 | \scanexp\copyingtext | |
7610 | \endgroup | |
2f5b1124 | 7611 | } |
366d6851 | 7612 | |
c94f48d7 | 7613 | |
9e9f9cc2 | 7614 | \message{defuns,} |
13632cfc UD |
7615 | % @defun etc. |
7616 | ||
9e9f9cc2 KB |
7617 | \newskip\defbodyindent \defbodyindent=.4in |
7618 | \newskip\defargsindent \defargsindent=50pt | |
9e9f9cc2 | 7619 | \newskip\deflastargmargin \deflastargmargin=18pt |
c94f48d7 | 7620 | \newcount\defunpenalty |
9e9f9cc2 | 7621 | |
82d5ce1d UD |
7622 | % Start the processing of @deffn: |
7623 | \def\startdefun{% | |
7624 | \ifnum\lastpenalty<10000 | |
7625 | \medbreak | |
c94f48d7 AJ |
7626 | \defunpenalty=10003 % Will keep this @deffn together with the |
7627 | % following @def command, see below. | |
2f5b1124 | 7628 | \else |
82d5ce1d UD |
7629 | % If there are two @def commands in a row, we'll have a \nobreak, |
7630 | % which is there to keep the function description together with its | |
7631 | % header. But if there's nothing but headers, we need to allow a | |
7632 | % break somewhere. Check specifically for penalty 10002, inserted | |
c94f48d7 | 7633 | % by \printdefunline, instead of 10000, since the sectioning |
82d5ce1d UD |
7634 | % commands also insert a nobreak penalty, and we don't want to allow |
7635 | % a break between a section heading and a defun. | |
c94f48d7 | 7636 | % |
0f8bbd69 | 7637 | % As a further refinement, we avoid "club" headers by signalling |
c94f48d7 AJ |
7638 | % with penalty of 10003 after the very first @deffn in the |
7639 | % sequence (see above), and penalty of 10002 after any following | |
7640 | % @def command. | |
7641 | \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi | |
82d5ce1d UD |
7642 | % |
7643 | % Similarly, after a section heading, do not allow a break. | |
7644 | % But do insert the glue. | |
7645 | \medskip % preceded by discardable penalty, so not a breakpoint | |
2f5b1124 UD |
7646 | \fi |
7647 | % | |
27692f89 UD |
7648 | \parindent=0in |
7649 | \advance\leftskip by \defbodyindent | |
7650 | \exdentamount=\defbodyindent | |
7651 | } | |
7652 | ||
82d5ce1d UD |
7653 | \def\dodefunx#1{% |
7654 | % First, check whether we are in the right environment: | |
7655 | \checkenv#1% | |
0ecb606c | 7656 | % |
82d5ce1d UD |
7657 | % As above, allow line break if we have multiple x headers in a row. |
7658 | % It's not a great place, though. | |
c94f48d7 | 7659 | \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi |
82d5ce1d UD |
7660 | % |
7661 | % And now, it's time to reuse the body of the original defun: | |
7662 | \expandafter\gobbledefun#1% | |
2f5b1124 | 7663 | } |
82d5ce1d | 7664 | \def\gobbledefun#1\startdefun{} |
2f5b1124 | 7665 | |
82d5ce1d | 7666 | % \printdefunline \deffnheader{text} |
27692f89 | 7667 | % |
82d5ce1d UD |
7668 | \def\printdefunline#1#2{% |
7669 | \begingroup | |
7670 | % call \deffnheader: | |
7671 | #1#2 \endheader | |
7672 | % common ending: | |
7673 | \interlinepenalty = 10000 | |
0f8bbd69 | 7674 | \advance\rightskip by 0pt plus 1fil\relax |
82d5ce1d UD |
7675 | \endgraf |
7676 | \nobreak\vskip -\parskip | |
c94f48d7 | 7677 | \penalty\defunpenalty % signal to \startdefun and \dodefunx |
82d5ce1d UD |
7678 | % Some of the @defun-type tags do not enable magic parentheses, |
7679 | % rendering the following check redundant. But we don't optimize. | |
7680 | \checkparencounts | |
7681 | \endgroup | |
27692f89 UD |
7682 | } |
7683 | ||
82d5ce1d | 7684 | \def\Edefun{\endgraf\medbreak} |
9e9f9cc2 | 7685 | |
82d5ce1d | 7686 | % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; |
0f8bbd69 | 7687 | % the only thing remaining is to define \deffnheader. |
b710a6e2 | 7688 | % |
82d5ce1d UD |
7689 | \def\makedefun#1{% |
7690 | \expandafter\let\csname E#1\endcsname = \Edefun | |
7691 | \edef\temp{\noexpand\domakedefun | |
7692 | \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% | |
7693 | \temp | |
27692f89 | 7694 | } |
3b82ab1c | 7695 | |
084e7d57 | 7696 | % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) } |
7158eae4 | 7697 | % |
82d5ce1d UD |
7698 | % Define \deffn and \deffnx, without parameters. |
7699 | % \deffnheader has to be defined explicitly. | |
10dc2a90 | 7700 | % |
82d5ce1d UD |
7701 | \def\domakedefun#1#2#3{% |
7702 | \envdef#1{% | |
7703 | \startdefun | |
0f8bbd69 | 7704 | \doingtypefnfalse % distinguish typed functions from all else |
82d5ce1d UD |
7705 | \parseargusing\activeparens{\printdefunline#3}% |
7706 | }% | |
7707 | \def#2{\dodefunx#1}% | |
7708 | \def#3% | |
a334319f UD |
7709 | } |
7710 | ||
0f8bbd69 JM |
7711 | \newif\ifdoingtypefn % doing typed function? |
7712 | \newif\ifrettypeownline % typeset return type on its own line? | |
7713 | ||
7714 | % @deftypefnnewline on|off says whether the return type of typed functions | |
7715 | % are printed on their own line. This affects @deftypefn, @deftypefun, | |
7716 | % @deftypeop, and @deftypemethod. | |
7717 | % | |
7718 | \parseargdef\deftypefnnewline{% | |
7719 | \def\temp{#1}% | |
7720 | \ifx\temp\onword | |
7721 | \expandafter\let\csname SETtxideftypefnnl\endcsname | |
7722 | = \empty | |
7723 | \else\ifx\temp\offword | |
7724 | \expandafter\let\csname SETtxideftypefnnl\endcsname | |
7725 | = \relax | |
7726 | \else | |
7727 | \errhelp = \EMsimple | |
7728 | \errmessage{Unknown @txideftypefnnl value `\temp', | |
7729 | must be on|off}% | |
7730 | \fi\fi | |
7731 | } | |
7732 | ||
7733 | % Untyped functions: | |
27692f89 | 7734 | |
82d5ce1d UD |
7735 | % @deffn category name args |
7736 | \makedefun{deffn}{\deffngeneral{}} | |
9e9f9cc2 | 7737 | |
82d5ce1d UD |
7738 | % @deffn category class name args |
7739 | \makedefun{defop}#1 {\defopon{#1\ \putwordon}} | |
9e9f9cc2 | 7740 | |
82d5ce1d UD |
7741 | % \defopon {category on}class name args |
7742 | \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } | |
9e9f9cc2 | 7743 | |
82d5ce1d | 7744 | % \deffngeneral {subind}category name args |
a334319f | 7745 | % |
82d5ce1d UD |
7746 | \def\deffngeneral#1#2 #3 #4\endheader{% |
7747 | % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. | |
7748 | \dosubind{fn}{\code{#3}}{#1}% | |
7749 | \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% | |
a334319f | 7750 | } |
9e9f9cc2 | 7751 | |
0f8bbd69 | 7752 | % Typed functions: |
9e9f9cc2 | 7753 | |
82d5ce1d UD |
7754 | % @deftypefn category type name args |
7755 | \makedefun{deftypefn}{\deftypefngeneral{}} | |
9e9f9cc2 | 7756 | |
82d5ce1d UD |
7757 | % @deftypeop category class type name args |
7758 | \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} | |
9e9f9cc2 | 7759 | |
82d5ce1d UD |
7760 | % \deftypeopon {category on}class type name args |
7761 | \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } | |
a334319f | 7762 | |
82d5ce1d UD |
7763 | % \deftypefngeneral {subind}category type name args |
7764 | % | |
7765 | \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% | |
7766 | \dosubind{fn}{\code{#4}}{#1}% | |
0f8bbd69 | 7767 | \doingtypefntrue |
82d5ce1d | 7768 | \defname{#2}{#3}{#4}\defunargs{#5\unskip}% |
9e9f9cc2 KB |
7769 | } |
7770 | ||
0f8bbd69 | 7771 | % Typed variables: |
a334319f | 7772 | |
82d5ce1d UD |
7773 | % @deftypevr category type var args |
7774 | \makedefun{deftypevr}{\deftypecvgeneral{}} | |
9e9f9cc2 | 7775 | |
82d5ce1d UD |
7776 | % @deftypecv category class type var args |
7777 | \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} | |
9e9f9cc2 | 7778 | |
82d5ce1d UD |
7779 | % \deftypecvof {category of}class type var args |
7780 | \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } | |
9e9f9cc2 | 7781 | |
82d5ce1d UD |
7782 | % \deftypecvgeneral {subind}category type var args |
7783 | % | |
7784 | \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% | |
7785 | \dosubind{vr}{\code{#4}}{#1}% | |
7786 | \defname{#2}{#3}{#4}\defunargs{#5\unskip}% | |
9e9f9cc2 KB |
7787 | } |
7788 | ||
0f8bbd69 | 7789 | % Untyped variables: |
9e9f9cc2 | 7790 | |
82d5ce1d UD |
7791 | % @defvr category var args |
7792 | \makedefun{defvr}#1 {\deftypevrheader{#1} {} } | |
a334319f | 7793 | |
82d5ce1d UD |
7794 | % @defcv category class var args |
7795 | \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} | |
a334319f | 7796 | |
82d5ce1d UD |
7797 | % \defcvof {category of}class var args |
7798 | \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } | |
9e9f9cc2 | 7799 | |
0f8bbd69 JM |
7800 | % Types: |
7801 | ||
82d5ce1d UD |
7802 | % @deftp category name args |
7803 | \makedefun{deftp}#1 #2 #3\endheader{% | |
7804 | \doind{tp}{\code{#2}}% | |
7805 | \defname{#1}{}{#2}\defunargs{#3\unskip}% | |
9e9f9cc2 KB |
7806 | } |
7807 | ||
82d5ce1d UD |
7808 | % Remaining @defun-like shortcuts: |
7809 | \makedefun{defun}{\deffnheader{\putwordDeffunc} } | |
7810 | \makedefun{defmac}{\deffnheader{\putwordDefmac} } | |
7811 | \makedefun{defspec}{\deffnheader{\putwordDefspec} } | |
7812 | \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } | |
7813 | \makedefun{defvar}{\defvrheader{\putwordDefvar} } | |
7814 | \makedefun{defopt}{\defvrheader{\putwordDefopt} } | |
7815 | \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } | |
7816 | \makedefun{defmethod}{\defopon\putwordMethodon} | |
7817 | \makedefun{deftypemethod}{\deftypeopon\putwordMethodon} | |
7818 | \makedefun{defivar}{\defcvof\putwordInstanceVariableof} | |
7819 | \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} | |
9e9f9cc2 | 7820 | |
82d5ce1d UD |
7821 | % \defname, which formats the name of the @def (not the args). |
7822 | % #1 is the category, such as "Function". | |
7823 | % #2 is the return type, if any. | |
7824 | % #3 is the function name. | |
13632cfc | 7825 | % |
82d5ce1d | 7826 | % We are followed by (but not passed) the arguments, if any. |
13632cfc | 7827 | % |
82d5ce1d | 7828 | \def\defname#1#2#3{% |
0f8bbd69 | 7829 | \par |
82d5ce1d UD |
7830 | % Get the values of \leftskip and \rightskip as they were outside the @def... |
7831 | \advance\leftskip by -\defbodyindent | |
7832 | % | |
0f8bbd69 JM |
7833 | % Determine if we are typesetting the return type of a typed function |
7834 | % on a line by itself. | |
7835 | \rettypeownlinefalse | |
7836 | \ifdoingtypefn % doing a typed function specifically? | |
7837 | % then check user option for putting return type on its own line: | |
7838 | \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else | |
7839 | \rettypeownlinetrue | |
7840 | \fi | |
7841 | \fi | |
7842 | % | |
7843 | % How we'll format the category name. Putting it in brackets helps | |
82d5ce1d UD |
7844 | % distinguish it from the body text that may end up on the next line |
7845 | % just below it. | |
7846 | \def\temp{#1}% | |
7847 | \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} | |
7848 | % | |
0f8bbd69 JM |
7849 | % Figure out line sizes for the paragraph shape. We'll always have at |
7850 | % least two. | |
7851 | \tempnum = 2 | |
7852 | % | |
82d5ce1d UD |
7853 | % The first line needs space for \box0; but if \rightskip is nonzero, |
7854 | % we need only space for the part of \box0 which exceeds it: | |
7855 | \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip | |
0f8bbd69 JM |
7856 | % |
7857 | % If doing a return type on its own line, we'll have another line. | |
7858 | \ifrettypeownline | |
7859 | \advance\tempnum by 1 | |
7860 | \def\maybeshapeline{0in \hsize}% | |
7861 | \else | |
7862 | \def\maybeshapeline{}% | |
7863 | \fi | |
7864 | % | |
82d5ce1d UD |
7865 | % The continuations: |
7866 | \dimen2=\hsize \advance\dimen2 by -\defargsindent | |
82d5ce1d | 7867 | % |
0f8bbd69 JM |
7868 | % The final paragraph shape: |
7869 | \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 | |
7870 | % | |
7871 | % Put the category name at the right margin. | |
82d5ce1d UD |
7872 | \noindent |
7873 | \hbox to 0pt{% | |
7874 | \hfil\box0 \kern-\hsize | |
7875 | % \hsize has to be shortened this way: | |
7876 | \kern\leftskip | |
7877 | % Intentionally do not respect \rightskip, since we need the space. | |
7878 | }% | |
7879 | % | |
7880 | % Allow all lines to be underfull without complaint: | |
7881 | \tolerance=10000 \hbadness=10000 | |
7882 | \exdentamount=\defbodyindent | |
7883 | {% | |
7884 | % defun fonts. We use typewriter by default (used to be bold) because: | |
7885 | % . we're printing identifiers, they should be in tt in principle. | |
7886 | % . in languages with many accents, such as Czech or French, it's | |
7887 | % common to leave accents off identifiers. The result looks ok in | |
7888 | % tt, but exceedingly strange in rm. | |
7889 | % . we don't want -- and --- to be treated as ligatures. | |
7890 | % . this still does not fix the ?` and !` ligatures, but so far no | |
7891 | % one has made identifiers using them :). | |
7892 | \df \tt | |
0f8bbd69 JM |
7893 | \def\temp{#2}% text of the return type |
7894 | \ifx\temp\empty\else | |
7895 | \tclose{\temp}% typeset the return type | |
7896 | \ifrettypeownline | |
7897 | % put return type on its own line; prohibit line break following: | |
7898 | \hfil\vadjust{\nobreak}\break | |
7899 | \else | |
7900 | \space % type on same line, so just followed by a space | |
7901 | \fi | |
7902 | \fi % no return type | |
82d5ce1d UD |
7903 | #3% output function name |
7904 | }% | |
7f7dd1d3 | 7905 | {\rm\enskip}% hskip 0.5 em of \rmfont |
82d5ce1d UD |
7906 | % |
7907 | \boldbrax | |
7908 | % arguments will be output next, if any. | |
9e9f9cc2 KB |
7909 | } |
7910 | ||
82d5ce1d UD |
7911 | % Print arguments in slanted roman (not ttsl), inconsistently with using |
7912 | % tt for the name. This is because literal text is sometimes needed in | |
7913 | % the argument list (groff manual), and ttsl and tt are not very | |
7914 | % distinguishable. Prevent hyphenation at `-' chars. | |
a334319f | 7915 | % |
82d5ce1d UD |
7916 | \def\defunargs#1{% |
7917 | % use sl by default (not ttsl), | |
7918 | % tt for the names. | |
7919 | \df \sl \hyphenchar\font=0 | |
7920 | % | |
7921 | % On the other hand, if an argument has two dashes (for instance), we | |
8fcb833a JM |
7922 | % want a way to get ttsl. We used to recommend @var for that, so |
7923 | % leave the code in, but it's strange for @var to lead to typewriter. | |
7924 | % Nowadays we recommend @code, since the difference between a ttsl hyphen | |
7925 | % and a tt hyphen is pretty tiny. @code also disables ?` !`. | |
0f8bbd69 | 7926 | \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% |
82d5ce1d UD |
7927 | #1% |
7928 | \sl\hyphenchar\font=45 | |
3b82ab1c UD |
7929 | } |
7930 | ||
82d5ce1d | 7931 | % We want ()&[] to print specially on the defun line. |
a334319f | 7932 | % |
82d5ce1d UD |
7933 | \def\activeparens{% |
7934 | \catcode`\(=\active \catcode`\)=\active | |
7935 | \catcode`\[=\active \catcode`\]=\active | |
7936 | \catcode`\&=\active | |
ebbad4cc UD |
7937 | } |
7938 | ||
82d5ce1d UD |
7939 | % Make control sequences which act like normal parenthesis chars. |
7940 | \let\lparen = ( \let\rparen = ) | |
9e9f9cc2 | 7941 | |
82d5ce1d UD |
7942 | % Be sure that we always have a definition for `(', etc. For example, |
7943 | % if the fn name has parens in it, \boldbrax will not be in effect yet, | |
7944 | % so TeX would otherwise complain about undefined control sequence. | |
7945 | { | |
7946 | \activeparens | |
7947 | \global\let(=\lparen \global\let)=\rparen | |
7948 | \global\let[=\lbrack \global\let]=\rbrack | |
7949 | \global\let& = \& | |
9e9f9cc2 | 7950 | |
82d5ce1d UD |
7951 | \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} |
7952 | \gdef\magicamp{\let&=\amprm} | |
7953 | } | |
9e9f9cc2 | 7954 | |
82d5ce1d | 7955 | \newcount\parencount |
9e9f9cc2 | 7956 | |
82d5ce1d UD |
7957 | % If we encounter &foo, then turn on ()-hacking afterwards |
7958 | \newif\ifampseen | |
7959 | \def\amprm#1 {\ampseentrue{\bf\ }} | |
7960 | ||
7961 | \def\parenfont{% | |
7962 | \ifampseen | |
7963 | % At the first level, print parens in roman, | |
7964 | % otherwise use the default font. | |
7965 | \ifnum \parencount=1 \rm \fi | |
7966 | \else | |
7967 | % The \sf parens (in \boldbrax) actually are a little bolder than | |
7968 | % the contained text. This is especially needed for [ and ] . | |
7969 | \sf | |
7970 | \fi | |
9e9f9cc2 | 7971 | } |
82d5ce1d UD |
7972 | \def\infirstlevel#1{% |
7973 | \ifampseen | |
7974 | \ifnum\parencount=1 | |
7975 | #1% | |
7976 | \fi | |
7977 | \fi | |
9e9f9cc2 | 7978 | } |
82d5ce1d | 7979 | \def\bfafterword#1 {#1 \bf} |
9e9f9cc2 | 7980 | |
82d5ce1d UD |
7981 | \def\opnr{% |
7982 | \global\advance\parencount by 1 | |
7983 | {\parenfont(}% | |
7984 | \infirstlevel \bfafterword | |
0ecb606c | 7985 | } |
82d5ce1d UD |
7986 | \def\clnr{% |
7987 | {\parenfont)}% | |
7988 | \infirstlevel \sl | |
7989 | \global\advance\parencount by -1 | |
0ecb606c | 7990 | } |
a334319f | 7991 | |
82d5ce1d UD |
7992 | \newcount\brackcount |
7993 | \def\lbrb{% | |
7994 | \global\advance\brackcount by 1 | |
7995 | {\bf[}% | |
7996 | } | |
7997 | \def\rbrb{% | |
7998 | {\bf]}% | |
7999 | \global\advance\brackcount by -1 | |
0ecb606c | 8000 | } |
9e9f9cc2 | 8001 | |
82d5ce1d UD |
8002 | \def\checkparencounts{% |
8003 | \ifnum\parencount=0 \else \badparencount \fi | |
8004 | \ifnum\brackcount=0 \else \badbrackcount \fi | |
8005 | } | |
c94f48d7 AJ |
8006 | % these should not use \errmessage; the glibc manual, at least, actually |
8007 | % has such constructs (when documenting function pointers). | |
82d5ce1d | 8008 | \def\badparencount{% |
c94f48d7 | 8009 | \message{Warning: unbalanced parentheses in @def...}% |
82d5ce1d UD |
8010 | \global\parencount=0 |
8011 | } | |
8012 | \def\badbrackcount{% | |
c94f48d7 | 8013 | \message{Warning: unbalanced square brackets in @def...}% |
82d5ce1d UD |
8014 | \global\brackcount=0 |
8015 | } | |
a334319f | 8016 | |
d66b7b41 | 8017 | |
f962d792 UD |
8018 | \message{macros,} |
8019 | % @macro. | |
f962d792 | 8020 | |
b710a6e2 | 8021 | % To do this right we need a feature of e-TeX, \scantokens, |
0c2b5752 | 8022 | % which we arrange to emulate with a temporary file in ordinary TeX. |
0f8bbd69 | 8023 | \ifx\eTeXversion\thisisundefined |
82d5ce1d UD |
8024 | \newwrite\macscribble |
8025 | \def\scantokens#1{% | |
8026 | \toks0={#1}% | |
8027 | \immediate\openout\macscribble=\jobname.tmp | |
8028 | \immediate\write\macscribble{\the\toks0}% | |
8029 | \immediate\closeout\macscribble | |
8030 | \input \jobname.tmp | |
8031 | } | |
a334319f | 8032 | \fi |
0ecb606c | 8033 | |
084e7d57 JM |
8034 | \let\aftermacroxxx\relax |
8035 | \def\aftermacro{\aftermacroxxx} | |
8036 | ||
8037 | % alias because \c means cedilla in @tex or @math | |
8038 | \let\texinfoc=\c | |
8039 | ||
7f7dd1d3 JM |
8040 | \newcount\savedcatcodeone |
8041 | \newcount\savedcatcodetwo | |
8042 | ||
084e7d57 JM |
8043 | % Used at the time of macro expansion. |
8044 | % Argument is macro body with arguments substituted | |
8045 | \def\scanmacro#1{% | |
0f8bbd69 | 8046 | \newlinechar`\^^M |
7f7dd1d3 JM |
8047 | \def\xeatspaces{\eatspaces}% |
8048 | % | |
8049 | % Temporarily undo catcode changes of \printindex. Set catcode of @ to | |
8050 | % 0 so that @-commands in macro expansions aren't printed literally when | |
8051 | % formatting an index file, where \ is used as the escape character. | |
8052 | \savedcatcodeone=\catcode`\@ | |
8053 | \savedcatcodetwo=\catcode`\\ | |
8054 | \catcode`\@=0 | |
8055 | \catcode`\\=\active | |
0f8bbd69 | 8056 | % |
084e7d57 | 8057 | % Process the macro body under the current catcode regime. |
7f7dd1d3 JM |
8058 | \scantokens{#1@texinfoc}\aftermacro% |
8059 | % | |
8060 | \catcode`\@=\savedcatcodeone | |
8061 | \catcode`\\=\savedcatcodetwo | |
0f8bbd69 | 8062 | % |
7f7dd1d3 | 8063 | % The \texinfoc is to remove the \newlinechar added by \scantokens, and |
084e7d57 JM |
8064 | % can be noticed by \parsearg. |
8065 | % The \aftermacro allows a \comment at the end of the macro definition | |
8066 | % to duplicate itself past the final \newlinechar added by \scantokens: | |
8067 | % this is used in the definition of \group to comment out a newline. We | |
8068 | % don't do the same for \c to support Texinfo files with macros that ended | |
8069 | % with a @c, which should no longer be necessary. | |
8070 | % We avoid surrounding the call to \scantokens with \bgroup and \egroup | |
8071 | % to allow macros to open or close groups themselves. | |
8072 | } | |
82d5ce1d | 8073 | |
084e7d57 | 8074 | % Used for copying and captions |
82d5ce1d | 8075 | \def\scanexp#1{% |
7f7dd1d3 | 8076 | \expandafter\scanmacro\expandafter{#1}% |
82d5ce1d UD |
8077 | } |
8078 | ||
0c2b5752 UD |
8079 | \newcount\paramno % Count of parameters |
8080 | \newtoks\macname % Macro name | |
8081 | \newif\ifrecursive % Is it recursive? | |
9251c568 AJ |
8082 | |
8083 | % List of all defined macros in the form | |
7f7dd1d3 | 8084 | % \commondummyword\macro1\commondummyword\macro2... |
9251c568 AJ |
8085 | % Currently is also contains all @aliases; the list can be split |
8086 | % if there is a need. | |
8087 | \def\macrolist{} | |
8088 | ||
8089 | % Add the macro to \macrolist | |
8090 | \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} | |
8091 | \def\addtomacrolistxxx#1{% | |
7f7dd1d3 | 8092 | \toks0 = \expandafter{\macrolist\commondummyword#1}% |
9251c568 AJ |
8093 | \xdef\macrolist{\the\toks0}% |
8094 | } | |
f962d792 | 8095 | |
61027f30 | 8096 | % Utility routines. |
82d5ce1d UD |
8097 | % This does \let #1 = #2, with \csnames; that is, |
8098 | % \let \csname#1\endcsname = \csname#2\endcsname | |
8099 | % (except of course we have to play expansion games). | |
0f8bbd69 | 8100 | % |
f962d792 | 8101 | \def\cslet#1#2{% |
82d5ce1d UD |
8102 | \expandafter\let |
8103 | \csname#1\expandafter\endcsname | |
8104 | \csname#2\endcsname | |
8105 | } | |
f962d792 | 8106 | |
61027f30 UD |
8107 | % Trim leading and trailing spaces off a string. |
8108 | % Concepts from aro-bend problem 15 (see CTAN). | |
8109 | {\catcode`\@=11 | |
8110 | \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} | |
8111 | \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} | |
8112 | \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} | |
8113 | \def\unbrace#1{#1} | |
8114 | \unbrace{\gdef\trim@@@ #1 } #2@{#1} | |
8115 | } | |
8116 | ||
8117 | % Trim a single trailing ^^M off a string. | |
e0f86659 | 8118 | {\catcode`\^^M=\other \catcode`\Q=3% |
61027f30 UD |
8119 | \gdef\eatcr #1{\eatcra #1Q^^MQ}% |
8120 | \gdef\eatcra#1^^MQ{\eatcrb#1Q}% | |
8121 | \gdef\eatcrb#1Q#2Q{#1}% | |
8122 | } | |
8123 | ||
0c2b5752 UD |
8124 | % Macro bodies are absorbed as an argument in a context where |
8125 | % all characters are catcode 10, 11 or 12, except \ which is active | |
0f8bbd69 JM |
8126 | % (as in normal texinfo). It is necessary to change the definition of \ |
8127 | % to recognize macro arguments; this is the job of \mbodybackslash. | |
8128 | % | |
c94f48d7 AJ |
8129 | % Non-ASCII encodings make 8-bit characters active, so un-activate |
8130 | % them to avoid their expansion. Must do this non-globally, to | |
8131 | % confine the change to the current group. | |
0f8bbd69 | 8132 | % |
a334319f | 8133 | % It's necessary to have hard CRs when the macro is executed. This is |
0f8bbd69 | 8134 | % done by making ^^M (\endlinechar) catcode 12 when reading the macro |
a334319f | 8135 | % body, and then making it the \newlinechar in \scanmacro. |
0f8bbd69 JM |
8136 | % |
8137 | \def\scanctxt{% used as subroutine | |
82d5ce1d UD |
8138 | \catcode`\"=\other |
8139 | \catcode`\+=\other | |
8140 | \catcode`\<=\other | |
8141 | \catcode`\>=\other | |
a334319f UD |
8142 | \catcode`\^=\other |
8143 | \catcode`\_=\other | |
8144 | \catcode`\|=\other | |
82d5ce1d | 8145 | \catcode`\~=\other |
7f7dd1d3 | 8146 | \passthroughcharstrue |
82d5ce1d UD |
8147 | } |
8148 | ||
0f8bbd69 | 8149 | \def\scanargctxt{% used for copying and captions, not macros. |
82d5ce1d | 8150 | \scanctxt |
084e7d57 | 8151 | \catcode`\@=\other |
82d5ce1d UD |
8152 | \catcode`\\=\other |
8153 | \catcode`\^^M=\other | |
8154 | } | |
8155 | ||
0f8bbd69 | 8156 | \def\macrobodyctxt{% used for @macro definitions |
82d5ce1d | 8157 | \scanctxt |
084e7d57 JM |
8158 | \catcode`\ =\other |
8159 | \catcode`\@=\other | |
e0f86659 UD |
8160 | \catcode`\{=\other |
8161 | \catcode`\}=\other | |
e0f86659 | 8162 | \catcode`\^^M=\other |
82d5ce1d UD |
8163 | \usembodybackslash |
8164 | } | |
0c2b5752 | 8165 | |
084e7d57 JM |
8166 | % Used when scanning braced macro arguments. Note, however, that catcode |
8167 | % changes here are ineffectual if the macro invocation was nested inside | |
8168 | % an argument to another Texinfo command. | |
8169 | \def\macroargctxt{% | |
82d5ce1d | 8170 | \scanctxt |
084e7d57 JM |
8171 | \catcode`\ =\active |
8172 | \catcode`\^^M=\other | |
8173 | \catcode`\\=\active | |
82d5ce1d | 8174 | } |
0f8bbd69 | 8175 | |
084e7d57 JM |
8176 | \def\macrolineargctxt{% used for whole-line arguments without braces |
8177 | \scanctxt | |
8178 | \catcode`\{=\other | |
8179 | \catcode`\}=\other | |
8180 | } | |
1e02536f | 8181 | |
0c2b5752 | 8182 | % \mbodybackslash is the definition of \ in @macro bodies. |
b710a6e2 | 8183 | % It maps \foo\ => \csname macarg.foo\endcsname => #N |
0c2b5752 UD |
8184 | % where N is the macro parameter number. |
8185 | % We define \csname macarg.\endcsname to be \realbackslash, so | |
8186 | % \\ in macro replacement text gets you a backslash. | |
0f8bbd69 | 8187 | % |
313a1174 | 8188 | {\catcode`@=0 @catcode`@\=@active |
0c2b5752 UD |
8189 | @gdef@usembodybackslash{@let\=@mbodybackslash} |
8190 | @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} | |
8191 | } | |
8192 | \expandafter\def\csname macarg.\endcsname{\realbackslash} | |
8193 | ||
0f8bbd69 JM |
8194 | \def\margbackslash#1{\char`\#1 } |
8195 | ||
313a1174 UD |
8196 | \def\macro{\recursivefalse\parsearg\macroxxx} |
8197 | \def\rmacro{\recursivetrue\parsearg\macroxxx} | |
8198 | ||
8199 | \def\macroxxx#1{% | |
0f8bbd69 | 8200 | \getargs{#1}% now \macname is the macname and \argl the arglist |
313a1174 | 8201 | \ifx\argl\empty % no arguments |
0f8bbd69 | 8202 | \paramno=0\relax |
f962d792 | 8203 | \else |
b710a6e2 | 8204 | \expandafter\parsemargdef \argl;% |
0f8bbd69 JM |
8205 | \if\paramno>256\relax |
8206 | \ifx\eTeXversion\thisisundefined | |
8207 | \errhelp = \EMsimple | |
8208 | \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} | |
8209 | \fi | |
8210 | \fi | |
f962d792 | 8211 | \fi |
b1418d8f | 8212 | \if1\csname ismacro.\the\macname\endcsname |
0c2b5752 | 8213 | \message{Warning: redefining \the\macname}% |
b1418d8f UD |
8214 | \else |
8215 | \expandafter\ifx\csname \the\macname\endcsname \relax | |
27692f89 | 8216 | \else \errmessage{Macro name \the\macname\space already defined}\fi |
b1418d8f UD |
8217 | \global\cslet{macsave.\the\macname}{\the\macname}% |
8218 | \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% | |
9251c568 | 8219 | \addtomacrolist{\the\macname}% |
f962d792 | 8220 | \fi |
0c2b5752 UD |
8221 | \begingroup \macrobodyctxt |
8222 | \ifrecursive \expandafter\parsermacbody | |
b710a6e2 | 8223 | \else \expandafter\parsemacbody |
0c2b5752 UD |
8224 | \fi} |
8225 | ||
82d5ce1d | 8226 | \parseargdef\unmacro{% |
b1418d8f UD |
8227 | \if1\csname ismacro.#1\endcsname |
8228 | \global\cslet{#1}{macsave.#1}% | |
8229 | \global\expandafter\let \csname ismacro.#1\endcsname=0% | |
e0f86659 | 8230 | % Remove the macro name from \macrolist: |
b1418d8f | 8231 | \begingroup |
e0f86659 | 8232 | \expandafter\let\csname#1\endcsname \relax |
7f7dd1d3 | 8233 | \let\commondummyword\unmacrodo |
e0f86659 | 8234 | \xdef\macrolist{\macrolist}% |
b1418d8f | 8235 | \endgroup |
f962d792 | 8236 | \else |
b1418d8f | 8237 | \errmessage{Macro #1 not defined}% |
f962d792 | 8238 | \fi |
0c2b5752 UD |
8239 | } |
8240 | ||
e0f86659 UD |
8241 | % Called by \do from \dounmacro on each macro. The idea is to omit any |
8242 | % macro definitions that have been changed to \relax. | |
7158eae4 | 8243 | % |
e0f86659 | 8244 | \def\unmacrodo#1{% |
9251c568 | 8245 | \ifx #1\relax |
e0f86659 UD |
8246 | % remove this |
8247 | \else | |
7f7dd1d3 | 8248 | \noexpand\commondummyword \noexpand#1% |
e0f86659 UD |
8249 | \fi |
8250 | } | |
8251 | ||
084e7d57 JM |
8252 | % \getargs -- Parse the arguments to a @macro line. Set \macname to |
8253 | % the name of the macro, and \argl to the braced argument list. | |
313a1174 UD |
8254 | \def\getargs#1{\getargsxxx#1{}} |
8255 | \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} | |
0f8bbd69 | 8256 | \def\getmacname#1 #2\relax{\macname={#1}} |
313a1174 | 8257 | \def\getmacargs#1{\def\argl{#1}} |
084e7d57 JM |
8258 | % This made use of the feature that if the last token of a |
8259 | % <parameter list> is #, then the preceding argument is delimited by | |
8260 | % an opening brace, and that opening brace is not consumed. | |
313a1174 | 8261 | |
084e7d57 JM |
8262 | % Parse the optional {params} list to @macro or @rmacro. |
8263 | % Set \paramno to the number of arguments, | |
8264 | % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a | |
8265 | % three-param macro.) Define \macarg.BLAH for each BLAH in the params | |
8266 | % list to some hook where the argument is to be expanded. If there are | |
8267 | % less than 10 arguments that hook is to be replaced by ##N where N | |
0f8bbd69 JM |
8268 | % is the position in that list, that is to say the macro arguments are to be |
8269 | % defined `a la TeX in the macro body. | |
8270 | % | |
0c2b5752 | 8271 | % That gets used by \mbodybackslash (above). |
0f8bbd69 | 8272 | % |
084e7d57 JM |
8273 | % If there are 10 or more arguments, a different technique is used: see |
8274 | % \parsemmanyargdef. | |
61027f30 | 8275 | % |
0f8bbd69 JM |
8276 | \def\parsemargdef#1;{% |
8277 | \paramno=0\def\paramlist{}% | |
8278 | \let\hash\relax | |
084e7d57 | 8279 | % \hash is redefined to `#' later to get it into definitions |
7f7dd1d3 | 8280 | \let\xeatspaces\relax |
0f8bbd69 | 8281 | \parsemargdefxxx#1,;,% |
0f8bbd69 JM |
8282 | \ifnum\paramno<10\relax\else |
8283 | \paramno0\relax | |
8284 | \parsemmanyargdef@@#1,;,% 10 or more arguments | |
8285 | \fi | |
8286 | } | |
0c2b5752 | 8287 | \def\parsemargdefxxx#1,{% |
313a1174 | 8288 | \if#1;\let\next=\relax |
0c2b5752 | 8289 | \else \let\next=\parsemargdefxxx |
0f8bbd69 | 8290 | \advance\paramno by 1 |
61027f30 | 8291 | \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname |
7f7dd1d3 | 8292 | {\xeatspaces{\hash\the\paramno}}% |
313a1174 | 8293 | \edef\paramlist{\paramlist\hash\the\paramno,}% |
0c2b5752 | 8294 | \fi\next} |
0c2b5752 | 8295 | |
084e7d57 JM |
8296 | % \parsemacbody, \parsermacbody |
8297 | % | |
8298 | % Read recursive and nonrecursive macro bodies. (They're different since | |
8299 | % rec and nonrec macros end differently.) | |
8300 | % | |
8301 | % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro | |
8302 | % body to be transformed. | |
8303 | % Set \macrobody to the body of the macro, and call \defmacro. | |
8304 | % | |
8305 | {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{% | |
8306 | \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% | |
8307 | {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{% | |
8308 | \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% | |
8309 | ||
8310 | % Make @ a letter, so that we can make private-to-Texinfo macro names. | |
8311 | \edef\texiatcatcode{\the\catcode`\@} | |
8312 | \catcode `@=11\relax | |
8313 | ||
8314 | %%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%% | |
8315 | ||
8316 | % If there are 10 or more arguments, a different technique is used, where the | |
8317 | % hook remains in the body, and when macro is to be expanded the body is | |
8318 | % processed again to replace the arguments. | |
8319 | % | |
8320 | % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the | |
8321 | % argument N value and then \edef the body (nothing else will expand because of | |
8322 | % the catcode regime under which the body was input). | |
8323 | % | |
8324 | % If you compile with TeX (not eTeX), and you have macros with 10 or more | |
8325 | % arguments, no macro can have more than 256 arguments (else error). | |
8326 | % | |
8327 | % In case that there are 10 or more arguments we parse again the arguments | |
8328 | % list to set new definitions for the \macarg.BLAH macros corresponding to | |
8329 | % each BLAH argument. It was anyhow needed to parse already once this list | |
8330 | % in order to count the arguments, and as macros with at most 9 arguments | |
8331 | % are by far more frequent than macro with 10 or more arguments, defining | |
8332 | % twice the \macarg.BLAH macros does not cost too much processing power. | |
0f8bbd69 JM |
8333 | \def\parsemmanyargdef@@#1,{% |
8334 | \if#1;\let\next=\relax | |
8335 | \else | |
8336 | \let\next=\parsemmanyargdef@@ | |
8337 | \edef\tempb{\eatspaces{#1}}% | |
8338 | \expandafter\def\expandafter\tempa | |
8339 | \expandafter{\csname macarg.\tempb\endcsname}% | |
8340 | % Note that we need some extra \noexpand\noexpand, this is because we | |
8341 | % don't want \the to be expanded in the \parsermacbody as it uses an | |
8342 | % \xdef . | |
8343 | \expandafter\edef\tempa | |
8344 | {\noexpand\noexpand\noexpand\the\toks\the\paramno}% | |
8345 | \advance\paramno by 1\relax | |
8346 | \fi\next} | |
8347 | ||
0f8bbd69 JM |
8348 | |
8349 | \let\endargs@\relax | |
8350 | \let\nil@\relax | |
8351 | \def\nilm@{\nil@}% | |
8352 | \long\def\nillm@{\nil@}% | |
8353 | ||
8354 | % This macro is expanded during the Texinfo macro expansion, not during its | |
084e7d57 | 8355 | % definition. It gets all the arguments' values and assigns them to macros |
0f8bbd69 JM |
8356 | % macarg.ARGNAME |
8357 | % | |
8358 | % #1 is the macro name | |
8359 | % #2 is the list of argument names | |
8360 | % #3 is the list of argument values | |
8361 | \def\getargvals@#1#2#3{% | |
8362 | \def\macargdeflist@{}% | |
8363 | \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. | |
8364 | \def\paramlist{#2,\nil@}% | |
8365 | \def\macroname{#1}% | |
8366 | \begingroup | |
8367 | \macroargctxt | |
8368 | \def\argvaluelist{#3,\nil@}% | |
8369 | \def\@tempa{#3}% | |
8370 | \ifx\@tempa\empty | |
8371 | \setemptyargvalues@ | |
8372 | \else | |
8373 | \getargvals@@ | |
8374 | \fi | |
8375 | } | |
0f8bbd69 JM |
8376 | \def\getargvals@@{% |
8377 | \ifx\paramlist\nilm@ | |
8378 | % Some sanity check needed here that \argvaluelist is also empty. | |
8379 | \ifx\argvaluelist\nillm@ | |
8380 | \else | |
8381 | \errhelp = \EMsimple | |
8382 | \errmessage{Too many arguments in macro `\macroname'!}% | |
8383 | \fi | |
8384 | \let\next\macargexpandinbody@ | |
8385 | \else | |
8386 | \ifx\argvaluelist\nillm@ | |
8387 | % No more arguments values passed to macro. Set remaining named-arg | |
8388 | % macros to empty. | |
8389 | \let\next\setemptyargvalues@ | |
8390 | \else | |
8391 | % pop current arg name into \@tempb | |
8392 | \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% | |
8393 | \expandafter\@tempa\expandafter{\paramlist}% | |
8394 | % pop current argument value into \@tempc | |
8395 | \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% | |
8396 | \expandafter\@tempa\expandafter{\argvaluelist}% | |
8397 | % Here \@tempb is the current arg name and \@tempc is the current arg value. | |
8398 | % First place the new argument macro definition into \@tempd | |
8399 | \expandafter\macname\expandafter{\@tempc}% | |
8400 | \expandafter\let\csname macarg.\@tempb\endcsname\relax | |
8401 | \expandafter\def\expandafter\@tempe\expandafter{% | |
8402 | \csname macarg.\@tempb\endcsname}% | |
8403 | \edef\@tempd{\long\def\@tempe{\the\macname}}% | |
8404 | \push@\@tempd\macargdeflist@ | |
8405 | \let\next\getargvals@@ | |
8406 | \fi | |
8407 | \fi | |
8408 | \next | |
8409 | } | |
8410 | ||
8411 | \def\push@#1#2{% | |
8412 | \expandafter\expandafter\expandafter\def | |
8413 | \expandafter\expandafter\expandafter#2% | |
8414 | \expandafter\expandafter\expandafter{% | |
8415 | \expandafter#1#2}% | |
8416 | } | |
8417 | ||
8418 | % Replace arguments by their values in the macro body, and place the result | |
084e7d57 JM |
8419 | % in macro \@tempa. |
8420 | % | |
0f8bbd69 JM |
8421 | \def\macvalstoargs@{% |
8422 | % To do this we use the property that token registers that are \the'ed | |
8423 | % within an \edef expand only once. So we are going to place all argument | |
8424 | % values into respective token registers. | |
8425 | % | |
8426 | % First we save the token context, and initialize argument numbering. | |
8427 | \begingroup | |
8428 | \paramno0\relax | |
8429 | % Then, for each argument number #N, we place the corresponding argument | |
8430 | % value into a new token list register \toks#N | |
8431 | \expandafter\putargsintokens@\saveparamlist@,;,% | |
8432 | % Then, we expand the body so that argument are replaced by their | |
8433 | % values. The trick for values not to be expanded themselves is that they | |
8434 | % are within tokens and that tokens expand only once in an \edef . | |
8435 | \edef\@tempc{\csname mac.\macroname .body\endcsname}% | |
8436 | % Now we restore the token stack pointer to free the token list registers | |
8437 | % which we have used, but we make sure that expanded body is saved after | |
8438 | % group. | |
8439 | \expandafter | |
8440 | \endgroup | |
8441 | \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% | |
8442 | } | |
8443 | ||
084e7d57 JM |
8444 | % Define the named-macro outside of this group and then close this group. |
8445 | % | |
0f8bbd69 | 8446 | \def\macargexpandinbody@{% |
0f8bbd69 JM |
8447 | \expandafter |
8448 | \endgroup | |
8449 | \macargdeflist@ | |
8450 | % First the replace in body the macro arguments by their values, the result | |
8451 | % is in \@tempa . | |
8452 | \macvalstoargs@ | |
8453 | % Then we point at the \norecurse or \gobble (for recursive) macro value | |
8454 | % with \@tempb . | |
8455 | \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname | |
8456 | % Depending on whether it is recursive or not, we need some tailing | |
8457 | % \egroup . | |
8458 | \ifx\@tempb\gobble | |
8459 | \let\@tempc\relax | |
8460 | \else | |
8461 | \let\@tempc\egroup | |
8462 | \fi | |
8463 | % And now we do the real job: | |
8464 | \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% | |
8465 | \@tempd | |
8466 | } | |
8467 | ||
8468 | \def\putargsintokens@#1,{% | |
8469 | \if#1;\let\next\relax | |
8470 | \else | |
8471 | \let\next\putargsintokens@ | |
8472 | % First we allocate the new token list register, and give it a temporary | |
8473 | % alias \@tempb . | |
8474 | \toksdef\@tempb\the\paramno | |
8475 | % Then we place the argument value into that token list register. | |
8476 | \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname | |
8477 | \expandafter\@tempb\expandafter{\@tempa}% | |
8478 | \advance\paramno by 1\relax | |
8479 | \fi | |
8480 | \next | |
8481 | } | |
8482 | ||
084e7d57 JM |
8483 | % Trailing missing arguments are set to empty. |
8484 | % | |
0f8bbd69 JM |
8485 | \def\setemptyargvalues@{% |
8486 | \ifx\paramlist\nilm@ | |
8487 | \let\next\macargexpandinbody@ | |
8488 | \else | |
8489 | \expandafter\setemptyargvaluesparser@\paramlist\endargs@ | |
8490 | \let\next\setemptyargvalues@ | |
8491 | \fi | |
8492 | \next | |
8493 | } | |
8494 | ||
8495 | \def\setemptyargvaluesparser@#1,#2\endargs@{% | |
8496 | \expandafter\def\expandafter\@tempa\expandafter{% | |
8497 | \expandafter\def\csname macarg.#1\endcsname{}}% | |
8498 | \push@\@tempa\macargdeflist@ | |
8499 | \def\paramlist{#2}% | |
8500 | } | |
8501 | ||
8502 | % #1 is the element target macro | |
8503 | % #2 is the list macro | |
8504 | % #3,#4\endargs@ is the list value | |
8505 | \def\pop@#1#2#3,#4\endargs@{% | |
8506 | \def#1{#3}% | |
8507 | \def#2{#4}% | |
8508 | } | |
8509 | \long\def\longpop@#1#2#3,#4\endargs@{% | |
8510 | \long\def#1{#3}% | |
8511 | \long\def#2{#4}% | |
8512 | } | |
0c2b5752 | 8513 | |
084e7d57 JM |
8514 | |
8515 | %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% | |
8516 | ||
8517 | ||
084e7d57 JM |
8518 | % This defines a Texinfo @macro or @rmacro, called by \parsemacbody. |
8519 | % \macrobody has the body of the macro in it, with placeholders for | |
7f7dd1d3 | 8520 | % its parameters, looking like "\xeatspaces{\hash 1}". |
084e7d57 JM |
8521 | % \paramno is the number of parameters |
8522 | % \paramlist is a TeX parameter text, e.g. "#1,#2,#3," | |
7f7dd1d3 | 8523 | % There are four cases: macros of zero, one, up to nine, and many arguments. |
61027f30 | 8524 | % \xdef is used so that macro definitions will survive the file |
084e7d57 | 8525 | % they're defined in: @include reads the file inside a group. |
0f8bbd69 | 8526 | % |
0c2b5752 | 8527 | \def\defmacro{% |
313a1174 | 8528 | \let\hash=##% convert placeholders to macro parameter chars |
084e7d57 | 8529 | \ifnum\paramno=1 |
7f7dd1d3 | 8530 | \def\xeatspaces##1{##1}% |
084e7d57 JM |
8531 | % This removes the pair of braces around the argument. We don't |
8532 | % use \eatspaces, because this can cause ends of lines to be lost | |
8533 | % when the argument to \eatspaces is read, leading to line-based | |
8534 | % commands like "@itemize" not being read correctly. | |
8535 | \else | |
7f7dd1d3 | 8536 | \let\xeatspaces\relax % suppress expansion |
084e7d57 | 8537 | \fi |
7f7dd1d3 JM |
8538 | \ifcase\paramno |
8539 | % 0 | |
8540 | \expandafter\xdef\csname\the\macname\endcsname{% | |
8541 | \noexpand\scanmacro{\macrobody}}% | |
8542 | \or % 1 | |
8543 | \expandafter\xdef\csname\the\macname\endcsname{% | |
8544 | \bgroup | |
8545 | \noexpand\braceorline | |
8546 | \expandafter\noexpand\csname\the\macname @@@\endcsname}% | |
8547 | \expandafter\xdef\csname\the\macname @@@\endcsname##1{% | |
8548 | \egroup | |
8549 | \noexpand\scanmacro{\macrobody}% | |
8550 | }% | |
8551 | \else % at most 9 | |
8552 | \ifnum\paramno<10\relax | |
8553 | % @MACNAME sets the context for reading the macro argument | |
8554 | % @MACNAME@@ gets the argument, processes backslashes and appends a | |
8555 | % comma. | |
8556 | % @MACNAME@@@ removes braces surrounding the argument list. | |
8557 | % @MACNAME@@@@ scans the macro body with arguments substituted. | |
61027f30 | 8558 | \expandafter\xdef\csname\the\macname\endcsname{% |
7f7dd1d3 JM |
8559 | \bgroup |
8560 | \noexpand\expandafter % This \expandafter skip any spaces after the | |
8561 | \noexpand\macroargctxt % macro before we change the catcode of space. | |
8562 | \noexpand\expandafter | |
8563 | \expandafter\noexpand\csname\the\macname @@\endcsname}% | |
8564 | \expandafter\xdef\csname\the\macname @@\endcsname##1{% | |
8565 | \noexpand\passargtomacro | |
8566 | \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}% | |
084e7d57 | 8567 | \expandafter\xdef\csname\the\macname @@@\endcsname##1{% |
7f7dd1d3 JM |
8568 | \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}% |
8569 | \expandafter\expandafter | |
8570 | \expandafter\xdef | |
8571 | \expandafter\expandafter | |
8572 | \csname\the\macname @@@@\endcsname\paramlist{% | |
8573 | \egroup\noexpand\scanmacro{\macrobody}}% | |
8574 | \else % 10 or more: | |
61027f30 | 8575 | \expandafter\xdef\csname\the\macname\endcsname{% |
7f7dd1d3 JM |
8576 | \noexpand\getargvals@{\the\macname}{\argl}% |
8577 | }% | |
8578 | \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody | |
8579 | \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble | |
0c2b5752 UD |
8580 | \fi |
8581 | \fi} | |
8582 | ||
084e7d57 | 8583 | \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes |
0f8bbd69 | 8584 | |
0c2b5752 UD |
8585 | \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} |
8586 | ||
084e7d57 JM |
8587 | |
8588 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
8589 | % | |
8590 | {\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape | |
8591 | @catcode`@_=11 % private names | |
8592 | @catcode`@!=11 % used as argument separator | |
8593 | ||
8594 | % \passargtomacro#1#2 - | |
8595 | % Call #1 with a list of tokens #2, with any doubled backslashes in #2 | |
8596 | % compressed to one. | |
8597 | % | |
8598 | % This implementation works by expansion, and not execution (so we cannot use | |
8599 | % \def or similar). This reduces the risk of this failing in contexts where | |
8600 | % complete expansion is done with no execution (for example, in writing out to | |
8601 | % an auxiliary file for an index entry). | |
8602 | % | |
8603 | % State is kept in the input stream: the argument passed to | |
8604 | % @look_ahead, @gobble_and_check_finish and @add_segment is | |
8605 | % | |
8606 | % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input) | |
8607 | % | |
8608 | % where: | |
8609 | % THE_MACRO - name of the macro we want to call | |
8610 | % ARG_RESULT - argument list we build to pass to that macro | |
8611 | % PENDING_BS - either a backslash or nothing | |
8612 | % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next | |
8613 | ||
8614 | @gdef@passargtomacro#1#2{% | |
8615 | @add_segment #1!{}@relax#2\@_finish\% | |
8616 | } | |
8617 | @gdef@_finish{@_finishx} @global@let@_finishx@relax | |
8618 | ||
8619 | % #1 - THE_MACRO ARG_RESULT | |
8620 | % #2 - PENDING_BS | |
8621 | % #3 - NEXT_TOKEN | |
8622 | % #4 used to look ahead | |
8623 | % | |
8624 | % If the next token is not a backslash, process the rest of the argument; | |
8625 | % otherwise, remove the next token. | |
8626 | @gdef@look_ahead#1!#2#3#4{% | |
8627 | @ifx#4\% | |
8628 | @expandafter@gobble_and_check_finish | |
8629 | @else | |
8630 | @expandafter@add_segment | |
8631 | @fi#1!{#2}#4#4% | |
8632 | } | |
8633 | ||
8634 | % #1 - THE_MACRO ARG_RESULT | |
8635 | % #2 - PENDING_BS | |
8636 | % #3 - NEXT_TOKEN | |
8637 | % #4 should be a backslash, which is gobbled. | |
8638 | % #5 looks ahead | |
8639 | % | |
8640 | % Double backslash found. Add a single backslash, and look ahead. | |
8641 | @gdef@gobble_and_check_finish#1!#2#3#4#5{% | |
8642 | @add_segment#1\!{}#5#5% | |
8643 | } | |
8644 | ||
8645 | @gdef@is_fi{@fi} | |
8646 | ||
8647 | % #1 - THE_MACRO ARG_RESULT | |
8648 | % #2 - PENDING_BS | |
8649 | % #3 - NEXT_TOKEN | |
8650 | % #4 is input stream until next backslash | |
8651 | % | |
8652 | % Input stream is either at the start of the argument, or just after a | |
8653 | % backslash sequence, either a lone backslash, or a doubled backslash. | |
8654 | % NEXT_TOKEN contains the first token in the input stream: if it is \finish, | |
8655 | % finish; otherwise, append to ARG_RESULT the segment of the argument up until | |
8656 | % the next backslash. PENDING_BACKSLASH contains a backslash to represent | |
8657 | % a backslash just before the start of the input stream that has not been | |
8658 | % added to ARG_RESULT. | |
8659 | @gdef@add_segment#1!#2#3#4\{% | |
8660 | @ifx#3@_finish | |
8661 | @call_the_macro#1!% | |
8662 | @else | |
8663 | % append the pending backslash to the result, followed by the next segment | |
8664 | @expandafter@is_fi@look_ahead#1#2#4!{\}@fi | |
8665 | % this @fi is discarded by @look_ahead. | |
8666 | % we can't get rid of it with \expandafter because we don't know how | |
8667 | % long #4 is. | |
8668 | } | |
8669 | ||
8670 | % #1 - THE_MACRO | |
8671 | % #2 - ARG_RESULT | |
8672 | % #3 discards the res of the conditional in @add_segment, and @is_fi ends the | |
8673 | % conditional. | |
8674 | @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}} | |
8675 | ||
8676 | } | |
8677 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
8678 | ||
8679 | % \braceorline MAC is used for a one-argument macro MAC. It checks | |
8680 | % whether the next non-whitespace character is a {. It sets the context | |
8681 | % for reading the argument (slightly different in the two cases). Then, | |
8682 | % to read the argument, in the whole-line case, it then calls the regular | |
8683 | % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC. | |
0f8bbd69 | 8684 | % |
9251c568 | 8685 | \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} |
0c2b5752 | 8686 | \def\braceorlinexxx{% |
084e7d57 JM |
8687 | \ifx\nchar\bgroup |
8688 | \macroargctxt | |
8689 | \expandafter\passargtomacro | |
8690 | \else | |
8691 | \macrolineargctxt\expandafter\parsearg | |
9251c568 | 8692 | \fi \macnamexxx} |
82d5ce1d | 8693 | |
407dc7a0 UD |
8694 | |
8695 | % @alias. | |
3b82ab1c | 8696 | % We need some trickery to remove the optional spaces around the equal |
0f8bbd69 JM |
8697 | % sign. Make them active and then expand them all to nothing. |
8698 | % | |
82d5ce1d | 8699 | \def\alias{\parseargusing\obeyspaces\aliasxxx} |
3b82ab1c | 8700 | \def\aliasxxx #1{\aliasyyy#1\relax} |
82d5ce1d UD |
8701 | \def\aliasyyy #1=#2\relax{% |
8702 | {% | |
8703 | \expandafter\let\obeyedspace=\empty | |
9251c568 | 8704 | \addtomacrolist{#1}% |
82d5ce1d UD |
8705 | \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% |
8706 | }% | |
8707 | \next | |
8708 | } | |
407dc7a0 UD |
8709 | |
8710 | ||
f962d792 | 8711 | \message{cross references,} |
13632cfc | 8712 | |
40c0dc53 | 8713 | \newwrite\auxfile |
40c0dc53 | 8714 | \newif\ifhavexrefs % True if xref values are known. |
9e9f9cc2 KB |
8715 | \newif\ifwarnedxrefs % True if we warned once that they aren't known. |
8716 | ||
40c0dc53 | 8717 | % @inforef is relatively simple. |
d66b7b41 | 8718 | \def\inforef #1{\inforefzzz #1,,,,**} |
0f8bbd69 JM |
8719 | \def\inforefzzz #1,#2,#3,#4**{% |
8720 | \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, | |
d66b7b41 KB |
8721 | node \samp{\ignorespaces#1{}}} |
8722 | ||
82d5ce1d UD |
8723 | % @node's only job in TeX is to define \lastnode, which is used in |
8724 | % cross-references. The @node line might or might not have commas, and | |
8725 | % might or might not have spaces before the first comma, like: | |
8726 | % @node foo , bar , ... | |
8727 | % We don't want such trailing spaces in the node name. | |
8728 | % | |
8729 | \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} | |
8730 | % | |
8731 | % also remove a trailing comma, in case of something like this: | |
8732 | % @node Help-Cross, , , Cross-refs | |
8733 | \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} | |
8734 | \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} | |
8735 | ||
313a1174 | 8736 | \let\nwnode=\node |
82d5ce1d UD |
8737 | \let\lastnode=\empty |
8738 | ||
8739 | % Write a cross-reference definition for the current node. #1 is the | |
8740 | % type (Ynumbered, Yappendix, Ynothing). | |
8741 | % | |
8742 | \def\donoderef#1{% | |
8743 | \ifx\lastnode\empty\else | |
8744 | \setref{\lastnode}{#1}% | |
8745 | \global\let\lastnode=\empty | |
313a1174 UD |
8746 | \fi |
8747 | } | |
9e9f9cc2 | 8748 | |
61027f30 | 8749 | % @anchor{NAME} -- define xref target at arbitrary point. |
b710a6e2 | 8750 | % |
3b82ab1c | 8751 | \newcount\savesfregister |
82d5ce1d UD |
8752 | % |
8753 | \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} | |
8754 | \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} | |
8755 | \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} | |
61027f30 | 8756 | |
e0f86659 | 8757 | % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an |
82d5ce1d | 8758 | % anchor), which consists of three parts: |
c94f48d7 | 8759 | % 1) NAME-title - the current sectioning name taken from \lastsection, |
82d5ce1d UD |
8760 | % or the anchor name. |
8761 | % 2) NAME-snt - section number and type, passed as the SNT arg, or | |
8762 | % empty for anchors. | |
8763 | % 3) NAME-pg - the page number. | |
8764 | % | |
8765 | % This is called from \donoderef, \anchor, and \dofloat. In the case of | |
8766 | % floats, there is an additional part, which is not written here: | |
8767 | % 4) NAME-lof - the text as it should appear in a @listoffloats. | |
8768 | % | |
8769 | \def\setref#1#2{% | |
3b82ab1c | 8770 | \pdfmkdest{#1}% |
82d5ce1d UD |
8771 | \iflinks |
8772 | {% | |
084e7d57 | 8773 | \requireauxfile |
82d5ce1d | 8774 | \atdummies % preserve commands, but don't expand them |
7f7dd1d3 JM |
8775 | % match definition in \xrdef, \refx, \xrefX. |
8776 | \def\value##1{##1}% | |
82d5ce1d UD |
8777 | \edef\writexrdef##1##2{% |
8778 | \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef | |
8779 | ##1}{##2}}% these are parameters of \writexrdef | |
8780 | }% | |
c94f48d7 | 8781 | \toks0 = \expandafter{\lastsection}% |
82d5ce1d UD |
8782 | \immediate \writexrdef{title}{\the\toks0 }% |
8783 | \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. | |
0f8bbd69 | 8784 | \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout |
82d5ce1d UD |
8785 | }% |
8786 | \fi | |
8787 | } | |
9e9f9cc2 | 8788 | |
0f8bbd69 JM |
8789 | % @xrefautosectiontitle on|off says whether @section(ing) names are used |
8790 | % automatically in xrefs, if the third arg is not explicitly specified. | |
8791 | % This was provided as a "secret" @set xref-automatic-section-title | |
8792 | % variable, now it's official. | |
8793 | % | |
8794 | \parseargdef\xrefautomaticsectiontitle{% | |
8795 | \def\temp{#1}% | |
8796 | \ifx\temp\onword | |
8797 | \expandafter\let\csname SETxref-automatic-section-title\endcsname | |
8798 | = \empty | |
8799 | \else\ifx\temp\offword | |
8800 | \expandafter\let\csname SETxref-automatic-section-title\endcsname | |
8801 | = \relax | |
8802 | \else | |
8803 | \errhelp = \EMsimple | |
8804 | \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', | |
8805 | must be on|off}% | |
8806 | \fi\fi | |
8807 | } | |
8808 | ||
8fcb833a | 8809 | % \f |
313a1174 UD |
8810 | % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is |
8811 | % the node name, #2 the name of the Info cross-reference, #3 the printed | |
8812 | % node name, #4 the name of the Info file, #5 the name of the printed | |
8813 | % manual. All but the node name can be omitted. | |
9e9f9cc2 | 8814 | % |
084e7d57 JM |
8815 | \def\pxref{\putwordsee{} \xrefXX} |
8816 | \def\xref{\putwordSee{} \xrefXX} | |
8817 | \def\ref{\xrefXX} | |
8818 | ||
8819 | \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX} | |
8820 | \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]} | |
0f8bbd69 | 8821 | % |
8fcb833a | 8822 | \newbox\toprefbox |
0f8bbd69 | 8823 | \newbox\printedrefnamebox |
8fcb833a | 8824 | \newbox\infofilenamebox |
0f8bbd69 JM |
8825 | \newbox\printedmanualbox |
8826 | % | |
9e9f9cc2 | 8827 | \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup |
3b82ab1c | 8828 | \unsepspaces |
0f8bbd69 | 8829 | % |
8fcb833a | 8830 | % Get args without leading/trailing spaces. |
82d5ce1d | 8831 | \def\printedrefname{\ignorespaces #3}% |
0f8bbd69 JM |
8832 | \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% |
8833 | % | |
8fcb833a JM |
8834 | \def\infofilename{\ignorespaces #4}% |
8835 | \setbox\infofilenamebox = \hbox{\infofilename\unskip}% | |
8836 | % | |
0f8bbd69 JM |
8837 | \def\printedmanual{\ignorespaces #5}% |
8838 | \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% | |
8839 | % | |
8840 | % If the printed reference name (arg #3) was not explicitly given in | |
8841 | % the @xref, figure out what we want to use. | |
8842 | \ifdim \wd\printedrefnamebox = 0pt | |
9e9f9cc2 | 8843 | % No printed node name was explicitly given. |
0f8bbd69 JM |
8844 | \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax |
8845 | % Not auto section-title: use node name inside the square brackets. | |
82d5ce1d | 8846 | \def\printedrefname{\ignorespaces #1}% |
9e9f9cc2 | 8847 | \else |
0f8bbd69 JM |
8848 | % Auto section-title: use chapter/section title inside |
8849 | % the square brackets if we have it. | |
8850 | \ifdim \wd\printedmanualbox > 0pt | |
8851 | % It is in another manual, so we don't have it; use node name. | |
82d5ce1d | 8852 | \def\printedrefname{\ignorespaces #1}% |
9e9f9cc2 KB |
8853 | \else |
8854 | \ifhavexrefs | |
0f8bbd69 | 8855 | % We (should) know the real title if we have the xref values. |
82d5ce1d | 8856 | \def\printedrefname{\refx{#1-title}{}}% |
9e9f9cc2 KB |
8857 | \else |
8858 | % Otherwise just copy the Info node name. | |
82d5ce1d | 8859 | \def\printedrefname{\ignorespaces #1}% |
9e9f9cc2 KB |
8860 | \fi% |
8861 | \fi | |
8862 | \fi | |
8863 | \fi | |
8864 | % | |
82d5ce1d | 8865 | % Make link in pdf output. |
13632cfc | 8866 | \ifpdf |
7f7dd1d3 | 8867 | % For pdfTeX and LuaTeX |
c94f48d7 | 8868 | {\indexnofonts |
8fcb833a | 8869 | \makevalueexpandable |
7f7dd1d3 | 8870 | \turnoffactive |
0f8bbd69 | 8871 | % This expands tokens, so do it after making catcode changes, so _ |
8fcb833a JM |
8872 | % etc. don't get their TeX definitions. This ignores all spaces in |
8873 | % #4, including (wrongly) those in the middle of the filename. | |
0f8bbd69 | 8874 | \getfilename{#4}% |
9251c568 | 8875 | % |
8fcb833a JM |
8876 | % This (wrongly) does not take account of leading or trailing |
8877 | % spaces in #1, which should be ignored. | |
7f7dd1d3 JM |
8878 | \setpdfdestname{#1}% |
8879 | % | |
8880 | \ifx\pdfdestname\empty | |
8881 | \def\pdfdestname{Top}% no empty targets | |
8fcb833a | 8882 | \fi |
0f8bbd69 JM |
8883 | % |
8884 | \leavevmode | |
8885 | \startlink attr{/Border [0 0 0]}% | |
e23f8d20 | 8886 | \ifnum\filenamelength>0 |
7f7dd1d3 | 8887 | goto file{\the\filename.pdf} name{\pdfdestname}% |
e23f8d20 | 8888 | \else |
7f7dd1d3 | 8889 | goto name{\pdfmkpgn{\pdfdestname}}% |
e23f8d20 UD |
8890 | \fi |
8891 | }% | |
c94f48d7 | 8892 | \setcolor{\linkcolor}% |
7f7dd1d3 JM |
8893 | \else |
8894 | \ifx\XeTeXrevision\thisisundefined | |
8895 | \else | |
8896 | % For XeTeX | |
8897 | {\indexnofonts | |
8898 | \makevalueexpandable | |
8899 | \turnoffactive | |
8900 | % This expands tokens, so do it after making catcode changes, so _ | |
8901 | % etc. don't get their TeX definitions. This ignores all spaces in | |
8902 | % #4, including (wrongly) those in the middle of the filename. | |
8903 | \getfilename{#4}% | |
8904 | % | |
8905 | % This (wrongly) does not take account of leading or trailing | |
8906 | % spaces in #1, which should be ignored. | |
8907 | \setpdfdestname{#1}% | |
8908 | % | |
8909 | \ifx\pdfdestname\empty | |
8910 | \def\pdfdestname{Top}% no empty targets | |
8911 | \fi | |
8912 | % | |
8913 | \leavevmode | |
8914 | \ifnum\filenamelength>0 | |
8915 | % With default settings, | |
8916 | % XeTeX (xdvipdfmx) replaces link destination names with integers. | |
8917 | % In this case, the replaced destination names of | |
8918 | % remote PDFs are no longer known. In order to avoid a replacement, | |
8919 | % you can use xdvipdfmx's command line option `-C 0x0010'. | |
8920 | % If you use XeTeX 0.99996+ (TeX Live 2016+), | |
8921 | % this command line option is no longer necessary | |
8922 | % because we can use the `dvipdfmx:config' special. | |
8923 | \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A | |
8924 | << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% | |
8925 | \else | |
8926 | \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A | |
8927 | << /S /GoTo /D (\pdfdestname) >> >>}% | |
8928 | \fi | |
8929 | }% | |
8930 | \setcolor{\linkcolor}% | |
8931 | \fi | |
13632cfc | 8932 | \fi |
82d5ce1d UD |
8933 | {% |
8934 | % Have to otherify everything special to allow the \csname to | |
8935 | % include an _ in the xref name, etc. | |
8936 | \indexnofonts | |
8937 | \turnoffactive | |
7f7dd1d3 | 8938 | \def\value##1{##1}% |
82d5ce1d UD |
8939 | \expandafter\global\expandafter\let\expandafter\Xthisreftitle |
8940 | \csname XR#1-title\endcsname | |
8941 | }% | |
7f7dd1d3 JM |
8942 | % |
8943 | % Float references are printed completely differently: "Figure 1.2" | |
8944 | % instead of "[somenode], p.3". \iffloat distinguishes them by | |
8945 | % \Xthisreftitle being set to a magic string. | |
82d5ce1d UD |
8946 | \iffloat\Xthisreftitle |
8947 | % If the user specified the print name (third arg) to the ref, | |
8948 | % print it instead of our usual "Figure 1.2". | |
0f8bbd69 | 8949 | \ifdim\wd\printedrefnamebox = 0pt |
9251c568 | 8950 | \refx{#1-snt}{}% |
82d5ce1d UD |
8951 | \else |
8952 | \printedrefname | |
8953 | \fi | |
7158eae4 | 8954 | % |
8fcb833a | 8955 | % If the user also gave the printed manual name (fifth arg), append |
82d5ce1d | 8956 | % "in MANUALNAME". |
0f8bbd69 | 8957 | \ifdim \wd\printedmanualbox > 0pt |
82d5ce1d UD |
8958 | \space \putwordin{} \cite{\printedmanual}% |
8959 | \fi | |
8960 | \else | |
8961 | % node/anchor (non-float) references. | |
a334319f | 8962 | % |
0f8bbd69 JM |
8963 | % If we use \unhbox to print the node names, TeX does not insert |
8964 | % empty discretionaries after hyphens, which means that it will not | |
8965 | % find a line break at a hyphen in a node names. Since some manuals | |
8966 | % are best written with fairly long node names, containing hyphens, | |
8967 | % this is a loss. Therefore, we give the text of the node name | |
8968 | % again, so it is as if TeX is seeing it for the first time. | |
8969 | % | |
0f8bbd69 | 8970 | \ifdim \wd\printedmanualbox > 0pt |
8fcb833a | 8971 | % Cross-manual reference with a printed manual name. |
0f8bbd69 | 8972 | % |
8fcb833a JM |
8973 | \crossmanualxref{\cite{\printedmanual\unskip}}% |
8974 | % | |
8975 | \else\ifdim \wd\infofilenamebox > 0pt | |
8976 | % Cross-manual reference with only an info filename (arg 4), no | |
8977 | % printed manual name (arg 5). This is essentially the same as | |
8978 | % the case above; we output the filename, since we have nothing else. | |
0f8bbd69 | 8979 | % |
8fcb833a JM |
8980 | \crossmanualxref{\code{\infofilename\unskip}}% |
8981 | % | |
82d5ce1d | 8982 | \else |
8fcb833a | 8983 | % Reference within this manual. |
0f8bbd69 | 8984 | % |
82d5ce1d UD |
8985 | % _ (for example) has to be the character _ for the purposes of the |
8986 | % control sequence corresponding to the node, but it has to expand | |
8987 | % into the usual \leavevmode...\vrule stuff for purposes of | |
8988 | % printing. So we \turnoffactive for the \refx-snt, back on for the | |
8989 | % printing, back off for the \refx-pg. | |
9251c568 | 8990 | {\turnoffactive |
82d5ce1d UD |
8991 | % Only output a following space if the -snt ref is nonempty; for |
8992 | % @unnumbered and @anchor, it won't be. | |
8993 | \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% | |
8994 | \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi | |
8995 | }% | |
0f8bbd69 | 8996 | % output the `[mynode]' via the macro below so it can be overridden. |
82d5ce1d UD |
8997 | \xrefprintnodename\printedrefname |
8998 | % | |
8999 | % But we always want a comma and a space: | |
9000 | ,\space | |
9001 | % | |
9002 | % output the `page 3'. | |
9251c568 | 9003 | \turnoffactive \putwordpage\tie\refx{#1-pg}{}% |
7f7dd1d3 JM |
9004 | % Add a , if xref followed by a space |
9005 | \if\space\noexpand\tokenafterxref ,% | |
9006 | \else\ifx\ \tokenafterxref ,% @TAB | |
9007 | \else\ifx\*\tokenafterxref ,% @* | |
9008 | \else\ifx\ \tokenafterxref ,% @SPACE | |
9009 | \else\ifx\ | |
9010 | \tokenafterxref ,% @NL | |
9011 | \else\ifx\tie\tokenafterxref ,% @tie | |
9012 | \fi\fi\fi\fi\fi\fi | |
8fcb833a | 9013 | \fi\fi |
9e9f9cc2 | 9014 | \fi |
3b82ab1c | 9015 | \endlink |
9e9f9cc2 KB |
9016 | \endgroup} |
9017 | ||
8fcb833a JM |
9018 | % Output a cross-manual xref to #1. Used just above (twice). |
9019 | % | |
9020 | % Only include the text "Section ``foo'' in" if the foo is neither | |
9021 | % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply | |
9022 | % "see The Foo Manual", the idea being to refer to the whole manual. | |
9023 | % | |
9024 | % But, this being TeX, we can't easily compare our node name against the | |
9025 | % string "Top" while ignoring the possible spaces before and after in | |
9026 | % the input. By adding the arbitrary 7sp below, we make it much less | |
9027 | % likely that a real node name would have the same width as "Top" (e.g., | |
9028 | % in a monospaced font). Hopefully it will never happen in practice. | |
9029 | % | |
9030 | % For the same basic reason, we retypeset the "Top" at every | |
9031 | % reference, since the current font is indeterminate. | |
9032 | % | |
9033 | \def\crossmanualxref#1{% | |
9034 | \setbox\toprefbox = \hbox{Top\kern7sp}% | |
9035 | \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% | |
9036 | \ifdim \wd2 > 7sp % nonempty? | |
9037 | \ifdim \wd2 = \wd\toprefbox \else % same as Top? | |
9038 | \putwordSection{} ``\printedrefname'' \putwordin{}\space | |
9039 | \fi | |
9040 | \fi | |
9041 | #1% | |
9042 | } | |
9043 | ||
7158eae4 UD |
9044 | % This macro is called from \xrefX for the `[nodename]' part of xref |
9045 | % output. It's a separate macro only so it can be changed more easily, | |
82d5ce1d | 9046 | % since square brackets don't work well in some documents. Particularly |
7158eae4 UD |
9047 | % one that Bob is working on :). |
9048 | % | |
9049 | \def\xrefprintnodename#1{[#1]} | |
9050 | ||
82d5ce1d | 9051 | % Things referred to by \setref. |
7158eae4 | 9052 | % |
9e9f9cc2 | 9053 | \def\Ynothing{} |
82d5ce1d UD |
9054 | \def\Yomitfromtoc{} |
9055 | \def\Ynumbered{% | |
e0f86659 UD |
9056 | \ifnum\secno=0 |
9057 | \putwordChapter@tie \the\chapno | |
9058 | \else \ifnum\subsecno=0 | |
9059 | \putwordSection@tie \the\chapno.\the\secno | |
9060 | \else \ifnum\subsubsecno=0 | |
9061 | \putwordSection@tie \the\chapno.\the\secno.\the\subsecno | |
9062 | \else | |
9063 | \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno | |
9064 | \fi\fi\fi | |
9065 | } | |
82d5ce1d | 9066 | \def\Yappendix{% |
e0f86659 UD |
9067 | \ifnum\secno=0 |
9068 | \putwordAppendix@tie @char\the\appendixno{}% | |
9069 | \else \ifnum\subsecno=0 | |
9070 | \putwordSection@tie @char\the\appendixno.\the\secno | |
9071 | \else \ifnum\subsubsecno=0 | |
9072 | \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno | |
9073 | \else | |
9074 | \putwordSection@tie | |
9075 | @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno | |
9076 | \fi\fi\fi | |
9077 | } | |
9e9f9cc2 | 9078 | |
7f7dd1d3 JM |
9079 | % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX |
9080 | % is output afterwards if non-empty. | |
9e9f9cc2 | 9081 | \def\refx#1#2{% |
084e7d57 | 9082 | \requireauxfile |
e0f86659 UD |
9083 | {% |
9084 | \indexnofonts | |
9085 | \otherbackslash | |
7f7dd1d3 | 9086 | \def\value##1{##1}% |
e0f86659 | 9087 | \expandafter\global\expandafter\let\expandafter\thisrefX |
82d5ce1d | 9088 | \csname XR#1\endcsname |
e0f86659 UD |
9089 | }% |
9090 | \ifx\thisrefX\relax | |
9e9f9cc2 | 9091 | % If not defined, say something at least. |
2eb45444 | 9092 | \angleleft un\-de\-fined\angleright |
f962d792 UD |
9093 | \iflinks |
9094 | \ifhavexrefs | |
0f8bbd69 JM |
9095 | {\toks0 = {#1}% avoid expansion of possibly-complex value |
9096 | \message{\linenumber Undefined cross reference `\the\toks0'.}}% | |
f962d792 UD |
9097 | \else |
9098 | \ifwarnedxrefs\else | |
9099 | \global\warnedxrefstrue | |
9100 | \message{Cross reference values unknown; you must run TeX again.}% | |
9101 | \fi | |
9e9f9cc2 KB |
9102 | \fi |
9103 | \fi | |
9104 | \else | |
9105 | % It's defined, so just use it. | |
e0f86659 | 9106 | \thisrefX |
9e9f9cc2 KB |
9107 | \fi |
9108 | #2% Output the suffix in any case. | |
9109 | } | |
9110 | ||
7f7dd1d3 JM |
9111 | % This is the macro invoked by entries in the aux file. Define a control |
9112 | % sequence for a cross-reference target (we prepend XR to the control sequence | |
9113 | % name to avoid collisions). The value is the page number. If this is a float | |
9114 | % type, we have more work to do. | |
b710a6e2 | 9115 | % |
82d5ce1d | 9116 | \def\xrdef#1#2{% |
7f7dd1d3 JM |
9117 | {% Expand the node or anchor name to remove control sequences. |
9118 | % \turnoffactive stops 8-bit characters being changed to commands | |
9119 | % like @'e. \refx does the same to retrieve the value in the definition. | |
c94f48d7 AJ |
9120 | \indexnofonts |
9121 | \turnoffactive | |
7f7dd1d3 | 9122 | \def\value##1{##1}% |
c94f48d7 AJ |
9123 | \xdef\safexrefname{#1}% |
9124 | }% | |
9125 | % | |
9126 | \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref | |
82d5ce1d UD |
9127 | % |
9128 | % Was that xref control sequence that we just defined for a float? | |
c94f48d7 | 9129 | \expandafter\iffloat\csname XR\safexrefname\endcsname |
82d5ce1d UD |
9130 | % it was a float, and we have the (safe) float type in \iffloattype. |
9131 | \expandafter\let\expandafter\floatlist | |
9132 | \csname floatlist\iffloattype\endcsname | |
9133 | % | |
9134 | % Is this the first time we've seen this float type? | |
9135 | \expandafter\ifx\floatlist\relax | |
9136 | \toks0 = {\do}% yes, so just \do | |
9137 | \else | |
9138 | % had it before, so preserve previous elements in list. | |
9139 | \toks0 = \expandafter{\floatlist\do}% | |
9140 | \fi | |
9141 | % | |
9142 | % Remember this xref in the control sequence \floatlistFLOATTYPE, | |
9143 | % for later use in \listoffloats. | |
c94f48d7 AJ |
9144 | \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 |
9145 | {\safexrefname}}% | |
82d5ce1d UD |
9146 | \fi |
9147 | } | |
9e9f9cc2 | 9148 | |
084e7d57 JM |
9149 | % If working on a large document in chapters, it is convenient to |
9150 | % be able to disable indexing, cross-referencing, and contents, for test runs. | |
9151 | % This is done with @novalidate at the beginning of the file. | |
9152 | % | |
9153 | \newif\iflinks \linkstrue % by default we want the aux files. | |
9154 | \let\novalidate = \linksfalse | |
9155 | ||
9156 | % Used when writing to the aux file, or when using data from it. | |
9157 | \def\requireauxfile{% | |
9158 | \iflinks | |
9159 | \tryauxfile | |
9160 | % Open the new aux file. TeX will close it automatically at exit. | |
9161 | \immediate\openout\auxfile=\jobname.aux | |
9162 | \fi | |
9163 | \global\let\requireauxfile=\relax % Only do this once. | |
9164 | } | |
9165 | ||
4dbca03b | 9166 | % Read the last existing aux file, if any. No error if none exists. |
82d5ce1d UD |
9167 | % |
9168 | \def\tryauxfile{% | |
9169 | \openin 1 \jobname.aux | |
9170 | \ifeof 1 \else | |
9251c568 | 9171 | \readdatafile{aux}% |
82d5ce1d UD |
9172 | \global\havexrefstrue |
9173 | \fi | |
9174 | \closein 1 | |
9175 | } | |
9176 | ||
9251c568 | 9177 | \def\setupdatafile{% |
4dbca03b | 9178 | \catcode`\^^@=\other |
55c14926 UD |
9179 | \catcode`\^^A=\other |
9180 | \catcode`\^^B=\other | |
4dbca03b KB |
9181 | \catcode`\^^C=\other |
9182 | \catcode`\^^D=\other | |
9183 | \catcode`\^^E=\other | |
9184 | \catcode`\^^F=\other | |
9185 | \catcode`\^^G=\other | |
9186 | \catcode`\^^H=\other | |
55c14926 | 9187 | \catcode`\^^K=\other |
4dbca03b | 9188 | \catcode`\^^L=\other |
9c2322bc UD |
9189 | \catcode`\^^N=\other |
9190 | \catcode`\^^P=\other | |
9191 | \catcode`\^^Q=\other | |
9192 | \catcode`\^^R=\other | |
9193 | \catcode`\^^S=\other | |
9194 | \catcode`\^^T=\other | |
9195 | \catcode`\^^U=\other | |
9196 | \catcode`\^^V=\other | |
9197 | \catcode`\^^W=\other | |
9198 | \catcode`\^^X=\other | |
9199 | \catcode`\^^Z=\other | |
4dbca03b KB |
9200 | \catcode`\^^[=\other |
9201 | \catcode`\^^\=\other | |
9202 | \catcode`\^^]=\other | |
9203 | \catcode`\^^^=\other | |
9204 | \catcode`\^^_=\other | |
e0f86659 | 9205 | % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. |
4dbca03b KB |
9206 | % in xref tags, i.e., node names. But since ^^e4 notation isn't |
9207 | % supported in the main text, it doesn't seem desirable. Furthermore, | |
9208 | % that is not enough: for node names that actually contain a ^ | |
9209 | % character, we would end up writing a line like this: 'xrdef {'hat | |
9210 | % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first | |
9211 | % argument, and \hat is not an expandable control sequence. It could | |
9212 | % all be worked out, but why? Either we support ^^ or we don't. | |
10dc2a90 | 9213 | % |
4dbca03b KB |
9214 | % The other change necessary for this was to define \auxhat: |
9215 | % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter | |
9216 | % and then to call \auxhat in \setq. | |
10dc2a90 | 9217 | % |
e0f86659 UD |
9218 | \catcode`\^=\other |
9219 | % | |
9220 | % Special characters. Should be turned off anyway, but... | |
4dbca03b KB |
9221 | \catcode`\~=\other |
9222 | \catcode`\[=\other | |
9223 | \catcode`\]=\other | |
9224 | \catcode`\"=\other | |
9225 | \catcode`\_=\other | |
9226 | \catcode`\|=\other | |
9227 | \catcode`\<=\other | |
9228 | \catcode`\>=\other | |
9229 | \catcode`\$=\other | |
9230 | \catcode`\#=\other | |
9231 | \catcode`\&=\other | |
e0f86659 | 9232 | \catcode`\%=\other |
40c0dc53 | 9233 | \catcode`+=\other % avoid \+ for paranoia even though we've turned it off |
e0f86659 | 9234 | % |
82d5ce1d UD |
9235 | % This is to support \ in node names and titles, since the \ |
9236 | % characters end up in a \csname. It's easier than | |
9237 | % leaving it active and making its active definition an actual \ | |
9238 | % character. What I don't understand is why it works in the *value* | |
9239 | % of the xrdef. Seems like it should be a catcode12 \, and that | |
9240 | % should not typeset properly. But it works, so I'm moving on for | |
9241 | % now. --karl, 15jan04. | |
9242 | \catcode`\\=\other | |
9243 | % | |
82d5ce1d | 9244 | % @ is our escape character in .aux files, and we need braces. |
4dbca03b KB |
9245 | \catcode`\{=1 |
9246 | \catcode`\}=2 | |
e0f86659 | 9247 | \catcode`\@=0 |
9251c568 | 9248 | } |
9e9f9cc2 | 9249 | |
9251c568 AJ |
9250 | \def\readdatafile#1{% |
9251 | \begingroup | |
9252 | \setupdatafile | |
9253 | \input\jobname.#1 | |
9254 | \endgroup} | |
9e9f9cc2 | 9255 | |
c94f48d7 | 9256 | |
82d5ce1d UD |
9257 | \message{insertions,} |
9258 | % including footnotes. | |
9e9f9cc2 KB |
9259 | |
9260 | \newcount \footnoteno | |
9261 | ||
9262 | % The trailing space in the following definition for supereject is | |
9263 | % vital for proper filling; pages come out unaligned when you do a | |
9264 | % pagealignmacro call if that space before the closing brace is | |
793fde8a KB |
9265 | % removed. (Generally, numeric constants should always be followed by a |
9266 | % space to prevent strange expansion errors.) | |
9e9f9cc2 KB |
9267 | \def\supereject{\par\penalty -20000\footnoteno =0 } |
9268 | ||
0f8bbd69 | 9269 | % @footnotestyle is meaningful for Info output only. |
9e9f9cc2 KB |
9270 | \let\footnotestyle=\comment |
9271 | ||
9e9f9cc2 KB |
9272 | {\catcode `\@=11 |
9273 | % | |
9274 | % Auto-number footnotes. Otherwise like plain. | |
9275 | \gdef\footnote{% | |
9276 | \global\advance\footnoteno by \@ne | |
9277 | \edef\thisfootno{$^{\the\footnoteno}$}% | |
9278 | % | |
9279 | % In case the footnote comes at the end of a sentence, preserve the | |
9280 | % extra spacing after we do the footnote number. | |
9281 | \let\@sf\empty | |
7158eae4 | 9282 | \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi |
9e9f9cc2 KB |
9283 | % |
9284 | % Remove inadvertent blank space before typesetting the footnote number. | |
9285 | \unskip | |
9286 | \thisfootno\@sf | |
e0f86659 | 9287 | \dofootnote |
9e9f9cc2 KB |
9288 | }% |
9289 | ||
9290 | % Don't bother with the trickery in plain.tex to not require the | |
9291 | % footnote text as a parameter. Our footnotes don't need to be so general. | |
10dc2a90 | 9292 | % |
82d5ce1d UD |
9293 | % Oh yes, they do; otherwise, @ifset (and anything else that uses |
9294 | % \parseargline) fails inside footnotes because the tokens are fixed when | |
3a3df4c7 | 9295 | % the footnote is read. --karl, 16nov96. |
9e9f9cc2 | 9296 | % |
e0f86659 | 9297 | \gdef\dofootnote{% |
82d5ce1d | 9298 | \insert\footins\bgroup |
e66a8203 JM |
9299 | % |
9300 | % Nested footnotes are not supported in TeX, that would take a lot | |
9301 | % more work. (\startsavinginserts does not suffice.) | |
084e7d57 | 9302 | \let\footnote=\errfootnotenest |
e66a8203 | 9303 | % |
9e9f9cc2 KB |
9304 | % We want to typeset this text as a normal paragraph, even if the |
9305 | % footnote reference occurs in (for example) a display environment. | |
9306 | % So reset some parameters. | |
7f7dd1d3 | 9307 | \hsize=\txipagewidth |
9e9f9cc2 KB |
9308 | \interlinepenalty\interfootnotelinepenalty |
9309 | \splittopskip\ht\strutbox % top baseline for broken footnotes | |
9310 | \splitmaxdepth\dp\strutbox | |
9311 | \floatingpenalty\@MM | |
9312 | \leftskip\z@skip | |
9313 | \rightskip\z@skip | |
9314 | \spaceskip\z@skip | |
9315 | \xspaceskip\z@skip | |
9316 | \parindent\defaultparindent | |
9317 | % | |
3b82ab1c UD |
9318 | \smallfonts \rm |
9319 | % | |
e23f8d20 UD |
9320 | % Because we use hanging indentation in footnotes, a @noindent appears |
9321 | % to exdent this text, so make it be a no-op. makeinfo does not use | |
9322 | % hanging indentation so @noindent can still be needed within footnote | |
9323 | % text after an @example or the like (not that this is good style). | |
9324 | \let\noindent = \relax | |
9325 | % | |
9326 | % Hang the footnote text off the number. Use \everypar in case the | |
9327 | % footnote extends for more than one paragraph. | |
9328 | \everypar = {\hang}% | |
9e9f9cc2 KB |
9329 | \textindent{\thisfootno}% |
9330 | % | |
9331 | % Don't crash into the line above the footnote text. Since this | |
9332 | % expands into a box, it must come within the paragraph, lest it | |
9333 | % provide a place where TeX can split the footnote. | |
9334 | \footstrut | |
0f8bbd69 JM |
9335 | % |
9336 | % Invoke rest of plain TeX footnote routine. | |
3a3df4c7 | 9337 | \futurelet\next\fo@t |
9e9f9cc2 | 9338 | } |
9e9f9cc2 KB |
9339 | }%end \catcode `\@=11 |
9340 | ||
084e7d57 | 9341 | \def\errfootnotenest{% |
e66a8203 JM |
9342 | \errhelp=\EMsimple |
9343 | \errmessage{Nested footnotes not supported in texinfo.tex, | |
9344 | even though they work in makeinfo; sorry} | |
9345 | } | |
9346 | ||
084e7d57 JM |
9347 | \def\errfootnoteheading{% |
9348 | \errhelp=\EMsimple | |
9349 | \errmessage{Footnotes in chapters, sections, etc., are not supported} | |
9350 | } | |
9351 | ||
82d5ce1d UD |
9352 | % In case a @footnote appears in a vbox, save the footnote text and create |
9353 | % the real \insert just after the vbox finished. Otherwise, the insertion | |
9354 | % would be lost. | |
0f8bbd69 | 9355 | % Similarly, if a @footnote appears inside an alignment, save the footnote |
82d5ce1d UD |
9356 | % text to a box and make the \insert when a row of the table is finished. |
9357 | % And the same can be done for other insert classes. --kasal, 16nov03. | |
e66a8203 | 9358 | % |
82d5ce1d UD |
9359 | % Replace the \insert primitive by a cheating macro. |
9360 | % Deeper inside, just make sure that the saved insertions are not spilled | |
9361 | % out prematurely. | |
9e9f9cc2 | 9362 | % |
82d5ce1d UD |
9363 | \def\startsavinginserts{% |
9364 | \ifx \insert\ptexinsert | |
9365 | \let\insert\saveinsert | |
9366 | \else | |
9367 | \let\checkinserts\relax | |
9368 | \fi | |
9e9f9cc2 KB |
9369 | } |
9370 | ||
82d5ce1d UD |
9371 | % This \insert replacement works for both \insert\footins{foo} and |
9372 | % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. | |
9e9f9cc2 | 9373 | % |
82d5ce1d UD |
9374 | \def\saveinsert#1{% |
9375 | \edef\next{\noexpand\savetobox \makeSAVEname#1}% | |
9376 | \afterassignment\next | |
9377 | % swallow the left brace | |
9378 | \let\temp = | |
9379 | } | |
9380 | \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} | |
9381 | \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} | |
9382 | ||
9383 | \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} | |
9384 | ||
9385 | \def\placesaveins#1{% | |
9386 | \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname | |
9387 | {\box#1}% | |
9388 | } | |
9389 | ||
9390 | % eat @SAVE -- beware, all of them have catcode \other: | |
9391 | { | |
9392 | \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) | |
9393 | \gdef\gobblesave @SAVE{} | |
9394 | } | |
9395 | ||
9396 | % initialization: | |
9397 | \def\newsaveins #1{% | |
9398 | \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% | |
9399 | \next | |
9400 | } | |
9401 | \def\newsaveinsX #1{% | |
9402 | \csname newbox\endcsname #1% | |
9403 | \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts | |
9404 | \checksaveins #1}% | |
9405 | } | |
9406 | ||
9407 | % initialize: | |
9408 | \let\checkinserts\empty | |
9409 | \newsaveins\footins | |
9410 | \newsaveins\margin | |
9411 | ||
9e9f9cc2 | 9412 | |
5ae3e846 UD |
9413 | % @image. We use the macros from epsf.tex to support this. |
9414 | % If epsf.tex is not installed and @image is used, we complain. | |
b710a6e2 | 9415 | % |
5ae3e846 UD |
9416 | % Check for and read epsf.tex up front. If we read it only at @image |
9417 | % time, we might be inside a group, and then its definitions would get | |
9418 | % undone and the next image would fail. | |
2eb45444 | 9419 | \openin 1 = epsf.tex |
5ae3e846 | 9420 | \ifeof 1 \else |
e0f86659 UD |
9421 | % Do not bother showing banner with epsf.tex v2.7k (available in |
9422 | % doc/epsf.tex and on ctan). | |
f962d792 | 9423 | \def\epsfannounce{\toks0 = }% |
5ae3e846 UD |
9424 | \input epsf.tex |
9425 | \fi | |
82d5ce1d | 9426 | \closein 1 |
5ae3e846 | 9427 | % |
13632cfc | 9428 | % We will only complain once about lack of epsf.tex. |
5ae3e846 UD |
9429 | \newif\ifwarnednoepsf |
9430 | \newhelp\noepsfhelp{epsf.tex must be installed for images to | |
9431 | work. It is also included in the Texinfo distribution, or you can get | |
b710a6e2 | 9432 | it from ftp://tug.org/tex/epsf.tex.} |
5ae3e846 | 9433 | % |
5ae3e846 | 9434 | \def\image#1{% |
8fcb833a | 9435 | \ifx\epsfbox\thisisundefined |
13632cfc UD |
9436 | \ifwarnednoepsf \else |
9437 | \errhelp = \noepsfhelp | |
9438 | \errmessage{epsf.tex not found, images will be ignored}% | |
9439 | \global\warnednoepsftrue | |
5ae3e846 UD |
9440 | \fi |
9441 | \else | |
e23f8d20 | 9442 | \imagexxx #1,,,,,\finish |
5ae3e846 UD |
9443 | \fi |
9444 | } | |
9445 | % | |
9446 | % Arguments to @image: | |
9447 | % #1 is (mandatory) image filename; we tack on .eps extension. | |
9448 | % #2 is (optional) width, #3 is (optional) height. | |
e23f8d20 UD |
9449 | % #4 is (ignored optional) html alt text. |
9450 | % #5 is (ignored optional) extension. | |
0f8bbd69 | 9451 | % #6 is just the usual extra ignored arg for parsing stuff. |
e23f8d20 | 9452 | \newif\ifimagevmode |
7ed7ad59 | 9453 | \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup |
e23f8d20 UD |
9454 | \catcode`\^^M = 5 % in case we're inside an example |
9455 | \normalturnoffactive % allow _ et al. in names | |
084e7d57 | 9456 | \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro |
e23f8d20 UD |
9457 | % If the image is by itself, center it. |
9458 | \ifvmode | |
9459 | \imagevmodetrue | |
8fcb833a JM |
9460 | \else \ifx\centersub\centerV |
9461 | % for @center @image, we need a vbox so we can have our vertical space | |
9462 | \imagevmodetrue | |
9463 | \vbox\bgroup % vbox has better behavior than vtop herev | |
9464 | \fi\fi | |
9465 | % | |
9466 | \ifimagevmode | |
0f8bbd69 | 9467 | \nobreak\medskip |
e23f8d20 UD |
9468 | % Usually we'll have text after the image which will insert |
9469 | % \parskip glue, so insert it here too to equalize the space | |
7158eae4 | 9470 | % above and below. |
e23f8d20 UD |
9471 | \nobreak\vskip\parskip |
9472 | \nobreak | |
e23f8d20 UD |
9473 | \fi |
9474 | % | |
0f8bbd69 | 9475 | % Leave vertical mode so that indentation from an enclosing |
8fcb833a JM |
9476 | % environment such as @quotation is respected. |
9477 | % However, if we're at the top level, we don't want the | |
9478 | % normal paragraph indentation. | |
9479 | % On the other hand, if we are in the case of @center @image, we don't | |
9480 | % want to start a paragraph, which will create a hsize-width box and | |
9481 | % eradicate the centering. | |
9482 | \ifx\centersub\centerV\else \noindent \fi | |
0f8bbd69 | 9483 | % |
e23f8d20 | 9484 | % Output the image. |
3b82ab1c | 9485 | \ifpdf |
7f7dd1d3 | 9486 | % For pdfTeX and LuaTeX <= 0.80 |
e23f8d20 | 9487 | \dopdfimage{#1}{#2}{#3}% |
3b82ab1c | 9488 | \else |
7f7dd1d3 JM |
9489 | \ifx\XeTeXrevision\thisisundefined |
9490 | % For epsf.tex | |
9491 | % \epsfbox itself resets \epsf?size at each figure. | |
9492 | \setbox0 = \hbox{\ignorespaces #2}% | |
9493 | \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi | |
9494 | \setbox0 = \hbox{\ignorespaces #3}% | |
9495 | \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi | |
9496 | \epsfbox{#1.eps}% | |
9497 | \else | |
9498 | % For XeTeX | |
9499 | \doxeteximage{#1}{#2}{#3}% | |
9500 | \fi | |
f962d792 | 9501 | \fi |
e23f8d20 | 9502 | % |
8fcb833a JM |
9503 | \ifimagevmode |
9504 | \medskip % space after a standalone image | |
9505 | \fi | |
9506 | \ifx\centersub\centerV \egroup \fi | |
e23f8d20 | 9507 | \endgroup} |
9e9f9cc2 | 9508 | |
5ae3e846 | 9509 | |
82d5ce1d UD |
9510 | % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, |
9511 | % etc. We don't actually implement floating yet, we always include the | |
9512 | % float "here". But it seemed the best name for the future. | |
9513 | % | |
9514 | \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} | |
9515 | ||
9516 | % There may be a space before second and/or third parameter; delete it. | |
9517 | \def\eatcommaspace#1, {#1,} | |
9518 | ||
9519 | % #1 is the optional FLOATTYPE, the text label for this float, typically | |
9520 | % "Figure", "Table", "Example", etc. Can't contain commas. If omitted, | |
9521 | % this float will not be numbered and cannot be referred to. | |
9522 | % | |
9523 | % #2 is the optional xref label. Also must be present for the float to | |
9524 | % be referable. | |
9525 | % | |
9526 | % #3 is the optional positioning argument; for now, it is ignored. It | |
9527 | % will somehow specify the positions allowed to float to (here, top, bottom). | |
9528 | % | |
9529 | % We keep a separate counter for each FLOATTYPE, which we reset at each | |
9530 | % chapter-level command. | |
9531 | \let\resetallfloatnos=\empty | |
9532 | % | |
9533 | \def\dofloat#1,#2,#3,#4\finish{% | |
9534 | \let\thiscaption=\empty | |
9535 | \let\thisshortcaption=\empty | |
9536 | % | |
9537 | % don't lose footnotes inside @float. | |
9538 | % | |
9539 | % BEWARE: when the floats start float, we have to issue warning whenever an | |
9540 | % insert appears inside a float which could possibly float. --kasal, 26may04 | |
9541 | % | |
9542 | \startsavinginserts | |
9543 | % | |
9544 | % We can't be used inside a paragraph. | |
9545 | \par | |
9546 | % | |
9547 | \vtop\bgroup | |
9548 | \def\floattype{#1}% | |
9549 | \def\floatlabel{#2}% | |
9550 | \def\floatloc{#3}% we do nothing with this yet. | |
9551 | % | |
9552 | \ifx\floattype\empty | |
9553 | \let\safefloattype=\empty | |
9554 | \else | |
9555 | {% | |
9556 | % the floattype might have accents or other special characters, | |
9557 | % but we need to use it in a control sequence name. | |
9558 | \indexnofonts | |
9559 | \turnoffactive | |
9560 | \xdef\safefloattype{\floattype}% | |
9561 | }% | |
9562 | \fi | |
9563 | % | |
9564 | % If label is given but no type, we handle that as the empty type. | |
9565 | \ifx\floatlabel\empty \else | |
9566 | % We want each FLOATTYPE to be numbered separately (Figure 1, | |
9567 | % Table 1, Figure 2, ...). (And if no label, no number.) | |
9568 | % | |
9569 | \expandafter\getfloatno\csname\safefloattype floatno\endcsname | |
9570 | \global\advance\floatno by 1 | |
9571 | % | |
9572 | {% | |
c94f48d7 | 9573 | % This magic value for \lastsection is output by \setref as the |
82d5ce1d UD |
9574 | % XREFLABEL-title value. \xrefX uses it to distinguish float |
9575 | % labels (which have a completely different output format) from | |
9576 | % node and anchor labels. And \xrdef uses it to construct the | |
9577 | % lists of floats. | |
9578 | % | |
c94f48d7 | 9579 | \edef\lastsection{\floatmagic=\safefloattype}% |
82d5ce1d UD |
9580 | \setref{\floatlabel}{Yfloat}% |
9581 | }% | |
9582 | \fi | |
9583 | % | |
9584 | % start with \parskip glue, I guess. | |
9585 | \vskip\parskip | |
9586 | % | |
9587 | % Don't suppress indentation if a float happens to start a section. | |
9588 | \restorefirstparagraphindent | |
9589 | } | |
9590 | ||
9591 | % we have these possibilities: | |
9592 | % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap | |
9593 | % @float Foo,lbl & no caption: Foo 1.1 | |
9594 | % @float Foo & @caption{Cap}: Foo: Cap | |
9595 | % @float Foo & no caption: Foo | |
9596 | % @float ,lbl & Caption{Cap}: 1.1: Cap | |
9597 | % @float ,lbl & no caption: 1.1 | |
9598 | % @float & @caption{Cap}: Cap | |
9599 | % @float & no caption: | |
9600 | % | |
9601 | \def\Efloat{% | |
9602 | \let\floatident = \empty | |
9603 | % | |
9604 | % In all cases, if we have a float type, it comes first. | |
9605 | \ifx\floattype\empty \else \def\floatident{\floattype}\fi | |
9606 | % | |
9607 | % If we have an xref label, the number comes next. | |
9608 | \ifx\floatlabel\empty \else | |
9609 | \ifx\floattype\empty \else % if also had float type, need tie first. | |
9610 | \appendtomacro\floatident{\tie}% | |
9611 | \fi | |
9612 | % the number. | |
9613 | \appendtomacro\floatident{\chaplevelprefix\the\floatno}% | |
9614 | \fi | |
9615 | % | |
9616 | % Start the printed caption with what we've constructed in | |
9617 | % \floatident, but keep it separate; we need \floatident again. | |
9618 | \let\captionline = \floatident | |
9619 | % | |
9620 | \ifx\thiscaption\empty \else | |
9621 | \ifx\floatident\empty \else | |
7f7dd1d3 | 9622 | \appendtomacro\captionline{: }% had ident, so need a colon between |
82d5ce1d UD |
9623 | \fi |
9624 | % | |
9625 | % caption text. | |
9626 | \appendtomacro\captionline{\scanexp\thiscaption}% | |
9627 | \fi | |
9628 | % | |
9629 | % If we have anything to print, print it, with space before. | |
9630 | % Eventually this needs to become an \insert. | |
9631 | \ifx\captionline\empty \else | |
9632 | \vskip.5\parskip | |
9633 | \captionline | |
9634 | % | |
9635 | % Space below caption. | |
9636 | \vskip\parskip | |
9637 | \fi | |
9638 | % | |
9639 | % If have an xref label, write the list of floats info. Do this | |
9640 | % after the caption, to avoid chance of it being a breakpoint. | |
9641 | \ifx\floatlabel\empty \else | |
9642 | % Write the text that goes in the lof to the aux file as | |
9643 | % \floatlabel-lof. Besides \floatident, we include the short | |
9644 | % caption if specified, else the full caption if specified, else nothing. | |
9645 | {% | |
084e7d57 | 9646 | \requireauxfile |
9251c568 AJ |
9647 | \atdummies |
9648 | % | |
7f7dd1d3 JM |
9649 | \ifx\thisshortcaption\empty |
9650 | \def\gtemp{\thiscaption}% | |
9651 | \else | |
9652 | \def\gtemp{\thisshortcaption}% | |
9653 | \fi | |
82d5ce1d | 9654 | \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident |
7f7dd1d3 | 9655 | \ifx\gtemp\empty \else : \gtemp \fi}}% |
82d5ce1d UD |
9656 | }% |
9657 | \fi | |
9658 | \egroup % end of \vtop | |
9659 | % | |
82d5ce1d UD |
9660 | \checkinserts |
9661 | } | |
9662 | ||
9663 | % Append the tokens #2 to the definition of macro #1, not expanding either. | |
9664 | % | |
9665 | \def\appendtomacro#1#2{% | |
9666 | \expandafter\def\expandafter#1\expandafter{#1#2}% | |
9667 | } | |
9668 | ||
9669 | % @caption, @shortcaption | |
9670 | % | |
9671 | \def\caption{\docaption\thiscaption} | |
9672 | \def\shortcaption{\docaption\thisshortcaption} | |
9673 | \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} | |
9674 | \def\defcaption#1#2{\egroup \def#1{#2}} | |
9675 | ||
9676 | % The parameter is the control sequence identifying the counter we are | |
9677 | % going to use. Create it if it doesn't exist and assign it to \floatno. | |
9678 | \def\getfloatno#1{% | |
9679 | \ifx#1\relax | |
9680 | % Haven't seen this figure type before. | |
9681 | \csname newcount\endcsname #1% | |
9682 | % | |
9683 | % Remember to reset this floatno at the next chap. | |
9684 | \expandafter\gdef\expandafter\resetallfloatnos | |
9685 | \expandafter{\resetallfloatnos #1=0 }% | |
9686 | \fi | |
9687 | \let\floatno#1% | |
9688 | } | |
9689 | ||
9690 | % \setref calls this to get the XREFLABEL-snt value. We want an @xref | |
9691 | % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we | |
9692 | % first read the @float command. | |
9693 | % | |
9694 | \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% | |
9695 | ||
9696 | % Magic string used for the XREFLABEL-title value, so \xrefX can | |
9697 | % distinguish floats from other xref types. | |
9698 | \def\floatmagic{!!float!!} | |
9699 | ||
9700 | % #1 is the control sequence we are passed; we expand into a conditional | |
9701 | % which is true if #1 represents a float ref. That is, the magic | |
c94f48d7 | 9702 | % \lastsection value which we \setref above. |
82d5ce1d UD |
9703 | % |
9704 | \def\iffloat#1{\expandafter\doiffloat#1==\finish} | |
9705 | % | |
9706 | % #1 is (maybe) the \floatmagic string. If so, #2 will be the | |
9707 | % (safe) float type for this float. We set \iffloattype to #2. | |
9708 | % | |
9709 | \def\doiffloat#1=#2=#3\finish{% | |
9710 | \def\temp{#1}% | |
9711 | \def\iffloattype{#2}% | |
9712 | \ifx\temp\floatmagic | |
9713 | } | |
9714 | ||
9715 | % @listoffloats FLOATTYPE - print a list of floats like a table of contents. | |
9716 | % | |
9717 | \parseargdef\listoffloats{% | |
9718 | \def\floattype{#1}% floattype | |
9719 | {% | |
9720 | % the floattype might have accents or other special characters, | |
9721 | % but we need to use it in a control sequence name. | |
9722 | \indexnofonts | |
9723 | \turnoffactive | |
9724 | \xdef\safefloattype{\floattype}% | |
9725 | }% | |
9726 | % | |
9727 | % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. | |
9728 | \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax | |
9729 | \ifhavexrefs | |
9730 | % if the user said @listoffloats foo but never @float foo. | |
9731 | \message{\linenumber No `\safefloattype' floats to list.}% | |
9732 | \fi | |
9733 | \else | |
9734 | \begingroup | |
9735 | \leftskip=\tocindent % indent these entries like a toc | |
9736 | \let\do=\listoffloatsdo | |
9737 | \csname floatlist\safefloattype\endcsname | |
9738 | \endgroup | |
9739 | \fi | |
9740 | } | |
9741 | ||
9742 | % This is called on each entry in a list of floats. We're passed the | |
9743 | % xref label, in the form LABEL-title, which is how we save it in the | |
9744 | % aux file. We strip off the -title and look up \XRLABEL-lof, which | |
9745 | % has the text we're supposed to typeset here. | |
9746 | % | |
9747 | % Figures without xref labels will not be included in the list (since | |
9748 | % they won't appear in the aux file). | |
9749 | % | |
9750 | \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} | |
9751 | \def\listoffloatsdoentry#1-title\finish{{% | |
9752 | % Can't fully expand XR#1-lof because it can contain anything. Just | |
9753 | % pass the control sequence. On the other hand, XR#1-pg is just the | |
9754 | % page number, and we want to fully expand that so we can get a link | |
9755 | % in pdf output. | |
9756 | \toksA = \expandafter{\csname XR#1-lof\endcsname}% | |
9757 | % | |
9758 | % use the same \entry macro we use to generate the TOC and index. | |
9759 | \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% | |
9760 | \writeentry | |
9761 | }} | |
9762 | ||
c94f48d7 | 9763 | |
407dc7a0 UD |
9764 | \message{localization,} |
9765 | ||
0f8bbd69 JM |
9766 | % For single-language documents, @documentlanguage is usually given very |
9767 | % early, just after @documentencoding. Single argument is the language | |
9768 | % (de) or locale (de_DE) abbreviation. | |
407dc7a0 | 9769 | % |
c94f48d7 AJ |
9770 | { |
9771 | \catcode`\_ = \active | |
9772 | \globaldefs=1 | |
084e7d57 | 9773 | \parseargdef\documentlanguage{% |
407dc7a0 | 9774 | \tex % read txi-??.tex file in plain TeX. |
c94f48d7 | 9775 | % Read the file by the name they passed if it exists. |
084e7d57 | 9776 | \let_ = \normalunderscore % normal _ character for filename test |
82d5ce1d UD |
9777 | \openin 1 txi-#1.tex |
9778 | \ifeof 1 | |
084e7d57 | 9779 | \documentlanguagetrywithoutunderscore #1_\finish |
82d5ce1d | 9780 | \else |
0f8bbd69 | 9781 | \globaldefs = 1 % everything in the txi-LL files needs to persist |
82d5ce1d UD |
9782 | \input txi-#1.tex |
9783 | \fi | |
9784 | \closein 1 | |
0f8bbd69 | 9785 | \endgroup % end raw TeX |
084e7d57 | 9786 | } |
c94f48d7 AJ |
9787 | % |
9788 | % If they passed de_DE, and txi-de_DE.tex doesn't exist, | |
9789 | % try txi-de.tex. | |
0f8bbd69 JM |
9790 | % |
9791 | \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% | |
c94f48d7 AJ |
9792 | \openin 1 txi-#1.tex |
9793 | \ifeof 1 | |
9794 | \errhelp = \nolanghelp | |
9795 | \errmessage{Cannot read language file txi-#1.tex}% | |
9796 | \else | |
0f8bbd69 | 9797 | \globaldefs = 1 % everything in the txi-LL files needs to persist |
c94f48d7 AJ |
9798 | \input txi-#1.tex |
9799 | \fi | |
9800 | \closein 1 | |
9801 | } | |
0f8bbd69 | 9802 | }% end of special _ catcode |
c94f48d7 | 9803 | % |
407dc7a0 | 9804 | \newhelp\nolanghelp{The given language definition file cannot be found or |
0f8bbd69 JM |
9805 | is empty. Maybe you need to install it? Putting it in the current |
9806 | directory should work if nowhere else does.} | |
9807 | ||
9808 | % This macro is called from txi-??.tex files; the first argument is the | |
9809 | % \language name to set (without the "\lang@" prefix), the second and | |
9810 | % third args are \{left,right}hyphenmin. | |
9811 | % | |
9812 | % The language names to pass are determined when the format is built. | |
9813 | % See the etex.log file created at that time, e.g., | |
9814 | % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. | |
9815 | % | |
9816 | % With TeX Live 2008, etex now includes hyphenation patterns for all | |
9817 | % available languages. This means we can support hyphenation in | |
9818 | % Texinfo, at least to some extent. (This still doesn't solve the | |
9819 | % accented characters problem.) | |
9820 | % | |
9821 | \catcode`@=11 | |
9822 | \def\txisetlanguage#1#2#3{% | |
9823 | % do not set the language if the name is undefined in the current TeX. | |
9824 | \expandafter\ifx\csname lang@#1\endcsname \relax | |
9825 | \message{no patterns for #1}% | |
9826 | \else | |
9827 | \global\language = \csname lang@#1\endcsname | |
9828 | \fi | |
9829 | % but there is no harm in adjusting the hyphenmin values regardless. | |
9830 | \global\lefthyphenmin = #2\relax | |
9831 | \global\righthyphenmin = #3\relax | |
9832 | } | |
407dc7a0 | 9833 | |
7f7dd1d3 JM |
9834 | % XeTeX and LuaTeX can handle Unicode natively. |
9835 | % Their default I/O uses UTF-8 sequences instead of a byte-wise operation. | |
9836 | % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise. | |
9837 | % | |
9838 | \newif\iftxinativeunicodecapable | |
9839 | \newif\iftxiusebytewiseio | |
9840 | ||
084e7d57 | 9841 | \ifx\XeTeXrevision\thisisundefined |
7f7dd1d3 JM |
9842 | \ifx\luatexversion\thisisundefined |
9843 | \txinativeunicodecapablefalse | |
9844 | \txiusebytewiseiotrue | |
9845 | \else | |
9846 | \txinativeunicodecapabletrue | |
9847 | \txiusebytewiseiofalse | |
9848 | \fi | |
084e7d57 | 9849 | \else |
7f7dd1d3 JM |
9850 | \txinativeunicodecapabletrue |
9851 | \txiusebytewiseiofalse | |
084e7d57 JM |
9852 | \fi |
9853 | ||
7f7dd1d3 JM |
9854 | % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex |
9855 | % for non-UTF-8 (byte-wise) encodings. | |
9856 | % | |
9857 | \def\setbytewiseio{% | |
9858 | \ifx\XeTeXrevision\thisisundefined | |
9859 | \else | |
9860 | \XeTeXdefaultencoding "bytes" % For subsequent files to be read | |
9861 | \XeTeXinputencoding "bytes" % For document root file | |
9862 | % Unfortunately, there seems to be no corresponding XeTeX command for | |
9863 | % output encoding. This is a problem for auxiliary index and TOC files. | |
9864 | % The only solution would be perhaps to write out @U{...} sequences in | |
9865 | % place of non-ASCII characters. | |
9866 | \fi | |
084e7d57 | 9867 | |
7f7dd1d3 JM |
9868 | \ifx\luatexversion\thisisundefined |
9869 | \else | |
9870 | \directlua{ | |
9871 | local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub | |
9872 | local function convert_char (char) | |
9873 | return utf8_char(byte(char)) | |
9874 | end | |
9875 | ||
9876 | local function convert_line (line) | |
9877 | return gsub(line, ".", convert_char) | |
9878 | end | |
9879 | ||
9880 | callback.register("process_input_buffer", convert_line) | |
9881 | ||
9882 | local function convert_line_out (line) | |
9883 | local line_out = "" | |
9884 | for c in string.utfvalues(line) do | |
9885 | line_out = line_out .. string.char(c) | |
9886 | end | |
9887 | return line_out | |
9888 | end | |
9889 | ||
9890 | callback.register("process_output_buffer", convert_line_out) | |
9891 | } | |
9892 | \fi | |
084e7d57 | 9893 | |
7f7dd1d3 | 9894 | \txiusebytewiseiotrue |
084e7d57 | 9895 | } |
084e7d57 JM |
9896 | |
9897 | ||
0f8bbd69 | 9898 | % Helpers for encodings. |
c94f48d7 AJ |
9899 | % Set the catcode of characters 128 through 255 to the specified number. |
9900 | % | |
9901 | \def\setnonasciicharscatcode#1{% | |
9902 | \count255=128 | |
9903 | \loop\ifnum\count255<256 | |
9904 | \global\catcode\count255=#1\relax | |
9905 | \advance\count255 by 1 | |
9906 | \repeat | |
9907 | } | |
407dc7a0 | 9908 | |
c94f48d7 AJ |
9909 | \def\setnonasciicharscatcodenonglobal#1{% |
9910 | \count255=128 | |
9911 | \loop\ifnum\count255<256 | |
9912 | \catcode\count255=#1\relax | |
9913 | \advance\count255 by 1 | |
9914 | \repeat | |
9915 | } | |
9916 | ||
9917 | % @documentencoding sets the definition of non-ASCII characters | |
9918 | % according to the specified encoding. | |
9919 | % | |
084e7d57 JM |
9920 | \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz} |
9921 | \def\documentencodingzzz#1{% | |
7f7dd1d3 | 9922 | % |
c94f48d7 AJ |
9923 | % Encoding being declared for the document. |
9924 | \def\declaredencoding{\csname #1.enc\endcsname}% | |
9925 | % | |
9926 | % Supported encodings: names converted to tokens in order to be able | |
9927 | % to compare them with \ifx. | |
9928 | \def\ascii{\csname US-ASCII.enc\endcsname}% | |
9929 | \def\latnine{\csname ISO-8859-15.enc\endcsname}% | |
9930 | \def\latone{\csname ISO-8859-1.enc\endcsname}% | |
9931 | \def\lattwo{\csname ISO-8859-2.enc\endcsname}% | |
9932 | \def\utfeight{\csname UTF-8.enc\endcsname}% | |
9933 | % | |
9934 | \ifx \declaredencoding \ascii | |
9935 | \asciichardefs | |
9936 | % | |
9937 | \else \ifx \declaredencoding \lattwo | |
7f7dd1d3 JM |
9938 | \iftxinativeunicodecapable |
9939 | \setbytewiseio | |
9940 | \fi | |
c94f48d7 AJ |
9941 | \setnonasciicharscatcode\active |
9942 | \lattwochardefs | |
9943 | % | |
0f8bbd69 | 9944 | \else \ifx \declaredencoding \latone |
7f7dd1d3 JM |
9945 | \iftxinativeunicodecapable |
9946 | \setbytewiseio | |
9947 | \fi | |
c94f48d7 AJ |
9948 | \setnonasciicharscatcode\active |
9949 | \latonechardefs | |
9950 | % | |
9951 | \else \ifx \declaredencoding \latnine | |
7f7dd1d3 JM |
9952 | \iftxinativeunicodecapable |
9953 | \setbytewiseio | |
9954 | \fi | |
c94f48d7 AJ |
9955 | \setnonasciicharscatcode\active |
9956 | \latninechardefs | |
9957 | % | |
9958 | \else \ifx \declaredencoding \utfeight | |
7f7dd1d3 JM |
9959 | \iftxinativeunicodecapable |
9960 | % For native Unicode handling (XeTeX and LuaTeX) | |
9961 | \nativeunicodechardefs | |
9962 | \else | |
9963 | % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX) | |
9964 | \setnonasciicharscatcode\active | |
9965 | % since we already invoked \utfeightchardefs at the top level | |
9966 | % (below), do not re-invoke it, otherwise our check for duplicated | |
9967 | % definitions gets triggered. Making non-ascii chars active is | |
9968 | % sufficient. | |
9969 | \fi | |
c94f48d7 | 9970 | % |
0f8bbd69 | 9971 | \else |
084e7d57 | 9972 | \message{Ignoring unknown document encoding: #1.}% |
c94f48d7 AJ |
9973 | % |
9974 | \fi % utfeight | |
9975 | \fi % latnine | |
9976 | \fi % latone | |
9977 | \fi % lattwo | |
9978 | \fi % ascii | |
7f7dd1d3 JM |
9979 | % |
9980 | \ifx\XeTeXrevision\thisisundefined | |
9981 | \else | |
9982 | \ifx \declaredencoding \utfeight | |
9983 | \else | |
9984 | \ifx \declaredencoding \ascii | |
9985 | \else | |
9986 | \message{Warning: XeTeX with non-UTF-8 encodings cannot handle % | |
9987 | non-ASCII characters in auxiliary files.}% | |
9988 | \fi | |
9989 | \fi | |
9990 | \fi | |
c94f48d7 | 9991 | } |
9e9f9cc2 | 9992 | |
084e7d57 | 9993 | % emacs-page |
c94f48d7 AJ |
9994 | % A message to be logged when using a character that isn't available |
9995 | % the default font encoding (OT1). | |
0f8bbd69 | 9996 | % |
084e7d57 | 9997 | \def\missingcharmsg#1{\message{Character missing, sorry: #1.}} |
c94f48d7 AJ |
9998 | |
9999 | % Take account of \c (plain) vs. \, (Texinfo) difference. | |
10000 | \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} | |
10001 | ||
10002 | % First, make active non-ASCII characters in order for them to be | |
10003 | % correctly categorized when TeX reads the replacement text of | |
10004 | % macros containing the character definitions. | |
10005 | \setnonasciicharscatcode\active | |
10006 | % | |
7f7dd1d3 JM |
10007 | |
10008 | \def\gdefchar#1#2{% | |
10009 | \gdef#1{% | |
10010 | \ifpassthroughchars | |
10011 | \string#1% | |
10012 | \else | |
10013 | #2% | |
10014 | \fi | |
10015 | }} | |
10016 | ||
c94f48d7 AJ |
10017 | % Latin1 (ISO-8859-1) character definitions. |
10018 | \def\latonechardefs{% | |
7f7dd1d3 JM |
10019 | \gdefchar^^a0{\tie} |
10020 | \gdefchar^^a1{\exclamdown} | |
10021 | \gdefchar^^a2{{\tcfont \char162}} % cent | |
10022 | \gdefchar^^a3{\pounds{}} | |
10023 | \gdefchar^^a4{{\tcfont \char164}} % currency | |
10024 | \gdefchar^^a5{{\tcfont \char165}} % yen | |
10025 | \gdefchar^^a6{{\tcfont \char166}} % broken bar | |
10026 | \gdefchar^^a7{\S} | |
10027 | \gdefchar^^a8{\"{}} | |
10028 | \gdefchar^^a9{\copyright{}} | |
10029 | \gdefchar^^aa{\ordf} | |
10030 | \gdefchar^^ab{\guillemetleft{}} | |
10031 | \gdefchar^^ac{\ensuremath\lnot} | |
10032 | \gdefchar^^ad{\-} | |
10033 | \gdefchar^^ae{\registeredsymbol{}} | |
10034 | \gdefchar^^af{\={}} | |
10035 | % | |
10036 | \gdefchar^^b0{\textdegree} | |
10037 | \gdefchar^^b1{$\pm$} | |
10038 | \gdefchar^^b2{$^2$} | |
10039 | \gdefchar^^b3{$^3$} | |
10040 | \gdefchar^^b4{\'{}} | |
10041 | \gdefchar^^b5{$\mu$} | |
10042 | \gdefchar^^b6{\P} | |
10043 | \gdefchar^^b7{\ensuremath\cdot} | |
10044 | \gdefchar^^b8{\cedilla\ } | |
10045 | \gdefchar^^b9{$^1$} | |
10046 | \gdefchar^^ba{\ordm} | |
10047 | \gdefchar^^bb{\guillemetright{}} | |
10048 | \gdefchar^^bc{$1\over4$} | |
10049 | \gdefchar^^bd{$1\over2$} | |
10050 | \gdefchar^^be{$3\over4$} | |
10051 | \gdefchar^^bf{\questiondown} | |
10052 | % | |
10053 | \gdefchar^^c0{\`A} | |
10054 | \gdefchar^^c1{\'A} | |
10055 | \gdefchar^^c2{\^A} | |
10056 | \gdefchar^^c3{\~A} | |
10057 | \gdefchar^^c4{\"A} | |
10058 | \gdefchar^^c5{\ringaccent A} | |
10059 | \gdefchar^^c6{\AE} | |
10060 | \gdefchar^^c7{\cedilla C} | |
10061 | \gdefchar^^c8{\`E} | |
10062 | \gdefchar^^c9{\'E} | |
10063 | \gdefchar^^ca{\^E} | |
10064 | \gdefchar^^cb{\"E} | |
10065 | \gdefchar^^cc{\`I} | |
10066 | \gdefchar^^cd{\'I} | |
10067 | \gdefchar^^ce{\^I} | |
10068 | \gdefchar^^cf{\"I} | |
10069 | % | |
10070 | \gdefchar^^d0{\DH} | |
10071 | \gdefchar^^d1{\~N} | |
10072 | \gdefchar^^d2{\`O} | |
10073 | \gdefchar^^d3{\'O} | |
10074 | \gdefchar^^d4{\^O} | |
10075 | \gdefchar^^d5{\~O} | |
10076 | \gdefchar^^d6{\"O} | |
10077 | \gdefchar^^d7{$\times$} | |
10078 | \gdefchar^^d8{\O} | |
10079 | \gdefchar^^d9{\`U} | |
10080 | \gdefchar^^da{\'U} | |
10081 | \gdefchar^^db{\^U} | |
10082 | \gdefchar^^dc{\"U} | |
10083 | \gdefchar^^dd{\'Y} | |
10084 | \gdefchar^^de{\TH} | |
10085 | \gdefchar^^df{\ss} | |
10086 | % | |
10087 | \gdefchar^^e0{\`a} | |
10088 | \gdefchar^^e1{\'a} | |
10089 | \gdefchar^^e2{\^a} | |
10090 | \gdefchar^^e3{\~a} | |
10091 | \gdefchar^^e4{\"a} | |
10092 | \gdefchar^^e5{\ringaccent a} | |
10093 | \gdefchar^^e6{\ae} | |
10094 | \gdefchar^^e7{\cedilla c} | |
10095 | \gdefchar^^e8{\`e} | |
10096 | \gdefchar^^e9{\'e} | |
10097 | \gdefchar^^ea{\^e} | |
10098 | \gdefchar^^eb{\"e} | |
10099 | \gdefchar^^ec{\`{\dotless i}} | |
10100 | \gdefchar^^ed{\'{\dotless i}} | |
10101 | \gdefchar^^ee{\^{\dotless i}} | |
10102 | \gdefchar^^ef{\"{\dotless i}} | |
10103 | % | |
10104 | \gdefchar^^f0{\dh} | |
10105 | \gdefchar^^f1{\~n} | |
10106 | \gdefchar^^f2{\`o} | |
10107 | \gdefchar^^f3{\'o} | |
10108 | \gdefchar^^f4{\^o} | |
10109 | \gdefchar^^f5{\~o} | |
10110 | \gdefchar^^f6{\"o} | |
10111 | \gdefchar^^f7{$\div$} | |
10112 | \gdefchar^^f8{\o} | |
10113 | \gdefchar^^f9{\`u} | |
10114 | \gdefchar^^fa{\'u} | |
10115 | \gdefchar^^fb{\^u} | |
10116 | \gdefchar^^fc{\"u} | |
10117 | \gdefchar^^fd{\'y} | |
10118 | \gdefchar^^fe{\th} | |
10119 | \gdefchar^^ff{\"y} | |
c94f48d7 AJ |
10120 | } |
10121 | ||
10122 | % Latin9 (ISO-8859-15) encoding character definitions. | |
10123 | \def\latninechardefs{% | |
10124 | % Encoding is almost identical to Latin1. | |
10125 | \latonechardefs | |
10126 | % | |
7f7dd1d3 JM |
10127 | \gdefchar^^a4{\euro{}} |
10128 | \gdefchar^^a6{\v S} | |
10129 | \gdefchar^^a8{\v s} | |
10130 | \gdefchar^^b4{\v Z} | |
10131 | \gdefchar^^b8{\v z} | |
10132 | \gdefchar^^bc{\OE} | |
10133 | \gdefchar^^bd{\oe} | |
10134 | \gdefchar^^be{\"Y} | |
c94f48d7 AJ |
10135 | } |
10136 | ||
10137 | % Latin2 (ISO-8859-2) character definitions. | |
10138 | \def\lattwochardefs{% | |
7f7dd1d3 JM |
10139 | \gdefchar^^a0{\tie} |
10140 | \gdefchar^^a1{\ogonek{A}} | |
10141 | \gdefchar^^a2{\u{}} | |
10142 | \gdefchar^^a3{\L} | |
10143 | \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}} | |
10144 | \gdefchar^^a5{\v L} | |
10145 | \gdefchar^^a6{\'S} | |
10146 | \gdefchar^^a7{\S} | |
10147 | \gdefchar^^a8{\"{}} | |
10148 | \gdefchar^^a9{\v S} | |
10149 | \gdefchar^^aa{\cedilla S} | |
10150 | \gdefchar^^ab{\v T} | |
10151 | \gdefchar^^ac{\'Z} | |
10152 | \gdefchar^^ad{\-} | |
10153 | \gdefchar^^ae{\v Z} | |
10154 | \gdefchar^^af{\dotaccent Z} | |
10155 | % | |
10156 | \gdefchar^^b0{\textdegree{}} | |
10157 | \gdefchar^^b1{\ogonek{a}} | |
10158 | \gdefchar^^b2{\ogonek{ }} | |
10159 | \gdefchar^^b3{\l} | |
10160 | \gdefchar^^b4{\'{}} | |
10161 | \gdefchar^^b5{\v l} | |
10162 | \gdefchar^^b6{\'s} | |
10163 | \gdefchar^^b7{\v{}} | |
10164 | \gdefchar^^b8{\cedilla\ } | |
10165 | \gdefchar^^b9{\v s} | |
10166 | \gdefchar^^ba{\cedilla s} | |
10167 | \gdefchar^^bb{\v t} | |
10168 | \gdefchar^^bc{\'z} | |
10169 | \gdefchar^^bd{\H{}} | |
10170 | \gdefchar^^be{\v z} | |
10171 | \gdefchar^^bf{\dotaccent z} | |
10172 | % | |
10173 | \gdefchar^^c0{\'R} | |
10174 | \gdefchar^^c1{\'A} | |
10175 | \gdefchar^^c2{\^A} | |
10176 | \gdefchar^^c3{\u A} | |
10177 | \gdefchar^^c4{\"A} | |
10178 | \gdefchar^^c5{\'L} | |
10179 | \gdefchar^^c6{\'C} | |
10180 | \gdefchar^^c7{\cedilla C} | |
10181 | \gdefchar^^c8{\v C} | |
10182 | \gdefchar^^c9{\'E} | |
10183 | \gdefchar^^ca{\ogonek{E}} | |
10184 | \gdefchar^^cb{\"E} | |
10185 | \gdefchar^^cc{\v E} | |
10186 | \gdefchar^^cd{\'I} | |
10187 | \gdefchar^^ce{\^I} | |
10188 | \gdefchar^^cf{\v D} | |
10189 | % | |
10190 | \gdefchar^^d0{\DH} | |
10191 | \gdefchar^^d1{\'N} | |
10192 | \gdefchar^^d2{\v N} | |
10193 | \gdefchar^^d3{\'O} | |
10194 | \gdefchar^^d4{\^O} | |
10195 | \gdefchar^^d5{\H O} | |
10196 | \gdefchar^^d6{\"O} | |
10197 | \gdefchar^^d7{$\times$} | |
10198 | \gdefchar^^d8{\v R} | |
10199 | \gdefchar^^d9{\ringaccent U} | |
10200 | \gdefchar^^da{\'U} | |
10201 | \gdefchar^^db{\H U} | |
10202 | \gdefchar^^dc{\"U} | |
10203 | \gdefchar^^dd{\'Y} | |
10204 | \gdefchar^^de{\cedilla T} | |
10205 | \gdefchar^^df{\ss} | |
10206 | % | |
10207 | \gdefchar^^e0{\'r} | |
10208 | \gdefchar^^e1{\'a} | |
10209 | \gdefchar^^e2{\^a} | |
10210 | \gdefchar^^e3{\u a} | |
10211 | \gdefchar^^e4{\"a} | |
10212 | \gdefchar^^e5{\'l} | |
10213 | \gdefchar^^e6{\'c} | |
10214 | \gdefchar^^e7{\cedilla c} | |
10215 | \gdefchar^^e8{\v c} | |
10216 | \gdefchar^^e9{\'e} | |
10217 | \gdefchar^^ea{\ogonek{e}} | |
10218 | \gdefchar^^eb{\"e} | |
10219 | \gdefchar^^ec{\v e} | |
10220 | \gdefchar^^ed{\'{\dotless{i}}} | |
10221 | \gdefchar^^ee{\^{\dotless{i}}} | |
10222 | \gdefchar^^ef{\v d} | |
10223 | % | |
10224 | \gdefchar^^f0{\dh} | |
10225 | \gdefchar^^f1{\'n} | |
10226 | \gdefchar^^f2{\v n} | |
10227 | \gdefchar^^f3{\'o} | |
10228 | \gdefchar^^f4{\^o} | |
10229 | \gdefchar^^f5{\H o} | |
10230 | \gdefchar^^f6{\"o} | |
10231 | \gdefchar^^f7{$\div$} | |
10232 | \gdefchar^^f8{\v r} | |
10233 | \gdefchar^^f9{\ringaccent u} | |
10234 | \gdefchar^^fa{\'u} | |
10235 | \gdefchar^^fb{\H u} | |
10236 | \gdefchar^^fc{\"u} | |
10237 | \gdefchar^^fd{\'y} | |
10238 | \gdefchar^^fe{\cedilla t} | |
10239 | \gdefchar^^ff{\dotaccent{}} | |
c94f48d7 AJ |
10240 | } |
10241 | ||
10242 | % UTF-8 character definitions. | |
0f8bbd69 | 10243 | % |
c94f48d7 AJ |
10244 | % This code to support UTF-8 is based on LaTeX's utf8.def, with some |
10245 | % changes for Texinfo conventions. It is included here under the GPL by | |
10246 | % permission from Frank Mittelbach and the LaTeX team. | |
0f8bbd69 | 10247 | % |
c94f48d7 AJ |
10248 | \newcount\countUTFx |
10249 | \newcount\countUTFy | |
10250 | \newcount\countUTFz | |
407dc7a0 | 10251 | |
c94f48d7 AJ |
10252 | \gdef\UTFviiiTwoOctets#1#2{\expandafter |
10253 | \UTFviiiDefined\csname u8:#1\string #2\endcsname} | |
10254 | % | |
10255 | \gdef\UTFviiiThreeOctets#1#2#3{\expandafter | |
10256 | \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} | |
407dc7a0 | 10257 | % |
c94f48d7 AJ |
10258 | \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter |
10259 | \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} | |
10260 | ||
10261 | \gdef\UTFviiiDefined#1{% | |
10262 | \ifx #1\relax | |
10263 | \message{\linenumber Unicode char \string #1 not defined for Texinfo}% | |
10264 | \else | |
10265 | \expandafter #1% | |
10266 | \fi | |
10267 | } | |
10268 | ||
7f7dd1d3 | 10269 | % Give non-ASCII bytes the active definitions for processing UTF-8 sequences |
c94f48d7 AJ |
10270 | \begingroup |
10271 | \catcode`\~13 | |
7f7dd1d3 | 10272 | \catcode`\$12 |
c94f48d7 AJ |
10273 | \catcode`\"12 |
10274 | ||
7f7dd1d3 JM |
10275 | % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp |
10276 | % substituting ~ and $ with a character token of that value. | |
c94f48d7 AJ |
10277 | \def\UTFviiiLoop{% |
10278 | \global\catcode\countUTFx\active | |
10279 | \uccode`\~\countUTFx | |
7f7dd1d3 | 10280 | \uccode`\$\countUTFx |
c94f48d7 AJ |
10281 | \uppercase\expandafter{\UTFviiiTmp}% |
10282 | \advance\countUTFx by 1 | |
10283 | \ifnum\countUTFx < \countUTFy | |
10284 | \expandafter\UTFviiiLoop | |
10285 | \fi} | |
10286 | ||
7f7dd1d3 JM |
10287 | % For bytes other than the first in a UTF-8 sequence. Not expected to |
10288 | % be expanded except when writing to auxiliary files. | |
10289 | \countUTFx = "80 | |
10290 | \countUTFy = "C2 | |
10291 | \def\UTFviiiTmp{% | |
10292 | \gdef~{% | |
10293 | \ifpassthroughchars $\fi}}% | |
10294 | \UTFviiiLoop | |
10295 | ||
c94f48d7 AJ |
10296 | \countUTFx = "C2 |
10297 | \countUTFy = "E0 | |
10298 | \def\UTFviiiTmp{% | |
7f7dd1d3 JM |
10299 | \gdef~{% |
10300 | \ifpassthroughchars $% | |
10301 | \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}% | |
c94f48d7 AJ |
10302 | \UTFviiiLoop |
10303 | ||
10304 | \countUTFx = "E0 | |
10305 | \countUTFy = "F0 | |
10306 | \def\UTFviiiTmp{% | |
7f7dd1d3 JM |
10307 | \gdef~{% |
10308 | \ifpassthroughchars $% | |
10309 | \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}% | |
c94f48d7 AJ |
10310 | \UTFviiiLoop |
10311 | ||
10312 | \countUTFx = "F0 | |
10313 | \countUTFy = "F4 | |
10314 | \def\UTFviiiTmp{% | |
7f7dd1d3 JM |
10315 | \gdef~{% |
10316 | \ifpassthroughchars $% | |
10317 | \else\expandafter\UTFviiiFourOctets\expandafter$\fi | |
10318 | }}% | |
c94f48d7 AJ |
10319 | \UTFviiiLoop |
10320 | \endgroup | |
10321 | ||
084e7d57 JM |
10322 | \def\globallet{\global\let} % save some \expandafter's below |
10323 | ||
10324 | % @U{xxxx} to produce U+xxxx, if we support it. | |
10325 | \def\U#1{% | |
10326 | \expandafter\ifx\csname uni:#1\endcsname \relax | |
7f7dd1d3 JM |
10327 | \iftxinativeunicodecapable |
10328 | % All Unicode characters can be used if native Unicode handling is | |
10329 | % active. However, if the font does not have the glyph, | |
10330 | % letters are missing. | |
10331 | \begingroup | |
10332 | \uccode`\.="#1\relax | |
10333 | \uppercase{.} | |
10334 | \endgroup | |
10335 | \else | |
10336 | \errhelp = \EMsimple | |
10337 | \errmessage{Unicode character U+#1 not supported, sorry}% | |
10338 | \fi | |
084e7d57 JM |
10339 | \else |
10340 | \csname uni:#1\endcsname | |
10341 | \fi | |
10342 | } | |
10343 | ||
7f7dd1d3 JM |
10344 | % These macros are used here to construct the name of a control |
10345 | % sequence to be defined. | |
10346 | \def\UTFviiiTwoOctetsName#1#2{% | |
10347 | \csname u8:#1\string #2\endcsname}% | |
10348 | \def\UTFviiiThreeOctetsName#1#2#3{% | |
10349 | \csname u8:#1\string #2\string #3\endcsname}% | |
10350 | \def\UTFviiiFourOctetsName#1#2#3#4{% | |
10351 | \csname u8:#1\string #2\string #3\string #4\endcsname}% | |
10352 | ||
10353 | % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX), | |
10354 | % provide a definition macro to replace a Unicode character; | |
10355 | % this gets used by the @U command | |
10356 | % | |
c94f48d7 AJ |
10357 | \begingroup |
10358 | \catcode`\"=12 | |
10359 | \catcode`\<=12 | |
10360 | \catcode`\.=12 | |
10361 | \catcode`\,=12 | |
10362 | \catcode`\;=12 | |
10363 | \catcode`\!=12 | |
10364 | \catcode`\~=13 | |
7f7dd1d3 | 10365 | \gdef\DeclareUnicodeCharacterUTFviii#1#2{% |
c94f48d7 | 10366 | \countUTFz = "#1\relax |
c94f48d7 AJ |
10367 | \begingroup |
10368 | \parseXMLCharref | |
7f7dd1d3 JM |
10369 | |
10370 | % Give \u8:... its definition. The sequence of seven \expandafter's | |
10371 | % expands after the \gdef three times, e.g. | |
10372 | % | |
10373 | % 1. \UTFviiTwoOctetsName B1 B2 | |
10374 | % 2. \csname u8:B1 \string B2 \endcsname | |
10375 | % 3. \u8: B1 B2 (a single control sequence token) | |
10376 | % | |
10377 | \expandafter\expandafter | |
10378 | \expandafter\expandafter | |
10379 | \expandafter\expandafter | |
10380 | \expandafter\gdef \UTFviiiTmp{#2}% | |
084e7d57 JM |
10381 | % |
10382 | \expandafter\ifx\csname uni:#1\endcsname \relax \else | |
10383 | \message{Internal error, already defined: #1}% | |
10384 | \fi | |
10385 | % | |
10386 | % define an additional control sequence for this code point. | |
10387 | \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp | |
c94f48d7 | 10388 | \endgroup} |
7f7dd1d3 JM |
10389 | % |
10390 | % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp | |
10391 | % to the corresponding UTF-8 sequence. | |
c94f48d7 AJ |
10392 | \gdef\parseXMLCharref{% |
10393 | \ifnum\countUTFz < "A0\relax | |
10394 | \errhelp = \EMsimple | |
10395 | \errmessage{Cannot define Unicode char value < 00A0}% | |
10396 | \else\ifnum\countUTFz < "800\relax | |
10397 | \parseUTFviiiA,% | |
7f7dd1d3 | 10398 | \parseUTFviiiB C\UTFviiiTwoOctetsName.,% |
c94f48d7 AJ |
10399 | \else\ifnum\countUTFz < "10000\relax |
10400 | \parseUTFviiiA;% | |
10401 | \parseUTFviiiA,% | |
7f7dd1d3 | 10402 | \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}% |
c94f48d7 AJ |
10403 | \else |
10404 | \parseUTFviiiA;% | |
10405 | \parseUTFviiiA,% | |
10406 | \parseUTFviiiA!% | |
7f7dd1d3 | 10407 | \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}% |
c94f48d7 AJ |
10408 | \fi\fi\fi |
10409 | } | |
10410 | ||
7f7dd1d3 JM |
10411 | % Extract a byte from the end of the UTF-8 representation of \countUTFx. |
10412 | % It must be a non-initial byte in the sequence. | |
10413 | % Change \uccode of #1 for it to be used in \parseUTFviiiB as one | |
10414 | % of the bytes. | |
c94f48d7 AJ |
10415 | \gdef\parseUTFviiiA#1{% |
10416 | \countUTFx = \countUTFz | |
10417 | \divide\countUTFz by 64 | |
7f7dd1d3 | 10418 | \countUTFy = \countUTFz % Save to be the future value of \countUTFz. |
c94f48d7 | 10419 | \multiply\countUTFz by 64 |
7f7dd1d3 JM |
10420 | |
10421 | % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract | |
10422 | % in order to get the last five bits. | |
c94f48d7 | 10423 | \advance\countUTFx by -\countUTFz |
7f7dd1d3 JM |
10424 | |
10425 | % Convert this to the byte in the UTF-8 sequence. | |
c94f48d7 AJ |
10426 | \advance\countUTFx by 128 |
10427 | \uccode `#1\countUTFx | |
10428 | \countUTFz = \countUTFy} | |
10429 | ||
7f7dd1d3 JM |
10430 | % Used to put a UTF-8 byte sequence into \UTFviiiTmp |
10431 | % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8 | |
10432 | % sequence. | |
10433 | % #2 is one of the \UTFviii*OctetsName macros. | |
10434 | % #3 is always a full stop (.) | |
10435 | % #4 is a template for the other bytes in the sequence. The values for these | |
10436 | % bytes is substituted in here with \uppercase using the \uccode's. | |
c94f48d7 AJ |
10437 | \gdef\parseUTFviiiB#1#2#3#4{% |
10438 | \advance\countUTFz by "#10\relax | |
10439 | \uccode `#3\countUTFz | |
10440 | \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} | |
10441 | \endgroup | |
10442 | ||
7f7dd1d3 JM |
10443 | % For native Unicode handling (XeTeX and LuaTeX), |
10444 | % provide a definition macro that sets a catcode to `other' non-globally | |
10445 | % | |
10446 | \def\DeclareUnicodeCharacterNativeOther#1#2{% | |
10447 | \catcode"#1=\other | |
10448 | } | |
10449 | ||
084e7d57 JM |
10450 | % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M |
10451 | % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) | |
10452 | % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) | |
10453 | % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A | |
10454 | % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B | |
10455 | % | |
10456 | % Many of our renditions are less than wonderful, and all the missing | |
10457 | % characters are available somewhere. Loading the necessary fonts | |
10458 | % awaits user request. We can't truly support Unicode without | |
10459 | % reimplementing everything that's been done in LaTeX for many years, | |
10460 | % plus probably using luatex or xetex, and who knows what else. | |
10461 | % We won't be doing that here in this simple file. But we can try to at | |
10462 | % least make most of the characters not bomb out. | |
10463 | % | |
7f7dd1d3 JM |
10464 | \def\unicodechardefs{% |
10465 | \DeclareUnicodeCharacter{00A0}{\tie}% | |
10466 | \DeclareUnicodeCharacter{00A1}{\exclamdown}% | |
084e7d57 | 10467 | \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent |
7f7dd1d3 | 10468 | \DeclareUnicodeCharacter{00A3}{\pounds{}}% |
084e7d57 JM |
10469 | \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency |
10470 | \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen | |
10471 | \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar | |
7f7dd1d3 JM |
10472 | \DeclareUnicodeCharacter{00A7}{\S}% |
10473 | \DeclareUnicodeCharacter{00A8}{\"{ }}% | |
10474 | \DeclareUnicodeCharacter{00A9}{\copyright{}}% | |
10475 | \DeclareUnicodeCharacter{00AA}{\ordf}% | |
10476 | \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}% | |
10477 | \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}% | |
10478 | \DeclareUnicodeCharacter{00AD}{\-}% | |
10479 | \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}% | |
10480 | \DeclareUnicodeCharacter{00AF}{\={ }}% | |
10481 | % | |
10482 | \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}% | |
10483 | \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}% | |
10484 | \DeclareUnicodeCharacter{00B2}{$^2$}% | |
10485 | \DeclareUnicodeCharacter{00B3}{$^3$}% | |
10486 | \DeclareUnicodeCharacter{00B4}{\'{ }}% | |
10487 | \DeclareUnicodeCharacter{00B5}{$\mu$}% | |
10488 | \DeclareUnicodeCharacter{00B6}{\P}% | |
10489 | \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}% | |
10490 | \DeclareUnicodeCharacter{00B8}{\cedilla{ }}% | |
10491 | \DeclareUnicodeCharacter{00B9}{$^1$}% | |
10492 | \DeclareUnicodeCharacter{00BA}{\ordm}% | |
10493 | \DeclareUnicodeCharacter{00BB}{\guillemetright{}}% | |
10494 | \DeclareUnicodeCharacter{00BC}{$1\over4$}% | |
10495 | \DeclareUnicodeCharacter{00BD}{$1\over2$}% | |
10496 | \DeclareUnicodeCharacter{00BE}{$3\over4$}% | |
10497 | \DeclareUnicodeCharacter{00BF}{\questiondown}% | |
10498 | % | |
10499 | \DeclareUnicodeCharacter{00C0}{\`A}% | |
10500 | \DeclareUnicodeCharacter{00C1}{\'A}% | |
10501 | \DeclareUnicodeCharacter{00C2}{\^A}% | |
10502 | \DeclareUnicodeCharacter{00C3}{\~A}% | |
10503 | \DeclareUnicodeCharacter{00C4}{\"A}% | |
10504 | \DeclareUnicodeCharacter{00C5}{\AA}% | |
10505 | \DeclareUnicodeCharacter{00C6}{\AE}% | |
10506 | \DeclareUnicodeCharacter{00C7}{\cedilla{C}}% | |
10507 | \DeclareUnicodeCharacter{00C8}{\`E}% | |
10508 | \DeclareUnicodeCharacter{00C9}{\'E}% | |
10509 | \DeclareUnicodeCharacter{00CA}{\^E}% | |
10510 | \DeclareUnicodeCharacter{00CB}{\"E}% | |
10511 | \DeclareUnicodeCharacter{00CC}{\`I}% | |
10512 | \DeclareUnicodeCharacter{00CD}{\'I}% | |
10513 | \DeclareUnicodeCharacter{00CE}{\^I}% | |
10514 | \DeclareUnicodeCharacter{00CF}{\"I}% | |
10515 | % | |
10516 | \DeclareUnicodeCharacter{00D0}{\DH}% | |
10517 | \DeclareUnicodeCharacter{00D1}{\~N}% | |
10518 | \DeclareUnicodeCharacter{00D2}{\`O}% | |
10519 | \DeclareUnicodeCharacter{00D3}{\'O}% | |
10520 | \DeclareUnicodeCharacter{00D4}{\^O}% | |
10521 | \DeclareUnicodeCharacter{00D5}{\~O}% | |
10522 | \DeclareUnicodeCharacter{00D6}{\"O}% | |
10523 | \DeclareUnicodeCharacter{00D7}{\ensuremath\times}% | |
10524 | \DeclareUnicodeCharacter{00D8}{\O}% | |
10525 | \DeclareUnicodeCharacter{00D9}{\`U}% | |
10526 | \DeclareUnicodeCharacter{00DA}{\'U}% | |
10527 | \DeclareUnicodeCharacter{00DB}{\^U}% | |
10528 | \DeclareUnicodeCharacter{00DC}{\"U}% | |
10529 | \DeclareUnicodeCharacter{00DD}{\'Y}% | |
10530 | \DeclareUnicodeCharacter{00DE}{\TH}% | |
10531 | \DeclareUnicodeCharacter{00DF}{\ss}% | |
10532 | % | |
10533 | \DeclareUnicodeCharacter{00E0}{\`a}% | |
10534 | \DeclareUnicodeCharacter{00E1}{\'a}% | |
10535 | \DeclareUnicodeCharacter{00E2}{\^a}% | |
10536 | \DeclareUnicodeCharacter{00E3}{\~a}% | |
10537 | \DeclareUnicodeCharacter{00E4}{\"a}% | |
10538 | \DeclareUnicodeCharacter{00E5}{\aa}% | |
10539 | \DeclareUnicodeCharacter{00E6}{\ae}% | |
10540 | \DeclareUnicodeCharacter{00E7}{\cedilla{c}}% | |
10541 | \DeclareUnicodeCharacter{00E8}{\`e}% | |
10542 | \DeclareUnicodeCharacter{00E9}{\'e}% | |
10543 | \DeclareUnicodeCharacter{00EA}{\^e}% | |
10544 | \DeclareUnicodeCharacter{00EB}{\"e}% | |
10545 | \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}% | |
10546 | \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}% | |
10547 | \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}% | |
10548 | \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}% | |
10549 | % | |
10550 | \DeclareUnicodeCharacter{00F0}{\dh}% | |
10551 | \DeclareUnicodeCharacter{00F1}{\~n}% | |
10552 | \DeclareUnicodeCharacter{00F2}{\`o}% | |
10553 | \DeclareUnicodeCharacter{00F3}{\'o}% | |
10554 | \DeclareUnicodeCharacter{00F4}{\^o}% | |
10555 | \DeclareUnicodeCharacter{00F5}{\~o}% | |
10556 | \DeclareUnicodeCharacter{00F6}{\"o}% | |
10557 | \DeclareUnicodeCharacter{00F7}{\ensuremath\div}% | |
10558 | \DeclareUnicodeCharacter{00F8}{\o}% | |
10559 | \DeclareUnicodeCharacter{00F9}{\`u}% | |
10560 | \DeclareUnicodeCharacter{00FA}{\'u}% | |
10561 | \DeclareUnicodeCharacter{00FB}{\^u}% | |
10562 | \DeclareUnicodeCharacter{00FC}{\"u}% | |
10563 | \DeclareUnicodeCharacter{00FD}{\'y}% | |
10564 | \DeclareUnicodeCharacter{00FE}{\th}% | |
10565 | \DeclareUnicodeCharacter{00FF}{\"y}% | |
10566 | % | |
10567 | \DeclareUnicodeCharacter{0100}{\=A}% | |
10568 | \DeclareUnicodeCharacter{0101}{\=a}% | |
10569 | \DeclareUnicodeCharacter{0102}{\u{A}}% | |
10570 | \DeclareUnicodeCharacter{0103}{\u{a}}% | |
10571 | \DeclareUnicodeCharacter{0104}{\ogonek{A}}% | |
10572 | \DeclareUnicodeCharacter{0105}{\ogonek{a}}% | |
10573 | \DeclareUnicodeCharacter{0106}{\'C}% | |
10574 | \DeclareUnicodeCharacter{0107}{\'c}% | |
10575 | \DeclareUnicodeCharacter{0108}{\^C}% | |
10576 | \DeclareUnicodeCharacter{0109}{\^c}% | |
10577 | \DeclareUnicodeCharacter{010A}{\dotaccent{C}}% | |
10578 | \DeclareUnicodeCharacter{010B}{\dotaccent{c}}% | |
10579 | \DeclareUnicodeCharacter{010C}{\v{C}}% | |
10580 | \DeclareUnicodeCharacter{010D}{\v{c}}% | |
10581 | \DeclareUnicodeCharacter{010E}{\v{D}}% | |
10582 | \DeclareUnicodeCharacter{010F}{d'}% | |
10583 | % | |
10584 | \DeclareUnicodeCharacter{0110}{\DH}% | |
10585 | \DeclareUnicodeCharacter{0111}{\dh}% | |
10586 | \DeclareUnicodeCharacter{0112}{\=E}% | |
10587 | \DeclareUnicodeCharacter{0113}{\=e}% | |
10588 | \DeclareUnicodeCharacter{0114}{\u{E}}% | |
10589 | \DeclareUnicodeCharacter{0115}{\u{e}}% | |
10590 | \DeclareUnicodeCharacter{0116}{\dotaccent{E}}% | |
10591 | \DeclareUnicodeCharacter{0117}{\dotaccent{e}}% | |
10592 | \DeclareUnicodeCharacter{0118}{\ogonek{E}}% | |
10593 | \DeclareUnicodeCharacter{0119}{\ogonek{e}}% | |
10594 | \DeclareUnicodeCharacter{011A}{\v{E}}% | |
10595 | \DeclareUnicodeCharacter{011B}{\v{e}}% | |
10596 | \DeclareUnicodeCharacter{011C}{\^G}% | |
10597 | \DeclareUnicodeCharacter{011D}{\^g}% | |
10598 | \DeclareUnicodeCharacter{011E}{\u{G}}% | |
10599 | \DeclareUnicodeCharacter{011F}{\u{g}}% | |
10600 | % | |
10601 | \DeclareUnicodeCharacter{0120}{\dotaccent{G}}% | |
10602 | \DeclareUnicodeCharacter{0121}{\dotaccent{g}}% | |
10603 | \DeclareUnicodeCharacter{0122}{\cedilla{G}}% | |
10604 | \DeclareUnicodeCharacter{0123}{\cedilla{g}}% | |
10605 | \DeclareUnicodeCharacter{0124}{\^H}% | |
10606 | \DeclareUnicodeCharacter{0125}{\^h}% | |
10607 | \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}% | |
10608 | \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}% | |
10609 | \DeclareUnicodeCharacter{0128}{\~I}% | |
10610 | \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}% | |
10611 | \DeclareUnicodeCharacter{012A}{\=I}% | |
10612 | \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}% | |
10613 | \DeclareUnicodeCharacter{012C}{\u{I}}% | |
10614 | \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}% | |
10615 | \DeclareUnicodeCharacter{012E}{\ogonek{I}}% | |
10616 | \DeclareUnicodeCharacter{012F}{\ogonek{i}}% | |
10617 | % | |
10618 | \DeclareUnicodeCharacter{0130}{\dotaccent{I}}% | |
10619 | \DeclareUnicodeCharacter{0131}{\dotless{i}}% | |
10620 | \DeclareUnicodeCharacter{0132}{IJ}% | |
10621 | \DeclareUnicodeCharacter{0133}{ij}% | |
10622 | \DeclareUnicodeCharacter{0134}{\^J}% | |
10623 | \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}% | |
10624 | \DeclareUnicodeCharacter{0136}{\cedilla{K}}% | |
10625 | \DeclareUnicodeCharacter{0137}{\cedilla{k}}% | |
10626 | \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}% | |
10627 | \DeclareUnicodeCharacter{0139}{\'L}% | |
10628 | \DeclareUnicodeCharacter{013A}{\'l}% | |
10629 | \DeclareUnicodeCharacter{013B}{\cedilla{L}}% | |
10630 | \DeclareUnicodeCharacter{013C}{\cedilla{l}}% | |
084e7d57 JM |
10631 | \DeclareUnicodeCharacter{013D}{L'}% should kern |
10632 | \DeclareUnicodeCharacter{013E}{l'}% should kern | |
7f7dd1d3 JM |
10633 | \DeclareUnicodeCharacter{013F}{L\U{00B7}}% |
10634 | % | |
10635 | \DeclareUnicodeCharacter{0140}{l\U{00B7}}% | |
10636 | \DeclareUnicodeCharacter{0141}{\L}% | |
10637 | \DeclareUnicodeCharacter{0142}{\l}% | |
10638 | \DeclareUnicodeCharacter{0143}{\'N}% | |
10639 | \DeclareUnicodeCharacter{0144}{\'n}% | |
10640 | \DeclareUnicodeCharacter{0145}{\cedilla{N}}% | |
10641 | \DeclareUnicodeCharacter{0146}{\cedilla{n}}% | |
10642 | \DeclareUnicodeCharacter{0147}{\v{N}}% | |
10643 | \DeclareUnicodeCharacter{0148}{\v{n}}% | |
10644 | \DeclareUnicodeCharacter{0149}{'n}% | |
10645 | \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}% | |
10646 | \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}% | |
10647 | \DeclareUnicodeCharacter{014C}{\=O}% | |
10648 | \DeclareUnicodeCharacter{014D}{\=o}% | |
10649 | \DeclareUnicodeCharacter{014E}{\u{O}}% | |
10650 | \DeclareUnicodeCharacter{014F}{\u{o}}% | |
10651 | % | |
10652 | \DeclareUnicodeCharacter{0150}{\H{O}}% | |
10653 | \DeclareUnicodeCharacter{0151}{\H{o}}% | |
10654 | \DeclareUnicodeCharacter{0152}{\OE}% | |
10655 | \DeclareUnicodeCharacter{0153}{\oe}% | |
10656 | \DeclareUnicodeCharacter{0154}{\'R}% | |
10657 | \DeclareUnicodeCharacter{0155}{\'r}% | |
10658 | \DeclareUnicodeCharacter{0156}{\cedilla{R}}% | |
10659 | \DeclareUnicodeCharacter{0157}{\cedilla{r}}% | |
10660 | \DeclareUnicodeCharacter{0158}{\v{R}}% | |
10661 | \DeclareUnicodeCharacter{0159}{\v{r}}% | |
10662 | \DeclareUnicodeCharacter{015A}{\'S}% | |
10663 | \DeclareUnicodeCharacter{015B}{\'s}% | |
10664 | \DeclareUnicodeCharacter{015C}{\^S}% | |
10665 | \DeclareUnicodeCharacter{015D}{\^s}% | |
10666 | \DeclareUnicodeCharacter{015E}{\cedilla{S}}% | |
10667 | \DeclareUnicodeCharacter{015F}{\cedilla{s}}% | |
10668 | % | |
10669 | \DeclareUnicodeCharacter{0160}{\v{S}}% | |
10670 | \DeclareUnicodeCharacter{0161}{\v{s}}% | |
10671 | \DeclareUnicodeCharacter{0162}{\cedilla{T}}% | |
10672 | \DeclareUnicodeCharacter{0163}{\cedilla{t}}% | |
10673 | \DeclareUnicodeCharacter{0164}{\v{T}}% | |
10674 | \DeclareUnicodeCharacter{0165}{\v{t}}% | |
10675 | \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}% | |
10676 | \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}% | |
10677 | \DeclareUnicodeCharacter{0168}{\~U}% | |
10678 | \DeclareUnicodeCharacter{0169}{\~u}% | |
10679 | \DeclareUnicodeCharacter{016A}{\=U}% | |
10680 | \DeclareUnicodeCharacter{016B}{\=u}% | |
10681 | \DeclareUnicodeCharacter{016C}{\u{U}}% | |
10682 | \DeclareUnicodeCharacter{016D}{\u{u}}% | |
10683 | \DeclareUnicodeCharacter{016E}{\ringaccent{U}}% | |
10684 | \DeclareUnicodeCharacter{016F}{\ringaccent{u}}% | |
10685 | % | |
10686 | \DeclareUnicodeCharacter{0170}{\H{U}}% | |
10687 | \DeclareUnicodeCharacter{0171}{\H{u}}% | |
10688 | \DeclareUnicodeCharacter{0172}{\ogonek{U}}% | |
10689 | \DeclareUnicodeCharacter{0173}{\ogonek{u}}% | |
10690 | \DeclareUnicodeCharacter{0174}{\^W}% | |
10691 | \DeclareUnicodeCharacter{0175}{\^w}% | |
10692 | \DeclareUnicodeCharacter{0176}{\^Y}% | |
10693 | \DeclareUnicodeCharacter{0177}{\^y}% | |
10694 | \DeclareUnicodeCharacter{0178}{\"Y}% | |
10695 | \DeclareUnicodeCharacter{0179}{\'Z}% | |
10696 | \DeclareUnicodeCharacter{017A}{\'z}% | |
10697 | \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}% | |
10698 | \DeclareUnicodeCharacter{017C}{\dotaccent{z}}% | |
10699 | \DeclareUnicodeCharacter{017D}{\v{Z}}% | |
10700 | \DeclareUnicodeCharacter{017E}{\v{z}}% | |
10701 | \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}% | |
10702 | % | |
10703 | \DeclareUnicodeCharacter{01C4}{D\v{Z}}% | |
10704 | \DeclareUnicodeCharacter{01C5}{D\v{z}}% | |
10705 | \DeclareUnicodeCharacter{01C6}{d\v{z}}% | |
10706 | \DeclareUnicodeCharacter{01C7}{LJ}% | |
10707 | \DeclareUnicodeCharacter{01C8}{Lj}% | |
10708 | \DeclareUnicodeCharacter{01C9}{lj}% | |
10709 | \DeclareUnicodeCharacter{01CA}{NJ}% | |
10710 | \DeclareUnicodeCharacter{01CB}{Nj}% | |
10711 | \DeclareUnicodeCharacter{01CC}{nj}% | |
10712 | \DeclareUnicodeCharacter{01CD}{\v{A}}% | |
10713 | \DeclareUnicodeCharacter{01CE}{\v{a}}% | |
10714 | \DeclareUnicodeCharacter{01CF}{\v{I}}% | |
10715 | % | |
10716 | \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}% | |
10717 | \DeclareUnicodeCharacter{01D1}{\v{O}}% | |
10718 | \DeclareUnicodeCharacter{01D2}{\v{o}}% | |
10719 | \DeclareUnicodeCharacter{01D3}{\v{U}}% | |
10720 | \DeclareUnicodeCharacter{01D4}{\v{u}}% | |
10721 | % | |
10722 | \DeclareUnicodeCharacter{01E2}{\={\AE}}% | |
10723 | \DeclareUnicodeCharacter{01E3}{\={\ae}}% | |
10724 | \DeclareUnicodeCharacter{01E6}{\v{G}}% | |
10725 | \DeclareUnicodeCharacter{01E7}{\v{g}}% | |
10726 | \DeclareUnicodeCharacter{01E8}{\v{K}}% | |
10727 | \DeclareUnicodeCharacter{01E9}{\v{k}}% | |
10728 | % | |
10729 | \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}% | |
10730 | \DeclareUnicodeCharacter{01F1}{DZ}% | |
10731 | \DeclareUnicodeCharacter{01F2}{Dz}% | |
10732 | \DeclareUnicodeCharacter{01F3}{dz}% | |
10733 | \DeclareUnicodeCharacter{01F4}{\'G}% | |
10734 | \DeclareUnicodeCharacter{01F5}{\'g}% | |
10735 | \DeclareUnicodeCharacter{01F8}{\`N}% | |
10736 | \DeclareUnicodeCharacter{01F9}{\`n}% | |
10737 | \DeclareUnicodeCharacter{01FC}{\'{\AE}}% | |
10738 | \DeclareUnicodeCharacter{01FD}{\'{\ae}}% | |
10739 | \DeclareUnicodeCharacter{01FE}{\'{\O}}% | |
10740 | \DeclareUnicodeCharacter{01FF}{\'{\o}}% | |
10741 | % | |
10742 | \DeclareUnicodeCharacter{021E}{\v{H}}% | |
10743 | \DeclareUnicodeCharacter{021F}{\v{h}}% | |
10744 | % | |
10745 | \DeclareUnicodeCharacter{0226}{\dotaccent{A}}% | |
10746 | \DeclareUnicodeCharacter{0227}{\dotaccent{a}}% | |
10747 | \DeclareUnicodeCharacter{0228}{\cedilla{E}}% | |
10748 | \DeclareUnicodeCharacter{0229}{\cedilla{e}}% | |
10749 | \DeclareUnicodeCharacter{022E}{\dotaccent{O}}% | |
10750 | \DeclareUnicodeCharacter{022F}{\dotaccent{o}}% | |
10751 | % | |
10752 | \DeclareUnicodeCharacter{0232}{\=Y}% | |
10753 | \DeclareUnicodeCharacter{0233}{\=y}% | |
10754 | \DeclareUnicodeCharacter{0237}{\dotless{j}}% | |
10755 | % | |
10756 | \DeclareUnicodeCharacter{02DB}{\ogonek{ }}% | |
10757 | % | |
084e7d57 | 10758 | % Greek letters upper case |
7f7dd1d3 JM |
10759 | \DeclareUnicodeCharacter{0391}{{\it A}}% |
10760 | \DeclareUnicodeCharacter{0392}{{\it B}}% | |
10761 | \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}% | |
10762 | \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}% | |
10763 | \DeclareUnicodeCharacter{0395}{{\it E}}% | |
10764 | \DeclareUnicodeCharacter{0396}{{\it Z}}% | |
10765 | \DeclareUnicodeCharacter{0397}{{\it H}}% | |
10766 | \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}% | |
10767 | \DeclareUnicodeCharacter{0399}{{\it I}}% | |
10768 | \DeclareUnicodeCharacter{039A}{{\it K}}% | |
10769 | \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}% | |
10770 | \DeclareUnicodeCharacter{039C}{{\it M}}% | |
10771 | \DeclareUnicodeCharacter{039D}{{\it N}}% | |
10772 | \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}% | |
10773 | \DeclareUnicodeCharacter{039F}{{\it O}}% | |
10774 | \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}% | |
10775 | \DeclareUnicodeCharacter{03A1}{{\it P}}% | |
084e7d57 | 10776 | %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma |
7f7dd1d3 JM |
10777 | \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}% |
10778 | \DeclareUnicodeCharacter{03A4}{{\it T}}% | |
10779 | \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}% | |
10780 | \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}% | |
10781 | \DeclareUnicodeCharacter{03A7}{{\it X}}% | |
10782 | \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}% | |
10783 | \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}% | |
10784 | % | |
084e7d57 | 10785 | % Vowels with accents |
7f7dd1d3 JM |
10786 | \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}% |
10787 | \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}% | |
10788 | \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}% | |
10789 | \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}% | |
10790 | \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}% | |
10791 | \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}% | |
10792 | % | |
084e7d57 | 10793 | % Standalone accent |
7f7dd1d3 JM |
10794 | \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}% |
10795 | % | |
084e7d57 | 10796 | % Greek letters lower case |
7f7dd1d3 JM |
10797 | \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}% |
10798 | \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}% | |
10799 | \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}% | |
10800 | \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}% | |
10801 | \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}% | |
10802 | \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}% | |
10803 | \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}% | |
10804 | \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}% | |
10805 | \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}% | |
10806 | \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}% | |
10807 | \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}% | |
10808 | \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}% | |
10809 | \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}% | |
10810 | \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}% | |
10811 | \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron | |
10812 | \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}% | |
10813 | \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}% | |
10814 | \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}% | |
10815 | \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}% | |
10816 | \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}% | |
10817 | \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}% | |
10818 | \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}% | |
10819 | \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}% | |
10820 | \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}% | |
10821 | \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}% | |
10822 | % | |
084e7d57 | 10823 | % More Greek vowels with accents |
7f7dd1d3 JM |
10824 | \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}% |
10825 | \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}% | |
10826 | \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}% | |
10827 | \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}% | |
10828 | \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}% | |
10829 | % | |
084e7d57 | 10830 | % Variant Greek letters |
7f7dd1d3 JM |
10831 | \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}% |
10832 | \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}% | |
10833 | \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}% | |
10834 | % | |
10835 | \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}% | |
10836 | \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}% | |
10837 | \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}% | |
10838 | \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}% | |
10839 | \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}% | |
10840 | \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}% | |
10841 | \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}% | |
10842 | \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}% | |
10843 | \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}% | |
10844 | \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}% | |
10845 | \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}% | |
10846 | \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}% | |
10847 | % | |
10848 | \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}% | |
10849 | \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}% | |
10850 | % | |
10851 | \DeclareUnicodeCharacter{1E20}{\=G}% | |
10852 | \DeclareUnicodeCharacter{1E21}{\=g}% | |
10853 | \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}% | |
10854 | \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}% | |
10855 | \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}% | |
10856 | \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}% | |
10857 | \DeclareUnicodeCharacter{1E26}{\"H}% | |
10858 | \DeclareUnicodeCharacter{1E27}{\"h}% | |
10859 | % | |
10860 | \DeclareUnicodeCharacter{1E30}{\'K}% | |
10861 | \DeclareUnicodeCharacter{1E31}{\'k}% | |
10862 | \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}% | |
10863 | \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}% | |
10864 | \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}% | |
10865 | \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}% | |
10866 | \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}% | |
10867 | \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}% | |
10868 | \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}% | |
10869 | \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}% | |
10870 | \DeclareUnicodeCharacter{1E3E}{\'M}% | |
10871 | \DeclareUnicodeCharacter{1E3F}{\'m}% | |
10872 | % | |
10873 | \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}% | |
10874 | \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}% | |
10875 | \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}% | |
10876 | \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}% | |
10877 | \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}% | |
10878 | \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}% | |
10879 | \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}% | |
10880 | \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}% | |
10881 | \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}% | |
10882 | \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}% | |
10883 | % | |
10884 | \DeclareUnicodeCharacter{1E54}{\'P}% | |
10885 | \DeclareUnicodeCharacter{1E55}{\'p}% | |
10886 | \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}% | |
10887 | \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}% | |
10888 | \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}% | |
10889 | \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}% | |
10890 | \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}% | |
10891 | \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}% | |
10892 | \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}% | |
10893 | \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}% | |
10894 | % | |
10895 | \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}% | |
10896 | \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}% | |
10897 | \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}% | |
10898 | \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}% | |
10899 | \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}% | |
10900 | \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}% | |
10901 | \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}% | |
10902 | \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}% | |
10903 | \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}% | |
10904 | \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}% | |
10905 | % | |
10906 | \DeclareUnicodeCharacter{1E7C}{\~V}% | |
10907 | \DeclareUnicodeCharacter{1E7D}{\~v}% | |
10908 | \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}% | |
10909 | \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}% | |
10910 | % | |
10911 | \DeclareUnicodeCharacter{1E80}{\`W}% | |
10912 | \DeclareUnicodeCharacter{1E81}{\`w}% | |
10913 | \DeclareUnicodeCharacter{1E82}{\'W}% | |
10914 | \DeclareUnicodeCharacter{1E83}{\'w}% | |
10915 | \DeclareUnicodeCharacter{1E84}{\"W}% | |
10916 | \DeclareUnicodeCharacter{1E85}{\"w}% | |
10917 | \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}% | |
10918 | \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}% | |
10919 | \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}% | |
10920 | \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}% | |
10921 | \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}% | |
10922 | \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}% | |
10923 | \DeclareUnicodeCharacter{1E8C}{\"X}% | |
10924 | \DeclareUnicodeCharacter{1E8D}{\"x}% | |
10925 | \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}% | |
10926 | \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}% | |
10927 | % | |
10928 | \DeclareUnicodeCharacter{1E90}{\^Z}% | |
10929 | \DeclareUnicodeCharacter{1E91}{\^z}% | |
10930 | \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}% | |
10931 | \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}% | |
10932 | \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}% | |
10933 | \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}% | |
10934 | \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}% | |
10935 | \DeclareUnicodeCharacter{1E97}{\"t}% | |
10936 | \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}% | |
10937 | \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}% | |
10938 | % | |
10939 | \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}% | |
10940 | \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}% | |
10941 | % | |
10942 | \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}% | |
10943 | \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}% | |
10944 | \DeclareUnicodeCharacter{1EBC}{\~E}% | |
10945 | \DeclareUnicodeCharacter{1EBD}{\~e}% | |
10946 | % | |
10947 | \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}% | |
10948 | \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}% | |
10949 | \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}% | |
10950 | \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}% | |
10951 | % | |
10952 | \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}% | |
10953 | \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}% | |
10954 | % | |
10955 | \DeclareUnicodeCharacter{1EF2}{\`Y}% | |
10956 | \DeclareUnicodeCharacter{1EF3}{\`y}% | |
10957 | \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}% | |
10958 | % | |
10959 | \DeclareUnicodeCharacter{1EF8}{\~Y}% | |
10960 | \DeclareUnicodeCharacter{1EF9}{\~y}% | |
10961 | % | |
084e7d57 | 10962 | % Punctuation |
7f7dd1d3 JM |
10963 | \DeclareUnicodeCharacter{2013}{--}% |
10964 | \DeclareUnicodeCharacter{2014}{---}% | |
10965 | \DeclareUnicodeCharacter{2018}{\quoteleft{}}% | |
10966 | \DeclareUnicodeCharacter{2019}{\quoteright{}}% | |
10967 | \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}% | |
10968 | \DeclareUnicodeCharacter{201C}{\quotedblleft{}}% | |
10969 | \DeclareUnicodeCharacter{201D}{\quotedblright{}}% | |
10970 | \DeclareUnicodeCharacter{201E}{\quotedblbase{}}% | |
10971 | \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}% | |
10972 | \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}% | |
10973 | \DeclareUnicodeCharacter{2022}{\bullet{}}% | |
10974 | \DeclareUnicodeCharacter{202F}{\thinspace}% | |
10975 | \DeclareUnicodeCharacter{2026}{\dots{}}% | |
10976 | \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}% | |
10977 | \DeclareUnicodeCharacter{203A}{\guilsinglright{}}% | |
10978 | % | |
10979 | \DeclareUnicodeCharacter{20AC}{\euro{}}% | |
10980 | % | |
10981 | \DeclareUnicodeCharacter{2192}{\expansion{}}% | |
10982 | \DeclareUnicodeCharacter{21D2}{\result{}}% | |
10983 | % | |
084e7d57 | 10984 | % Mathematical symbols |
7f7dd1d3 JM |
10985 | \DeclareUnicodeCharacter{2200}{\ensuremath\forall}% |
10986 | \DeclareUnicodeCharacter{2203}{\ensuremath\exists}% | |
10987 | \DeclareUnicodeCharacter{2208}{\ensuremath\in}% | |
10988 | \DeclareUnicodeCharacter{2212}{\minus{}}% | |
10989 | \DeclareUnicodeCharacter{2217}{\ast}% | |
10990 | \DeclareUnicodeCharacter{221E}{\ensuremath\infty}% | |
10991 | \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}% | |
10992 | \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}% | |
10993 | \DeclareUnicodeCharacter{2229}{\ensuremath\cap}% | |
10994 | \DeclareUnicodeCharacter{2261}{\equiv{}}% | |
10995 | \DeclareUnicodeCharacter{2264}{\ensuremath\leq}% | |
10996 | \DeclareUnicodeCharacter{2265}{\ensuremath\geq}% | |
10997 | \DeclareUnicodeCharacter{2282}{\ensuremath\subset}% | |
10998 | \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}% | |
10999 | % | |
11000 | \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}% | |
11001 | \DeclareUnicodeCharacter{2032}{\ensuremath\prime}% | |
11002 | \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}% | |
11003 | \DeclareUnicodeCharacter{2111}{\ensuremath\Im}% | |
11004 | \DeclareUnicodeCharacter{2113}{\ensuremath\ell}% | |
11005 | \DeclareUnicodeCharacter{2118}{\ensuremath\wp}% | |
11006 | \DeclareUnicodeCharacter{211C}{\ensuremath\Re}% | |
11007 | \DeclareUnicodeCharacter{2127}{\ensuremath\mho}% | |
11008 | \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}% | |
11009 | \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}% | |
11010 | \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}% | |
11011 | \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}% | |
11012 | \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}% | |
11013 | \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}% | |
11014 | \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}% | |
11015 | \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}% | |
11016 | \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}% | |
11017 | \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}% | |
11018 | \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}% | |
11019 | \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}% | |
11020 | \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}% | |
11021 | \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}% | |
11022 | \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}% | |
11023 | \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}% | |
11024 | \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}% | |
11025 | \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}% | |
11026 | \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}% | |
11027 | \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}% | |
11028 | \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}% | |
11029 | \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}% | |
11030 | \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}% | |
11031 | \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}% | |
11032 | \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}% | |
11033 | \DeclareUnicodeCharacter{2201}{\ensuremath\complement}% | |
11034 | \DeclareUnicodeCharacter{2202}{\ensuremath\partial}% | |
11035 | \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}% | |
11036 | \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}% | |
11037 | \DeclareUnicodeCharacter{2209}{\ensuremath\notin}% | |
11038 | \DeclareUnicodeCharacter{220B}{\ensuremath\owns}% | |
11039 | \DeclareUnicodeCharacter{220F}{\ensuremath\prod}% | |
11040 | \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}% | |
11041 | \DeclareUnicodeCharacter{2211}{\ensuremath\sum}% | |
11042 | \DeclareUnicodeCharacter{2213}{\ensuremath\mp}% | |
11043 | \DeclareUnicodeCharacter{2218}{\ensuremath\circ}% | |
11044 | \DeclareUnicodeCharacter{221A}{\ensuremath\surd}% | |
11045 | \DeclareUnicodeCharacter{221D}{\ensuremath\propto}% | |
11046 | \DeclareUnicodeCharacter{2220}{\ensuremath\angle}% | |
11047 | \DeclareUnicodeCharacter{2223}{\ensuremath\mid}% | |
11048 | \DeclareUnicodeCharacter{2228}{\ensuremath\vee}% | |
11049 | \DeclareUnicodeCharacter{222A}{\ensuremath\cup}% | |
11050 | \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}% | |
11051 | \DeclareUnicodeCharacter{222E}{\ensuremath\oint}% | |
11052 | \DeclareUnicodeCharacter{223C}{\ensuremath\sim}% | |
11053 | \DeclareUnicodeCharacter{2240}{\ensuremath\wr}% | |
11054 | \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}% | |
11055 | \DeclareUnicodeCharacter{2245}{\ensuremath\cong}% | |
11056 | \DeclareUnicodeCharacter{2248}{\ensuremath\approx}% | |
11057 | \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}% | |
11058 | \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}% | |
11059 | \DeclareUnicodeCharacter{2260}{\ensuremath\neq}% | |
11060 | \DeclareUnicodeCharacter{226A}{\ensuremath\ll}% | |
11061 | \DeclareUnicodeCharacter{226B}{\ensuremath\gg}% | |
11062 | \DeclareUnicodeCharacter{227A}{\ensuremath\prec}% | |
11063 | \DeclareUnicodeCharacter{227B}{\ensuremath\succ}% | |
11064 | \DeclareUnicodeCharacter{2283}{\ensuremath\supset}% | |
11065 | \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}% | |
11066 | \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}% | |
11067 | \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}% | |
11068 | \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}% | |
11069 | \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}% | |
11070 | \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}% | |
11071 | \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}% | |
11072 | \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}% | |
11073 | \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}% | |
11074 | \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}% | |
11075 | \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}% | |
11076 | \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}% | |
11077 | \DeclareUnicodeCharacter{2299}{\ensuremath\odot}% | |
11078 | \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}% | |
11079 | \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}% | |
11080 | \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}% | |
11081 | \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}% | |
11082 | \DeclareUnicodeCharacter{22A8}{\ensuremath\models}% | |
11083 | \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}% | |
11084 | \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}% | |
11085 | \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}% | |
11086 | \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}% | |
11087 | \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}% | |
11088 | \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}% | |
11089 | \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}% | |
11090 | \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}% | |
11091 | \DeclareUnicodeCharacter{22C6}{\ensuremath\star}% | |
11092 | \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}% | |
11093 | \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}% | |
11094 | \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}% | |
11095 | \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}% | |
11096 | \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}% | |
11097 | \DeclareUnicodeCharacter{2322}{\ensuremath\frown}% | |
11098 | \DeclareUnicodeCharacter{2323}{\ensuremath\smile}% | |
11099 | % | |
11100 | \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}% | |
11101 | \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}% | |
11102 | \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}% | |
11103 | \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}% | |
11104 | \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}% | |
11105 | \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}% | |
11106 | \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}% | |
11107 | \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}% | |
11108 | \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}% | |
11109 | \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}% | |
11110 | \DeclareUnicodeCharacter{266D}{\ensuremath\flat}% | |
11111 | \DeclareUnicodeCharacter{266E}{\ensuremath\natural}% | |
11112 | \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}% | |
11113 | \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}% | |
11114 | \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}% | |
11115 | \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}% | |
11116 | \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}% | |
11117 | \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}% | |
11118 | \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}% | |
11119 | \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}% | |
11120 | \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}% | |
11121 | \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}% | |
11122 | \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}% | |
11123 | \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}% | |
11124 | \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}% | |
11125 | \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}% | |
11126 | \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}% | |
11127 | \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}% | |
11128 | \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}% | |
11129 | \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}% | |
11130 | \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}% | |
11131 | % | |
11132 | \global\mathchardef\checkmark="1370% actually the square root sign | |
11133 | \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}% | |
11134 | }% end of \unicodechardefs | |
11135 | ||
11136 | % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command) | |
11137 | % It makes the setting that replace UTF-8 byte sequence. | |
11138 | \def\utfeightchardefs{% | |
11139 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii | |
11140 | \unicodechardefs | |
11141 | } | |
c94f48d7 | 11142 | |
7f7dd1d3 JM |
11143 | % Whether the active definitions of non-ASCII characters expand to |
11144 | % non-active tokens with the same character code. This is used to | |
11145 | % write characters literally, instead of using active definitions for | |
11146 | % printing the correct glyphs. | |
11147 | \newif\ifpassthroughchars | |
11148 | \passthroughcharsfalse | |
11149 | ||
11150 | % For native Unicode handling (XeTeX and LuaTeX), | |
11151 | % provide a definition macro to replace/pass-through a Unicode character | |
11152 | % | |
11153 | \def\DeclareUnicodeCharacterNative#1#2{% | |
11154 | \catcode"#1=\active | |
11155 | \def\dodeclareunicodecharacternative##1##2##3{% | |
11156 | \begingroup | |
11157 | \uccode`\~="##2\relax | |
11158 | \uppercase{\gdef~}{% | |
11159 | \ifpassthroughchars | |
11160 | ##1% | |
11161 | \else | |
11162 | ##3% | |
11163 | \fi | |
11164 | } | |
11165 | \endgroup | |
11166 | } | |
11167 | \begingroup | |
11168 | \uccode`\.="#1\relax | |
11169 | \uppercase{\def\UTFNativeTmp{.}}% | |
11170 | \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% | |
11171 | \endgroup | |
c94f48d7 AJ |
11172 | } |
11173 | ||
7f7dd1d3 JM |
11174 | % Native Unicode handling (XeTeX and LuaTeX) character replacing definition. |
11175 | % It activates the setting that replaces Unicode characters. | |
11176 | \def\nativeunicodechardefs{% | |
11177 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative | |
11178 | \unicodechardefs | |
11179 | } | |
11180 | ||
11181 | % For native Unicode handling (XeTeX and LuaTeX), | |
11182 | % make the character token expand | |
11183 | % to the sequences given in \unicodechardefs for printing. | |
11184 | \def\DeclareUnicodeCharacterNativeAtU#1#2{% | |
11185 | \def\UTFAtUTmp{#2} | |
11186 | \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp | |
11187 | } | |
11188 | ||
11189 | % @U command definitions for native Unicode handling (XeTeX and LuaTeX). | |
11190 | \def\nativeunicodechardefsatu{% | |
11191 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU | |
11192 | \unicodechardefs | |
084e7d57 JM |
11193 | } |
11194 | ||
7f7dd1d3 JM |
11195 | % US-ASCII character definitions. |
11196 | \def\asciichardefs{% nothing need be done | |
11197 | \relax | |
11198 | } | |
084e7d57 | 11199 | |
7f7dd1d3 JM |
11200 | % define all Unicode characters we know about, for the sake of @U. |
11201 | \iftxinativeunicodecapable | |
11202 | \nativeunicodechardefsatu | |
11203 | \else | |
11204 | \utfeightchardefs | |
11205 | \fi | |
084e7d57 JM |
11206 | |
11207 | ||
c94f48d7 AJ |
11208 | % Make non-ASCII characters printable again for compatibility with |
11209 | % existing Texinfo documents that may use them, even without declaring a | |
11210 | % document encoding. | |
11211 | % | |
11212 | \setnonasciicharscatcode \other | |
11213 | ||
11214 | ||
11215 | \message{formatting,} | |
11216 | ||
9e9f9cc2 | 11217 | \newdimen\defaultparindent \defaultparindent = 15pt |
9e9f9cc2 | 11218 | |
474be527 KB |
11219 | \chapheadingskip = 15pt plus 4pt minus 2pt |
11220 | \secheadingskip = 12pt plus 3pt minus 2pt | |
11221 | \subsecheadingskip = 9pt plus 2pt minus 2pt | |
11222 | ||
9e9f9cc2 | 11223 | % Prevent underfull vbox error messages. |
0c2b5752 | 11224 | \vbadness = 10000 |
9e9f9cc2 | 11225 | |
0f8bbd69 JM |
11226 | % Don't be very finicky about underfull hboxes, either. |
11227 | \hbadness = 6666 | |
313a1174 | 11228 | |
c94f48d7 | 11229 | % Following George Bush, get rid of widows and orphans. |
9e9f9cc2 KB |
11230 | \widowpenalty=10000 |
11231 | \clubpenalty=10000 | |
11232 | ||
11233 | % Use TeX 3.0's \emergencystretch to help line breaking, but if we're | |
11234 | % using an old version of TeX, don't do anything. We want the amount of | |
11235 | % stretch added to depend on the line length, hence the dependence on | |
407dc7a0 | 11236 | % \hsize. We call this whenever the paper size is set. |
9e9f9cc2 | 11237 | % |
0c2b5752 UD |
11238 | \def\setemergencystretch{% |
11239 | \ifx\emergencystretch\thisisundefined | |
11240 | % Allow us to assign to \emergencystretch anyway. | |
11241 | \def\emergencystretch{\dimen0}% | |
11242 | \else | |
13632cfc | 11243 | \emergencystretch = .15\hsize |
0c2b5752 UD |
11244 | \fi |
11245 | } | |
9e9f9cc2 | 11246 | |
9251c568 AJ |
11247 | % Parameters in order: 1) textheight; 2) textwidth; |
11248 | % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; | |
11249 | % 7) physical page height; 8) physical page width. | |
7158eae4 | 11250 | % |
2f5b1124 UD |
11251 | % We also call \setleading{\textleading}, so the caller should define |
11252 | % \textleading. The caller should also set \parskip. | |
0c2b5752 | 11253 | % |
2f5b1124 | 11254 | \def\internalpagesizes#1#2#3#4#5#6#7#8{% |
0c2b5752 UD |
11255 | \voffset = #3\relax |
11256 | \topskip = #6\relax | |
11257 | \splittopskip = \topskip | |
11258 | % | |
11259 | \vsize = #1\relax | |
11260 | \advance\vsize by \topskip | |
11261 | \outervsize = \vsize | |
d667195c | 11262 | \advance\outervsize by 2\topandbottommargin |
7f7dd1d3 | 11263 | \txipageheight = \vsize |
474be527 | 11264 | % |
0c2b5752 UD |
11265 | \hsize = #2\relax |
11266 | \outerhsize = \hsize | |
11267 | \advance\outerhsize by 0.5in | |
7f7dd1d3 | 11268 | \txipagewidth = \hsize |
474be527 | 11269 | % |
0c2b5752 UD |
11270 | \normaloffset = #4\relax |
11271 | \bindingoffset = #5\relax | |
474be527 | 11272 | % |
2f5b1124 UD |
11273 | \ifpdf |
11274 | \pdfpageheight #7\relax | |
11275 | \pdfpagewidth #8\relax | |
c94f48d7 AJ |
11276 | % if we don't reset these, they will remain at "1 true in" of |
11277 | % whatever layout pdftex was dumped with. | |
11278 | \pdfhorigin = 1 true in | |
11279 | \pdfvorigin = 1 true in | |
7f7dd1d3 JM |
11280 | \else |
11281 | \ifx\XeTeXrevision\thisisundefined | |
11282 | \else | |
11283 | \pdfpageheight #7\relax | |
11284 | \pdfpagewidth #8\relax | |
11285 | % XeTeX does not have \pdfhorigin and \pdfvorigin. | |
11286 | \fi | |
2f5b1124 UD |
11287 | \fi |
11288 | % | |
e23f8d20 UD |
11289 | \setleading{\textleading} |
11290 | % | |
0c2b5752 UD |
11291 | \parindent = \defaultparindent |
11292 | \setemergencystretch | |
9e9f9cc2 KB |
11293 | } |
11294 | ||
0c2b5752 UD |
11295 | % @letterpaper (the default). |
11296 | \def\letterpaper{{\globaldefs = 1 | |
11297 | \parskip = 3pt plus 2pt minus 1pt | |
e23f8d20 | 11298 | \textleading = 13.2pt |
0c2b5752 UD |
11299 | % |
11300 | % If page is nothing but text, make it come out even. | |
c94f48d7 | 11301 | \internalpagesizes{607.2pt}{6in}% that's 46 lines |
2f5b1124 UD |
11302 | {\voffset}{.25in}% |
11303 | {\bindingoffset}{36pt}% | |
11304 | {11in}{8.5in}% | |
0c2b5752 | 11305 | }} |
9e9f9cc2 | 11306 | |
9251c568 | 11307 | % Use @smallbook to reset parameters for 7x9.25 trim size. |
0c2b5752 UD |
11308 | \def\smallbook{{\globaldefs = 1 |
11309 | \parskip = 2pt plus 1pt | |
e23f8d20 | 11310 | \textleading = 12pt |
0c2b5752 | 11311 | % |
2f5b1124 | 11312 | \internalpagesizes{7.5in}{5in}% |
c94f48d7 | 11313 | {-.2in}{0in}% |
2f5b1124 UD |
11314 | {\bindingoffset}{16pt}% |
11315 | {9.25in}{7in}% | |
0c2b5752 UD |
11316 | % |
11317 | \lispnarrowing = 0.3in | |
11318 | \tolerance = 700 | |
11319 | \hfuzz = 1pt | |
11320 | \contentsrightmargin = 0pt | |
0c2b5752 | 11321 | \defbodyindent = .5cm |
0c2b5752 UD |
11322 | }} |
11323 | ||
9251c568 AJ |
11324 | % Use @smallerbook to reset parameters for 6x9 trim size. |
11325 | % (Just testing, parameters still in flux.) | |
11326 | \def\smallerbook{{\globaldefs = 1 | |
11327 | \parskip = 1.5pt plus 1pt | |
11328 | \textleading = 12pt | |
11329 | % | |
11330 | \internalpagesizes{7.4in}{4.8in}% | |
11331 | {-.2in}{-.4in}% | |
11332 | {0pt}{14pt}% | |
11333 | {9in}{6in}% | |
11334 | % | |
11335 | \lispnarrowing = 0.25in | |
11336 | \tolerance = 700 | |
11337 | \hfuzz = 1pt | |
11338 | \contentsrightmargin = 0pt | |
11339 | \defbodyindent = .4cm | |
11340 | }} | |
11341 | ||
0c2b5752 UD |
11342 | % Use @afourpaper to print on European A4 paper. |
11343 | \def\afourpaper{{\globaldefs = 1 | |
0c2b5752 | 11344 | \parskip = 3pt plus 2pt minus 1pt |
2f5b1124 | 11345 | \textleading = 13.2pt |
0c2b5752 | 11346 | % |
7158eae4 | 11347 | % Double-side printing via postscript on Laserjet 4050 |
2f5b1124 UD |
11348 | % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. |
11349 | % To change the settings for a different printer or situation, adjust | |
11350 | % \normaloffset until the front-side and back-side texts align. Then | |
11351 | % do the same for \bindingoffset. You can set these for testing in | |
11352 | % your texinfo source file like this: | |
11353 | % @tex | |
11354 | % \global\normaloffset = -6mm | |
11355 | % \global\bindingoffset = 10mm | |
11356 | % @end tex | |
c94f48d7 | 11357 | \internalpagesizes{673.2pt}{160mm}% that's 51 lines |
2f5b1124 UD |
11358 | {\voffset}{\hoffset}% |
11359 | {\bindingoffset}{44pt}% | |
11360 | {297mm}{210mm}% | |
0c2b5752 UD |
11361 | % |
11362 | \tolerance = 700 | |
11363 | \hfuzz = 1pt | |
2f5b1124 UD |
11364 | \contentsrightmargin = 0pt |
11365 | \defbodyindent = 5mm | |
0c2b5752 | 11366 | }} |
9e9f9cc2 | 11367 | |
be1152ca UD |
11368 | % Use @afivepaper to print on European A5 paper. |
11369 | % From romildo@urano.iceb.ufop.br, 2 July 2000. | |
11370 | % He also recommends making @example and @lisp be small. | |
11371 | \def\afivepaper{{\globaldefs = 1 | |
be1152ca | 11372 | \parskip = 2pt plus 1pt minus 0.1pt |
e23f8d20 | 11373 | \textleading = 12.5pt |
be1152ca | 11374 | % |
2f5b1124 UD |
11375 | \internalpagesizes{160mm}{120mm}% |
11376 | {\voffset}{\hoffset}% | |
11377 | {\bindingoffset}{8pt}% | |
11378 | {210mm}{148mm}% | |
be1152ca UD |
11379 | % |
11380 | \lispnarrowing = 0.2in | |
11381 | \tolerance = 800 | |
11382 | \hfuzz = 1.2pt | |
2f5b1124 | 11383 | \contentsrightmargin = 0pt |
be1152ca UD |
11384 | \defbodyindent = 2mm |
11385 | \tableindent = 12mm | |
be1152ca UD |
11386 | }} |
11387 | ||
7158eae4 | 11388 | % A specific text layout, 24x15cm overall, intended for A4 paper. |
0c2b5752 | 11389 | \def\afourlatex{{\globaldefs = 1 |
0c2b5752 | 11390 | \afourpaper |
2f5b1124 UD |
11391 | \internalpagesizes{237mm}{150mm}% |
11392 | {\voffset}{4.6mm}% | |
11393 | {\bindingoffset}{7mm}% | |
11394 | {297mm}{210mm}% | |
0c2b5752 | 11395 | % |
2f5b1124 | 11396 | % Must explicitly reset to 0 because we call \afourpaper. |
0c2b5752 UD |
11397 | \globaldefs = 0 |
11398 | }} | |
9e9f9cc2 | 11399 | |
2f5b1124 UD |
11400 | % Use @afourwide to print on A4 paper in landscape format. |
11401 | \def\afourwide{{\globaldefs = 1 | |
0c2b5752 | 11402 | \afourpaper |
2f5b1124 UD |
11403 | \internalpagesizes{241mm}{165mm}% |
11404 | {\voffset}{-2.95mm}% | |
11405 | {\bindingoffset}{7mm}% | |
11406 | {297mm}{210mm}% | |
11407 | \globaldefs = 0 | |
11408 | }} | |
0c2b5752 UD |
11409 | |
11410 | % @pagesizes TEXTHEIGHT[,TEXTWIDTH] | |
11411 | % Perhaps we should allow setting the margins, \topskip, \parskip, | |
11412 | % and/or leading, also. Or perhaps we should compute them somehow. | |
b710a6e2 | 11413 | % |
82d5ce1d | 11414 | \parseargdef\pagesizes{\pagesizesyyy #1,,\finish} |
0c2b5752 UD |
11415 | \def\pagesizesyyy#1,#2,#3\finish{{% |
11416 | \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi | |
11417 | \globaldefs = 1 | |
11418 | % | |
11419 | \parskip = 3pt plus 2pt minus 1pt | |
e23f8d20 | 11420 | \setleading{\textleading}% |
0c2b5752 | 11421 | % |
c94f48d7 | 11422 | \dimen0 = #1\relax |
2f5b1124 UD |
11423 | \advance\dimen0 by \voffset |
11424 | % | |
11425 | \dimen2 = \hsize | |
11426 | \advance\dimen2 by \normaloffset | |
11427 | % | |
11428 | \internalpagesizes{#1}{\hsize}% | |
11429 | {\voffset}{\normaloffset}% | |
11430 | {\bindingoffset}{44pt}% | |
11431 | {\dimen0}{\dimen2}% | |
0c2b5752 UD |
11432 | }} |
11433 | ||
11434 | % Set default to letter. | |
b710a6e2 | 11435 | % |
0c2b5752 UD |
11436 | \letterpaper |
11437 | ||
13632cfc | 11438 | |
0c2b5752 | 11439 | \message{and turning on texinfo input format.} |
9e9f9cc2 | 11440 | |
0f8bbd69 JM |
11441 | \def^^L{\par} % remove \outer, so ^L can appear in an @comment |
11442 | ||
11443 | % DEL is a comment character, in case @c does not suffice. | |
11444 | \catcode`\^^? = 14 | |
11445 | ||
9e9f9cc2 | 11446 | % Define macros to output various characters with catcode for normal text. |
0f8bbd69 JM |
11447 | \catcode`\"=\other \def\normaldoublequote{"} |
11448 | \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix | |
11449 | \catcode`\+=\other \def\normalplus{+} | |
11450 | \catcode`\<=\other \def\normalless{<} | |
11451 | \catcode`\>=\other \def\normalgreater{>} | |
11452 | \catcode`\^=\other \def\normalcaret{^} | |
11453 | \catcode`\_=\other \def\normalunderscore{_} | |
11454 | \catcode`\|=\other \def\normalverticalbar{|} | |
11455 | \catcode`\~=\other \def\normaltilde{~} | |
9e9f9cc2 | 11456 | |
82d5ce1d UD |
11457 | % This macro is used to make a character print one way in \tt |
11458 | % (where it can probably be output as-is), and another way in other fonts, | |
9e9f9cc2 KB |
11459 | % where something hairier probably needs to be done. |
11460 | % | |
11461 | % #1 is what to print if we are indeed using \tt; #2 is what to print | |
11462 | % otherwise. Since all the Computer Modern typewriter fonts have zero | |
11463 | % interword stretch (and shrink), and it is reasonable to expect all | |
11464 | % typewriter fonts to have this, we can check that font parameter. | |
11465 | % | |
13632cfc UD |
11466 | \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} |
11467 | ||
11468 | % Same as above, but check for italic font. Actually this also catches | |
11469 | % non-italic slanted fonts since it is impossible to distinguish them from | |
11470 | % italic fonts. But since this is only used by $ and it uses \sl anyway | |
11471 | % this is not a problem. | |
11472 | \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} | |
9e9f9cc2 | 11473 | |
084e7d57 JM |
11474 | % Set catcodes for Texinfo file |
11475 | ||
11476 | % Active characters for printing the wanted glyph. | |
9e9f9cc2 KB |
11477 | % Most of these we simply print from the \tt font, but for some, we can |
11478 | % use math or other variants that look better in normal text. | |
084e7d57 | 11479 | % |
9e9f9cc2 | 11480 | \catcode`\"=\active |
40c0dc53 | 11481 | \def\activedoublequote{{\tt\char34}} |
9e9f9cc2 | 11482 | \let"=\activedoublequote |
21fea2e2 | 11483 | \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde |
084e7d57 JM |
11484 | \chardef\hatchar=`\^ |
11485 | \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat | |
9e9f9cc2 KB |
11486 | |
11487 | \catcode`\_=\active | |
11488 | \def_{\ifusingtt\normalunderscore\_} | |
e0f86659 | 11489 | \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } |
084e7d57 | 11490 | \let\realunder=_ |
9e9f9cc2 | 11491 | |
084e7d57 | 11492 | \catcode`\|=\active \def|{{\tt\char124}} |
21fea2e2 | 11493 | |
9e9f9cc2 | 11494 | \chardef \less=`\< |
21fea2e2 | 11495 | \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless |
9e9f9cc2 | 11496 | \chardef \gtr=`\> |
21fea2e2 JM |
11497 | \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr |
11498 | \catcode`\+=\active \def+{{\tt \char 43}} | |
11499 | \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix | |
084e7d57 JM |
11500 | \catcode`\-=\active \let-=\normaldash |
11501 | ||
21fea2e2 JM |
11502 | |
11503 | % used for headline/footline in the output routine, in case the page | |
11504 | % breaks in the middle of an @tex block. | |
11505 | \def\texinfochars{% | |
11506 | \let< = \activeless | |
11507 | \let> = \activegtr | |
11508 | \let~ = \activetilde | |
11509 | \let^ = \activehat | |
11510 | \markupsetuplqdefault \markupsetuprqdefault | |
11511 | \let\b = \strong | |
11512 | \let\i = \smartitalic | |
11513 | % in principle, all other definitions in \tex have to be undone too. | |
11514 | } | |
9e9f9cc2 | 11515 | |
9251c568 AJ |
11516 | % Used sometimes to turn off (effectively) the active characters even after |
11517 | % parsing them. | |
11518 | \def\turnoffactive{% | |
11519 | \normalturnoffactive | |
11520 | \otherbackslash | |
11521 | } | |
11522 | ||
9e9f9cc2 KB |
11523 | \catcode`\@=0 |
11524 | ||
82d5ce1d | 11525 | % \backslashcurfont outputs one backslash character in current font, |
e0f86659 | 11526 | % as in \char`\\. |
82d5ce1d UD |
11527 | \global\chardef\backslashcurfont=`\\ |
11528 | \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work | |
9e9f9cc2 | 11529 | |
9251c568 AJ |
11530 | % \realbackslash is an actual character `\' with catcode other, and |
11531 | % \doublebackslash is two of them (for the pdf outlines). | |
11532 | {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} | |
11533 | ||
084e7d57 | 11534 | % In Texinfo, backslash is an active character; it prints the backslash |
9251c568 | 11535 | % in fixed width font. |
0f8bbd69 JM |
11536 | \catcode`\\=\active % @ for escape char from now on. |
11537 | ||
084e7d57 JM |
11538 | % Print a typewriter backslash. For math mode, we can't simply use |
11539 | % \backslashcurfont: the story here is that in math mode, the \char | |
11540 | % of \backslashcurfont ends up printing the roman \ from the math symbol | |
11541 | % font (because \char in math mode uses the \mathcode, and plain.tex | |
11542 | % sets \mathcode`\\="026E). Hence we use an explicit \mathchar, | |
0f8bbd69 JM |
11543 | % which is the decimal equivalent of "715c (class 7, e.g., use \fam; |
11544 | % ignored family value; char position "5C). We can't use " for the | |
11545 | % usual hex value because it has already been made active. | |
0f8bbd69 | 11546 | |
084e7d57 JM |
11547 | @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} |
11548 | @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. | |
11549 | ||
82d5ce1d | 11550 | % \rawbackslash defines an active \ to do \backslashcurfont. |
e0f86659 | 11551 | % \otherbackslash defines an active \ to be a literal `\' character with |
0f8bbd69 | 11552 | % catcode other. We switch back and forth between these. |
9251c568 AJ |
11553 | @gdef@rawbackslash{@let\=@backslashcurfont} |
11554 | @gdef@otherbackslash{@let\=@realbackslash} | |
9e9f9cc2 | 11555 | |
9251c568 | 11556 | % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of |
084e7d57 | 11557 | % the literal character `\'. |
8fcb833a JM |
11558 | % |
11559 | {@catcode`- = @active | |
11560 | @gdef@normalturnoffactive{% | |
7f7dd1d3 | 11561 | @passthroughcharstrue |
8fcb833a JM |
11562 | @let-=@normaldash |
11563 | @let"=@normaldoublequote | |
11564 | @let$=@normaldollar %$ font-lock fix | |
11565 | @let+=@normalplus | |
11566 | @let<=@normalless | |
11567 | @let>=@normalgreater | |
8fcb833a JM |
11568 | @let^=@normalcaret |
11569 | @let_=@normalunderscore | |
11570 | @let|=@normalverticalbar | |
11571 | @let~=@normaltilde | |
084e7d57 | 11572 | @let\=@ttbackslash |
8fcb833a JM |
11573 | @markupsetuplqdefault |
11574 | @markupsetuprqdefault | |
11575 | @unsepspaces | |
11576 | } | |
e0f86659 UD |
11577 | } |
11578 | ||
084e7d57 JM |
11579 | % If a .fmt file is being used, characters that might appear in a file |
11580 | % name cannot be active until we have parsed the command line. | |
11581 | % So turn them off again, and have @fixbackslash turn them back on. | |
11582 | @catcode`+=@other @catcode`@_=@other | |
9e9f9cc2 | 11583 | |
084e7d57 JM |
11584 | % \enablebackslashhack - allow file to begin `\input texinfo' |
11585 | % | |
9e9f9cc2 KB |
11586 | % If a .fmt file is being used, we don't want the `\input texinfo' to show up. |
11587 | % That is what \eatinput is for; after that, the `\' should revert to printing | |
11588 | % a backslash. | |
084e7d57 JM |
11589 | % If the file did not have a `\input texinfo', then it is turned off after |
11590 | % the first line; otherwise the first `\' in the file would cause an error. | |
11591 | % This is used on the very last line of this file, texinfo.tex. | |
11592 | % We also use @c to call @fixbackslash, in case ends of lines are hidden. | |
11593 | { | |
11594 | @catcode`@^=7 | |
11595 | @catcode`@^^M=13@gdef@enablebackslashhack{% | |
11596 | @global@let\ = @eatinput% | |
11597 | @catcode`@^^M=13% | |
11598 | @def@c{@fixbackslash@c}% | |
7f7dd1d3 | 11599 | % Definition for the newline at the end of this file. |
084e7d57 | 11600 | @def ^^M{@let^^M@secondlinenl}% |
7f7dd1d3 JM |
11601 | % Definition for a newline in the main Texinfo file. |
11602 | @gdef @secondlinenl{@fixbackslash}% | |
084e7d57 JM |
11603 | }} |
11604 | ||
11605 | {@catcode`@^=7 @catcode`@^^M=13% | |
11606 | @gdef@eatinput input texinfo#1^^M{@fixbackslash}} | |
11607 | ||
11608 | % Emergency active definition of newline, in case an active newline token | |
11609 | % appears by mistake. | |
11610 | {@catcode`@^=7 @catcode13=13% | |
11611 | @gdef@enableemergencynewline{% | |
11612 | @gdef^^M{% | |
11613 | @par% | |
11614 | %<warning: active newline>@par% | |
11615 | }}} | |
11616 | ||
9e9f9cc2 | 11617 | |
13632cfc | 11618 | @gdef@fixbackslash{% |
084e7d57 JM |
11619 | @ifx\@eatinput @let\ = @ttbackslash @fi |
11620 | @catcode13=5 % regular end of line | |
11621 | @enableemergencynewline | |
11622 | @let@c=@texinfoc | |
11623 | % Also turn back on active characters that might appear in the input | |
11624 | % file name, in case not using a pre-dumped format. | |
13632cfc UD |
11625 | @catcode`+=@active |
11626 | @catcode`@_=@active | |
084e7d57 JM |
11627 | % |
11628 | % If texinfo.cnf is present on the system, read it. | |
11629 | % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets | |
11630 | % called at the beginning of every Texinfo file. Not opening texinfo.cnf | |
11631 | % directly in this file, texinfo.tex, makes it possible to make a format | |
11632 | % file for Texinfo. | |
11633 | % | |
11634 | @openin 1 texinfo.cnf | |
11635 | @ifeof 1 @else @input texinfo.cnf @fi | |
11636 | @closein 1 | |
13632cfc | 11637 | } |
9e9f9cc2 | 11638 | |
084e7d57 | 11639 | |
13632cfc UD |
11640 | % Say @foo, not \foo, in error messages. |
11641 | @escapechar = `@@ | |
11642 | ||
0f8bbd69 JM |
11643 | % These (along with & and #) are made active for url-breaking, so need |
11644 | % active definitions as the normal characters. | |
11645 | @def@normaldot{.} | |
11646 | @def@normalquest{?} | |
11647 | @def@normalslash{/} | |
9e9f9cc2 | 11648 | |
0f8bbd69 JM |
11649 | % These look ok in all fonts, so just make them not special. |
11650 | % @hashchar{} gets its own user-level command, because of #line. | |
11651 | @catcode`@& = @other @def@normalamp{&} | |
11652 | @catcode`@# = @other @def@normalhash{#} | |
11653 | @catcode`@% = @other @def@normalpercent{%} | |
11654 | ||
11655 | @let @hashchar = @normalhash | |
11656 | ||
11657 | @c Finally, make ` and ' active, so that txicodequoteundirected and | |
11658 | @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we | |
11659 | @c don't make ` and ' active, @code will not get them as active chars. | |
11660 | @c Do this last of all since we use ` in the previous @catcode assignments. | |
11661 | @catcode`@'=@active | |
11662 | @catcode`@`=@active | |
11663 | @markupsetuplqdefault | |
11664 | @markupsetuprqdefault | |
13632cfc | 11665 | |
9e9f9cc2 | 11666 | @c Local variables: |
d667195c | 11667 | @c eval: (add-hook 'write-file-hooks 'time-stamp) |
084e7d57 | 11668 | @c page-delimiter: "^\\\\message\\|emacs-page" |
d667195c | 11669 | @c time-stamp-start: "def\\\\texinfoversion{" |
3b82ab1c | 11670 | @c time-stamp-format: "%:y-%02m-%02d.%02H" |
d667195c | 11671 | @c time-stamp-end: "}" |
9e9f9cc2 | 11672 | @c End: |
82d5ce1d UD |
11673 | |
11674 | @c vim:sw=2: | |
11675 | ||
084e7d57 | 11676 | @enablebackslashhack |