Mercurial > gnulib
comparison build-aux/texinfo.tex @ 40204:db8428454956
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Sun, 03 Mar 2019 14:09:37 -0800 |
parents | 30d91797009f |
children | 053dfcf64bef |
comparison
equal
deleted
inserted
replaced
40203:30d91797009f | 40204:db8428454956 |
---|---|
1 % texinfo.tex -- TeX macros to handle Texinfo files. | 1 % texinfo.tex -- TeX macros to handle Texinfo files. |
2 % | 2 % |
3 % Load plain if necessary, i.e., if running under initex. | 3 % Load plain if necessary, i.e., if running under initex. |
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi | 4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi |
5 % | 5 % |
6 \def\texinfoversion{2019-02-28.20} | 6 \def\texinfoversion{2019-03-02.16} |
7 | 7 |
8 % | 8 % |
9 % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. | 9 % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. |
10 % | 10 % |
11 % This texinfo.tex file is free software: you can redistribute it and/or | 11 % This texinfo.tex file is free software: you can redistribute it and/or |
256 % (\thissection) refers to the chapter (section) in effect at the top | 256 % (\thissection) refers to the chapter (section) in effect at the top |
257 % of a page, or that at the bottom of a page. | 257 % of a page, or that at the bottom of a page. |
258 | 258 |
259 % \domark is called twice inside \chapmacro, to add one | 259 % \domark is called twice inside \chapmacro, to add one |
260 % mark before the section break, and one after. | 260 % mark before the section break, and one after. |
261 % In the second call \prevchapterdefs is the same as \lastchapterdefs, | 261 % In the second call \prevchapterdefs is the same as \currentchapterdefs, |
262 % and \prevsectiondefs is the same as \lastsectiondefs. | 262 % and \prevsectiondefs is the same as \currentsectiondefs. |
263 % Then if the page is not broken at the mark, some of the previous | 263 % Then if the page is not broken at the mark, some of the previous |
264 % section appears on the page, and we can get the name of this section | 264 % section appears on the page, and we can get the name of this section |
265 % from \firstmark for @everyheadingmarks top. | 265 % from \firstmark for @everyheadingmarks top. |
266 % @everyheadingmarks bottom uses \botmark. | 266 % @everyheadingmarks bottom uses \botmark. |
267 % | 267 % |
268 % See page 260 of The TeXbook. | 268 % See page 260 of The TeXbook. |
269 \def\domark{% | 269 \def\domark{% |
270 \toks0=\expandafter{\lastchapterdefs}% | 270 \toks0=\expandafter{\currentchapterdefs}% |
271 \toks2=\expandafter{\lastsectiondefs}% | 271 \toks2=\expandafter{\currentsectiondefs}% |
272 \toks4=\expandafter{\prevchapterdefs}% | 272 \toks4=\expandafter{\prevchapterdefs}% |
273 \toks6=\expandafter{\prevsectiondefs}% | 273 \toks6=\expandafter{\prevsectiondefs}% |
274 \toks8=\expandafter{\lastcolordefs}% | 274 \toks8=\expandafter{\currentcolordefs}% |
275 \mark{% | 275 \mark{% |
276 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top | 276 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top |
277 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom | 277 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom |
278 \noexpand\else \the\toks8 % 2: color marks | 278 \noexpand\else \the\toks8 % 2: color marks |
279 }% | 279 }% |
286 % page or the contents), so we use \firstmark there -- this gets us | 286 % page or the contents), so we use \firstmark there -- this gets us |
287 % the mark with the chapter defs, unless the user sneaks in, e.g., | 287 % the mark with the chapter defs, unless the user sneaks in, e.g., |
288 % @setcolor (or @url, or @link, etc.) between @contents and the very | 288 % @setcolor (or @url, or @link, etc.) between @contents and the very |
289 % first @chapter. | 289 % first @chapter. |
290 \def\gettopheadingmarks{% | 290 \def\gettopheadingmarks{% |
291 \ifcase0\topmark\fi | 291 \ifcase0\the\savedtopmark\fi |
292 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi | 292 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi |
293 } | 293 } |
294 \def\getbottomheadingmarks{\ifcase1\botmark\fi} | 294 \def\getbottomheadingmarks{\ifcase1\botmark\fi} |
295 \def\getcolormarks{\ifcase2\topmark\fi} | 295 \def\getcolormarks{\ifcase2\the\savedtopmark\fi} |
296 | 296 |
297 % Avoid "undefined control sequence" errors. | 297 % Avoid "undefined control sequence" errors. |
298 \def\lastchapterdefs{} | 298 \def\currentchapterdefs{} |
299 \def\lastsectiondefs{} | 299 \def\currentsectiondefs{} |
300 \def\lastsection{} | 300 \def\currentsection{} |
301 \def\prevchapterdefs{} | 301 \def\prevchapterdefs{} |
302 \def\prevsectiondefs{} | 302 \def\prevsectiondefs{} |
303 \def\lastcolordefs{} | 303 \def\currentcolordefs{} |
304 | 304 |
305 % Margin to add to right of even pages, to left of odd pages. | 305 % Margin to add to right of even pages, to left of odd pages. |
306 \newdimen\bindingoffset | 306 \newdimen\bindingoffset |
307 \newdimen\normaloffset | 307 \newdimen\normaloffset |
308 \newdimen\txipagewidth \newdimen\txipageheight | 308 \newdimen\txipagewidth \newdimen\txipageheight |
309 | 309 |
310 % Main output routine. | 310 % Main output routine. |
311 % | 311 % |
312 \chardef\PAGE = 255 | 312 \chardef\PAGE = 255 |
313 \output = {\onepageout{\pagecontents\PAGE}} | 313 \output = {\savetopmark\onepageout{\pagecontents\PAGE}} |
314 | 314 |
315 \newbox\headlinebox | 315 \newbox\headlinebox |
316 \newbox\footlinebox | 316 \newbox\footlinebox |
317 | |
318 % When outputting the double column layout for indices, an output routine | |
319 % is run several times, which hides the original value of \topmark. This | |
320 % can lead to a page heading being output and duplicating the chapter heading | |
321 % of the index. Hence, save the contents of \topmark at the beginning of | |
322 % the output routine. The saved contents are valid until we actually | |
323 % \shipout a page. | |
324 % | |
325 % (We used to run a short output routine to actually set \topmark and | |
326 % \firstmark to the right values, but if this was called with an empty page | |
327 % containing whatsits for writing index entries, the whatsits would be thrown | |
328 % away and the index auxiliary file would remain empty.) | |
329 % | |
330 \newtoks\savedtopmark | |
331 \newif\iftopmarksaved | |
332 \topmarksavedtrue | |
333 \def\savetopmark{% | |
334 \iftopmarksaved\else | |
335 \global\savedtopmark=\expandafter{\topmark}% | |
336 \global\topmarksavedtrue | |
337 \fi | |
338 } | |
317 | 339 |
318 % \onepageout takes a vbox as an argument. | 340 % \onepageout takes a vbox as an argument. |
319 % \shipout a vbox for a single page, adding an optional header, footer | 341 % \shipout a vbox for a single page, adding an optional header, footer |
320 % and footnote. This also causes index entries for this page to be written | 342 % and footnote. This also causes index entries for this page to be written |
321 % to the auxiliary files. | 343 % to the auxiliary files. |
324 \hoffset=\normaloffset | 346 \hoffset=\normaloffset |
325 % | 347 % |
326 \ifodd\pageno \advance\hoffset by \bindingoffset | 348 \ifodd\pageno \advance\hoffset by \bindingoffset |
327 \else \advance\hoffset by -\bindingoffset\fi | 349 \else \advance\hoffset by -\bindingoffset\fi |
328 % | 350 % |
329 % Common context changes for both heading and footing. | |
330 % Do this outside of the \shipout so @code etc. will be expanded in | |
331 % the headline as they should be, not taken literally (outputting ''code). | |
332 \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars} | |
333 % | |
334 % Retrieve the information for the headings from the marks in the page, | 351 % Retrieve the information for the headings from the marks in the page, |
335 % and call Plain TeX's \makeheadline and \makefootline, which use the | 352 % and call Plain TeX's \makeheadline and \makefootline, which use the |
336 % values in \headline and \footline. | 353 % values in \headline and \footline. |
337 % | 354 % |
338 % This is used to check if we are on the first page of a chapter. | 355 % This is used to check if we are on the first page of a chapter. |
339 \ifcase1\topmark\fi | 356 \ifcase1\the\savedtopmark\fi |
340 \let\prevchaptername\thischaptername | 357 \let\prevchaptername\thischaptername |
341 \ifcase0\firstmark\fi | 358 \ifcase0\firstmark\fi |
342 \let\curchaptername\thischaptername | 359 \let\curchaptername\thischaptername |
343 % | 360 % |
344 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi | 361 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi |
345 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi | |
346 % | 362 % |
347 \ifx\curchaptername\prevchaptername | 363 \ifx\curchaptername\prevchaptername |
348 \let\thischapterheading\thischapter | 364 \let\thischapterheading\thischapter |
349 \else | 365 \else |
350 % \thischapterheading is the same as \thischapter except it is blank | 366 % \thischapterheading is the same as \thischapter except it is blank |
351 % for the first page of a chapter. This is to prevent the chapter name | 367 % for the first page of a chapter. This is to prevent the chapter name |
352 % being shown twice. | 368 % being shown twice. |
353 \def\thischapterheading{}% | 369 \def\thischapterheading{}% |
354 \fi | 370 \fi |
355 % | 371 % |
372 % Common context changes for both heading and footing. | |
373 % Do this outside of the \shipout so @code etc. will be expanded in | |
374 % the headline as they should be, not taken literally (outputting ''code). | |
375 \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars} | |
376 % | |
356 \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}% | 377 \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}% |
378 % | |
379 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi | |
357 \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}% | 380 \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}% |
358 % | 381 % |
359 {% | 382 {% |
360 % Set context for writing to auxiliary files like index files. | 383 % Set context for writing to auxiliary files like index files. |
361 % Have to do this stuff outside the \shipout because we want it to | 384 % Have to do this stuff outside the \shipout because we want it to |
382 % The \baselineskip=24pt in plain's \makefootline has no effect. | 405 % The \baselineskip=24pt in plain's \makefootline has no effect. |
383 \vskip 24pt | 406 \vskip 24pt |
384 \unvbox\footlinebox | 407 \unvbox\footlinebox |
385 \fi | 408 \fi |
386 % | 409 % |
387 }% end of \shipout\vbox | 410 }% |
388 }% end of group with \indexdummies | 411 }% |
412 \global\topmarksavedfalse | |
389 \advancepageno | 413 \advancepageno |
390 \ifnum\outputpenalty>-20000 \else\dosupereject\fi | 414 \ifnum\outputpenalty>-20000 \else\dosupereject\fi |
391 } | 415 } |
392 | 416 |
393 \newinsert\margin \dimen\margin=\maxdimen | 417 \newinsert\margin \dimen\margin=\maxdimen |
1159 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} | 1183 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} |
1160 % | 1184 % |
1161 % Set color, and create a mark which defines \thiscolor accordingly, | 1185 % Set color, and create a mark which defines \thiscolor accordingly, |
1162 % so that \makeheadline knows which color to restore. | 1186 % so that \makeheadline knows which color to restore. |
1163 \def\setcolor#1{% | 1187 \def\setcolor#1{% |
1164 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% | 1188 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% |
1165 \domark | 1189 \domark |
1166 \pdfsetcolor{#1}% | 1190 \pdfsetcolor{#1}% |
1167 } | 1191 } |
1168 % | 1192 % |
1169 \def\maincolor{\rgbBlack} | 1193 \def\maincolor{\rgbBlack} |
1170 \pdfsetcolor{\maincolor} | 1194 \pdfsetcolor{\maincolor} |
1171 \edef\thiscolor{\maincolor} | 1195 \edef\thiscolor{\maincolor} |
1172 \def\lastcolordefs{} | 1196 \def\currentcolordefs{} |
1173 % | 1197 % |
1174 \def\makefootline{% | 1198 \def\makefootline{% |
1175 \baselineskip24pt | 1199 \baselineskip24pt |
1176 \line{\pdfsetcolor{\maincolor}\the\footline}% | 1200 \line{\pdfsetcolor{\maincolor}\the\footline}% |
1177 } | 1201 } |
1545 \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} | 1569 \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} |
1546 % | 1570 % |
1547 % Set color, and create a mark which defines \thiscolor accordingly, | 1571 % Set color, and create a mark which defines \thiscolor accordingly, |
1548 % so that \makeheadline knows which color to restore. | 1572 % so that \makeheadline knows which color to restore. |
1549 \def\setcolor#1{% | 1573 \def\setcolor#1{% |
1550 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% | 1574 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% |
1551 \domark | 1575 \domark |
1552 \pdfsetcolor{#1}% | 1576 \pdfsetcolor{#1}% |
1553 } | 1577 } |
1554 % | 1578 % |
1555 \def\maincolor{\rgbBlack} | 1579 \def\maincolor{\rgbBlack} |
1556 \pdfsetcolor{\maincolor} | 1580 \pdfsetcolor{\maincolor} |
1557 \edef\thiscolor{\maincolor} | 1581 \edef\thiscolor{\maincolor} |
1558 \def\lastcolordefs{} | 1582 \def\currentcolordefs{} |
1559 % | 1583 % |
1560 \def\makefootline{% | 1584 \def\makefootline{% |
1561 \baselineskip24pt | 1585 \baselineskip24pt |
1562 \line{\pdfsetcolor{\maincolor}\the\footline}% | 1586 \line{\pdfsetcolor{\maincolor}\the\footline}% |
1563 } | 1587 } |
5253 \let\indexbackslash=\relax | 5277 \let\indexbackslash=\relax |
5254 {\catcode`\@=0 \catcode`\\=\active | 5278 {\catcode`\@=0 \catcode`\\=\active |
5255 @gdef@useindexbackslash{@def\{{@indexbackslash}}} | 5279 @gdef@useindexbackslash{@def\{{@indexbackslash}}} |
5256 } | 5280 } |
5257 | 5281 |
5258 % Definition for writing index entry text. | |
5259 \def\sortas#1{}% | |
5260 | |
5261 % Definition for writing index entry sort key. | 5282 % Definition for writing index entry sort key. |
5262 { | 5283 { |
5263 \catcode`\-=13 | 5284 \catcode`\-=13 |
5264 \gdef\indexwritesortas{% | 5285 \gdef\indexwritesortas{% |
5265 \begingroup | 5286 \begingroup |
5267 \indexwritesortasxxx} | 5288 \indexwritesortasxxx} |
5268 \gdef\indexwritesortasxxx#1{% | 5289 \gdef\indexwritesortasxxx#1{% |
5269 \xdef\indexsortkey{#1}\endgroup} | 5290 \xdef\indexsortkey{#1}\endgroup} |
5270 } | 5291 } |
5271 | 5292 |
5293 % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}": | |
5294 % * Set \bracedtext to "{aaa}{bbb}" | |
5295 % * Set \fullindexsortkey to "aaa @subentry ZZZ" | |
5296 % | |
5297 \def\splitindexentry#1{% | |
5298 \gdef\fullindexsortkey{}% | |
5299 \xdef\bracedtext{}% | |
5300 \def\sep{}% | |
5301 \expandafter\doindexsegment#1\subentry\finish\subentry | |
5302 } | |
5303 | |
5304 % append the results from the next segment | |
5305 \def\doindexsegment#1\subentry{% | |
5306 \def\segment{#1}% | |
5307 \ifx\segment\isfinish | |
5308 \else | |
5309 % | |
5310 % Fully expand the segment, throwing away any @sortas directives, and | |
5311 % trim spaces. | |
5312 \def\sortas##1{}% | |
5313 \edef\trimmed{\segment}% | |
5314 \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% | |
5315 % | |
5316 \xdef\bracedtext{\bracedtext{\trimmed}}% | |
5317 % | |
5318 % Get the string to sort by. Process the segment with all | |
5319 % font commands turned off. | |
5320 \bgroup | |
5321 \let\sortas\indexwritesortas | |
5322 \indexnofonts | |
5323 % The braces around the commands are recognized by texindex. | |
5324 \def\lbracechar{{\indexlbrace}}% | |
5325 \def\rbracechar{{\indexrbrace}}% | |
5326 \let\{=\lbracechar | |
5327 \let\}=\rbracechar | |
5328 % | |
5329 \let\indexsortkey\empty | |
5330 % Execute the segment and throw away the typeset output. This executes | |
5331 % any @sortas commands in this segment. | |
5332 \setbox\dummybox = \hbox{\segment}% | |
5333 \ifx\indexsortkey\empty{% | |
5334 \indexnonalnumdisappear | |
5335 \xdef\trimmed{\segment}% | |
5336 \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% | |
5337 \xdef\indexsortkey{\trimmed}% | |
5338 \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi | |
5339 }\fi | |
5340 % | |
5341 % Append to \fullindexsortkey. | |
5342 \edef\tmp{\gdef\noexpand\fullindexsortkey{% | |
5343 \fullindexsortkey\sep\indexsortkey}}% | |
5344 \tmp | |
5345 \egroup | |
5346 \def\sep{\subentry}% | |
5347 % | |
5348 \expandafter\doindexsegment | |
5349 \fi | |
5350 } | |
5351 \def\isfinish{\finish}% | |
5352 | |
5353 \let\subentry\relax | |
5272 | 5354 |
5273 % Write the entry in \toks0 to the index file. | 5355 % Write the entry in \toks0 to the index file. |
5274 % | 5356 % |
5275 \def\dosubindwrite{% | 5357 \def\dosubindwrite{% |
5276 % Put the index entry in the margin if desired. | 5358 % Put the index entry in the margin if desired. |
5280 % | 5362 % |
5281 % Remember, we are within a group. | 5363 % Remember, we are within a group. |
5282 \indexdummies % Must do this here, since \bf, etc expand at this stage | 5364 \indexdummies % Must do this here, since \bf, etc expand at this stage |
5283 \useindexbackslash % \indexbackslash isn't defined now so it will be output | 5365 \useindexbackslash % \indexbackslash isn't defined now so it will be output |
5284 % as is; and it will print as backslash. | 5366 % as is; and it will print as backslash. |
5285 % The braces around \indexbrace are recognized by texindex. | 5367 % |
5286 % | 5368 % Split the entry into primary entry and any subentries, and get the index |
5287 % Get the string to sort by, by processing the index entry with all | 5369 % sort key. |
5288 % font commands turned off. | 5370 \splitindexentry\indextext |
5289 {\indexnofonts | |
5290 \def\lbracechar{{\indexlbrace}}% | |
5291 \def\rbracechar{{\indexrbrace}}% | |
5292 \let\{=\lbracechar | |
5293 \let\}=\rbracechar | |
5294 \indexnonalnumdisappear | |
5295 \xdef\indexsortkey{}% | |
5296 \let\sortas=\indexwritesortas | |
5297 \setbox\dummybox = \hbox{\indextext}% Execute any \sortas | |
5298 \ifx\indexsortkey\empty | |
5299 \xdef\indexsortkey{\indextext}% | |
5300 \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi | |
5301 \fi | |
5302 }% | |
5303 % | 5371 % |
5304 % Set up the complete index entry, with both the sort key and | 5372 % Set up the complete index entry, with both the sort key and |
5305 % the original text, including any font commands. We write | 5373 % the original text, including any font commands. We write |
5306 % three arguments to \entry to the .?? file (four in the | 5374 % three arguments to \entry to the .?? file (four in the |
5307 % subentry case), texindex reduces to two when writing the .??s | 5375 % subentry case), texindex reduces to two when writing the .??s |
5308 % sorted result. | 5376 % sorted result. |
5309 % | 5377 % |
5310 % Fully expand the text of the index entry and trim spaces. | |
5311 \edef\indextext{\indextext}% | |
5312 \edef\indextext{\expandafter\eatspaces\expandafter{\indextext}}% | |
5313 \toks0=\expandafter{\indextext}% | |
5314 \edef\temp{% | 5378 \edef\temp{% |
5315 \write\writeto{% | 5379 \write\writeto{% |
5316 \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}% | 5380 \string\entry{\fullindexsortkey}{\noexpand\folio}\bracedtext}% |
5317 }% | 5381 }% |
5318 \temp | 5382 \temp |
5319 } | 5383 } |
5320 \newbox\dummybox % used above | 5384 \newbox\dummybox % used above |
5321 | 5385 |
5787 \catcode`\@=11 % private names | 5851 \catcode`\@=11 % private names |
5788 | 5852 |
5789 \newbox\partialpage | 5853 \newbox\partialpage |
5790 \newdimen\doublecolumnhsize | 5854 \newdimen\doublecolumnhsize |
5791 | 5855 |
5792 % Use inside an output routine to save \topmark and \firstmark | |
5793 \def\savemarks{% | |
5794 \global\savedtopmark=\expandafter{\topmark }% | |
5795 \global\savedfirstmark=\expandafter{\firstmark }% | |
5796 } | |
5797 \newtoks\savedtopmark | |
5798 \newtoks\savedfirstmark | |
5799 | |
5800 % Set \topmark and \firstmark for next time \output runs. | |
5801 % Can't be run from withinside \output (because any material | |
5802 % added while an output routine is active, including | |
5803 % penalties, is saved for after it finishes). The page so far | |
5804 % should be empty, otherwise what's on it will be thrown away. | |
5805 \def\restoremarks{% | |
5806 \mark{\the\savedtopmark}% | |
5807 \bgroup\output = {% | |
5808 \setbox\dummybox=\box\PAGE | |
5809 }abc\eject\egroup | |
5810 % "abc" because output routine doesn't fire for a completely empty page. | |
5811 \mark{\the\savedfirstmark}% | |
5812 } | |
5813 | |
5814 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns | 5856 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns |
5815 % If not much space left on page, start a new page. | 5857 % If not much space left on page, start a new page. |
5816 \ifdim\pagetotal>0.8\vsize\vfill\eject\fi | 5858 \ifdim\pagetotal>0.8\vsize\vfill\eject\fi |
5817 % | 5859 % |
5818 % Grab any single-column material above us. | 5860 % Grab any single-column material above us. |
5819 \output = {% | 5861 \output = {% |
5862 \savetopmark | |
5820 % | 5863 % |
5821 % Here is a possibility not foreseen in manmac: if we accumulate a | 5864 % Here is a possibility not foreseen in manmac: if we accumulate a |
5822 % whole lot of material, we might end up calling this \output | 5865 % whole lot of material, we might end up calling this \output |
5823 % routine twice in a row (see the doublecol-lose test, which is | 5866 % routine twice in a row (see the doublecol-lose test, which is |
5824 % essentially a couple of indexes with @setchapternewpage off). In | 5867 % essentially a couple of indexes with @setchapternewpage off). In |
5832 \global\setbox\partialpage = \vbox{% | 5875 \global\setbox\partialpage = \vbox{% |
5833 % Unvbox the main output page. | 5876 % Unvbox the main output page. |
5834 \unvbox\PAGE | 5877 \unvbox\PAGE |
5835 \kern-\topskip \kern\baselineskip | 5878 \kern-\topskip \kern\baselineskip |
5836 }% | 5879 }% |
5837 \savemarks | |
5838 }% | 5880 }% |
5839 \eject % run that output routine to set \partialpage | 5881 \eject % run that output routine to set \partialpage |
5840 \restoremarks | |
5841 % | |
5842 % We recover the two marks that the last output routine saved in order | |
5843 % to propagate the information in marks added around a chapter heading, | |
5844 % which could be otherwise be lost by the time the final page is output. | |
5845 % | |
5846 % | 5882 % |
5847 % Use the double-column output routine for subsequent pages. | 5883 % Use the double-column output routine for subsequent pages. |
5848 \output = {\doublecolumnout}% | 5884 \output = {\doublecolumnout}% |
5849 % | 5885 % |
5850 % Change the page size parameters. We could do this once outside this | 5886 % Change the page size parameters. We could do this once outside this |
5881 % The double-column output routine for all double-column pages except | 5917 % The double-column output routine for all double-column pages except |
5882 % the last, which is done by \balancecolumns. | 5918 % the last, which is done by \balancecolumns. |
5883 % | 5919 % |
5884 \def\doublecolumnout{% | 5920 \def\doublecolumnout{% |
5885 % | 5921 % |
5922 \savetopmark | |
5886 \splittopskip=\topskip \splitmaxdepth=\maxdepth | 5923 \splittopskip=\topskip \splitmaxdepth=\maxdepth |
5887 \dimen@ = \vsize | 5924 \dimen@ = \vsize |
5888 \divide\dimen@ by 2 | 5925 \divide\dimen@ by 2 |
5889 % | 5926 % |
5890 % box0 will be the left-hand column, box2 the right. | 5927 % box0 will be the left-hand column, box2 the right. |
5936 % page builder, unlike penalties (see The TeXbook, pp. 280-281). | 5973 % page builder, unlike penalties (see The TeXbook, pp. 280-281). |
5937 \penalty0 | 5974 \penalty0 |
5938 % | 5975 % |
5939 \output = {% | 5976 \output = {% |
5940 % Split the last of the double-column material. | 5977 % Split the last of the double-column material. |
5941 \savemarks | 5978 \savetopmark |
5942 \balancecolumns | 5979 \balancecolumns |
5943 }% | 5980 }% |
5944 \eject % call the \output just set | 5981 \eject % call the \output just set |
5945 \ifdim\pagetotal=0pt | 5982 \ifdim\pagetotal=0pt |
5946 % Having called \balancecolumns once, we do not | 5983 % Having called \balancecolumns once, we do not |
5947 % want to call it again. Therefore, reset \output to its normal | 5984 % want to call it again. Therefore, reset \output to its normal |
5948 % definition right away. | 5985 % definition right away. |
5949 \global\output = {\onepageout{\pagecontents\PAGE}}% | 5986 \global\output = {\onepageout{\pagecontents\PAGE}}% |
5950 % | 5987 % |
5951 \endgroup % started in \begindoublecolumns | 5988 \endgroup % started in \begindoublecolumns |
5952 \restoremarks | |
5953 % Leave the double-column material on the current page, no automatic | 5989 % Leave the double-column material on the current page, no automatic |
5954 % page break. | 5990 % page break. |
5955 \box\balancedcolumns | 5991 \box\balancedcolumns |
5956 % | 5992 % |
5957 % \pagegoal was set to the doubled \vsize above, since we restarted | 5993 % \pagegoal was set to the doubled \vsize above, since we restarted |
6462 % | 6498 % |
6463 \def\chapmacro#1#2#3{% | 6499 \def\chapmacro#1#2#3{% |
6464 \expandafter\ifx\thisenv\titlepage\else | 6500 \expandafter\ifx\thisenv\titlepage\else |
6465 \checkenv{}% chapters, etc., should not start inside an environment. | 6501 \checkenv{}% chapters, etc., should not start inside an environment. |
6466 \fi | 6502 \fi |
6467 % FIXME: \chapmacro is currently called from inside \titlepage when | |
6468 % \setcontentsaftertitlepage to print the "Table of Contents" heading, but | |
6469 % this should probably be done by \sectionheading with an option to print | |
6470 % in chapter size. | |
6471 % | |
6472 % Insert the first mark before the heading break (see notes for \domark). | 6503 % Insert the first mark before the heading break (see notes for \domark). |
6473 \let\prevchapterdefs=\lastchapterdefs | 6504 \let\prevchapterdefs=\currentchapterdefs |
6474 \let\prevsectiondefs=\lastsectiondefs | 6505 \let\prevsectiondefs=\currentsectiondefs |
6475 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% | 6506 \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% |
6476 \gdef\thissection{}}% | 6507 \gdef\thissection{}}% |
6477 % | 6508 % |
6478 \def\temptype{#2}% | 6509 \def\temptype{#2}% |
6479 \ifx\temptype\Ynothingkeyword | 6510 \ifx\temptype\Ynothingkeyword |
6480 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% | 6511 \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% |
6481 \gdef\thischapter{\thischaptername}}% | 6512 \gdef\thischapter{\thischaptername}}% |
6482 \else\ifx\temptype\Yomitfromtockeyword | 6513 \else\ifx\temptype\Yomitfromtockeyword |
6483 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% | 6514 \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% |
6484 \gdef\thischapter{}}% | 6515 \gdef\thischapter{}}% |
6485 \else\ifx\temptype\Yappendixkeyword | 6516 \else\ifx\temptype\Yappendixkeyword |
6486 \toks0={#1}% | 6517 \toks0={#1}% |
6487 \xdef\lastchapterdefs{% | 6518 \xdef\currentchapterdefs{% |
6488 \gdef\noexpand\thischaptername{\the\toks0}% | 6519 \gdef\noexpand\thischaptername{\the\toks0}% |
6489 \gdef\noexpand\thischapternum{\appendixletter}% | 6520 \gdef\noexpand\thischapternum{\appendixletter}% |
6490 % \noexpand\putwordAppendix avoids expanding indigestible | 6521 % \noexpand\putwordAppendix avoids expanding indigestible |
6491 % commands in some of the translations. | 6522 % commands in some of the translations. |
6492 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} | 6523 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} |
6493 \noexpand\thischapternum: | 6524 \noexpand\thischapternum: |
6494 \noexpand\thischaptername}% | 6525 \noexpand\thischaptername}% |
6495 }% | 6526 }% |
6496 \else | 6527 \else |
6497 \toks0={#1}% | 6528 \toks0={#1}% |
6498 \xdef\lastchapterdefs{% | 6529 \xdef\currentchapterdefs{% |
6499 \gdef\noexpand\thischaptername{\the\toks0}% | 6530 \gdef\noexpand\thischaptername{\the\toks0}% |
6500 \gdef\noexpand\thischapternum{\the\chapno}% | 6531 \gdef\noexpand\thischapternum{\the\chapno}% |
6501 % \noexpand\putwordChapter avoids expanding indigestible | 6532 % \noexpand\putwordChapter avoids expanding indigestible |
6502 % commands in some of the translations. | 6533 % commands in some of the translations. |
6503 \gdef\noexpand\thischapter{\noexpand\putwordChapter{} | 6534 \gdef\noexpand\thischapter{\noexpand\putwordChapter{} |
6513 % Insert the chapter heading break. | 6544 % Insert the chapter heading break. |
6514 \pchapsepmacro | 6545 \pchapsepmacro |
6515 % | 6546 % |
6516 % Now the second mark, after the heading break. No break points | 6547 % Now the second mark, after the heading break. No break points |
6517 % between here and the heading. | 6548 % between here and the heading. |
6518 \let\prevchapterdefs=\lastchapterdefs | 6549 \let\prevchapterdefs=\currentchapterdefs |
6519 \let\prevsectiondefs=\lastsectiondefs | 6550 \let\prevsectiondefs=\currentsectiondefs |
6520 \domark | 6551 \domark |
6521 % | 6552 % |
6522 {% | 6553 {% |
6523 \chapfonts \rm | 6554 \chapfonts \rm |
6524 \let\footnote=\errfootnoteheading % give better error message | 6555 \let\footnote=\errfootnoteheading % give better error message |
6525 % | 6556 % |
6526 % Have to define \lastsection before calling \donoderef, because the | 6557 % Have to define \currentsection before calling \donoderef, because the |
6527 % xref code eventually uses it. On the other hand, it has to be called | 6558 % xref code eventually uses it. On the other hand, it has to be called |
6528 % after \pchapsepmacro, or the headline will change too soon. | 6559 % after \pchapsepmacro, or the headline will change too soon. |
6529 \gdef\lastsection{#1}% | 6560 \gdef\currentsection{#1}% |
6530 % | 6561 % |
6531 % Only insert the separating space if we have a chapter/appendix | 6562 % Only insert the separating space if we have a chapter/appendix |
6532 % number, and don't print the unnumbered ``number''. | 6563 % number, and don't print the unnumbered ``number''. |
6533 \ifx\temptype\Ynothingkeyword | 6564 \ifx\temptype\Ynothingkeyword |
6534 \setbox0 = \hbox{}% | 6565 \setbox0 = \hbox{}% |
6613 % | 6644 % |
6614 % Switch to the right set of fonts. | 6645 % Switch to the right set of fonts. |
6615 \csname #2fonts\endcsname \rm | 6646 \csname #2fonts\endcsname \rm |
6616 % | 6647 % |
6617 % Insert first mark before the heading break (see notes for \domark). | 6648 % Insert first mark before the heading break (see notes for \domark). |
6618 \let\prevsectiondefs=\lastsectiondefs | 6649 \let\prevsectiondefs=\currentsectiondefs |
6619 \ifx\temptype\Ynothingkeyword | 6650 \ifx\temptype\Ynothingkeyword |
6620 \ifx\sectionlevel\seckeyword | 6651 \ifx\sectionlevel\seckeyword |
6621 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% | 6652 \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% |
6622 \gdef\thissection{\thissectionname}}% | 6653 \gdef\thissection{\thissectionname}}% |
6623 \fi | 6654 \fi |
6624 \else\ifx\temptype\Yomitfromtockeyword | 6655 \else\ifx\temptype\Yomitfromtockeyword |
6625 % Don't redefine \thissection. | 6656 % Don't redefine \thissection. |
6626 \else\ifx\temptype\Yappendixkeyword | 6657 \else\ifx\temptype\Yappendixkeyword |
6627 \ifx\sectionlevel\seckeyword | 6658 \ifx\sectionlevel\seckeyword |
6628 \toks0={#1}% | 6659 \toks0={#1}% |
6629 \xdef\lastsectiondefs{% | 6660 \xdef\currentsectiondefs{% |
6630 \gdef\noexpand\thissectionname{\the\toks0}% | 6661 \gdef\noexpand\thissectionname{\the\toks0}% |
6631 \gdef\noexpand\thissectionnum{#4}% | 6662 \gdef\noexpand\thissectionnum{#4}% |
6632 % \noexpand\putwordSection avoids expanding indigestible | 6663 % \noexpand\putwordSection avoids expanding indigestible |
6633 % commands in some of the translations. | 6664 % commands in some of the translations. |
6634 \gdef\noexpand\thissection{\noexpand\putwordSection{} | 6665 \gdef\noexpand\thissection{\noexpand\putwordSection{} |
6637 }% | 6668 }% |
6638 \fi | 6669 \fi |
6639 \else | 6670 \else |
6640 \ifx\sectionlevel\seckeyword | 6671 \ifx\sectionlevel\seckeyword |
6641 \toks0={#1}% | 6672 \toks0={#1}% |
6642 \xdef\lastsectiondefs{% | 6673 \xdef\currentsectiondefs{% |
6643 \gdef\noexpand\thissectionname{\the\toks0}% | 6674 \gdef\noexpand\thissectionname{\the\toks0}% |
6644 \gdef\noexpand\thissectionnum{#4}% | 6675 \gdef\noexpand\thissectionnum{#4}% |
6645 % \noexpand\putwordSection avoids expanding indigestible | 6676 % \noexpand\putwordSection avoids expanding indigestible |
6646 % commands in some of the translations. | 6677 % commands in some of the translations. |
6647 \gdef\noexpand\thissection{\noexpand\putwordSection{} | 6678 \gdef\noexpand\thissection{\noexpand\putwordSection{} |
6663 % Insert space above the heading. | 6694 % Insert space above the heading. |
6664 \csname #2headingbreak\endcsname | 6695 \csname #2headingbreak\endcsname |
6665 % | 6696 % |
6666 % Now the second mark, after the heading break. No break points | 6697 % Now the second mark, after the heading break. No break points |
6667 % between here and the heading. | 6698 % between here and the heading. |
6668 \global\let\prevsectiondefs=\lastsectiondefs | 6699 \global\let\prevsectiondefs=\currentsectiondefs |
6669 \domark | 6700 \domark |
6670 % | 6701 % |
6671 % Only insert the space after the number if we have a section number. | 6702 % Only insert the space after the number if we have a section number. |
6672 \ifx\temptype\Ynothingkeyword | 6703 \ifx\temptype\Ynothingkeyword |
6673 \setbox0 = \hbox{}% | 6704 \setbox0 = \hbox{}% |
6674 \def\toctype{unn}% | 6705 \def\toctype{unn}% |
6675 \gdef\lastsection{#1}% | 6706 \gdef\currentsection{#1}% |
6676 \else\ifx\temptype\Yomitfromtockeyword | 6707 \else\ifx\temptype\Yomitfromtockeyword |
6677 % for @headings -- no section number, don't include in toc, | 6708 % for @headings -- no section number, don't include in toc, |
6678 % and don't redefine \lastsection. | 6709 % and don't redefine \currentsection. |
6679 \setbox0 = \hbox{}% | 6710 \setbox0 = \hbox{}% |
6680 \def\toctype{omit}% | 6711 \def\toctype{omit}% |
6681 \let\sectionlevel=\empty | 6712 \let\sectionlevel=\empty |
6682 \else\ifx\temptype\Yappendixkeyword | 6713 \else\ifx\temptype\Yappendixkeyword |
6683 \setbox0 = \hbox{#4\enspace}% | 6714 \setbox0 = \hbox{#4\enspace}% |
6684 \def\toctype{app}% | 6715 \def\toctype{app}% |
6685 \gdef\lastsection{#1}% | 6716 \gdef\currentsection{#1}% |
6686 \else | 6717 \else |
6687 \setbox0 = \hbox{#4\enspace}% | 6718 \setbox0 = \hbox{#4\enspace}% |
6688 \def\toctype{num}% | 6719 \def\toctype{num}% |
6689 \gdef\lastsection{#1}% | 6720 \gdef\currentsection{#1}% |
6690 \fi\fi\fi | 6721 \fi\fi\fi |
6691 % | 6722 % |
6692 % Write the toc entry (before \donoderef). See comments in \chapmacro. | 6723 % Write the toc entry (before \donoderef). See comments in \chapmacro. |
6693 \writetocentry{\toctype\sectionlevel}{#1}{#4}% | 6724 \writetocentry{\toctype\sectionlevel}{#1}{#4}% |
6694 % | 6725 % |
8748 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} | 8779 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} |
8749 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} | 8780 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} |
8750 | 8781 |
8751 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an | 8782 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an |
8752 % anchor), which consists of three parts: | 8783 % anchor), which consists of three parts: |
8753 % 1) NAME-title - the current sectioning name taken from \lastsection, | 8784 % 1) NAME-title - the current sectioning name taken from \currentsection, |
8754 % or the anchor name. | 8785 % or the anchor name. |
8755 % 2) NAME-snt - section number and type, passed as the SNT arg, or | 8786 % 2) NAME-snt - section number and type, passed as the SNT arg, or |
8756 % empty for anchors. | 8787 % empty for anchors. |
8757 % 3) NAME-pg - the page number. | 8788 % 3) NAME-pg - the page number. |
8758 % | 8789 % |
8770 \def\value##1{##1}% | 8801 \def\value##1{##1}% |
8771 \edef\writexrdef##1##2{% | 8802 \edef\writexrdef##1##2{% |
8772 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef | 8803 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef |
8773 ##1}{##2}}% these are parameters of \writexrdef | 8804 ##1}{##2}}% these are parameters of \writexrdef |
8774 }% | 8805 }% |
8775 \toks0 = \expandafter{\lastsection}% | 8806 \toks0 = \expandafter{\currentsection}% |
8776 \immediate \writexrdef{title}{\the\toks0 }% | 8807 \immediate \writexrdef{title}{\the\toks0 }% |
8777 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. | 8808 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. |
8778 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout | 8809 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout |
8779 }% | 8810 }% |
8780 \fi | 8811 \fi |
9568 % | 9599 % |
9569 \expandafter\getfloatno\csname\safefloattype floatno\endcsname | 9600 \expandafter\getfloatno\csname\safefloattype floatno\endcsname |
9570 \global\advance\floatno by 1 | 9601 \global\advance\floatno by 1 |
9571 % | 9602 % |
9572 {% | 9603 {% |
9573 % This magic value for \lastsection is output by \setref as the | 9604 % This magic value for \currentsection is output by \setref as the |
9574 % XREFLABEL-title value. \xrefX uses it to distinguish float | 9605 % XREFLABEL-title value. \xrefX uses it to distinguish float |
9575 % labels (which have a completely different output format) from | 9606 % labels (which have a completely different output format) from |
9576 % node and anchor labels. And \xrdef uses it to construct the | 9607 % node and anchor labels. And \xrdef uses it to construct the |
9577 % lists of floats. | 9608 % lists of floats. |
9578 % | 9609 % |
9579 \edef\lastsection{\floatmagic=\safefloattype}% | 9610 \edef\currentsection{\floatmagic=\safefloattype}% |
9580 \setref{\floatlabel}{Yfloat}% | 9611 \setref{\floatlabel}{Yfloat}% |
9581 }% | 9612 }% |
9582 \fi | 9613 \fi |
9583 % | 9614 % |
9584 % start with \parskip glue, I guess. | 9615 % start with \parskip glue, I guess. |
9697 % distinguish floats from other xref types. | 9728 % distinguish floats from other xref types. |
9698 \def\floatmagic{!!float!!} | 9729 \def\floatmagic{!!float!!} |
9699 | 9730 |
9700 % #1 is the control sequence we are passed; we expand into a conditional | 9731 % #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 | 9732 % which is true if #1 represents a float ref. That is, the magic |
9702 % \lastsection value which we \setref above. | 9733 % \currentsection value which we \setref above. |
9703 % | 9734 % |
9704 \def\iffloat#1{\expandafter\doiffloat#1==\finish} | 9735 \def\iffloat#1{\expandafter\doiffloat#1==\finish} |
9705 % | 9736 % |
9706 % #1 is (maybe) the \floatmagic string. If so, #2 will be the | 9737 % #1 is (maybe) the \floatmagic string. If so, #2 will be the |
9707 % (safe) float type for this float. We set \iffloattype to #2. | 9738 % (safe) float type for this float. We set \iffloattype to #2. |