1 | % \iffalse ltxdoc klootch |
---|
2 | % ltxgrid.dtx: package to change page grid, MVL. |
---|
3 | % Copyright (c) 1999 Arthur Ogawa |
---|
4 | % |
---|
5 | % Disclaimer |
---|
6 | % This file is distributed WITHOUT ANY WARRANTY; |
---|
7 | % without even the implied warranty of |
---|
8 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
9 | % ReadMe |
---|
10 | % For the documentation and more detailed instructions for |
---|
11 | % installation, typeset this document with \LaTeX. |
---|
12 | % \fi |
---|
13 | % \GetFileInfo{ltxgrid.dtx}\CheckSum{4234} |
---|
14 | % |
---|
15 | % \iffalse ltxdoc klootch |
---|
16 | %<*ltxgrid> |
---|
17 | %%% @LaTeX-file{ |
---|
18 | %%% filename = "ltxgrid.dtx", |
---|
19 | %%% version = "1.0rc5", |
---|
20 | %%% date = "2001/07/26", |
---|
21 | %%% time = "12:23:00 GMT+8", |
---|
22 | %%% checksum = "4234", |
---|
23 | %%% author = "Arthur Ogawa (mailto:ogawa@teleport.com), |
---|
24 | %%% commissioned by the American Physical Society. |
---|
25 | %%% ", |
---|
26 | %%% copyright = "Copyright (C) 1999, 2000 Arthur Ogawa, |
---|
27 | %%% distributed under the terms of the |
---|
28 | %%% LaTeX Project Public License, see |
---|
29 | %%% ftp://ctan.tug.org/macros/latex/base/lppl.txt |
---|
30 | %%% ", |
---|
31 | %%% address = "Arthur Ogawa, |
---|
32 | %%% USA", |
---|
33 | %%% telephone = "", |
---|
34 | %%% FAX = "", |
---|
35 | %%% email = "ogawa@teleport.com", |
---|
36 | %%% codetable = "ISO/ASCII", |
---|
37 | %%% keywords = "latex, page grid, main vertical list", |
---|
38 | %%% supported = "yes", |
---|
39 | %%% abstract = "package to change page grid, MVL", |
---|
40 | %%% docstring = "The checksum field above generated by ltxdoc", |
---|
41 | %%% } |
---|
42 | %</ltxgrid> |
---|
43 | % \fi |
---|
44 | % |
---|
45 | % \iffalse ltxdoc klootch |
---|
46 | % The following references the \file{00readme.txt} file, |
---|
47 | % which contains basic information about this package. |
---|
48 | % The contents of this file are generated when |
---|
49 | % you typeset the programmer's documentation. |
---|
50 | % Search on "{filecontents*}{00readme.txt}" to locate it. |
---|
51 | % \fi\input{00readme.txt}% |
---|
52 | % |
---|
53 | % \subsection{Bill of Materials} |
---|
54 | % |
---|
55 | % Following is a list of the files in this distribution arranged |
---|
56 | % according to provenance. |
---|
57 | % |
---|
58 | % \subsubsection{Primary Source}% |
---|
59 | % One single file generates all. |
---|
60 | %\begin{verbatim} |
---|
61 | %ltxgrid.dtx |
---|
62 | %\end{verbatim} |
---|
63 | % |
---|
64 | % \subsubsection{Generated by \texttt{latex ltxgrid.dtx}}% |
---|
65 | % Typesetting the source file under \LaTeX\ |
---|
66 | % generates the readme and the installer. |
---|
67 | %\begin{verbatim} |
---|
68 | %00readme.txt ltxgrid.ins |
---|
69 | %\end{verbatim} |
---|
70 | % |
---|
71 | % \subsubsection{Generated by \texttt{tex ltxgrid.ins}}% |
---|
72 | % Typesetting the installer generates |
---|
73 | % the package files. |
---|
74 | %\begin{verbatim} |
---|
75 | %ltxgrid.sty |
---|
76 | %\end{verbatim} |
---|
77 | % |
---|
78 | % \subsubsection{Documentation}% |
---|
79 | % The following are the online documentation: |
---|
80 | % \begin{verbatim} |
---|
81 | %ltxgrid.pdf |
---|
82 | % \end{verbatim} |
---|
83 | % |
---|
84 | % \subsubsection{Auxiliary}% |
---|
85 | % The following are auxiliary files generated |
---|
86 | % in the course of running \LaTeX: |
---|
87 | % \begin{verbatim} |
---|
88 | %ltxgrid.aux ltxgrid.idx ltxgrid.ind ltxgrid.log ltxgrid.toc |
---|
89 | % \end{verbatim} |
---|
90 | % |
---|
91 | % \section{Code common to all modules}% |
---|
92 | % |
---|
93 | % The following may look a bit klootchy, but we |
---|
94 | % want to require only one place in this file |
---|
95 | % where the version number is stated, |
---|
96 | % and we also want to ensure that the version |
---|
97 | % number is embedded into every generated file. |
---|
98 | % |
---|
99 | % Now we declare that |
---|
100 | % these files can only be used with \LaTeXe. |
---|
101 | % An appropriate message is displayed if |
---|
102 | % a different \TeX{} format is used. |
---|
103 | % \begin{macrocode} |
---|
104 | %<*doc|ltxgrid> |
---|
105 | \NeedsTeXFormat{LaTeX2e}[1995/12/01]% |
---|
106 | %</doc|ltxgrid> |
---|
107 | % \end{macrocode} |
---|
108 | % As desired, the following modules all |
---|
109 | % take common version information: |
---|
110 | % \begin{macrocode} |
---|
111 | %<ltxgrid>\ProvidesFile{ltxgrid.sty}% |
---|
112 | %<*doc> |
---|
113 | \expandafter\ProvidesFile\expandafter{\jobname.dtx}% |
---|
114 | %</doc> |
---|
115 | % \end{macrocode} |
---|
116 | % |
---|
117 | % The following line contains, for once and for all, |
---|
118 | % the version and date information. |
---|
119 | % By various means, this information is reproduced |
---|
120 | % consistently in all generated files and in the |
---|
121 | % typeset documentation. |
---|
122 | % \begin{macrocode} |
---|
123 | %<*doc|ltxgrid> |
---|
124 | [2001/07/26 1.0rc5 page grid package]% \fileversion |
---|
125 | %</doc|ltxgrid> |
---|
126 | % \end{macrocode} |
---|
127 | % |
---|
128 | % |
---|
129 | % \section{The driver module \texttt{doc}} |
---|
130 | % |
---|
131 | % This module, consisting of the present section, |
---|
132 | % typesets the programmer's documentation, |
---|
133 | % generating the \file{.ins} installer and \file{00readme.txt} as required. |
---|
134 | % |
---|
135 | % Because the only uncommented-out lines of code at the beginning of |
---|
136 | % this file constitute the \file{doc} module itself, |
---|
137 | % we can simply typeset the \file{.dtx} file directly, |
---|
138 | % and there is thus rarely any need to |
---|
139 | % generate the ``doc'' {\sc docstrip} module. |
---|
140 | % Module delimiters are nonetheless required so that |
---|
141 | % this code does not find its way into the other modules. |
---|
142 | % |
---|
143 | % The \enve{document} command concludes the typesetting run. |
---|
144 | % |
---|
145 | % \begin{macrocode} |
---|
146 | %<*doc> |
---|
147 | % \end{macrocode} |
---|
148 | % |
---|
149 | % \subsection{The Preamble} |
---|
150 | % The programmers documentation is formatted |
---|
151 | % with the \classname{ltxdoc} class with local customizations, |
---|
152 | % and with the usual code line indexing. |
---|
153 | % \begin{macrocode} |
---|
154 | \documentclass{ltxdoc} |
---|
155 | \RequirePackage{ltxdocext}% |
---|
156 | \RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}% |
---|
157 | \ifx\package@font\@undefined\else |
---|
158 | \expandafter\expandafter |
---|
159 | \expandafter\RequirePackage |
---|
160 | \expandafter\expandafter |
---|
161 | \expandafter{% |
---|
162 | \csname package@font\endcsname |
---|
163 | }% |
---|
164 | \fi |
---|
165 | \CodelineIndex\EnableCrossrefs |
---|
166 | % \end{macrocode} |
---|
167 | % |
---|
168 | % \subsubsection{Docstrip and info directives} |
---|
169 | % We use so many {\sc docstrip} modules that we set the |
---|
170 | % \texttt{StandardModuleDepth} counter to 1. |
---|
171 | % \begin{macrocode} |
---|
172 | \setcounter{StandardModuleDepth}{1} |
---|
173 | % \end{macrocode} |
---|
174 | % The following command retrieves the date and version information |
---|
175 | % from this file. |
---|
176 | % \begin{macrocode} |
---|
177 | \expandafter\GetFileInfo\expandafter{\jobname.dtx}% |
---|
178 | % \end{macrocode} |
---|
179 | % |
---|
180 | % |
---|
181 | % \subsection{The installer file} |
---|
182 | % |
---|
183 | % The installer \file{ltxgrid.ins} appears here. |
---|
184 | % If you have retrieved the standard distribution of this package, |
---|
185 | % the installer file is already on your filesystem. |
---|
186 | % If you are bootstrapping, |
---|
187 | % the first typesetting of the \file{.dtx} file |
---|
188 | % will cause the installer to be generated. |
---|
189 | % |
---|
190 | % The following modules are used to direct |
---|
191 | % {\sc docstrip} in generating the external files: |
---|
192 | % \begin{center} |
---|
193 | % \begin{tabular}{lll} |
---|
194 | % \textbf{Module}&\textbf{File}&\textbf{Description}\\ |
---|
195 | % doc &\file{ltxgrid.drv}&driver for programmer's documentation\\ |
---|
196 | % ltxgrid,ltxgrid-krn &\file{ltxgrid.sty}&this package\\ |
---|
197 | % ltxgrid-krn& &the portion of this package suitable for inclusion within another package |
---|
198 | % \end{tabular} |
---|
199 | % \end{center} |
---|
200 | % |
---|
201 | % \begin{macrocode} |
---|
202 | \begin{filecontents}{ltxgrid.ins} |
---|
203 | %% This file will generate documentation and runtime files |
---|
204 | %% from ltxgrid.dtx when run through LaTeX or TeX. |
---|
205 | \input docstrip |
---|
206 | \preamble |
---|
207 | |
---|
208 | This is a generated file; |
---|
209 | altering it directly is inadvisable; |
---|
210 | instead, modify the original source file. |
---|
211 | See the URL in the file 00readme.txt. |
---|
212 | |
---|
213 | Copyright notice. |
---|
214 | |
---|
215 | These files are distributed |
---|
216 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
217 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
218 | |
---|
219 | \endpreamble |
---|
220 | \keepsilent |
---|
221 | \generate{% |
---|
222 | \file{ltxgrid.drv}{\from{ltxgrid.dtx}{doc}}% |
---|
223 | \file{ltxgrid.sty}{% |
---|
224 | \from{ltxgrid.dtx}{ltxgrid,ltxgrid-krn}% |
---|
225 | }% |
---|
226 | }% |
---|
227 | \ifToplevel{ |
---|
228 | \Msg{***********************************************************} |
---|
229 | \Msg{*} |
---|
230 | \Msg{* To finish the installation, please move} |
---|
231 | \Msg{* ltxgrid.sty} |
---|
232 | \Msg{* into a directory searched by TeX;} |
---|
233 | \Msg{* in a TDS-compliant installation:} |
---|
234 | \Msg{* texmf/tex/macros/latex/ao/.} |
---|
235 | \Msg{*} |
---|
236 | \Msg{* To produce the documentation, |
---|
237 | run ltxgrid.dtx through LaTeX.} |
---|
238 | \Msg{*} |
---|
239 | \Msg{* Happy TeXing} |
---|
240 | \Msg{***********************************************************} |
---|
241 | } |
---|
242 | \endbatchfile |
---|
243 | \end{filecontents} |
---|
244 | % \end{macrocode} |
---|
245 | % Note that, because all of the files generated by the installer |
---|
246 | % are part of the standard distribution, it will |
---|
247 | % be necessary to run the installer only when bootstrapping |
---|
248 | % (or, of course, during development). |
---|
249 | % Note, too, that it is rare to generate the \file{doc} |
---|
250 | % module because it suffices to simply typeset the \file{.dtx} file itself. |
---|
251 | % |
---|
252 | % \subsection{The ``Read Me'' File} |
---|
253 | % As promised above, here is the contents of the |
---|
254 | % ``Read Me'' file. That file serves a double purpose, |
---|
255 | % since it also constitutes the beginining of the |
---|
256 | % programmer's documentation. What better thing, after |
---|
257 | % all, to have appear at the beginning of the |
---|
258 | % typeset documentation? |
---|
259 | % |
---|
260 | % A good discussion of how to write a ReadMe file can be found in |
---|
261 | % Engst, Tonya, ``Writing a ReadMe File? Read This'' |
---|
262 | % \emph{MacTech} October 1998, p. 58. |
---|
263 | % |
---|
264 | % Note the appearance of the |
---|
265 | % \cmd\StopEventually\ command, which marks the |
---|
266 | % dividing line between the user documentation |
---|
267 | % and the programmer documentation. |
---|
268 | % |
---|
269 | % The usual user will not be asked to |
---|
270 | % do a full build, not to speak |
---|
271 | % of the bootstrap. |
---|
272 | % Instructions for carrying these processes |
---|
273 | % begin the programmer's manual. |
---|
274 | % |
---|
275 | % \begin{macrocode} |
---|
276 | \begin{filecontents*}{00readme.txt} |
---|
277 | \title{% |
---|
278 | A \LaTeX\ Package for changing the page grid and MVL% |
---|
279 | \thanks{% |
---|
280 | This file has version number \fileversion, |
---|
281 | last revised \filedate.% |
---|
282 | % For version number and date, |
---|
283 | % search on "\fileversion" in the .dtx file, |
---|
284 | % or see the end of the 00readme.txt file. |
---|
285 | }% |
---|
286 | }% |
---|
287 | |
---|
288 | \author{% |
---|
289 | Arthur Ogawa (\texttt{mailto:ogawa@teleport.com}), |
---|
290 | \fileversion\\Copyright (C) 1999, 2000 Arthur Ogawa |
---|
291 | }% |
---|
292 | \maketitle |
---|
293 | |
---|
294 | This file embodies the \classname{ltxgrid} package, |
---|
295 | the implementation and its user documentation. |
---|
296 | |
---|
297 | The distribution point for this work is |
---|
298 | \url{ftp://ftp.teleport.com/users/ogawa/macros/latex/contrib/supported/ltxgrid...}, |
---|
299 | which contains fully unpacked, prebuilt runtime files and documentation. |
---|
300 | |
---|
301 | The \classname{ltxgrid} package was commissioned by the American Physical Society |
---|
302 | and is distributed under the terms of the \LaTeX\ Project Public License, |
---|
303 | the same license under which all the portions of \LaTeX\ itself is distributed. |
---|
304 | Please see \url{http://ctan.tug.org/macros/latex/base/lppl.txt} for details. |
---|
305 | |
---|
306 | To use this document class, you must have a working |
---|
307 | \TeX\ installation equipped with \LaTeXe\ |
---|
308 | and possibly pdftex and Adobe Acrobat Reader or equivalent. |
---|
309 | |
---|
310 | To install, retrieve the distribution, |
---|
311 | unpack it into a directory on the target computer, |
---|
312 | into a location in your filesystem where it will be found by \LaTeX; |
---|
313 | in a TDS-compliant installation this would be: |
---|
314 | \file{texmf/tex/macros/latex/ao/.} |
---|
315 | |
---|
316 | To use, read the user documentation \file{ltxgrid.pdf}. |
---|
317 | |
---|
318 | \tableofcontents |
---|
319 | |
---|
320 | \section{Processing Instructions} |
---|
321 | |
---|
322 | The package file \file{ltxgrid.sty} |
---|
323 | is generated from this file, \file{ltxgrid.dtx}, |
---|
324 | using the {\sc docstrip} facility of \LaTeX |
---|
325 | via |tex ltxgrid.ins|. |
---|
326 | The typeset documentation that you are now reading is generated from |
---|
327 | the same file by typesetting it with \LaTeX\ or pdftex |
---|
328 | via |latex ltxgrid.dtx| or |pdflatex ltxgrid.dtx|. |
---|
329 | |
---|
330 | \subsection{Build Instructions} |
---|
331 | |
---|
332 | You may bootstrap this suite of files solely from \file{ltxgrid.dtx}. |
---|
333 | Prepare by installing \LaTeXe\ (and either tex or pdftex) on your computer, |
---|
334 | then carry out the following steps: |
---|
335 | \begin{enumerate} |
---|
336 | \item |
---|
337 | Within an otherwise empty directory, |
---|
338 | typeset \file{ltxgrid.dtx} with \LaTeX\ or pdflatex; |
---|
339 | you will obtain the typeset documentation you are now reading, |
---|
340 | along with |
---|
341 | the installer \file{ltxgrid.ins}, |
---|
342 | and the file \file{00readme.txt}. |
---|
343 | |
---|
344 | Note: you will have to run \LaTeX\ twice, then \file{makeindex}, then |
---|
345 | \LaTeX\ again in order to obtain a valid index and table of contents. |
---|
346 | \item |
---|
347 | Now typeset \file{ltxgrid.ins}, |
---|
348 | thereby generating the package file \file{ltxgrid.sty}. |
---|
349 | \item |
---|
350 | Install \classname{ltxgrid.sty} |
---|
351 | by moving it to a location |
---|
352 | in your filesystem where they will be found by \LaTeX. |
---|
353 | \end{enumerate} |
---|
354 | \end{filecontents*} |
---|
355 | % \end{macrocode} |
---|
356 | % |
---|
357 | % \subsection{The Document Body} |
---|
358 | % |
---|
359 | % Here is the document body, containing only a |
---|
360 | % \cmd\DocInput\ directive---referring to this very file. |
---|
361 | % This very cute self-reference is a common \classname{ltxdoc} idiom. |
---|
362 | % \begin{macrocode} |
---|
363 | \begin{document}% |
---|
364 | \expandafter\DocInput\expandafter{\jobname.dtx}% |
---|
365 | % ^^A\PrintChanges |
---|
366 | \end{document} |
---|
367 | % \end{macrocode} |
---|
368 | % |
---|
369 | % \begin{macrocode} |
---|
370 | %</doc> |
---|
371 | % \end{macrocode} |
---|
372 | % |
---|
373 | % \section{Using this package} |
---|
374 | % Once this package is installed on your filesystem, you can employ it in |
---|
375 | % adding functionality to \LaTeX\ by invoking it in your document or document class. |
---|
376 | % |
---|
377 | % \subsection{Invoking the package} |
---|
378 | % In your document, you can simply call it up in your preamble: |
---|
379 | % \begin{verbatim} |
---|
380 | %\documentclass{book}% |
---|
381 | %\usepackage{ltxgrid}% |
---|
382 | %\begin{document} |
---|
383 | %<your document here> |
---|
384 | %\end{document} |
---|
385 | % \end{verbatim} |
---|
386 | % However, the preferred way is to invoke this package from within your |
---|
387 | % customized document class: |
---|
388 | % \begin{verbatim} |
---|
389 | %\NeedsTeXFormat{LaTeX2e}[1995/12/01]% |
---|
390 | %\ProvidesClass{myclass}% |
---|
391 | %\LoadClass{book}% |
---|
392 | %\RequirePackage{ltxgrid}% |
---|
393 | %<class customization commands> |
---|
394 | %\endinput |
---|
395 | % \end{verbatim} |
---|
396 | % |
---|
397 | % Note that this package requires the features of the \classname{ltxutil} package, |
---|
398 | % available at |
---|
399 | % \url{ftp://ftp.teleport.com/users/ogawa/macros/latex/contrib/supported/ltxutil/}. |
---|
400 | % |
---|
401 | % Once loaded, the package gives you acccess to certain procedures, |
---|
402 | % usually to be invoked by a \LaTeX\ command or environment, but not at the document level. |
---|
403 | % |
---|
404 | % \subsection{Changing the page grid}% |
---|
405 | % This package provides two procedures, \cmd\onecolumngrid, \cmd\twocolumngrid, |
---|
406 | % that change the page grid (it can be extended to more columns and to other page grids). |
---|
407 | % |
---|
408 | % They differ from standard \LaTeX's \cmd\onecolumn\ and \cmd\twocolumn\ commands in that |
---|
409 | % they do not force a page break. Also, upon leaving a multiple-column grid, the columns are balanced. |
---|
410 | % In other respects they work same. |
---|
411 | % |
---|
412 | % They differ from the grid-changing commands of Frank Mittelbach's \classname{multicol} package |
---|
413 | % in that they allow floats of all types (single- and double column floats, that is) and |
---|
414 | % preserve compatability with the \classname{longtable} package. |
---|
415 | % |
---|
416 | % These commands must be issued in vertical mode (conceivably via a \cmd\vadjust) such that |
---|
417 | % they are ultimately present in the MVL, where they can do their work. |
---|
418 | % Because they do not work in \LaTeX's left-right mode, they are unsuitable at the |
---|
419 | % document level. |
---|
420 | % Furthermore, packaging a grid command in a \cmd\vadjust, although possible, will probably |
---|
421 | % not acheive satisfactory page layout. |
---|
422 | % |
---|
423 | % Page grid commands are not intended to be issued unnecessarily: only the first of |
---|
424 | % two successive \cmd\onecolumngrid\ commands is effective; the second will be silently ignored. |
---|
425 | % |
---|
426 | % \DescribeMacro\onecolumngrid |
---|
427 | % You command \LaTeX\ to return to the one-column grid with the |
---|
428 | % \cmd\onecolumngrid\ command. If you are already in the one-column grid, this |
---|
429 | % is a no-op. The one-column grid is considered special of all page grids, in that |
---|
430 | % no portion of the page is held back (in \cmd\pagesofar); all items that might go |
---|
431 | % on the current page (with the exception of floats and footnotes) are on the MVL. |
---|
432 | % |
---|
433 | % \DescribeMacro\twocolumngrid |
---|
434 | % You command \LaTeX\ to return to the two-column grid with the |
---|
435 | % \cmd\twocolumngrid\ command. If you are already in the two-column grid, this |
---|
436 | % is a no-op. |
---|
437 | % |
---|
438 | % These two commands should be issued by a macro procedure that can ensure that |
---|
439 | % \TeX\ is in outer vertical mode. |
---|
440 | % |
---|
441 | % \subsection{Changing the MVL}% |
---|
442 | % |
---|
443 | % This package also provides commands to modify the main vertical list (MVL) in a safe way. |
---|
444 | % The scheme here is to structure, insofar possible, \TeX's MVL as follows: |
---|
445 | %\begin{quotation} |
---|
446 | %box or boxes\\ |
---|
447 | %penalty\\ |
---|
448 | %glue |
---|
449 | %\end{quotation} |
---|
450 | % This should be a familiar sequence. It is the prototype sequence for a vertical list, |
---|
451 | % and is followed when \TeX\ breaks paragraphs into lines, and when \TeX\ generates |
---|
452 | % a display math equation. |
---|
453 | % |
---|
454 | % If you (as a macro programmer) wish to modify the value of the penalty or glue item, |
---|
455 | % you can use one of the MVL-altering commands to do so. Certain operations are implemented |
---|
456 | % here; you can make up your own. |
---|
457 | % |
---|
458 | % Note that these commands must be issued in vertical mode, perhaps via a \cmd\vadjust\ or a \cmd\noalign. |
---|
459 | % They can work directly if you are in inner mode (say within a parbox or a minipage). |
---|
460 | % |
---|
461 | % \DescribeMacro\removestuff |
---|
462 | % You instruct \LaTeX\ to remove both the penalty and the glue item with this command. |
---|
463 | % |
---|
464 | % \DescribeMacro\addstuff |
---|
465 | % You issue the \cmd\addstuff\arg{penalty}\arg{glue} command to add a penalty, glue, or both. |
---|
466 | % If you do not wish to add one or the other, the corresponding argument should be nil. |
---|
467 | % Note that the effect of \cmd\addstuff\ is to stack the penalties and glue items. |
---|
468 | % Therefore, the lesser of the two penalties takes effect, |
---|
469 | % and the two glue items add together. |
---|
470 | % |
---|
471 | % \cmd\addstuff\ is limited because once applied, it cannot be applied again with correct results. |
---|
472 | % |
---|
473 | % \DescribeMacro\replacestuff |
---|
474 | % The \cmd\replacestuff\ command is syntactically the same as \cmd\addstuff, but works |
---|
475 | % differently: the existing penalty and glue are replaced or modified. |
---|
476 | % |
---|
477 | % The specified penalty is not inserted if the existing penalty is greater than 10000 |
---|
478 | % (that is, in case of a \cmd\nobreak), otherwise, the lower (non-zero) of the two penalties is inserted. |
---|
479 | % |
---|
480 | % If the specified glue has a larger natural component than the existing glue, we replace the glue. |
---|
481 | % However, if the specified glue's natural component is negative, then the existing glue's natural component is |
---|
482 | % changed by that amount. |
---|
483 | % |
---|
484 | % \cmd\replacestuff\ can be applied mutiple times bceause it retains the list structure in the canonical form. |
---|
485 | % |
---|
486 | % Note that we treat two penalties specially (as does \TeX): a penalty of 10000 is considered |
---|
487 | % a garbage value, to be replaced if found. This is the signal value that \TeX\ inserts on |
---|
488 | % the MVL replacing the penalty that caused the page break (if the page break occurred at a penalty). |
---|
489 | % Also, a penalty of zero is indistinguishable from no penalty at all, so it will always |
---|
490 | % be replaced by the given value. |
---|
491 | % |
---|
492 | % Therefore, it is highly recommended to never set any of \TeX's penalty parameters to |
---|
493 | % zero (a value of, say, 1, is practically the same), nor should a skip parameter be set to zero |
---|
494 | % (instead, use, say, 1sp). Also, to prevent a pagebreak, do not use a penalty of 10000, use, say |
---|
495 | % 10001 instead. |
---|
496 | % |
---|
497 | % You can define your own construct that modifies the MVL: |
---|
498 | % Define a command, say, \cmd\myadjust, as follows: |
---|
499 | %\begin{verbatim} |
---|
500 | %\def\myadjust#1{\noexpand\do@main@vlist{\noexpand\@myadjust{#1}}\@tempa}% |
---|
501 | %\end{verbatim} |
---|
502 | % that is, \cmd\myadjust\ invokes \cmd\do@main@vlist, passing it the procedure name |
---|
503 | % \cmd\@myadjust\ along with the arguments thereof pre-expanded. |
---|
504 | % Next, define the procedure \cmd\@myadjust: |
---|
505 | %\begin{verbatim} |
---|
506 | %\def\@myadjust#1{<meddle with the MVL>}% |
---|
507 | %\end{verbatim} |
---|
508 | % when \cmd\@myadjust\ executes, you will be in the output routine (in inner vertical mode) |
---|
509 | % and the MVL will be that very vertical list. |
---|
510 | % |
---|
511 | % |
---|
512 | % |
---|
513 | % |
---|
514 | % \section{Compatability with \LaTeX's Required Packages} |
---|
515 | % Certain packages, usually ones written by members of the |
---|
516 | % \LaTeX\ Project itself, have been designated ``required'' and |
---|
517 | % are distributed as part of standard \LaTeX. |
---|
518 | % These packages have been placed in a priviledged position |
---|
519 | % vis \'a vis the \LaTeX\ kernel in that they override the definitions of certain kernel macros. |
---|
520 | % |
---|
521 | % Compatability between \classname{ltxgrid} and these packages is complicated |
---|
522 | % by a number of factors. First is that \classname{ltxgrid} alters the meaning of some of the same |
---|
523 | % kernel macros as certain of the ``required'' packages. |
---|
524 | % Second is that fact that certain of the ``required'' packages of \LaTeX\ are incompatible with |
---|
525 | % each other. |
---|
526 | % |
---|
527 | % Examples of the first kind are the \classname{ftnright}, \classname{multicol}, and \classname{longtable} |
---|
528 | % packages. |
---|
529 | % The \classname{ltxgrid} package is not compatible with \classname{multicol}, |
---|
530 | % but if you are using \classname{ltxgrid}, you do not need to use \classname{ftnright} or \classname{multicol} |
---|
531 | % anyway. The \classname{ltxgrid} package does however attempt to be compatible with \classname{longtable}. |
---|
532 | % |
---|
533 | % Among the ``required'' packages that are mutually incompatible are \classname{multicol} and \classname{longtable}, |
---|
534 | % the incompatibility arising because both packages replace \LaTeX's output routine: |
---|
535 | % if one package is active, the other must not be so. |
---|
536 | % This state of affairs has remained essentially unchanged since the introduction of the two as \LaTeX2.09 packages in the late 1980s. |
---|
537 | % |
---|
538 | % The reason that \classname{ltxgrid} can remain compatible with \classname{longtable} is due to the |
---|
539 | % introduction of a more modern architecture, the ``output routine dispatcher'', which allows all macro packages access to the |
---|
540 | % safe processing environment of the output routine, on an equal footing. |
---|
541 | % The relevant portions of the \classname{longtable} package are reimplemented in \classname{ltxgrid} |
---|
542 | % to take advantage of this mechanism. |
---|
543 | % |
---|
544 | % Timing is critical: |
---|
545 | % the \classname{ltxgrid} package will be incompatible with any package that |
---|
546 | % redefines any of the kernel macros that \classname{ltxgrid} patches---if that |
---|
547 | % package is loaded \emph{after} \classname{ltxgrid}. |
---|
548 | % |
---|
549 | % Hereinafter follows some notes on specific \LaTeX\ packages. |
---|
550 | % |
---|
551 | % \subsection{ftnright} |
---|
552 | % Frank Mittelbach's \classname{ftnright} package effects a change to \LaTeX's |
---|
553 | % \cmd\twocolumn\ mode such that footnotes are set at the bottom of the right-hand |
---|
554 | % column instead of at the foot of each of the two columns. |
---|
555 | % |
---|
556 | % Note that it overwrites three \LaTeX\ kernel macros: \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol. |
---|
557 | % Fortunately none of the three are patched by \classname{ltxgrid}, so that compatability |
---|
558 | % is not excluded on this basis. |
---|
559 | % |
---|
560 | % At the same time, it changes the meaning of \cmd\footnotesize, the macro that is automatically |
---|
561 | % invoked when setting a document's footnote into type. |
---|
562 | % One might well argue that it is an error for the meaning of \cmd\footnotesize\ to be determined by |
---|
563 | % a package such as \classname{ftnright}, that indeed such a choice should be made in the |
---|
564 | % document class, or in a file such as \file{bk10.clo}. |
---|
565 | % |
---|
566 | % To avoid being tripped up by this misfeature in \classname{ftnright}, it is only necessary to |
---|
567 | % reassert our meaning for \cmd\footnotesize\ later on, after \classname{ftnright} has been loaded. |
---|
568 | % |
---|
569 | % Note that \classname{ftnright} inserts code that demands that \LaTeX's flag \cmd\if@twocolumn\ |
---|
570 | % is true, that is, it will complain if deployed in a \cmd\onecolumn\ document. |
---|
571 | % It is therefore necessary for any other multicolumn package to assert that flag in order to |
---|
572 | % avoid this package's complaint. It is an interesting question exactly why this package has |
---|
573 | % this limitation. After all, a one-column page grid is just a degenerate case of the |
---|
574 | % two column. |
---|
575 | % |
---|
576 | % \subsection{longtable} |
---|
577 | % David Carlisle's \classname{longtable} package sets tables that can be so long as to break over pages. |
---|
578 | % According to its author, it uses the same override of \LaTeX's output routine as |
---|
579 | % Frank Mittelbach's \classname{multicol} package. By implication, then, it has a hard |
---|
580 | % incompatability with the latter. |
---|
581 | % |
---|
582 | % The \classname{longtable} package also performs a check of whether the document is in |
---|
583 | % \cmd\twocolumn\ mode, and declines to work if this is the case. It is not clear, however, |
---|
584 | % that there is any true incompatability present if so. It's just that David did not see any reason |
---|
585 | % anyone would want to set such long tables in a multicolumn document, hence the check. |
---|
586 | % |
---|
587 | % There does not appear to be any indication that \classname{longtable} would work less |
---|
588 | % well under \classname{ltxgrid} than under standard \LaTeX's \cmd\twocolumn\ mode. |
---|
589 | % Therefore, this \classname{ltxgrid} patches \classname{longtable} (if loaded) so as to provide |
---|
590 | % compatability. In the course of which, \classname{longtable} becomes more robust |
---|
591 | % (\classname{longtable} has mumerous bugs and incompatabilities of long standing, |
---|
592 | % some of which are repaired by \classname{ltxgrid}). |
---|
593 | % |
---|
594 | % One problem remains, namely that, if a \env{longtable} environment breaks over columns |
---|
595 | % and thereby inserts its special headers and footers at that break, and those columms are then |
---|
596 | % balanced (due to a return to the one-column page grid), then those inserted rows |
---|
597 | % will remain, and may no longer fall at the column break. This will, of course look |
---|
598 | % wrong. |
---|
599 | % |
---|
600 | % The only way to fix this problem is to avoid doing column balancing in the way |
---|
601 | % I have implemented here; such an enhancement to this package is possible. |
---|
602 | % |
---|
603 | % \subsection{multicol} |
---|
604 | % Frank Mittelbach's \classname{multicol} package provides a page grid with many columns, |
---|
605 | % albeit denies the placement of floats in individual columns. |
---|
606 | % |
---|
607 | % It esablishes its own \cmd\output\ routine, which is the reason it runs afoul of |
---|
608 | % the \classname{longtable} package. On the other hand, \classname{ltxgrid} specifically |
---|
609 | % allows for the case where a package installs its own \cmd\output\ routine, so |
---|
610 | % there is no incompatability on that basis. |
---|
611 | % |
---|
612 | % Still, it is pointless to use \classname{multicol} if you are using \classname{ltxgrid}, |
---|
613 | % since both packages provide multicolumn page layouts. |
---|
614 | % Therefore, \classname{multicol} is not supported by \classname{ltxgrid}. |
---|
615 | % |
---|
616 | % \subsection{ltxgrid} |
---|
617 | % It has been pointed out that one of the disadvantages of adopting the \classname{ltxgrid} package is that |
---|
618 | % it does alter the \LaTeX\ kernel. |
---|
619 | % Any package that itself alters the \LaTeX\ kernel may be incompatible with \classname{ltxgrid}, and new packages |
---|
620 | % (destined perhaps to become part of the successor to \LaTeXe) may break \classname{ltxgrid}. |
---|
621 | % |
---|
622 | % The consequence is that packages introduced in future, and future changes to \LaTeX\ may be incompatible |
---|
623 | % with \classname{ltxgrid}. |
---|
624 | % This is, of course, true. |
---|
625 | % The development plan for \classname{ltxgrid} is that when such packages and \LaTeX\ kernel changes come about, |
---|
626 | % the burden will be on \classname{ltxgrid} to change in a way that provides for continued compatability with |
---|
627 | % those packages and \LaTeX\ kernel changes. |
---|
628 | % |
---|
629 | % |
---|
630 | % \section{How \classname{ltxgrid} places footnotes} |
---|
631 | % |
---|
632 | % In conventional multicolumn layouts, a footnote will appear at the bottom of the column in which it is called out. |
---|
633 | % The \classname{ltxgrid} package implements this conventional layout choice by default. |
---|
634 | % However, other choices are possible (a la \classname{ftnright}, whose compatability with \classname{ltxgrid} has not been tested). |
---|
635 | % |
---|
636 | % One unusual feature of \classname{ltxgrid}'s default implementation must be mentioned, though, |
---|
637 | % namely the case in a two-column page grid, where a footnote is followed by a temporary change to the one-column page grid |
---|
638 | % (e.g., for a wide equation). |
---|
639 | % In such a case, the material above the wide material is split into two columns, and a footnote whose callout |
---|
640 | % appears in the right-hand column will nonetheless be set at the base of the left column. |
---|
641 | % |
---|
642 | % This arrangement was chosen because it ensures that the footnotes at the bottom of any page will appear in |
---|
643 | % numerical order. It can be argued that this choice is ``incorrect'', but be that as it may, |
---|
644 | % the \classname{ltxgrid} package does not foreclose on other arrangements for the footnotes. |
---|
645 | % The package can be adapted to accomodate any page design desired. |
---|
646 | % |
---|
647 | % \section{Limitations in \classname{ltxgrid}'s default column balancing method}% |
---|
648 | % |
---|
649 | % In a multicolumn page grid, when encountering a page that is not completely full, |
---|
650 | % it is customary to set the material in balanced columns (typically with the last column no longer than any of the others). |
---|
651 | % Such a case also crops up when temporarily interrupting the multicolumn grid to set material on the full width of the page: |
---|
652 | % the material on the page above the break is customarily set in balanced columns. |
---|
653 | % |
---|
654 | % An awkward case arises when we have already set one or more complete columns of type before encountering the need to |
---|
655 | % balance columns. In this subset of cases, the default in \classname{ltxgrid} is to |
---|
656 | % do an operation I call ``re-balancing'': |
---|
657 | % the material on the page so far is pasted back together into a single column, and new, balanced column breaks are |
---|
658 | % calculated. |
---|
659 | % |
---|
660 | % This scheme typically works fine, but it has a significant vulnerability: |
---|
661 | % any discardable items trimmed at the original column break is lost, never to be retrieved. |
---|
662 | % Consequently, after re-balancing, an element like, say, a section head can fail to have the correct amount of whitespace above. |
---|
663 | % |
---|
664 | % This problem is due to an unfortunate optimization in \TeX, wherein a certain class of nodes is trimmed from the |
---|
665 | % top of main vertical list upon returning from the output routine: |
---|
666 | % any penalty, glue, or leader node falls in to this class of discardable nodes, |
---|
667 | % and trimming proceeds until a non-discardable node (such as a box, or rule) is encountered. |
---|
668 | % It gets better: a third class of nodes is transparent to this trimming process; |
---|
669 | % they are neither discarded nor do they halt the process of trimming: |
---|
670 | % mark nodes and all whatsits fall into this class of transparent nodes; |
---|
671 | % they are quietly passed over during trimming. |
---|
672 | % |
---|
673 | % An alternative approach for \TeX\ to take would have been, |
---|
674 | % rather than discarding the node entirely, to simply mark it as discarded. |
---|
675 | % (Implementors of NTS, please note!) |
---|
676 | % Then, upon shipping out, such nodes would not make it into the DVI. |
---|
677 | % \TeX's optimization, driven by the small computer architectures current when it was developed, |
---|
678 | % does save mem, but at the cost of revisiting page breaks in a reliable way. |
---|
679 | % |
---|
680 | % FIXME: how to fix a column break in the above case? Widetext? |
---|
681 | % |
---|
682 | %\StopEventually{} |
---|
683 | % |
---|
684 | % \section{Implementation of package} |
---|
685 | % |
---|
686 | % Special acknowledgment: this package uses concepts pioneered |
---|
687 | % and first realized by William Baxter (mailto:web@superscript.com) |
---|
688 | % in his SuperScript line of commercial typesetting tools, and |
---|
689 | % which are used here with his permission. His thorough understanding |
---|
690 | % of \TeX's output routine underpins the entire \classname{ltxgrid} |
---|
691 | % package. |
---|
692 | % |
---|
693 | % \subsection{Beginning of the \file{ltxgrid} {\sc docstrip} module} |
---|
694 | % Requires the underpinnings of the \classname{ltxkrnext} package. |
---|
695 | % \begin{macrocode} |
---|
696 | %<*ltxgrid> |
---|
697 | \def\package@name{ltxgrid}% |
---|
698 | \expandafter\PackageInfo\expandafter{\package@name}{% |
---|
699 | Page grid for \protect\LaTeXe, |
---|
700 | by A. Ogawa (ogawa@teleport.com)% |
---|
701 | }% |
---|
702 | \RequirePackage{ltxutil}% |
---|
703 | %</ltxgrid> |
---|
704 | % \end{macrocode} |
---|
705 | % |
---|
706 | % \subsection{Banner}% |
---|
707 | % Credit where due. |
---|
708 | % \begin{macrocode} |
---|
709 | %<*ltxgrid-krn> |
---|
710 | \typeout{% |
---|
711 | ltxgrid: portions licensed from W. E. Baxter (web@superscript.com)% |
---|
712 | }% |
---|
713 | % \end{macrocode} |
---|
714 | % |
---|
715 | % \subsection{Sundry}% |
---|
716 | % Here are assorted macro definitions. |
---|
717 | % \begin{macro}{\lineloop} |
---|
718 | % The document-level command \cmd\lineloop\ sets numbered lines until the |
---|
719 | % specified count is reached. |
---|
720 | % This command is mainly used to construct test documents. |
---|
721 | % \begin{macrocode} |
---|
722 | \newcounter{linecount} |
---|
723 | \def\lineloop#1{% |
---|
724 | \loop |
---|
725 | \ifnum\c@linecount<#1\relax |
---|
726 | \global\advance\c@linecount\@ne |
---|
727 | \par |
---|
728 | \hb@xt@\hsize{% |
---|
729 | \ifnum\c@linecount<100 0\fi\ifnum\c@linecount<10 0\fi\number\c@linecount |
---|
730 | \vrule depth2.5\p@ |
---|
731 | \leaders\hrule\hfil |
---|
732 | }% |
---|
733 | \penalty\interlinepenalty |
---|
734 | \repeat |
---|
735 | }% |
---|
736 | % \end{macrocode} |
---|
737 | % \end{macro} |
---|
738 | % |
---|
739 | % |
---|
740 | % \subsection{Mark Components}% |
---|
741 | % |
---|
742 | % Override LaTeX's mark macros to allow more components. |
---|
743 | % |
---|
744 | % We remain bound by the weakness of LaTeX's scheme in that |
---|
745 | % one cannot emulate the action of \TeX\ whereby |
---|
746 | % material with marks can be inserted in the middle of |
---|
747 | % a vertical list such that the marks are reliably calculated. |
---|
748 | % If we did that, \cmd\@themark\ would no longer be utilized. |
---|
749 | % |
---|
750 | % A more robust scheme involves placing all marks (component and value) |
---|
751 | % into a list (using global scoping, i.e., \cmd\gdef), |
---|
752 | % and using \cmd\@@mark to place an index on that list into the MVL. |
---|
753 | % Then, e.g., \cmd\@@botmark signifies the place where that list is to be cut, |
---|
754 | % and the \cmd\botmark\ of any component is |
---|
755 | % the value of the last element of the cut |
---|
756 | % list having the given component. The \cmd\firstmark\ and \cmd\topmark\ |
---|
757 | % can likewise be defined relative to \cmd\@@firstmark\ and \cmd\@@topmark, |
---|
758 | % except in the latter case, we want the first following the cut instead of the last |
---|
759 | % preceding the cut. |
---|
760 | % |
---|
761 | % The limitation of this scheme is its demands upon \TeX's mem. |
---|
762 | % The list of marks would need to be trimmed back to, effectively, |
---|
763 | % \cmd\topmark\ at the beginning of every page. |
---|
764 | % |
---|
765 | % This approach is not yet part of the extended LaTeX kernel. |
---|
766 | % |
---|
767 | % \begin{macro}{\@@mark} |
---|
768 | % \begin{macro}{\@@topmark} |
---|
769 | % \begin{macro}{\@@firstmark} |
---|
770 | % \begin{macro}{\@@botmark} |
---|
771 | % \begin{macro}{\@@splitfirstmark} |
---|
772 | % \begin{macro}{\@@splitbotmark} |
---|
773 | % Remember primitives under a new set of names. |
---|
774 | % \begin{macrocode} |
---|
775 | \let\@@mark\mark |
---|
776 | \let\@@topmark\topmark |
---|
777 | \let\@@firstmark\firstmark |
---|
778 | \let\@@botmark\botmark |
---|
779 | \let\@@splitfirstmark\splitfirstmark |
---|
780 | \let\@@splitbotmark\splitbotmark |
---|
781 | % \end{macrocode} |
---|
782 | % \end{macro} |
---|
783 | % \end{macro} |
---|
784 | % \end{macro} |
---|
785 | % \end{macro} |
---|
786 | % \end{macro} |
---|
787 | % \end{macro} |
---|
788 | % |
---|
789 | % \subsubsection{Procedures that expose the component data structure}% |
---|
790 | % This portion of the code exposes the internal representation of |
---|
791 | % the mark components. If we wish to add more components, we will have to revise |
---|
792 | % these macro definitions: |
---|
793 | % \cmd\@themark, |
---|
794 | % \cmd\nul@mark, |
---|
795 | % \cmd\set@mark@netw@, |
---|
796 | % \cmd\set@marktw@, |
---|
797 | % \cmd\set@markthr@@, |
---|
798 | % \cmd\get@mark@@ne, |
---|
799 | % \cmd\get@mark@tw@, |
---|
800 | % \cmd\get@mark@thr@@, |
---|
801 | % \cmd\get@mark@f@ur. |
---|
802 | % |
---|
803 | % \begin{macro}{\@themark} |
---|
804 | %FIXME: is it safer to eliminate \cmd\@themark\ in favor of a message that evaluates \cmd\@@botmark? |
---|
805 | % |
---|
806 | % Note: these definitions expose the data structure of mark components. |
---|
807 | % \begin{macrocode} |
---|
808 | \def\@themark{{}{}{}{}}% |
---|
809 | \def\nul@mark{{}{}{}{}\@@nul}% |
---|
810 | % \end{macrocode} |
---|
811 | % \end{macro} |
---|
812 | % |
---|
813 | % \begin{macro}{\set@mark@netw@} |
---|
814 | % \begin{macro}{\set@marktw@} |
---|
815 | % \begin{macro}{\set@markthr@@} |
---|
816 | % These procedures insert the new value of a particular mark component into the given argument. |
---|
817 | % They expose the data structure of mark components. |
---|
818 | % |
---|
819 | % \begin{macrocode} |
---|
820 | \def\set@mark@netw@#1#2#3#4#5#6#7{\gdef#1{{#6}{#7}{#4}{#5}}\do@mark}% |
---|
821 | \def\set@marktw@#1#2#3#4#5#6{\gdef#1{{#2}{#6}{#4}{#5}}\do@mark}% |
---|
822 | \def\set@markthr@@#1#2#3#4#5#6{\gdef#1{{#2}{#3}{#6}{#5}}\do@mark}% |
---|
823 | % \end{macrocode} |
---|
824 | % \end{macro} |
---|
825 | % \end{macro} |
---|
826 | % \end{macro} |
---|
827 | % |
---|
828 | % \begin{macro}{\get@mark@@ne} |
---|
829 | % \begin{macro}{\get@mark@tw@} |
---|
830 | % \begin{macro}{\get@mark@thr@@} |
---|
831 | % \begin{macro}{\get@mark@f@ur} |
---|
832 | % These procedures retreive the value of a particular mark component. |
---|
833 | % They expose the data structure of mark components. |
---|
834 | % \begin{macrocode} |
---|
835 | \def\get@mark@@ne#1#2#3#4#5\@@nul{#1}% |
---|
836 | \def\get@mark@tw@#1#2#3#4#5\@@nul{#2}% |
---|
837 | \def\get@mark@thr@@#1#2#3#4#5\@@nul{#3}% |
---|
838 | \def\get@mark@f@ur#1#2#3#4#5\@@nul{#4}% |
---|
839 | % \end{macrocode} |
---|
840 | % \end{macro} |
---|
841 | % \end{macro} |
---|
842 | % \end{macro} |
---|
843 | % \end{macro} |
---|
844 | % |
---|
845 | % |
---|
846 | % \subsubsection{Procedures that do not expose the component data structure}% |
---|
847 | % |
---|
848 | % \begin{macro}{\mark@netw@} |
---|
849 | % \begin{macro}{\marktw@} |
---|
850 | % \begin{macro}{\markthr@@} |
---|
851 | % These procedures insert the new value of a particular mark component into \cmd\@themark, |
---|
852 | % then execute \cmd\do@mark. |
---|
853 | % They constitute the implementation layer for mark components one, two, and three. |
---|
854 | % An analogous procedure for component four could be defined; call it \cmd\markf@ur. |
---|
855 | % |
---|
856 | % \begin{macrocode} |
---|
857 | \def\mark@netw@{\expandafter\set@mark@netw@\expandafter\@themark\@themark}% |
---|
858 | \def\marktw@{\expandafter\set@marktw@\expandafter\@themark\@themark}% |
---|
859 | \def\markthr@@{\expandafter\set@markthr@@\expandafter\@themark\@themark}% |
---|
860 | % \end{macrocode} |
---|
861 | % \end{macro} |
---|
862 | % \end{macro} |
---|
863 | % \end{macro} |
---|
864 | % |
---|
865 | % \begin{macro}{\do@mark} |
---|
866 | % \begin{macro}{\do@@mark} |
---|
867 | % Access procedures \cmd\mark (AKA \cmd\@@mark). |
---|
868 | % The \cmd\do@mark\ procedure is used when a mark is being put down into the MVL; |
---|
869 | % \cmd\do@@mark\ when this happens in the output routine. |
---|
870 | % \begin{macrocode} |
---|
871 | \def\do@mark{\do@@mark\@themark\nobreak@mark}% |
---|
872 | \def\do@@mark#1{% |
---|
873 | \begingroup |
---|
874 | \let@mark |
---|
875 | \@@mark{#1}% |
---|
876 | \endgroup |
---|
877 | }% |
---|
878 | % \end{macrocode} |
---|
879 | % \end{macro} |
---|
880 | % \end{macro} |
---|
881 | % |
---|
882 | % \begin{macro}{\let@mark} |
---|
883 | % \begin{macro}{\nobreak@mark}% |
---|
884 | % The procedure that makes \cmd\csname s robust within a mark. |
---|
885 | % Use \cmd\appdef\ and \cmd\robust@\ to extend the list. |
---|
886 | % \begin{macrocode} |
---|
887 | \def\let@mark{% |
---|
888 | \let\protect\@unexpandable@protect |
---|
889 | \let\label\relax |
---|
890 | \let\index\relax |
---|
891 | \let\glossary\relax |
---|
892 | }% |
---|
893 | \def\nobreak@mark{% |
---|
894 | \@if@sw\if@nobreak\fi{\@ifvmode{\nobreak}{}}{}% |
---|
895 | }% |
---|
896 | % \end{macrocode} |
---|
897 | % \end{macro} |
---|
898 | % \end{macro} |
---|
899 | % |
---|
900 | % |
---|
901 | % \subsubsection{Using mark components}% |
---|
902 | % |
---|
903 | % These procedures use the component mark mechanism to implement |
---|
904 | % a mark component that remembers the current environment (used in page makeup) |
---|
905 | % and the the two mark components left over from the original \LaTeX. |
---|
906 | % The fourth component is presently unused. |
---|
907 | % |
---|
908 | % \begin{macro}{\mark@envir} |
---|
909 | % The third mark component's access procedures. |
---|
910 | % The \cmd\mark@envir\ and \cmd\bot@envir\ commands are a good model of how to write |
---|
911 | % access procedures for a new mark component. |
---|
912 | % \begin{macrocode} |
---|
913 | \def\mark@envir{\markthr@@}% |
---|
914 | \def\bot@envir{% |
---|
915 | \expandafter\expandafter |
---|
916 | \expandafter\get@mark@thr@@ |
---|
917 | \expandafter\@@botmark |
---|
918 | \nul@mark |
---|
919 | }% |
---|
920 | % \end{macrocode} |
---|
921 | % \end{macro} |
---|
922 | % |
---|
923 | % \begin{macro}{\markboth} |
---|
924 | % \begin{macro}{\markright} |
---|
925 | % \begin{macro}{\leftmark} |
---|
926 | % \begin{macro}{\rightmark} |
---|
927 | % Set procedures for legacy components. |
---|
928 | % \begin{macrocode} |
---|
929 | \def\markboth{\mark@netw@}% |
---|
930 | \def\markright{\marktw@}% |
---|
931 | % \end{macrocode} |
---|
932 | % |
---|
933 | % Retrieval procedures for legacy mark components. |
---|
934 | % The procedure for retrieving the first component from \cmd\botmark\ |
---|
935 | % and the second component from \cmd\firstmark have names in \LaTeX; |
---|
936 | % they are called, respectively, \cmd\leftmark\ and \cmd\rightmark. |
---|
937 | % |
---|
938 | % It is possible to retrieve the components of \cmd\topmark\ |
---|
939 | % as well: use \cmd\saved@@topmark. |
---|
940 | % \begin{macrocode} |
---|
941 | \def\leftmark{% |
---|
942 | \expandafter\expandafter |
---|
943 | \expandafter\get@mark@@ne |
---|
944 | \expandafter\saved@@botmark |
---|
945 | \nul@mark |
---|
946 | }% |
---|
947 | \def\rightmark{% |
---|
948 | \expandafter\expandafter |
---|
949 | \expandafter\get@mark@tw@ |
---|
950 | \expandafter\saved@@firstmark |
---|
951 | \nul@mark |
---|
952 | }% |
---|
953 | % \end{macrocode} |
---|
954 | % \end{macro} |
---|
955 | % \end{macro} |
---|
956 | % \end{macro} |
---|
957 | % \end{macro} |
---|
958 | % |
---|
959 | % |
---|
960 | % |
---|
961 | % \subsection{Output Super-routine}% |
---|
962 | % |
---|
963 | % We want to change \LaTeX's output routine, but do not wish to remain vulnerable |
---|
964 | % to interference from such ``required'' packages as |
---|
965 | % \classname{multicol} (authored by Frank Mittelbach) |
---|
966 | % and \classname{longtable} (authored by David P. Carlisle), which |
---|
967 | % swap in their own output routines when the respective package is active. |
---|
968 | % |
---|
969 | % The better mechanism, used here, is due to William Baxter (web@superscript.com), |
---|
970 | % who has allowed his several ideas to be used in this package. |
---|
971 | % |
---|
972 | % In what follows, we effectively wrap up the old \LaTeX\ output routine inside |
---|
973 | % a new, more flexible ``super routine''. When the output routine is called, |
---|
974 | % the ``super routine'' acts as a dispatcher. If the old routine is needed, it is called. |
---|
975 | % |
---|
976 | % If a package attempts to substitute in their own output routine, they will effectively |
---|
977 | % be modifying a token register by the name of \cmd\output. |
---|
978 | % The primitive \cmd\output\ is now known by a different name, which should no longer be |
---|
979 | % necessary to use. |
---|
980 | % |
---|
981 | % Usage note: to make a visit to the output routine employing the dispatcher, enter |
---|
982 | % with a value of \cmd\outputpenalty\ that corresponds to a macro. Defining as follows: |
---|
983 | %\begin{verbatim} |
---|
984 | %\@namedef{output@10000}{<your code here>}% |
---|
985 | %\end{verbatim} |
---|
986 | % by convention, your output routine should void out \cmd\box\cmd\@cclv. |
---|
987 | % |
---|
988 | % In rewriting \LaTeX's output dispatcher |
---|
989 | % in a much simpler form, we also avoid the sin of multiple \cmd\shipout s |
---|
990 | % within a single visit to the output routine. |
---|
991 | % |
---|
992 | % Conceptually, we divide visits to the output routine into two classes. |
---|
993 | % The first involves natural page breaks |
---|
994 | % (at a \cmd\newpage\ or when \cmd\pagetotal $>$ \cmd\pagegoal) |
---|
995 | % and usually resulting in \cmd\box\cmd\@cclv\ either being shipped out or |
---|
996 | % salted away (e.g., each column in a multicolumn layout). |
---|
997 | % We might call this class the ``natural output routines''; the \cmd\outputpenalty\ |
---|
998 | % will never be less than $-10000$. |
---|
999 | % Furthermore, we ensure that \cmd\holdinginserts\ is cleared when |
---|
1000 | % calling such routines. |
---|
1001 | % |
---|
1002 | % The other class involves a forced visit to the output routine |
---|
1003 | % via a large negative penalty ($< -10000$). They do not generally |
---|
1004 | % result in a \cmd\shipout\ of \cmd\box\cmd\@cclv: they may be dead cycles. |
---|
1005 | % We provide a mechanism (call it a ``one-off'' output routine) that allows |
---|
1006 | % us to specify certain processing to be done when \TeX\ reaches |
---|
1007 | % the current position on the page. |
---|
1008 | % |
---|
1009 | % One-off output routines themselves fall into two divisions, ones |
---|
1010 | % that process \cmd\box\cmd\@cclv, and ones that work on the main vertical list (MVL). |
---|
1011 | % The former are typified by changes to the page grid, perhaps |
---|
1012 | % even column balancing. |
---|
1013 | % The latter involve the insertion of penalties or glue and the processing of floats. |
---|
1014 | % |
---|
1015 | % The natural output routine is a single procedure. We have not introduced multiple |
---|
1016 | % natural output routines based on the \cmd\outputpenalty\ because \TeX\ does not |
---|
1017 | % support such a thing: \TeX\ sometimes lays down a penalty whose value is the sum |
---|
1018 | % of other penalties. Because of this, we cannot depend on the value of \cmd\outputpenalty\ |
---|
1019 | % in such areas. |
---|
1020 | % |
---|
1021 | % We do introduce flexibility in the form of a mechanism for patching into the |
---|
1022 | % natural output routine. Three hooks are offered, allowing a procedure |
---|
1023 | % to prepare for the upcoming visit to the output routine, |
---|
1024 | % access to \cmd\box\cmd\@cclv, and after shipping out (or otherwise |
---|
1025 | % committing the material to the page). |
---|
1026 | % |
---|
1027 | % Environments, commands, and even packages can install their |
---|
1028 | % own procedures into these hooks. |
---|
1029 | % For instance, if the longtable package is loaded, it will install |
---|
1030 | % its procedures, but those procedures will punt if the page break |
---|
1031 | % being processed does not actually fall within a longtable environment. |
---|
1032 | % |
---|
1033 | % \begin{macro}{\primitive@output} |
---|
1034 | % Here we remember the \TeX\ primitive \cmd\output\ and its value, |
---|
1035 | % and then proceed to take over the \cmd\csname\ of \cmd\output, |
---|
1036 | % making it a \cmd\toks\ register and installing the old value of |
---|
1037 | % the output routine. |
---|
1038 | % \begin{macrocode} |
---|
1039 | \let\primitive@output\output |
---|
1040 | % \end{macrocode} |
---|
1041 | % \end{macro} |
---|
1042 | % |
---|
1043 | % \begin{macro}{\output} |
---|
1044 | % Grab the tokens in \cmd\the\cmd\output\ (but without the extra set of braces). |
---|
1045 | % The value of \cmd\toks@\ must remain untouched until loaded into the appropriate token |
---|
1046 | % register; this is done a few lines below. |
---|
1047 | % \begin{macrocode} |
---|
1048 | \long\def\@tempa#1\@@nil{#1}% |
---|
1049 | \toks@ |
---|
1050 | \expandafter\expandafter |
---|
1051 | \expandafter{% |
---|
1052 | \expandafter \@tempa |
---|
1053 | \the\output |
---|
1054 | \@@nil |
---|
1055 | }% |
---|
1056 | \newtoks\output |
---|
1057 | \output\expandafter{\the\toks@}% |
---|
1058 | % \end{macrocode} |
---|
1059 | % \end{macro} |
---|
1060 | % |
---|
1061 | % \begin{macro}{\dispatch@output} |
---|
1062 | % We now install our own output routine in place of the |
---|
1063 | % old one, which is still available as \cmd\the\cmd\output. |
---|
1064 | % |
---|
1065 | % The output routine is simply the procedure \cmd\dispatch@output. |
---|
1066 | % It either dispatches to a procedure based on a particular value of |
---|
1067 | % \cmd\outputpenalty\ or it executes \cmd\the\cmd\output\ tokens. |
---|
1068 | % \begin{macrocode} |
---|
1069 | \primitive@output{\dispatch@output}% |
---|
1070 | \def\dispatch@output{% |
---|
1071 | \let\par\@@par |
---|
1072 | \expandafter\let\expandafter\@tempa\csname output@\the\outputpenalty\endcsname |
---|
1073 | \outputdebug@sw{% |
---|
1074 | \saythe\badness |
---|
1075 | \saythe\outputpenalty |
---|
1076 | \saythe\holdinginserts |
---|
1077 | \say\thepagegrid |
---|
1078 | \saythe\pagegrid@col |
---|
1079 | \saythe\pagegrid@cur |
---|
1080 | %\say\bot@envir |
---|
1081 | \saythe\insertpenalties |
---|
1082 | %\say\@@topmark |
---|
1083 | %\say\saved@@topmark |
---|
1084 | %\say\@@firstmark |
---|
1085 | %\say\saved@@firstmark |
---|
1086 | \say\@@botmark |
---|
1087 | %\say\saved@@botmark |
---|
1088 | \saythe\pagegoal |
---|
1089 | \saythe\pagetotal |
---|
1090 | \saythe{\badness\@cclv}% |
---|
1091 | \expandafter\@ifx\expandafter{\csname output@-\the\execute@message@pen\endcsname\@tempa}{% |
---|
1092 | \say\@message@saved |
---|
1093 | }{% |
---|
1094 | \expandafter\say\csname output@\the\outputpenalty\endcsname |
---|
1095 | }% |
---|
1096 | \say\@toplist |
---|
1097 | \say\@botlist |
---|
1098 | \say\@dbltoplist |
---|
1099 | \say\@deferlist |
---|
1100 | {\tracingall\scrollmode |
---|
1101 | \showbox\@cclv |
---|
1102 | \showbox\@cclv@saved |
---|
1103 | \showbox\pagesofar |
---|
1104 | \showbox\footbox |
---|
1105 | \showbox\footins@saved |
---|
1106 | \showbox\footins |
---|
1107 | \showlists |
---|
1108 | }% |
---|
1109 | }{}% |
---|
1110 | \@ifnotrelax\@tempa{\@tempa}{\the\output}% |
---|
1111 | }% |
---|
1112 | \@ifxundefined{\outputdebug@sw}{% |
---|
1113 | \@booleanfalse\outputdebug@sw |
---|
1114 | }{}% |
---|
1115 | % \end{macrocode} |
---|
1116 | % \end{macro} |
---|
1117 | % |
---|
1118 | % |
---|
1119 | % \subsection{Further thoughts about inserts} |
---|
1120 | % |
---|
1121 | % The only safe way to deal with inserts is to either set \cmd\holdininserts\ or |
---|
1122 | % to commit to using whatever insert comes your way: you cannot change your mind |
---|
1123 | % once you see a non-void \cmd\box\cmd\footins, say. |
---|
1124 | % |
---|
1125 | % Therefore all output routine processing must proceed with \cmd\holdinginserts\ set |
---|
1126 | % until you are sure of the material to be committed to the page. At that point, you |
---|
1127 | % can clear \cmd\holdinginserts, spew \cmd\box\cmd\@cclv, put down the appropriate penalty, |
---|
1128 | % and exit, with the knowledge that \TeX\ will re-find the same pagebreak, this time |
---|
1129 | % visiting the output routine with everything, including inserts, in their proper |
---|
1130 | % place. |
---|
1131 | % This technique applies to split elements (screens, longtable, index) as well as to |
---|
1132 | % manufactured pages (float pages and clearpage pages). |
---|
1133 | % |
---|
1134 | % Therefore, the output routine must not make assumptions about whether \cmd\holdinginserts\ |
---|
1135 | % should be cleared; instead this must be left to the one-off output routines or the natural output routine. |
---|
1136 | % |
---|
1137 | % If we are manufacturing pages (``float page processing''), and if \cmd\pagegoal\ is not equal to |
---|
1138 | % \cmd\vsize, then inserts are at hand, and our criterion should take into account the insert |
---|
1139 | % material, even though we cannot measure its height based on the size of \cmd\box\cmd\footins\ |
---|
1140 | % (because \cmd\holdinginserts\ is set, you see). |
---|
1141 | % |
---|
1142 | % It would be better to take the complement of \cmd\floatpagefraction\ and use that |
---|
1143 | % as a standard for the looseness of the page. Since \cmd\pagegoal\ reflects the inserted material, |
---|
1144 | % the criterion becomes the difference of the aggregate height of the floats and the \cmd\pagegoal\ |
---|
1145 | % versus this "page looseness" standard. |
---|
1146 | % |
---|
1147 | % As a check, consider what happens if we bail out: \cmd\@deferlist\ has never been touched, so it |
---|
1148 | % requires no attention. Also, \cmd\holdinginserts\ has never been cleared, so inserts require |
---|
1149 | % no attention. So we only have to ensure that marks are preserved, which is already taken |
---|
1150 | % care of by the message handler mechanism. |
---|
1151 | % |
---|
1152 | % If we are doing ordinary page cutting, then the scheme would be to detect whether we are within |
---|
1153 | % a screen (or longtable as may be), do the adjustment to the page height, and return, but this time |
---|
1154 | % with \cmd\holdinginserts\ cleared. Upon reentering the output routine, we may or may not be within |
---|
1155 | % the screen environment, but we are now sure to have a final page break, and we can commit this |
---|
1156 | % material (by shipping out or by saving it out as a full column). |
---|
1157 | % |
---|
1158 | % In the above, the first of the two visits to the output routine is a dead cycle and requires |
---|
1159 | % propagation of marks, but nothing else. |
---|
1160 | % |
---|
1161 | % The natural output routine |
---|
1162 | % |
---|
1163 | % Here is the portion of the output routine that fields cases not handled by |
---|
1164 | % the dispatcher. |
---|
1165 | % |
---|
1166 | % The default is to ship out a page and then look around for more material |
---|
1167 | % that might constitute a ``float page''. However, because \cmd\holdinginserts\ |
---|
1168 | % is normally set, this output routine must first have a dead cycle and |
---|
1169 | % come back again with \cmd\holdinginserts\ cleared. |
---|
1170 | % Then, after shipping out, it puts down a message that |
---|
1171 | % will manufacture zero or more float pages, finally terminating |
---|
1172 | % with a procedure that commits floats to a new unfinished page. |
---|
1173 | % |
---|
1174 | % To accomodate special processing, we execute hooks whose name is based |
---|
1175 | % on the value of the "envir" mark component. The default is "document", |
---|
1176 | % ensured by an initial mark of that value; the associated procedures |
---|
1177 | % are all nil. Any unknown envir value will "\cmd\relax\ out". |
---|
1178 | % |
---|
1179 | % The code \cmd\move@insert@sw\ tells whether we are on our first visit to |
---|
1180 | % the output routine (with \cmd\holdinginserts\ still set), or our second |
---|
1181 | % (with \cmd\holdinginserts\ cleared). The output routine will toggle the |
---|
1182 | % setting. |
---|
1183 | % |
---|
1184 | % The commands \cmd\hold@insertions\ and \cmd\move@insertions\ respectively |
---|
1185 | % clear and set the state of \cmd\move@insert@sw, so this procedure effectively |
---|
1186 | % clears \cmd\holdinginserts\ just long enough to pick up the insertions. |
---|
1187 | % Important: any output routine that clears \cmd\holdinginserts\ |
---|
1188 | % must guarentee that it is restored on the subsequent visit to the output routine. |
---|
1189 | % Or, to put it another way, if an output routine detects that \cmd\holdinginserts\ |
---|
1190 | % is cleared, it should take it upon itself to restore it before exiting. |
---|
1191 | % |
---|
1192 | % The branch with \cmd\holdinginserts\ set is executed first; the other |
---|
1193 | % branch follows on practically immediately thereafter. In the first branch, |
---|
1194 | % we simply execute the appropriate hook and then execute a dead cycle. |
---|
1195 | % |
---|
1196 | % In the branch with \cmd\holdinginserts\ cleared, the procedure |
---|
1197 | % builds up the current column, which is now complete, with \cmd\@makecol, then |
---|
1198 | % dispatches to the shipout routine associated with the current page grid, \cmd\output@column@. |
---|
1199 | % At the end, it triggers the execution of an output routine to prepare the next column (or page). |
---|
1200 | % |
---|
1201 | % \subsection{Natural output routine}% |
---|
1202 | % |
---|
1203 | % \begin{macro}{\output} |
---|
1204 | % Here is what has become of the output routine of \LaTeX. |
---|
1205 | % It is of necessity divided into phases, \cmd\output@holding\ is executed upon first encountering the natural page-breaking point, while inserts are being held. |
---|
1206 | % The second phase, \cmd\output@moving, is set in motion by the first: here the same material (in most cases) will be processed with \cmd\holdinginserts\ cleared. |
---|
1207 | % |
---|
1208 | % \begin{macrocode} |
---|
1209 | \output={\toggle@insert\output@holding\output@moving}% |
---|
1210 | % \end{macrocode} |
---|
1211 | % |
---|
1212 | % The procedure \cmd\output@holding\ |
---|
1213 | % is our first cycle through the output routine; \cmd\holdinginserts\ is still set. |
---|
1214 | % We give the current environment a heads up |
---|
1215 | % (it is through this means that \classname{longtable} sets its running header and footer), |
---|
1216 | % then we execute a dead cycle, which should propagate marks. |
---|
1217 | % |
---|
1218 | % One corner case that can crop up is the presence of a single unbreakable chunk whose size is larger |
---|
1219 | % than \cmd\vsize. |
---|
1220 | % Doing a dead cycle under such circumstances will not find the same breakpoint as this time |
---|
1221 | % (remember we threw in a \cmd\mark\ node). |
---|
1222 | % Instead, we attempt to remove the excess height of the material, so we can continue to propagate marks. |
---|
1223 | % |
---|
1224 | % The corner case is at hand if the natural size of \cmd\box\cmd\@cclv\ exceeds \cmd\pagegoal\ and |
---|
1225 | % the contents cannot be shrunk to fit. |
---|
1226 | % |
---|
1227 | % \begin{macrocode} |
---|
1228 | \def\output@holding{% |
---|
1229 | \csname output@init@\bot@envir\endcsname |
---|
1230 | %\vbadness\@M |
---|
1231 | %\vfuzz\maxdimen |
---|
1232 | \@if@exceed@pagegoal{\unvcopy\@cclv}{% |
---|
1233 | \setbox\z@\vbox{\unvcopy\@cclv}% |
---|
1234 | \outputdebug@sw{{\tracingall\scrollmode\showbox\z@}}{}% |
---|
1235 | \dimen@\ht\@cclv\advance\dimen@-\ht\z@ |
---|
1236 | \dead@cycle@repair\dimen@ |
---|
1237 | }{% |
---|
1238 | \dead@cycle |
---|
1239 | }% |
---|
1240 | }% |
---|
1241 | \def\@if@exceed@pagegoal#1{% |
---|
1242 | \begingroup |
---|
1243 | \setbox\z@\vbox{#1}% |
---|
1244 | \dimen@\ht\z@\advance\dimen@\dp\z@ |
---|
1245 | \outputdebug@sw{\saythe\dimen@}{}% |
---|
1246 | \@ifdim{\dimen@>\pagegoal}{% |
---|
1247 | \setbox\z@\vbox{\@@mark{}\unvbox\z@}% |
---|
1248 | \splittopskip\topskip |
---|
1249 | \splitmaxdepth\maxdepth |
---|
1250 | \vbadness\@M |
---|
1251 | \vfuzz\maxdimen |
---|
1252 | \setbox\tw@\vsplit\z@ to\pagegoal |
---|
1253 | \outputdebug@sw{{\tracingall\scrollmode\showbox\tw@\showbox\z@}}{}% |
---|
1254 | \setbox\tw@\vbox{\unvbox\tw@}% |
---|
1255 | \@ifdim{\ht\tw@=\z@}{% |
---|
1256 | \ltxgrid@info{Found overly large chunk while preparing to move insertions. Attempting repairs}% |
---|
1257 | \aftergroup\true@sw |
---|
1258 | }{% |
---|
1259 | \aftergroup\false@sw |
---|
1260 | }% |
---|
1261 | }{% |
---|
1262 | \aftergroup\false@sw |
---|
1263 | }% |
---|
1264 | \endgroup |
---|
1265 | }% |
---|
1266 | % \end{macrocode} |
---|
1267 | % |
---|
1268 | % The procedure \cmd\output@moving\ |
---|
1269 | % is our second cycle through the output routine; \cmd\holdinginserts\ is now cleared, |
---|
1270 | % and \cmd\insert s will have been split off into their respective box registers, like \cmd\footins. |
---|
1271 | % |
---|
1272 | % \begin{enumerate} |
---|
1273 | % \item |
---|
1274 | % Set the values of \cmd\topmark\ and \cmd\firstmark. |
---|
1275 | % \item |
---|
1276 | % If we got here because of a \cmd\clearpage\ command, remove the protection box that this mechanism has left on the MVL. |
---|
1277 | % \item |
---|
1278 | % If the contents of \cmd\box\cmd\@cclv\ are non-trivial, commit it to the current page or ship it out as the case may call for. |
---|
1279 | % \item |
---|
1280 | % If not, discard it (we are at the end of \cmd\clearpage\ processing). |
---|
1281 | % \item |
---|
1282 | % Set various values, including the available space for setting type on the next column (\cmd\@colroom). |
---|
1283 | % \end{enumerate} |
---|
1284 | % |
---|
1285 | % The processing for a non-trivial \cmd\box\cmd\@cclv\ are: |
---|
1286 | % \begin{enumerate} |
---|
1287 | % \item |
---|
1288 | % Execute the head procedure for the current environment. |
---|
1289 | % \item |
---|
1290 | % Make up a column and ship it out (or commit it to the current page) via a procedure keyed to the current page grid. |
---|
1291 | % \item |
---|
1292 | % Put down an interrupt for \cmd\do@startcolumn@pen: this will force a visit to the output routine for the |
---|
1293 | % purpose of committing floats to the next column. |
---|
1294 | % \item |
---|
1295 | % Possibly put down an interrupt to continue \cmd\clearpage\ proccessing. |
---|
1296 | % \item |
---|
1297 | % Execute the tail procedure for the current environment. |
---|
1298 | % \end{enumerate} |
---|
1299 | % |
---|
1300 | % |
---|
1301 | % The processing for a trivial \cmd\box\cmd\@cclv\ are: |
---|
1302 | % \begin{enumerate} |
---|
1303 | % \item |
---|
1304 | % Void out \cmd\box\cmd\@cclv\ and give appropriate warning messages and diagnostics. |
---|
1305 | %% \item |
---|
1306 | %% Put down the same interrupts as for the non-trivial case above. |
---|
1307 | % \end{enumerate} |
---|
1308 | % |
---|
1309 | % \begin{macrocode} |
---|
1310 | \def\output@moving{% |
---|
1311 | \set@top@firstmark |
---|
1312 | \@ifnum{\outputpenalty=\do@newpage@pen}{% |
---|
1313 | \setbox\@cclv\vbox{% |
---|
1314 | \unvbox\@cclv |
---|
1315 | \setbox\z@\lastbox |
---|
1316 | \@ifdim{\ht\z@=\ht\@protection@box}{\box\lastbox}{\unskip}% |
---|
1317 | }% |
---|
1318 | }{}% |
---|
1319 | \@cclv@nontrivial@sw{% |
---|
1320 | \csname output@prep@\bot@envir \endcsname |
---|
1321 | \@makecol\csname output@column@\thepagegrid\endcsname |
---|
1322 | \protect@penalty\do@startcolumn@pen |
---|
1323 | \clearpage@sw{% |
---|
1324 | \protect@penalty\do@endpage@pen |
---|
1325 | }{}% |
---|
1326 | \csname output@post@\bot@envir \endcsname |
---|
1327 | }{% |
---|
1328 | {\setbox\z@\box\@cclv}% |
---|
1329 | }% |
---|
1330 | \set@colroom |
---|
1331 | \global\@mparbottom\z@ |
---|
1332 | \global\@textfloatsheight\z@ %FIXME: this legacy LaTeX variable is set, but never queried! |
---|
1333 | }% |
---|
1334 | % \end{macrocode} |
---|
1335 | % |
---|
1336 | % The procedure \cmd\@cclv@nontrivial@sw\ determines if this visit to \cmd\output@moving\ |
---|
1337 | % is a trivial one, which happens at the end of \cmd\clearpage\ processing and under some pathological circumstances. |
---|
1338 | % It emits a Boolean, so it is syntactically like \cmd\true@sw, albeit does not execute solely via expansion. |
---|
1339 | % |
---|
1340 | % Note: the case where \cmd\box\cmd\@cclv\ is void comes up at the very beginning of the job, when |
---|
1341 | % typesetting a (full-page-width) title block in a two-column layout. |
---|
1342 | % |
---|
1343 | % Note: the code that removes the last box and skip from the output is intended to detect the case |
---|
1344 | % where the output has whatit nodes followed by topskip and a protection box. |
---|
1345 | % This is what happens under normal circumstances at the end of \cmd\clearpage\ processing. |
---|
1346 | % \begin{macrocode} |
---|
1347 | \def\@cclv@nontrivial@sw{% |
---|
1348 | \@ifx@empty\@toplist{% |
---|
1349 | \@ifx@empty\@botlist{% |
---|
1350 | \@ifvoid\footins{% |
---|
1351 | \@ifvoid\@cclv{% |
---|
1352 | \false@sw |
---|
1353 | }{% |
---|
1354 | \setbox\z@\vbox{\unvcopy\@cclv}% |
---|
1355 | \@ifdim{\ht\z@=\topskip}{% |
---|
1356 | \setbox\z@\vbox{% |
---|
1357 | \unvbox\z@ |
---|
1358 | \setbox\z@\lastbox\dimen@\lastskip\unskip |
---|
1359 | \@ifdim{\ht\z@=\ht\@protection@box}{% |
---|
1360 | \advance\dimen@\ht\z@ |
---|
1361 | \@ifdim{\dimen@=\topskip}{% |
---|
1362 | \aftergroup\true@sw |
---|
1363 | }{% |
---|
1364 | \aftergroup\false@sw |
---|
1365 | }% |
---|
1366 | }{% |
---|
1367 | \aftergroup\false@sw |
---|
1368 | }% |
---|
1369 | }% |
---|
1370 | {% |
---|
1371 | \false@sw % Normal for \clearpage |
---|
1372 | }{% |
---|
1373 | \true@sw |
---|
1374 | }% |
---|
1375 | }{% |
---|
1376 | \@ifdim{\ht\z@=\z@}{% |
---|
1377 | \ltxgrid@info{Found trivial column. Discarding it}% |
---|
1378 | \outputdebug@sw{{\tracingall\scrollmode\showbox\@cclv}}{}% |
---|
1379 | \false@sw |
---|
1380 | }{% |
---|
1381 | \true@sw |
---|
1382 | }% |
---|
1383 | }% |
---|
1384 | }% |
---|
1385 | }{% |
---|
1386 | \true@sw |
---|
1387 | }% |
---|
1388 | }{% |
---|
1389 | \true@sw |
---|
1390 | }% |
---|
1391 | }{% |
---|
1392 | \true@sw |
---|
1393 | }% |
---|
1394 | }% |
---|
1395 | % \end{macrocode} |
---|
1396 | % |
---|
1397 | % |
---|
1398 | % \end{macro} |
---|
1399 | % |
---|
1400 | % \begin{macro}{\protect@penalty} |
---|
1401 | % The procedure \cmd\protect@penalty\ is the utility procedure for invoking a |
---|
1402 | % one-off output routine. Such a routine can expect to find the protection box |
---|
1403 | % above it in \cmd\box\cmd\@cclv: it should remove that box. |
---|
1404 | % |
---|
1405 | % Note that \cmd\execute@message\ does the same thing as \cmd\protect@penalty, but |
---|
1406 | % in a slightly different way. |
---|
1407 | % |
---|
1408 | % We create a specially formulated box that will be universally used when a protection box is needed. |
---|
1409 | % In this way, we can always recognize when \cmd\box\cmd\@cclv\ is trivial: |
---|
1410 | % it will consist of whatsits followed by \cmd\topskip\ glue and the \cmd\@protection@box. |
---|
1411 | % \begin{macrocode} |
---|
1412 | \def\protect@penalty#1{\protection@box\penalty-#1\relax}% |
---|
1413 | \newbox\@protection@box |
---|
1414 | \setbox\@protection@box\vbox to1986sp{\vfil}% |
---|
1415 | \def\protection@box{\nointerlineskip\copy\@protection@box}% |
---|
1416 | % \end{macrocode} |
---|
1417 | % \end{macro} |
---|
1418 | % |
---|
1419 | % \begin{macro}{\dead@cycle} |
---|
1420 | % \begin{macro}{\dead@cycle@repair} |
---|
1421 | % The procedure \cmd\dead@cycle\ is defined separately as a utility which can be used by |
---|
1422 | % any output processing routine to emulate what takes place in the standard output routine. |
---|
1423 | % |
---|
1424 | % Here, we have entered the output routine with \cmd\holdinginserts\ enabled, which means that we |
---|
1425 | % are not yet ready to ship out material, because the \cmd\insert\ registers are being held. |
---|
1426 | % We want to clear \cmd\holdinginserts\ and come back here with the same page break as before, whereupon |
---|
1427 | % we may properly proceed with page makeup. |
---|
1428 | % |
---|
1429 | % To do this, we |
---|
1430 | % propagate marks, then spew the contents of \cmd\box\cmd\@cclv\ followed by the |
---|
1431 | % original output penalty that landed us here (but only if it is not 10000, |
---|
1432 | % the flag value for a pagebreak not at a penalty). |
---|
1433 | % |
---|
1434 | % However, the natural output routine should do this only if \cmd\box\cmd\@cclv\ is nontrivial. |
---|
1435 | % A pathological case exists wherein a box of height greater than \cmd\textheight\ would cause an infinite loop involving the output routine. |
---|
1436 | % The procedure \cmd\dead@cycle@repair, attempts to catch this case and avoid the loop. |
---|
1437 | % |
---|
1438 | % The test of the height of \cmd\box\cmd\@cclv\ is not the correct one, because this test will run afoul in |
---|
1439 | % the case where \cmd\box\cmd\@cclv\ contains nothing but an \cmd\insert\ node. What to do? |
---|
1440 | % |
---|
1441 | % It is possible that the pathological case can be detected by looking at \cmd\pagetotal. If that quantity is |
---|
1442 | % zero, then \cmd\box\cmd\@cclv\ really is trivial. |
---|
1443 | % |
---|
1444 | % In the procedure \cmd\dead@cycle@repair, if \cmd\box\cmd\@cclv\ is nontrivial, we execute \cmd\dead@cycle, |
---|
1445 | % otherwise it contains nothing but a mark, so we dispense with propagating marks |
---|
1446 | % and we simply spew out \cmd\box\cmd\@cclv\ without an accompanying mark. |
---|
1447 | % This has the effect of failing to propagate marks, but this problem is preferrable to the infinite loop, |
---|
1448 | % which in principle could crash even a robust operating system by filling up the file system. |
---|
1449 | % |
---|
1450 | % If a document has such a large chunk, it should be fixed, so we give a message in the log. |
---|
1451 | % |
---|
1452 | % You ask, ``In what way does this infinite loop come about?'' Good question! |
---|
1453 | % |
---|
1454 | % The setup is a chunk in the MVL that is taller than \cmd\textheight. |
---|
1455 | % (Yes, it's that simple.) |
---|
1456 | % As soon as the previous page ships out, the MVL will contain a mark (propagated from the previous page) followed |
---|
1457 | % by that large chunk (call it the `big bad box', albeit does not need to be a single box). |
---|
1458 | % The next visit to the output routine will be a natural page break, but |
---|
1459 | % \TeX\ will select the juncture between the mark and the big bad box as the least-cost page break. |
---|
1460 | % Unless the test in \cmd\dead@cycle\ is done, the cycle is perpetuated when the macro |
---|
1461 | % reinserts the mark. |
---|
1462 | % |
---|
1463 | % The crux matter is achieving, in a robust way, the goal of going from a \cmd\holdinginserts\ state to one |
---|
1464 | % where the insertions are moving. |
---|
1465 | % |
---|
1466 | % \begin{macrocode} |
---|
1467 | \def\dead@cycle@repair#1{% |
---|
1468 | \expandafter\do@@mark |
---|
1469 | \expandafter{% |
---|
1470 | \@@botmark |
---|
1471 | }% |
---|
1472 | \unvbox\@cclv |
---|
1473 | \nointerlineskip |
---|
1474 | \vbox to#1{\vss}% |
---|
1475 | \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
---|
1476 | }% |
---|
1477 | \def\dead@cycle@repair@protected#1{% |
---|
1478 | \expandafter\do@@mark |
---|
1479 | \expandafter{% |
---|
1480 | \@@botmark |
---|
1481 | }% |
---|
1482 | \begingroup |
---|
1483 | \unvbox\@cclv |
---|
1484 | \setbox\z@\lastbox % Remove protection box |
---|
1485 | \nointerlineskip |
---|
1486 | \advance#1-\ht\@protection@box |
---|
1487 | \vbox to#1{\vss}% |
---|
1488 | \protection@box % Reinsert protection box |
---|
1489 | \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
---|
1490 | \endgroup |
---|
1491 | }% |
---|
1492 | \def\dead@cycle{% |
---|
1493 | \expandafter\do@@mark |
---|
1494 | \expandafter{% |
---|
1495 | \@@botmark |
---|
1496 | }% |
---|
1497 | \unvbox\@cclv |
---|
1498 | \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
---|
1499 | }% |
---|
1500 | % \end{macrocode} |
---|
1501 | % \end{macro} |
---|
1502 | % \end{macro} |
---|
1503 | % |
---|
1504 | % \begin{macro}{\output@init@document} |
---|
1505 | % \begin{macro}{\output@prep@document} |
---|
1506 | % \begin{macro}{\output@post@document} |
---|
1507 | % The default processing simply provides for insertion of held-over footnotes. |
---|
1508 | % At a natural page break, we are either at the bottom of a column or at the bottom |
---|
1509 | % of a page. In either case, the \cmd\output@init@\ processing adjusts for the height |
---|
1510 | % of the held-over footnotes and bails out. |
---|
1511 | % Upon our return, at \cmd\output@prep@\ time, the page break will accomodate the material; |
---|
1512 | % it is now actually inserted by concatenating it with the contents of \cmd\footins. |
---|
1513 | % The default processing for \cmd\output@post@\ is nil. |
---|
1514 | % \begin{macrocode} |
---|
1515 | \def\output@init@document{% |
---|
1516 | \@ifvoid\footbox{}{% |
---|
1517 | \global\advance\vsize-\ht\footbox |
---|
1518 | \global\advance\vsize-\dp\footbox |
---|
1519 | }% |
---|
1520 | }% |
---|
1521 | \def\output@prep@document{% |
---|
1522 | \@ifvoid\footbox{}{% |
---|
1523 | % {\tracingall\scrollmode\showbox\footbox\showbox\footins}% |
---|
1524 | \setbox\footins\vbox{\unvbox\footbox\unvbox\footins}% |
---|
1525 | }% |
---|
1526 | }% |
---|
1527 | \def\output@post@document{}% |
---|
1528 | % \end{macrocode} |
---|
1529 | % \end{macro} |
---|
1530 | % \end{macro} |
---|
1531 | % \end{macro} |
---|
1532 | % |
---|
1533 | % \begin{macro}{\@opcol} |
---|
1534 | % The standard \LaTeX\ procedure \cmd\@opcol\ is now completely obsoleted. |
---|
1535 | % \begin{macrocode} |
---|
1536 | \let\@opcol\@undefined |
---|
1537 | % \end{macrocode} |
---|
1538 | % \end{macro} |
---|
1539 | % |
---|
1540 | % \begin{macro}{\@makecol} |
---|
1541 | % The procedure \cmd\@makecol\ packages up a page along with all its insertions and floats. |
---|
1542 | % Therefore it is essential that it be executed with \cmd\holdininserts\ cleared. |
---|
1543 | % |
---|
1544 | % Note that there is a corner case when in a multi-column grid, where the change back to |
---|
1545 | % one-column grid occurs just after a complete page ships out. We want to detect when |
---|
1546 | % \cmd\@cclv\ contains nothing but a \cmd\mark, but this is a \TeX\ impossibility. |
---|
1547 | % |
---|
1548 | % Note on \cmd\@kludgeins: we have removed this mechanism from \LaTeX, because the implementation |
---|
1549 | % of \cmd\enlargethispage\ no longer requires it. |
---|
1550 | % Here, for consistency sake, we remove \cmd\@makespecialcolbox. |
---|
1551 | % \begin{macrocode} |
---|
1552 | \def\@makecol{% |
---|
1553 | \setbox\@outputbox\vbox{% |
---|
1554 | \boxmaxdepth\@maxdepth |
---|
1555 | \@tempdima\dp\@cclv |
---|
1556 | \unvbox\@cclv |
---|
1557 | \vskip-\@tempdima |
---|
1558 | }% |
---|
1559 | \xdef\@freelist{\@freelist\@midlist}\global\let\@midlist\@empty |
---|
1560 | \@combinefloats |
---|
1561 | \@combineinserts\@outputbox\footins |
---|
1562 | %\@ifvbox\@kludgeins{% |
---|
1563 | % \@makespecialcolbox |
---|
1564 | %}{% |
---|
1565 | \set@adj@colht\dimen@ |
---|
1566 | \count@\vbadness |
---|
1567 | \vbadness\@M |
---|
1568 | \setbox\@outputbox\vbox to\dimen@{% |
---|
1569 | \@texttop |
---|
1570 | \dimen@\dp\@outputbox |
---|
1571 | \unvbox\@outputbox |
---|
1572 | \vskip-\dimen@ |
---|
1573 | \@textbottom |
---|
1574 | }% |
---|
1575 | \vbadness\count@ |
---|
1576 | %}% |
---|
1577 | \global\maxdepth\@maxdepth |
---|
1578 | }% |
---|
1579 | \let\@makespecialcolbox\@undefined |
---|
1580 | % \end{macrocode} |
---|
1581 | % \end{macro} |
---|
1582 | % |
---|
1583 | % \begin{macro}{\@combineinserts} |
---|
1584 | % We split out the procedure to add the \cmd\footins\ insertions to the packaged-up page. |
---|
1585 | % Any other non-trivial insertions should also be dealt with at this time. |
---|
1586 | % \begin{macrocode} |
---|
1587 | \def\@combineinserts#1#2{% |
---|
1588 | \setbox#1\vbox{% |
---|
1589 | \unvbox#1% |
---|
1590 | % {\tracingall\scrollmode\showbox#2}% |
---|
1591 | \vbox{% |
---|
1592 | \@ifvoid#2{}{% |
---|
1593 | \vskip\skip\footins |
---|
1594 | \color@begingroup |
---|
1595 | \normalcolor |
---|
1596 | \footnoterule |
---|
1597 | \nointerlineskip |
---|
1598 | \box#2% |
---|
1599 | \color@endgroup |
---|
1600 | }{}% |
---|
1601 | }% |
---|
1602 | }% |
---|
1603 | }% |
---|
1604 | % \end{macrocode} |
---|
1605 | % \end{macro} |
---|
1606 | % |
---|
1607 | % \begin{macro}{\@floatplacement} |
---|
1608 | % In standard \LaTeX, someone (DPC?) makes the assumption that \cmd\@fpmin\ can be assigned |
---|
1609 | % locally. This is no longer true now that we ship no more than one page per visit to the output routine. |
---|
1610 | % We apply a bandaid. |
---|
1611 | % \begin{macrocode} |
---|
1612 | \appdef\@floatplacement{% |
---|
1613 | \global\@fpmin\@fpmin |
---|
1614 | }% |
---|
1615 | % \end{macrocode} |
---|
1616 | % \end{macro} |
---|
1617 | % |
---|
1618 | % \begin{macro}{\pagebreak@pen} |
---|
1619 | % While we are in the way of registering certain penalty values, |
---|
1620 | % let us register the smallest one that will force a visit to the output routine. |
---|
1621 | % However, this penalty will not have an assciated macro: we wish to execute the |
---|
1622 | % natural output routine instead. |
---|
1623 | % |
---|
1624 | % Note that this penalty is invoked by \cmd\clearpage\ and \cmd\newpage. |
---|
1625 | % \begin{macrocode} |
---|
1626 | \mathchardef\pagebreak@pen=\@M |
---|
1627 | \expandafter\let\csname output@-\the\pagebreak@pen\endcsname\relax |
---|
1628 | % \end{macrocode} |
---|
1629 | % \end{macro} |
---|
1630 | % |
---|
1631 | % |
---|
1632 | % \subsection{Float placement}% |
---|
1633 | % |
---|
1634 | % \begin{macro}{\do@startcolumn@pen} |
---|
1635 | % The procedure \cmd\do@startcolumn@pen\ is executed as a one-off output routine |
---|
1636 | % just after a page is shipped out (or, in a multicolumn page grid, a column is salted away). |
---|
1637 | % |
---|
1638 | % Its job is to either generate a ``float page'' (in reality a column) for shipping out, |
---|
1639 | % or to commit deferred floats to the fresh column, concluding with a dead cycle. |
---|
1640 | % In the former case, we accomodate split footnotes and other insertions (by comparing \cmd\vsize\ and \cmd\pagegoal): |
---|
1641 | % the floats are spewed onto the page, whereupon \LaTeX's output routine will place the footnotes and ship out, |
---|
1642 | % iterating the process once again. |
---|
1643 | % |
---|
1644 | % Note that when this procedure is invoked, \cmd\box\cmd\@cclv\ still has within it the protection box, so we |
---|
1645 | % start by removing it. Note also that if there was a split insertion held over from the previous page, the |
---|
1646 | % insert node will be present in \cmd\box\cmd\@cclv, \emph{prior to} the protection box. For this reason, we cannot |
---|
1647 | % just throw away that box, as we might be tempted to do. |
---|
1648 | % |
---|
1649 | % FIXME: where else do we possibly inappropriately discard \cmd\box\cmd\@cclv? |
---|
1650 | % |
---|
1651 | % Note that, because a column or page page had previously just been completed, |
---|
1652 | % we can assume that there is nothing of importance on the page, |
---|
1653 | % and because no message is being passed, we can preserve marks in a simple way. |
---|
1654 | % |
---|
1655 | % A Note on terminology: |
---|
1656 | % In a single-column page grid, you might expect that we would execute the procedure \cmd\do@startpage. |
---|
1657 | % But this is not so. |
---|
1658 | % \LaTeX\ has a confustion of long standing, |
---|
1659 | % in which the procedures that handle full-page width floats in a two-column page grid all have in their names |
---|
1660 | % the string `dbl', which erroneously suggests having something to do with ``double''. It does not: |
---|
1661 | % when you see `dbl', think ``full page width''. |
---|
1662 | % \begin{macrocode} |
---|
1663 | \mathchardef\do@startcolumn@pen=10005 |
---|
1664 | \@namedef{output@-\the\do@startcolumn@pen}{\do@startcolumn}% |
---|
1665 | \def\do@startcolumn{% |
---|
1666 | \setbox\@cclv\vbox{\unvbox\@cclv\setbox\z@\lastbox\unskip}% |
---|
1667 | \clearpage@sw{\@clearfloatplacement}{\@floatplacement}% |
---|
1668 | \set@colroom |
---|
1669 | \@booleanfalse\pfloat@avail@sw |
---|
1670 | \begingroup |
---|
1671 | \@colht\@colroom |
---|
1672 | \@booleanfalse\float@avail@sw |
---|
1673 | \@tryfcolumn\test@colfloat |
---|
1674 | \float@avail@sw{\aftergroup\@booleantrue\aftergroup\pfloat@avail@sw}{}% |
---|
1675 | \endgroup |
---|
1676 | \fcolmade@sw{% |
---|
1677 | \setbox\@cclv\vbox{\unvbox\@outputbox\unvbox\@cclv}% |
---|
1678 | % \csname float@column@\thepagegrid\endcsname |
---|
1679 | % \csname output@column@\thepagegrid\endcsname |
---|
1680 | \outputpenalty-\pagebreak@pen % ask for a return visit, this time with insertions and all. |
---|
1681 | \dead@cycle |
---|
1682 | }{% |
---|
1683 | \begingroup |
---|
1684 | \let\@elt\@scolelt |
---|
1685 | \let\reserved@b\@deferlist\global\let\@deferlist\@empty\reserved@b |
---|
1686 | \endgroup |
---|
1687 | \clearpage@sw{% |
---|
1688 | \outputpenalty\@M |
---|
1689 | }{% |
---|
1690 | \outputpenalty\do@newpage@pen |
---|
1691 | }% |
---|
1692 | \dead@cycle |
---|
1693 | }% |
---|
1694 | \check@deferlist@stuck\do@startcolumn |
---|
1695 | \set@vsize |
---|
1696 | }% |
---|
1697 | \def\@scolelt#1{\def\@currbox{#1}\@addtonextcol}% |
---|
1698 | \def\test@colfloat#1{% |
---|
1699 | \csname @floatselect@sw@\thepagegrid\endcsname#1{}{\@testtrue}% |
---|
1700 | \@if@sw\if@test\fi{}{\aftergroup\@booleantrue\aftergroup\float@avail@sw}% |
---|
1701 | }% |
---|
1702 | % \end{macrocode} |
---|
1703 | % \end{macro} |
---|
1704 | % |
---|
1705 | % \begin{macro}{\@addtonextcol} |
---|
1706 | % We must adjust \cmd\@addtonextcol\ to take held-over inserts into account. |
---|
1707 | % Now that all deferred floats are queued up together (in order), we must have a way of |
---|
1708 | % differentiating them; this is done by the page grid-dependent procedure \cmd\@floatselect@sw@. |
---|
1709 | % \begin{macrocode} |
---|
1710 | \def\@addtonextcol{% |
---|
1711 | \begingroup |
---|
1712 | \@insertfalse |
---|
1713 | \@setfloattypecounts |
---|
1714 | \csname @floatselect@sw@\thepagegrid\endcsname\@currbox{% |
---|
1715 | \@ifnum{\@fpstype=8 }{}{% |
---|
1716 | \@ifnum{\@fpstype=24 }{}{% |
---|
1717 | \@flsettextmin |
---|
1718 | \@reqcolroom \ht\@currbox |
---|
1719 | \advance \@reqcolroom \@textmin |
---|
1720 | \advance \@reqcolroom \vsize % take into account split insertions |
---|
1721 | \advance \@reqcolroom -\pagegoal |
---|
1722 | \@ifdim{\@colroom>\@reqcolroom}{% |
---|
1723 | \@flsetnum \@colnum |
---|
1724 | \@ifnum{\@colnum>\z@}{% |
---|
1725 | \@bitor\@currtype\@deferlist |
---|
1726 | \@if@sw\if@test\fi{}{% |
---|
1727 | \@addtotoporbot |
---|
1728 | }% |
---|
1729 | }{}% |
---|
1730 | }{}% |
---|
1731 | }% |
---|
1732 | }% |
---|
1733 | }{}% |
---|
1734 | \@if@sw\if@insert\fi{}{% |
---|
1735 | \@cons\@deferlist\@currbox |
---|
1736 | }% |
---|
1737 | \endgroup |
---|
1738 | }% |
---|
1739 | % \end{macrocode} |
---|
1740 | % \end{macro} |
---|
1741 | % |
---|
1742 | % \begin{macro}{\do@startpage@pen} |
---|
1743 | % \begin{macro}{\forcefloats@sw} |
---|
1744 | % \begin{macro}{\@sdblcolelt} |
---|
1745 | % \begin{macro}{\test@dblfloat} |
---|
1746 | % \begin{macro}{\@if@notdblfloat} |
---|
1747 | % Similar to \cmd\do@startcolumn, |
---|
1748 | % the procedure \cmd\do@startpage\ starts up a new page (not column) in a multi-column page grid. |
---|
1749 | % It is invoked after a page is shipped out in a multi-column page grid, and |
---|
1750 | % it commits full-page-width floats to the fresh page, possibly resulting in a float page. |
---|
1751 | % In implementation, it is similar to \cmd\do@startcolumn, except that |
---|
1752 | % it commits effectively via \cmd\@addtodblcol\ instead of \cmd\@addtonextcol. |
---|
1753 | % Note that this procedure will inevitably be followed by \cmd\do@startcolumn. |
---|
1754 | % |
---|
1755 | % Some details of the procedure: |
---|
1756 | % |
---|
1757 | % We begin by removing the protection box from \cmd\box\cmd\@cclv, then setting the values of the |
---|
1758 | % float placement parameters appropriately, and resetting \cmd\@colht, \cmd\@colroom, and \cmd\vsize\ to base values. |
---|
1759 | % |
---|
1760 | % Next we attempt to compose a float page, a page consisting entirely of floats. If successful, |
---|
1761 | % we ship out the float page and lay down an interrupt that will send us back here for another try. |
---|
1762 | % |
---|
1763 | % If no float page is formed, we attempt to commit full-page-width floats to the text page, and return with a dead cycle. |
---|
1764 | % We are now ready to compose columns of text. |
---|
1765 | % |
---|
1766 | % Note that all floats (both column floats and full-page-width floats) move through a single queue. |
---|
1767 | % To differentiate between the two, the width of the float is compared to \cmd\textwidth. |
---|
1768 | % This comparison is encapsulated in the macro \cmd\@if@notdblfloat, which should be used whenever |
---|
1769 | % such a determination must be made. This procedure returns a Boolean. |
---|
1770 | % \begin{macrocode} |
---|
1771 | \mathchardef\do@startpage@pen=10006 |
---|
1772 | \@namedef{output@-\the\do@startpage@pen}{\do@startpage}% |
---|
1773 | \def\do@startpage{% |
---|
1774 | \setbox\@cclv\vbox{\unvbox\@cclv\setbox\z@\lastbox\unskip}% |
---|
1775 | \clearpage@sw{\@clearfloatplacement}{\@dblfloatplacement}% |
---|
1776 | \set@colht |
---|
1777 | \@booleanfalse\pfloat@avail@sw |
---|
1778 | \begingroup |
---|
1779 | \@booleanfalse\float@avail@sw |
---|
1780 | \@tryfcolumn\test@dblfloat |
---|
1781 | \float@avail@sw{\aftergroup\@booleantrue\aftergroup\pfloat@avail@sw}{}% |
---|
1782 | \endgroup |
---|
1783 | \fcolmade@sw{% |
---|
1784 | \global\setbox\pagesofar\vbox{\unvbox\pagesofar\unvbox\@outputbox}% |
---|
1785 | \@combinepage |
---|
1786 | \@combinedblfloats |
---|
1787 | \@outputpage |
---|
1788 | \global\pagegrid@cur\@ne |
---|
1789 | \protect@penalty\do@startpage@pen |
---|
1790 | }{% |
---|
1791 | \begingroup |
---|
1792 | \@booleanfalse\float@avail@sw |
---|
1793 | \let\@elt\@sdblcolelt |
---|
1794 | \let\reserved@b\@deferlist\global\let\@deferlist\@empty\reserved@b |
---|
1795 | \endgroup |
---|
1796 | \@ifdim{\@colht=\textheight}{% No luck... |
---|
1797 | \pfloat@avail@sw{% ...but a float *was* available! |
---|
1798 | \forcefloats@sw{% |
---|
1799 | \ltxgrid@warn{Forced dequeueing of floats stalled}% |
---|
1800 | }{% |
---|
1801 | \ltxgrid@warn{Dequeueing of floats stalled}% |
---|
1802 | }% |
---|
1803 | }{}% |
---|
1804 | }{}% |
---|
1805 | \outputpenalty\@M |
---|
1806 | \dead@cycle |
---|
1807 | }% |
---|
1808 | \check@deferlist@stuck\do@startpage |
---|
1809 | \set@colht |
---|
1810 | %\set@colroom |
---|
1811 | }% |
---|
1812 | \def\@sdblcolelt#1{\def\@currbox{#1}\@addtodblcol}% |
---|
1813 | \def\test@dblfloat#1{% |
---|
1814 | \@if@notdblfloat{#1}{\@testtrue}{}% |
---|
1815 | \@if@sw\if@test\fi{}{\aftergroup\@booleantrue\aftergroup\float@avail@sw}% |
---|
1816 | }% |
---|
1817 | \def\@if@notdblfloat#1{\@ifdim{\wd#1<\textwidth}}% |
---|
1818 | \@booleanfalse\forcefloats@sw |
---|
1819 | % \end{macrocode} |
---|
1820 | % \end{macro} |
---|
1821 | % \end{macro} |
---|
1822 | % \end{macro} |
---|
1823 | % \end{macro} |
---|
1824 | % \end{macro} |
---|
1825 | % |
---|
1826 | % \begin{macro}{\@addtodblcol} |
---|
1827 | % |
---|
1828 | % The procedure \cmd\@addtodblcol\ is called into play at the beginning of each fresh page |
---|
1829 | % and operates on each deferred float, in the hopes of placing one or more such floats |
---|
1830 | % at the top of the current page. |
---|
1831 | % |
---|
1832 | % We alter the procedure of standard \LaTeX\ by putting failed floats into |
---|
1833 | % \cmd\@deferlist\ instead of \cmd\@dbldeferlist. Having done so, we must have a means |
---|
1834 | % of differentiating full-page-width floats from column-width floats. |
---|
1835 | % We assume that the latter will always be narrower than \cmd\textwidth. |
---|
1836 | % |
---|
1837 | % In aid of detecting a stalled float flushing process, we set a Boolean if we encounter |
---|
1838 | % a qualified full-page-width float here. Any that qualify but fail the rest of the tests |
---|
1839 | % might still pass when reconsidered on an otherwise blank page. |
---|
1840 | % \begin{macrocode} |
---|
1841 | \def\@addtodblcol{% |
---|
1842 | \begingroup |
---|
1843 | \@if@notdblfloat{\@currbox}{% |
---|
1844 | \false@sw |
---|
1845 | }{% |
---|
1846 | \@setfloattypecounts |
---|
1847 | \@getfpsbit \tw@ |
---|
1848 | \@bitor \@currtype \@deferlist |
---|
1849 | \@if@sw\if@test\fi{% |
---|
1850 | \false@sw |
---|
1851 | }{% |
---|
1852 | \@ifodd\@tempcnta{% |
---|
1853 | \aftergroup\@booleantrue\aftergroup\float@avail@sw |
---|
1854 | \@flsetnum \@dbltopnum |
---|
1855 | \@ifnum{\@dbltopnum>\z@}{% |
---|
1856 | \@ifdim{\@dbltoproom>\ht\@currbox}{% |
---|
1857 | \true@sw |
---|
1858 | }{% |
---|
1859 | \@ifnum{\@fpstype<\sixt@@n}{% |
---|
1860 | \begingroup |
---|
1861 | \advance \@dbltoproom \@textmin |
---|
1862 | \@ifdim{\@dbltoproom>\ht\@currbox}{% |
---|
1863 | \endgroup\true@sw |
---|
1864 | }{% |
---|
1865 | \endgroup\false@sw |
---|
1866 | }% |
---|
1867 | }{% |
---|
1868 | \false@sw |
---|
1869 | }% |
---|
1870 | }% |
---|
1871 | }{% |
---|
1872 | \false@sw |
---|
1873 | }% |
---|
1874 | }{% |
---|
1875 | \false@sw |
---|
1876 | }% |
---|
1877 | }% |
---|
1878 | }% |
---|
1879 | {% |
---|
1880 | \@tempdima -\ht\@currbox |
---|
1881 | \advance\@tempdima |
---|
1882 | -\@ifx{\@dbltoplist\@empty}{\dbltextfloatsep}{\dblfloatsep}% |
---|
1883 | \global \advance \@dbltoproom \@tempdima |
---|
1884 | \global \advance \@colht \@tempdima |
---|
1885 | \global \advance \@dbltopnum \m@ne |
---|
1886 | \@cons \@dbltoplist \@currbox |
---|
1887 | }{% |
---|
1888 | \@cons \@deferlist \@currbox |
---|
1889 | }% |
---|
1890 | \endgroup |
---|
1891 | }% |
---|
1892 | % \end{macrocode} |
---|
1893 | % \end{macro} |
---|
1894 | % |
---|
1895 | % \begin{macro}{\@tryfcolumn} |
---|
1896 | % \begin{macro}{\@wtryfc} |
---|
1897 | % \begin{macro}{\@xtryfc} |
---|
1898 | % \begin{macro}{\@ztryfc} |
---|
1899 | % Whenever a page is shipped out, \LaTeX\ automatically tries out a float column: |
---|
1900 | % a page containing nothing but floats (and, as we have added here, split footnotes). |
---|
1901 | % |
---|
1902 | % The following four procedures employ certain macros to communicate between each other: |
---|
1903 | % |
---|
1904 | % \cmd\fcolmade@sw, a boolean, says whether we were successful in making a float column. |
---|
1905 | % |
---|
1906 | % \cmd\if@test, a \cmd\newif\ switch, says a float has failed some test. |
---|
1907 | % |
---|
1908 | % \cmd\@deferlist, is the input to the process, a list, of deferred floats. |
---|
1909 | % |
---|
1910 | % \cmd\@trylist, a list, stores the deferred floats to be tried out on the float column. |
---|
1911 | % |
---|
1912 | % \cmd\@failedlist, a list of floats that have failed the selection for the float column. |
---|
1913 | % |
---|
1914 | % \cmd\@flfail, a list of floats that have failed the second selection for the float column. |
---|
1915 | % |
---|
1916 | % \cmd\@flsucceed, a list, the floats that have been successfully placed on the float column. |
---|
1917 | % |
---|
1918 | % \cmd\@freelist, a list, receives any freed floats. |
---|
1919 | % |
---|
1920 | % \cmd\@colht, a dimen, the available space for the column, including column floats and insertions (footnotes). |
---|
1921 | % |
---|
1922 | % \cmd\@fpmin, a dimen, the required minimum height for the float column. |
---|
1923 | % |
---|
1924 | % \cmd\@outputbox, a box, the output of the process. |
---|
1925 | % |
---|
1926 | % \cmd\@fptop, \cmd\@fpsep, \cmd\@fpbot, glue, placed above, between, and below floats on the float column. |
---|
1927 | % |
---|
1928 | % \cmd\@currtype, a count, used temporarily for the float's bits. |
---|
1929 | % |
---|
1930 | % \cmd\@tempcnta, a count, used temporarily for the float's bits. |
---|
1931 | % |
---|
1932 | % In \cmd\@tryfcolumn, we alter the criterion for a float page, because if footnotes are present at this point |
---|
1933 | % (presumably due to a split insertion) then \cmd\@fpmin is no longer the right threshold to apply. |
---|
1934 | % |
---|
1935 | % Note that we have changed \cmd\@tryfcolumn, \cmd\@xtryfc, and \cmd\@ztryfc\ syntactically so that the procedure |
---|
1936 | % to test for the float's being a column float versus a full-page-width float is passed in as an |
---|
1937 | % argument. |
---|
1938 | % |
---|
1939 | % \begin{macrocode} |
---|
1940 | \def\@tryfcolumn#1{% |
---|
1941 | \global\@booleanfalse\fcolmade@sw |
---|
1942 | \@ifx@empty\@deferlist{}{% |
---|
1943 | \global\let\@trylist\@deferlist |
---|
1944 | \global\let\@failedlist\@empty |
---|
1945 | \begingroup |
---|
1946 | \dimen@\vsize\advance\dimen@-\pagegoal\@ifdim{\dimen@>\z@}{% |
---|
1947 | \advance\@fpmin-\dimen@ |
---|
1948 | }{}% |
---|
1949 | \def\@elt{\@xtryfc#1}\@trylist |
---|
1950 | \endgroup |
---|
1951 | \fcolmade@sw{% |
---|
1952 | \global\setbox\@outputbox\vbox{\vskip \@fptop}% |
---|
1953 | \let \@elt \@wtryfc \@flsucceed |
---|
1954 | \global\setbox\@outputbox\vbox{\unvbox\@outputbox |
---|
1955 | \unskip \vskip \@fpbot |
---|
1956 | }% |
---|
1957 | \let \@elt \relax |
---|
1958 | \xdef\@deferlist{\@failedlist\@flfail}% |
---|
1959 | \xdef\@freelist{\@freelist\@flsucceed}% |
---|
1960 | }{}% |
---|
1961 | }% |
---|
1962 | }% |
---|
1963 | \def\@wtryfc #1{% |
---|
1964 | \global\setbox\@outputbox\vbox{\unvbox\@outputbox |
---|
1965 | \box #1\vskip\@fpsep |
---|
1966 | }% |
---|
1967 | }% |
---|
1968 | \def\@xtryfc#1#2{% |
---|
1969 | \@next\reserved@a\@trylist{}{}% trim \@trylist. Ugly! |
---|
1970 | \@currtype \count #2% |
---|
1971 | \divide\@currtype\@xxxii\multiply\@currtype\@xxxii |
---|
1972 | \@bitor \@currtype \@failedlist |
---|
1973 | \@testfp #2% |
---|
1974 | #1#2% |
---|
1975 | \@ifdim{\ht #2>\@colht }{\@testtrue}{}% |
---|
1976 | \@if@sw\if@test\fi{% |
---|
1977 | \@cons\@failedlist #2% |
---|
1978 | }{% |
---|
1979 | \begingroup |
---|
1980 | \gdef\@flsucceed{\@elt #2}% |
---|
1981 | \global\let\@flfail\@empty |
---|
1982 | \@tempdima\ht #2% |
---|
1983 | \def \@elt {\@ztryfc#1}\@trylist |
---|
1984 | \@ifdim{\@tempdima >\@fpmin}{% |
---|
1985 | \global\@booleantrue\fcolmade@sw |
---|
1986 | }{% |
---|
1987 | \@cons\@failedlist #2% |
---|
1988 | }% |
---|
1989 | \endgroup |
---|
1990 | \fcolmade@sw{% |
---|
1991 | \let \@elt \@gobble |
---|
1992 | }{}% |
---|
1993 | }% |
---|
1994 | }% |
---|
1995 | \def\@ztryfc #1#2{% |
---|
1996 | \@tempcnta \count#2% |
---|
1997 | \divide\@tempcnta\@xxxii\multiply\@tempcnta\@xxxii |
---|
1998 | \@bitor \@tempcnta {\@failedlist \@flfail}% |
---|
1999 | \@testfp #2% |
---|
2000 | #1#2% |
---|
2001 | \@tempdimb\@tempdima |
---|
2002 | \advance\@tempdimb \ht#2\advance\@tempdimb\@fpsep |
---|
2003 | \@ifdim{\@tempdimb >\@colht}{% |
---|
2004 | \@testtrue |
---|
2005 | }{}% |
---|
2006 | \@if@sw\if@test\fi{% |
---|
2007 | \@cons\@flfail #2% |
---|
2008 | }{% |
---|
2009 | \@cons\@flsucceed #2% |
---|
2010 | \@tempdima\@tempdimb |
---|
2011 | }% |
---|
2012 | }% |
---|
2013 | % \end{macrocode} |
---|
2014 | % \end{macro} |
---|
2015 | % \end{macro} |
---|
2016 | % \end{macro} |
---|
2017 | % \end{macro} |
---|
2018 | % |
---|
2019 | % |
---|
2020 | % \subsection{Clearing pages}% |
---|
2021 | % |
---|
2022 | % Clearing the page is an elaboration of ending the page: it entails flushing all floats. |
---|
2023 | % |
---|
2024 | % This package might make number of float flushing algorithms available, |
---|
2025 | % a very simple one that does not try to produce excellent pages, |
---|
2026 | % another that tries to make the best use of space, |
---|
2027 | % and a more complex one that tries to balance columns. |
---|
2028 | % |
---|
2029 | % At the beginning of the page-clearing process, by definition all of the paragraph text involved is on the MVL and all floats have been encountered. |
---|
2030 | % There may be material in \cmd\pagesofar, and (in a multi-column page grid) any number of columns of the page have been composed. |
---|
2031 | % Also, there might be footnote material saved up in \cmd\footbox. |
---|
2032 | % |
---|
2033 | % Because we did not want to perform multiple \cmd\shipout s per visit to the output routine, |
---|
2034 | % our multi-column page makeup will not compose multiple columns per visit. |
---|
2035 | % This implementation detail may not require alteration, but it is not a limitation that is truly necessary: |
---|
2036 | % it is only multiple \cmd\shipout s per visit that must be avoided. |
---|
2037 | % |
---|
2038 | % The crux matter is how to continue with flushing floats even after the material in the MVL is exhausted. |
---|
2039 | % At that point, we must, upon completion of the output routine, |
---|
2040 | % insert into the MVL an interrupt that triggers the next step in the processing. |
---|
2041 | % |
---|
2042 | % Therefore, after processing a \cmd\do@startcolumn\ interrupt, we must somehow force the completion of that column. |
---|
2043 | % This could be done by inserting a \cmd\do@newpage@pen\ interrupt. |
---|
2044 | % |
---|
2045 | % And after processing a \cmd\do@startpage@pen\ interrupt, that results in \cmd\@dbltopinsert s, |
---|
2046 | % we must ensure that the multiple columns on the page get completed, so that the page itself finally gets shipped out. |
---|
2047 | % This part will proceed automatically given that \cmd\do@startcolumn\ processing completes successfully. |
---|
2048 | % |
---|
2049 | % The process will not be complete until all deferred floats have been placed and shipped out, and all saved-up footnotes have been inserted. |
---|
2050 | % |
---|
2051 | % Full-page-width floats can get out of order of column floats. This problem can be remedied by holding them all in the same list. |
---|
2052 | % We therefore stop using \cmd\@dbldeferlist\ entirely, and all of the procedures that formerly used it have been rewritten to |
---|
2053 | % use \cmd\@deferlist\ instead. When traversing the list, we apply a selector on the given box that determines whether it is a column-width or page-width float. |
---|
2054 | % This selector is different depending on the page grid. |
---|
2055 | % |
---|
2056 | % When the \cmd\@deferlist\ is processed (by any means), we have to take care of the case where a float of one category is passed over but we are looking for a float of the other category. |
---|
2057 | % Here, we must terminate processing, to avoid disordering the floats. This we do by the usual means. |
---|
2058 | % |
---|
2059 | % The system has a Boolean that says we are clearing pages: \cmd\clearpage@sw; if it is true, |
---|
2060 | % then at the tail of \cmd\do@startcolumn\ processing, we should put down a (\cmd\vfil?) \cmd\do@newpage@pen\ interrupt. |
---|
2061 | % This is because the MVL is now empty, so we have to force the columns to complete. |
---|
2062 | % |
---|
2063 | % One potential very pathological case would be where there is one or more deferred floats that never successfully get placed: |
---|
2064 | % placing floats has stalled, and we will ship out blank pages indefinitely. How to detect this case? |
---|
2065 | % |
---|
2066 | % First, \cmd\do@startpage\ will evidently be stalled if the following are all true: |
---|
2067 | % a) \cmd\@tryfcolumn\ and \cmd\@sdblcolelt\ both fail, |
---|
2068 | % b) there are deferred floats available for page placement, and |
---|
2069 | % c) the \cmd\@colht=\cmd\textheight, that is, the full page height is available for placement of column floats. |
---|
2070 | % |
---|
2071 | % Second, \cmd\do@startcolumn\ will evidently be stalled if the following are all true: |
---|
2072 | % a) tryfcolumn fails, |
---|
2073 | % b) there are deferred floats available for column placement, and |
---|
2074 | % a) the \cmd\@colroom=\cmd\textheight, that is, the full page height is available for placement of column floats. |
---|
2075 | % |
---|
2076 | % |
---|
2077 | % \begin{macro}{\cleardoublepage} |
---|
2078 | % \begin{macro}{\clearpage} |
---|
2079 | % \begin{macro}{\newpage} |
---|
2080 | % \begin{macro}{\newpage@prep} |
---|
2081 | % The function of \cmd\clearpage\ is to end the current page with \cmd\newpage\ and then |
---|
2082 | % ship out additional pages until (\footins) inserts and (deferred) floats are exhausted. |
---|
2083 | % |
---|
2084 | % The method involves setting the float placement parameters to completely permissive values |
---|
2085 | % and kicking out the current page (using a non-discardable penalty). |
---|
2086 | % A possibly short page will be shipped out, followed |
---|
2087 | % by any number of float pages. However these float pages, because using permissive float placement, |
---|
2088 | % will exhaust all inserts and deferred floats. |
---|
2089 | % |
---|
2090 | % Bug Note: in the code for \cmd\clearpage, the first penalty we output is an unprotected \cmd\pagebreak@pen. |
---|
2091 | % I tried using a protected \cmd\do@newpage@pen, but that gave rise to a corner case where a blank page |
---|
2092 | % was output. |
---|
2093 | % |
---|
2094 | % At present, the \cmd\clearpage\ procedure does the same as \cmd\newpage, |
---|
2095 | % except that \cmd\clearpage@sw\ is turned on, |
---|
2096 | % and the (discardable) \cmd\newpage\ is inevitably followed by the same procedures |
---|
2097 | % that are executed if a page is shipped out. |
---|
2098 | % |
---|
2099 | % FIXME: it seems that better than \cmd\pagebreak@pen\ would be an unprotected penalty of a special value that would |
---|
2100 | % entail output routine processing consisting of the following steps: |
---|
2101 | % 3) \cmd\unvbox\cmd\@cclv, |
---|
2102 | % 1) set \cmd\clearpage@sw\ to \cmd\true@sw, |
---|
2103 | % 2) put down a protected \cmd\do@startcolumn@pen, |
---|
2104 | % 4) take a dead cycle. |
---|
2105 | % |
---|
2106 | % The effect would be to liberalize float placement options for the current column as well as further columns that may be output as part of \cmd\clearpage\ processing. |
---|
2107 | % Of course, it would still be necessary to set \cmd\clearpage@sw\ again via an interrupt. |
---|
2108 | % |
---|
2109 | % An optimization might be to clear \cmd\clearpage@sw\ as part of the same interrupt, |
---|
2110 | % but that would actually not work properly, because it is necessary for \cmd\do@endpage\ to |
---|
2111 | % possibly invoke furhter visits to the output routine before clearpage processing ceases. |
---|
2112 | % \begin{macrocode} |
---|
2113 | \def\newpage@prep{% |
---|
2114 | \if@noskipsec |
---|
2115 | \ifx \@nodocument\relax |
---|
2116 | \leavevmode |
---|
2117 | \global \@noskipsecfalse |
---|
2118 | \fi |
---|
2119 | \fi |
---|
2120 | \if@inlabel |
---|
2121 | \leavevmode |
---|
2122 | \global \@inlabelfalse |
---|
2123 | \fi |
---|
2124 | \if@nobreak \@nobreakfalse \everypar{}\fi |
---|
2125 | \par |
---|
2126 | }% |
---|
2127 | \def \newpage {% |
---|
2128 | \newpage@prep |
---|
2129 | \do@output@MVL{% |
---|
2130 | \vfil |
---|
2131 | \penalty-\pagebreak@pen |
---|
2132 | }% |
---|
2133 | }% |
---|
2134 | \def\clearpage{% |
---|
2135 | \newpage@prep |
---|
2136 | \do@output@MVL{% |
---|
2137 | \vfil |
---|
2138 | \penalty-\pagebreak@pen |
---|
2139 | \global\@booleantrue\clearpage@sw |
---|
2140 | \protect@penalty\do@startcolumn@pen |
---|
2141 | \protect@penalty\do@endpage@pen |
---|
2142 | }% |
---|
2143 | \do@output@MVL{% |
---|
2144 | \global\@booleanfalse\clearpage@sw |
---|
2145 | }% |
---|
2146 | }% |
---|
2147 | \def\cleardoublepage{% |
---|
2148 | \clearpage |
---|
2149 | \@if@sw\if@twoside\fi{% |
---|
2150 | \@ifodd\c@page{}{% |
---|
2151 | \null\clearpage |
---|
2152 | }% |
---|
2153 | }{}% |
---|
2154 | }% |
---|
2155 | \@booleanfalse\clearpage@sw |
---|
2156 | % \end{macrocode} |
---|
2157 | % \end{macro} |
---|
2158 | % \end{macro} |
---|
2159 | % \end{macro} |
---|
2160 | % \end{macro} |
---|
2161 | % |
---|
2162 | % \begin{macro}{\do@endpage@pen} |
---|
2163 | % The penalty \cmd\do@endpage@pen\ simply dispatches to the page grid procedure that forces an end page. |
---|
2164 | % That procedure should test whether there is anything to ship out (say committed floats), then act accordingly. |
---|
2165 | % Note that as part of this work, it should \cmd\unvbox\cmd\@cclv, which has been left boxed up so it can be |
---|
2166 | % measured. |
---|
2167 | % \begin{macrocode} |
---|
2168 | \mathchardef\do@endpage@pen=10007 |
---|
2169 | \@namedef{output@-\the\do@endpage@pen}{% |
---|
2170 | \csname end@column@\thepagegrid\endcsname |
---|
2171 | }% |
---|
2172 | % \end{macrocode} |
---|
2173 | % \end{macro} |
---|
2174 | % |
---|
2175 | % \begin{macro}{\do@newpage@pen} |
---|
2176 | % The penalty \cmd\do@newpage@pen\ allows a ``non-discardable \cmd\newpage'' command: |
---|
2177 | % a \cmd\newpage\ command that will not disappear at a pagebreak. |
---|
2178 | % This visit to the output routine will not be dispatched to an interrupt, |
---|
2179 | % rather the natural output routine will be executed, where it |
---|
2180 | % will remove the protection box. |
---|
2181 | % |
---|
2182 | % Call this routine by executing \cmd\protect@penalty\cmd\do@newpage@pen. |
---|
2183 | % \begin{macrocode} |
---|
2184 | \mathchardef\do@newpage@pen=10001 |
---|
2185 | \expandafter\let\csname output@-\the\do@newpage@pen\endcsname\relax |
---|
2186 | % \end{macrocode} |
---|
2187 | % \end{macro} |
---|
2188 | % |
---|
2189 | % \begin{macro}{\@clearfloatplacement} |
---|
2190 | % The procedure \cmd\@clearfloatplacement\ sets all of the float placement parameters |
---|
2191 | % to completely permissive values. The standard values appear as comments. |
---|
2192 | % \begin{macrocode} |
---|
2193 | \def\@clearfloatplacement{% |
---|
2194 | \global\@topnum \maxdimen % \c@topnumber |
---|
2195 | \global\@toproom \maxdimen % \topfraction\@colht |
---|
2196 | \global\@botnum \maxdimen % \c@bottomnumber |
---|
2197 | \global\@botroom \maxdimen % \bottomfraction\@colht |
---|
2198 | \global\@colnum \maxdimen % \c@totalnumber |
---|
2199 | %\global\@fpmin \z@ % \floatpagefraction\@colht |
---|
2200 | \global\@dbltopnum \maxdimen % \c@dbltopnumber |
---|
2201 | \global\@dbltoproom \maxdimen % \dbltopfraction\@colht |
---|
2202 | \global\@textmin \z@ % \@colht\advance \@textmin -\@dbltoproom |
---|
2203 | \global\@fpmin \z@ % \dblfloatpagefraction\textheight |
---|
2204 | \let\@testfp\@gobble |
---|
2205 | \appdef\@setfloattypecounts{\@fpstype16\advance\@fpstype\m@ne}% |
---|
2206 | }% |
---|
2207 | % \end{macrocode} |
---|
2208 | % \end{macro} |
---|
2209 | % |
---|
2210 | % \begin{macro}{\@doclearpage} |
---|
2211 | % The \cmd\@doclearpage\ procedure is now obsoleted, as is \cmd\@makefcolumn, which it invoked. |
---|
2212 | % \begin{macrocode} |
---|
2213 | \let\@doclearpage\@undefined |
---|
2214 | \let\@makefcolumn\@undefined |
---|
2215 | % \end{macrocode} |
---|
2216 | % \end{macro} |
---|
2217 | % |
---|
2218 | % \begin{macro}{\clr@top@firstmark} |
---|
2219 | % \begin{macro}{\set@top@firstmark} |
---|
2220 | % \begin{macro}{\@outputpage} |
---|
2221 | % We want accurate values of \cmd\topmark\ and \cmd\firstmark, but we must deal with |
---|
2222 | % the fact that there are many different ways of contributing material |
---|
2223 | % to the page. Only upon the first contribution to the page is the value of \cmd\topmark\ |
---|
2224 | % accurate. However, with \cmd\firstmark\ we must potentially examine each contribution |
---|
2225 | % because the first mark on the page may happen to fall in the last piece of material contributed. |
---|
2226 | % |
---|
2227 | % To begin, we define the procedure that initializes the macros to appropriate flag values. |
---|
2228 | % \begin{macrocode} |
---|
2229 | \def\clr@top@firstmark{% |
---|
2230 | \global\let\saved@@topmark\@undefined |
---|
2231 | \global\let\saved@@firstmark\@empty |
---|
2232 | \global\let\saved@@botmark\@empty |
---|
2233 | }% |
---|
2234 | \clr@top@firstmark |
---|
2235 | % \end{macrocode} |
---|
2236 | % |
---|
2237 | % Note that the flag value for \cmd\saved@@topmark\ is \cmd\@undefined, just as one would |
---|
2238 | % expect. But that for \cmd\saved@@firstmark\ and \cmd\saved@@botmark\ is \cmd\@empty. |
---|
2239 | % |
---|
2240 | % Next, we define procedure \cmd\set@top@firstmark; it will be exercised everywhere material is contributed, |
---|
2241 | % capturing the mark values if appropriate. |
---|
2242 | % \begin{macrocode} |
---|
2243 | \def\set@top@firstmark{% |
---|
2244 | \@ifxundefined\saved@@topmark{\expandafter\gdef\expandafter\saved@@topmark\expandafter{\@@topmark}}{}% |
---|
2245 | \@if@empty\saved@@firstmark{\expandafter\gdef\expandafter\saved@@firstmark\expandafter{\@@firstmark}}{}% |
---|
2246 | \@if@empty\@@botmark{}{\expandafter\gdef\expandafter\saved@@botmark\expandafter{\@@botmark}}% |
---|
2247 | }% |
---|
2248 | % \end{macrocode} |
---|
2249 | % When should \cmd\set@top@firstmark\ be called? |
---|
2250 | % A good candidate for a universal procedure for handling contributed material is |
---|
2251 | % the natural output routine; are any other calls needed? |
---|
2252 | % |
---|
2253 | % Yes, in \cmd\save@column\ we must execute \cmd\set@top@firstmark\ because we are about to |
---|
2254 | % save away \cmd\box\cmd\@cclv, and we will never see its marks again (unless it is unboxed into the MVL), |
---|
2255 | % because \TeX\ lets one access a box's marks only within an output routine that has put that box into \cmd\box\cmd\@cclv. |
---|
2256 | % |
---|
2257 | % As soon as a page is shipped out, we initialize the two macros that |
---|
2258 | % hold the values of \cmd\topmark\ and \cmd\firstmark, respectively. |
---|
2259 | % \LaTeX\ has exactly one procedure \cmd\@outputpage\ that does \cmd\shipout, |
---|
2260 | % which is as it should be: we tailpatch it, and the job is done. |
---|
2261 | % \begin{macrocode} |
---|
2262 | \appdef\@outputpage{% |
---|
2263 | \clr@top@firstmark |
---|
2264 | }% |
---|
2265 | % \end{macrocode} |
---|
2266 | % \end{macro} |
---|
2267 | % \end{macro} |
---|
2268 | % \end{macro} |
---|
2269 | % |
---|
2270 | % |
---|
2271 | % \subsection{Other interfaces to \LaTeX}% |
---|
2272 | % |
---|
2273 | % \begin{macro}{\@float} |
---|
2274 | % \begin{macro}{\@dblfloat} |
---|
2275 | % \begin{macro}{\@yfloat} |
---|
2276 | % \begin{macro}{\fps@} |
---|
2277 | % \begin{macro}{\fpsd@} |
---|
2278 | % The \LaTeX\ kernel procedures \cmd\@float\ and \cmd\@dblfloat\ are treated on an equal footing. |
---|
2279 | % Each now takes environment-specific float placement defaults. |
---|
2280 | % If none are defined for the calling environment, we apply a default. |
---|
2281 | % |
---|
2282 | % A parameter is passed that will set the width of text within the float, normally \cmd\columnwidth, |
---|
2283 | % and in the "dbl" version, \cmd\textwidth. However, an environment such as \env{turnpage} |
---|
2284 | % may change the meanings of these macros to allow turnpage floats. |
---|
2285 | % |
---|
2286 | % \begin{macrocode} |
---|
2287 | \def\@float#1{% |
---|
2288 | \@ifnextchar[{%}]{%Brace-matching klootch |
---|
2289 | \@yfloat\width@float{#1}% |
---|
2290 | }{% |
---|
2291 | \@ifxundefined@cs{fps@#1}{% |
---|
2292 | \edef\reserved@a{\noexpand\@yfloat\noexpand\width@float{#1}[\csname fps@\endcsname]}\reserved@a |
---|
2293 | }{% |
---|
2294 | \edef\reserved@a{\noexpand\@yfloat\noexpand\width@float{#1}[\csname fps@#1\endcsname]}\reserved@a |
---|
2295 | }% |
---|
2296 | }% |
---|
2297 | }% |
---|
2298 | \def\@dblfloat#1{% |
---|
2299 | \@ifnum{\pagegrid@col=\@ne}{% |
---|
2300 | \@float{#1}% |
---|
2301 | }{% |
---|
2302 | \@ifnextchar[{%}]{%Brace-matching klootch |
---|
2303 | \@yfloat\widthd@float{#1}% |
---|
2304 | }{% |
---|
2305 | \@ifxundefined@cs{fpsd@#1}{% |
---|
2306 | \edef\reserved@a{\noexpand\@yfloat\noexpand\widthd@float{#1}[\csname fpsd@\endcsname]}\reserved@a |
---|
2307 | }{% |
---|
2308 | \edef\reserved@a{\noexpand\@yfloat\noexpand\widthd@float{#1}[\csname fpsd@#1\endcsname]}\reserved@a |
---|
2309 | }% |
---|
2310 | }% |
---|
2311 | }% |
---|
2312 | }% |
---|
2313 | \def\@yfloat#1#2[#3]{% |
---|
2314 | \@xfloat{#2}[#3]% |
---|
2315 | \hsize#1\linewidth\hsize |
---|
2316 | \minipagefootnote@init |
---|
2317 | }% |
---|
2318 | \def\fps@{tbp}% |
---|
2319 | \def\fpsd@{tp}% |
---|
2320 | \def\width@float{\columnwidth}% |
---|
2321 | \def\widthd@float{\textwidth}% |
---|
2322 | % \end{macrocode} |
---|
2323 | % \end{macro} |
---|
2324 | % \end{macro} |
---|
2325 | % \end{macro} |
---|
2326 | % \end{macro} |
---|
2327 | % \end{macro} |
---|
2328 | % |
---|
2329 | % \begin{macro}{\end@float} |
---|
2330 | % \begin{macro}{\end@dblfloat} |
---|
2331 | % \begin{macro}{\end@@float} |
---|
2332 | % \begin{macro}{\check@currbox@count} |
---|
2333 | % \begin{macro}{\minipagefootnote@init} |
---|
2334 | % \begin{macro}{\minipagefootnote@here} |
---|
2335 | % \LaTeX\ kernel procedures \cmd\end@float\ and \cmd\end@dblfloat\ |
---|
2336 | % have been changed to work alike; in particular, floats of both classes |
---|
2337 | % are deferred into the same queue. |
---|
2338 | % This measure ensures that they will be placed in their original order, |
---|
2339 | % an aspect in which \LaTeX\ is broken. |
---|
2340 | % |
---|
2341 | % Note: when retrieving floats from the queues, we can differentiate those of the two categories |
---|
2342 | % by the width of the box. |
---|
2343 | % |
---|
2344 | % Floats are processed via an output routine message, and are checked for |
---|
2345 | % sanity in re the float placement options. In the case of full-page-width floats, |
---|
2346 | % we ensure that the h and b float placement options are never asserted, because they |
---|
2347 | % make no sense. |
---|
2348 | % |
---|
2349 | % Note that if we get to the end of the float box and still have pending |
---|
2350 | % footnotes, we put then out. |
---|
2351 | % |
---|
2352 | % LaTeX Bug note: if a user types \cmd\begin{table*}[h], the float will never succeed in being placed! |
---|
2353 | % we try to catch such cases. |
---|
2354 | % |
---|
2355 | % Note that the macro \cmd\check@currbox@count\ trys to catch cases where the float placement options |
---|
2356 | % are such that the float can never be placed. |
---|
2357 | % \begin{macrocode} |
---|
2358 | \def\end@float{% |
---|
2359 | \end@@float{% |
---|
2360 | \check@currbox@count |
---|
2361 | }% |
---|
2362 | }% |
---|
2363 | \def\end@dblfloat{% |
---|
2364 | \@ifnum{\pagegrid@col=\@ne}{% |
---|
2365 | \end@float |
---|
2366 | }{% |
---|
2367 | \end@@float{% |
---|
2368 | \@boxfpsbit\@currbox{1}\@ifodd\@tempcnta{\global\advance\count\@currbox\m@ne}{}% |
---|
2369 | \@boxfpsbit\@currbox{4}\@ifodd\@tempcnta{\global\advance\count\@currbox-4\relax}{}% |
---|
2370 | \global\wd\@currbox\textwidth % Klootch |
---|
2371 | \check@currbox@count |
---|
2372 | }% |
---|
2373 | }% |
---|
2374 | }% |
---|
2375 | \def\end@@float#1{% |
---|
2376 | \minipagefootnote@here |
---|
2377 | %\minipagefootnotes |
---|
2378 | \@endfloatbox |
---|
2379 | #1% |
---|
2380 | \@ifnum{\@floatpenalty <\z@}{% |
---|
2381 | \@largefloatcheck |
---|
2382 | \@cons\@currlist\@currbox |
---|
2383 | \@ifnum{\@floatpenalty <-\@Mii}{% |
---|
2384 | \do@output@cclv{\@add@float}% |
---|
2385 | }{% |
---|
2386 | \vadjust{\do@output@cclv{\@add@float}}% |
---|
2387 | \@Esphack |
---|
2388 | }% |
---|
2389 | }{}% |
---|
2390 | }% |
---|
2391 | \def\check@currbox@count{% |
---|
2392 | \@ifnum{\count\@currbox>\z@}{% |
---|
2393 | \count@\count\@currbox\divide\count@\sixt@@n\multiply\count@\sixt@@n |
---|
2394 | \@tempcnta\count\@currbox\advance\@tempcnta-\count@ |
---|
2395 | \@ifnum{\@tempcnta=\z@}{% |
---|
2396 | \ltxgrid@warn{Float cannot be placed}% |
---|
2397 | }{}% |
---|
2398 | }{% |
---|
2399 | % Is a \marginpar |
---|
2400 | }% |
---|
2401 | }% |
---|
2402 | \providecommand\minipagefootnote@init{}% |
---|
2403 | \providecommand\minipagefootnote@here{}% |
---|
2404 | % \end{macrocode} |
---|
2405 | % \end{macro} |
---|
2406 | % \end{macro} |
---|
2407 | % \end{macro} |
---|
2408 | % \end{macro} |
---|
2409 | % \end{macro} |
---|
2410 | % \end{macro} |
---|
2411 | % |
---|
2412 | % \begin{macro}{\@specialoutput} |
---|
2413 | % The \cmd\@add@float\ procedure used to reside in standard \LaTeX's \cmd\@specialoutput, |
---|
2414 | % which is no more. |
---|
2415 | % |
---|
2416 | % Historical Note: \cmd\@specialoutput\ and Lamport's method of an output routine dispatcher |
---|
2417 | % is the genesis of our more powerful and refined way of using \TeX's output routine to |
---|
2418 | % safely accomplish page makeup tasks. To it and to him we owe acknowledgement and thanks. |
---|
2419 | % \begin{macrocode} |
---|
2420 | \let\@specialoutput\@undefined |
---|
2421 | % \end{macrocode} |
---|
2422 | % \end{macro} |
---|
2423 | % |
---|
2424 | % \begin{macro}{\@add@float} |
---|
2425 | % In the following, we do not need to execute \cmd\@reinserts, which was wrong anyway, as you cannot |
---|
2426 | % reliably recover insertions when they split (unless you have a way of reinserting the captured insertion |
---|
2427 | % ahead of the split-off part). |
---|
2428 | % |
---|
2429 | % Now that full-page-width floats are being processed the same as column floats, we |
---|
2430 | % have to nip in here and cause them always to be deferred. |
---|
2431 | % |
---|
2432 | % At the very end, the \cmd\vsize\ is adjusted for any newly committed float. |
---|
2433 | % \begin{macrocode} |
---|
2434 | \def\@add@float{% |
---|
2435 | \@pageht\ht\@cclv\@pagedp\dp\@cclv |
---|
2436 | \unvbox\@cclv |
---|
2437 | \@next\@currbox\@currlist{% |
---|
2438 | \csname @floatselect@sw@\thepagegrid\endcsname\@currbox{% |
---|
2439 | \@ifnum{\count\@currbox>\z@}{% |
---|
2440 | \advance \@pageht \@pagedp |
---|
2441 | \advance \@pageht \vsize \advance \@pageht -\pagegoal % do not assume \holdinginserts is cleared! |
---|
2442 | % \@ifvbox\@kludgeins{% |
---|
2443 | % \@ifdim{\wd\@kludgeins=\z@}{% |
---|
2444 | % \advance \@pageht \ht\@kludgeins |
---|
2445 | % }{}% |
---|
2446 | % }{}% |
---|
2447 | % \@reinserts |
---|
2448 | \@addtocurcol % Commit an h float |
---|
2449 | }{% |
---|
2450 | % \@reinserts |
---|
2451 | \@addmarginpar |
---|
2452 | }% |
---|
2453 | }{% |
---|
2454 | \@resethfps |
---|
2455 | \@cons\@deferlist\@currbox |
---|
2456 | }% |
---|
2457 | }{\@latexbug}% |
---|
2458 | \@ifnum{\outputpenalty<\z@}{% |
---|
2459 | \@if@sw\if@nobreak\fi{% |
---|
2460 | \nobreak |
---|
2461 | }{% |
---|
2462 | \addpenalty \interlinepenalty |
---|
2463 | }% |
---|
2464 | }{}% |
---|
2465 | \set@vsize |
---|
2466 | }% |
---|
2467 | % \end{macrocode} |
---|
2468 | % \end{macro} |
---|
2469 | % |
---|
2470 | % \begin{macro}{\@reinserts} |
---|
2471 | % The \cmd\@reinserts\ procedure of standard \LaTeX\ is now obsoleted. |
---|
2472 | % \begin{macrocode} |
---|
2473 | \let\@reinserts\@undefined |
---|
2474 | % \end{macrocode} |
---|
2475 | % \end{macro} |
---|
2476 | % |
---|
2477 | % \begin{macro}{\@addtocurcol} |
---|
2478 | % We modify the \cmd\@addtocurcol\ procedure of standard \LaTeX\ |
---|
2479 | % so that a float placed ``here'' may break over pages. |
---|
2480 | % \begin{macrocode} |
---|
2481 | \def \@addtocurcol {% |
---|
2482 | \@insertfalse |
---|
2483 | \@setfloattypecounts |
---|
2484 | \ifnum \@fpstype=8 |
---|
2485 | \else |
---|
2486 | \ifnum \@fpstype=24 |
---|
2487 | \else |
---|
2488 | \@flsettextmin |
---|
2489 | \advance \@textmin \@textfloatsheight |
---|
2490 | \@reqcolroom \@pageht |
---|
2491 | \ifdim \@textmin>\@reqcolroom |
---|
2492 | \@reqcolroom \@textmin |
---|
2493 | \fi |
---|
2494 | \advance \@reqcolroom \ht\@currbox |
---|
2495 | \ifdim \@colroom>\@reqcolroom |
---|
2496 | \@flsetnum \@colnum |
---|
2497 | \ifnum \@colnum>\z@ |
---|
2498 | \@bitor\@currtype\@deferlist |
---|
2499 | \if@test |
---|
2500 | \else |
---|
2501 | \@bitor\@currtype\@botlist |
---|
2502 | \if@test |
---|
2503 | \@addtobot |
---|
2504 | \else |
---|
2505 | \ifodd \count\@currbox |
---|
2506 | \advance \@reqcolroom \intextsep |
---|
2507 | \ifdim \@colroom>\@reqcolroom |
---|
2508 | \global \advance \@colnum \m@ne |
---|
2509 | \global \advance \@textfloatsheight \ht\@currbox |
---|
2510 | \global \advance \@textfloatsheight 2\intextsep |
---|
2511 | \@cons \@midlist \@currbox |
---|
2512 | \if@nobreak |
---|
2513 | \nobreak |
---|
2514 | \@nobreakfalse |
---|
2515 | \everypar{}% |
---|
2516 | \else |
---|
2517 | \addpenalty \interlinepenalty |
---|
2518 | \fi |
---|
2519 | \vskip \intextsep |
---|
2520 | \unvbox\@currbox %AO |
---|
2521 | \penalty\interlinepenalty |
---|
2522 | \vskip\intextsep |
---|
2523 | \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi |
---|
2524 | \outputpenalty \z@ |
---|
2525 | \@inserttrue |
---|
2526 | \fi |
---|
2527 | \fi |
---|
2528 | \if@insert |
---|
2529 | \else |
---|
2530 | \@addtotoporbot |
---|
2531 | \fi |
---|
2532 | \fi |
---|
2533 | \fi |
---|
2534 | \fi |
---|
2535 | \fi |
---|
2536 | \fi |
---|
2537 | \fi |
---|
2538 | \if@insert |
---|
2539 | \else |
---|
2540 | \@resethfps |
---|
2541 | \@cons\@deferlist\@currbox |
---|
2542 | \fi |
---|
2543 | }% |
---|
2544 | % \end{macrocode} |
---|
2545 | % \end{macro} |
---|
2546 | % |
---|
2547 | % \begin{macro}{\if@twocolumn} |
---|
2548 | % The \cmd\newif\ switch \cmd\if@twocolumn\ is entirely unused. However its access words are invoked by |
---|
2549 | % \LaTeX's \cmd\document\ procedure, so we de-fang it. |
---|
2550 | % \begin{macrocode} |
---|
2551 | \@twocolumnfalse |
---|
2552 | \let\@twocolumntrue\@twocolumnfalse |
---|
2553 | % \end{macrocode} |
---|
2554 | % \end{macro} |
---|
2555 | % |
---|
2556 | % \begin{macro}{\@addmarginpar} |
---|
2557 | % The procedure \cmd\@addmarginpar\ used to access \cmd\if@twocolumn, but that switch is not reliable; |
---|
2558 | % the better way is to use \cmd\thepagegrid. We establish a convention for a page-grid-oriented |
---|
2559 | % procedure, e.g., \cmd\@addmarginpar@one, that emits a boolean, telling this procedure |
---|
2560 | % whether to set the marginpar on the left or right. |
---|
2561 | % \begin{macrocode} |
---|
2562 | \def\@addmarginpar{% |
---|
2563 | \@next\@marbox\@currlist{% |
---|
2564 | \@cons\@freelist\@marbox\@cons\@freelist\@currbox |
---|
2565 | }\@latexbug |
---|
2566 | \setbox\@marbox\hb@xt@\columnwidth{% |
---|
2567 | \csname @addmarginpar@\thepagegrid\endcsname{% |
---|
2568 | \hskip-\marginparsep\hskip-\marginparwidth |
---|
2569 | \box\@currbox |
---|
2570 | }{% |
---|
2571 | \hskip\columnwidth\hskip\marginparsep |
---|
2572 | \box\@marbox |
---|
2573 | }% |
---|
2574 | \hss |
---|
2575 | }% |
---|
2576 | \setbox\z@\box\@currbox |
---|
2577 | \@tempdima\@mparbottom |
---|
2578 | \advance\@tempdima -\@pageht |
---|
2579 | \advance\@tempdima\ht\@marbox |
---|
2580 | \@ifdim{\@tempdima >\z@}{% |
---|
2581 | \@latex@warning@no@line {Marginpar on page \thepage\space moved}% |
---|
2582 | }{% |
---|
2583 | \@tempdima\z@ |
---|
2584 | }% |
---|
2585 | \global\@mparbottom\@pageht |
---|
2586 | \global\advance\@mparbottom\@tempdima |
---|
2587 | \global\advance\@mparbottom\dp\@marbox |
---|
2588 | \global\advance\@mparbottom\marginparpush |
---|
2589 | \advance\@tempdima -\ht\@marbox |
---|
2590 | \global\setbox \@marbox |
---|
2591 | \vbox {\vskip \@tempdima |
---|
2592 | \box \@marbox}% |
---|
2593 | \global \ht\@marbox \z@ |
---|
2594 | \global \dp\@marbox \z@ |
---|
2595 | \kern -\@pagedp |
---|
2596 | \nointerlineskip |
---|
2597 | \box\@marbox |
---|
2598 | \nointerlineskip |
---|
2599 | \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}% |
---|
2600 | }% |
---|
2601 | % \end{macrocode} |
---|
2602 | % \end{macro} |
---|
2603 | % |
---|
2604 | % \begin{environment}{turnpage} |
---|
2605 | % Any float (viz., \env{figure} or \env{table}) within the scope of this environment |
---|
2606 | % will be a turnpage float: It will be assumed to occupy an entire page (constitute a float page), |
---|
2607 | % the width will be \cmd\textheight, the height \cmd\textwidth, and the entire float will be presented |
---|
2608 | % rotated 90 degrees. |
---|
2609 | % |
---|
2610 | % The implementation requires the services of the \cmd\rotatebox\ command, so we supply a dummy definition |
---|
2611 | % that explains things to the user. |
---|
2612 | % \begin{macrocode} |
---|
2613 | \newenvironment{turnpage}{% |
---|
2614 | \def\width@float{\textheight}% |
---|
2615 | \def\widthd@float{\textheight}% |
---|
2616 | \appdef\@endfloatbox{% |
---|
2617 | \@ifxundefined\@currbox{% |
---|
2618 | \ltxgrid@warn{Cannot rotate! Not a float}% |
---|
2619 | }{% |
---|
2620 | \setbox\@currbox\vbox to\textwidth{\vfil\unvbox\@currbox\vfil}% |
---|
2621 | \global\setbox\@currbox\vbox{\rotatebox{90}{\box\@currbox}}% |
---|
2622 | }% |
---|
2623 | }% |
---|
2624 | }{% |
---|
2625 | }% |
---|
2626 | \def\rotatebox@dummy#1#2{% |
---|
2627 | \ltxgrid@warn{You must load the graphics or graphicx package in order to use the turnpage environment}% |
---|
2628 | #2% |
---|
2629 | }% |
---|
2630 | \AtBeginDocument{% |
---|
2631 | \@ifxundefined\rotatebox{\let\rotatebox\rotatebox@dummy}{}% |
---|
2632 | }% |
---|
2633 | % \end{macrocode} |
---|
2634 | % \end{environment} |
---|
2635 | % |
---|
2636 | % |
---|
2637 | % \subsection{One-off output routines} |
---|
2638 | % |
---|
2639 | % These procedures are executed in lieu of \cmd\the\cmd\output\ when the output penalty has the associated flag value. |
---|
2640 | % |
---|
2641 | % \begin{macro}{output@-1073741824} |
---|
2642 | % The first one-off output routine handles the end of the job, wherein |
---|
2643 | % \LaTeX\ executes \cmd\@@end, and breaks to the output with a penalty of |
---|
2644 | % $"40000000 = 2^{32}/4$. We simply discard \cmd\box\cmd\@cclv\ and leave. |
---|
2645 | % This means that \LaTeX\ is obligated to do \cmd\clearpage\ as part of |
---|
2646 | % its \enve{document} processing, otherwise material will be lost. |
---|
2647 | % \begin{macrocode} |
---|
2648 | \@namedef{output@-1073741824}{%"40000000 |
---|
2649 | \deadcycles\z@ |
---|
2650 | %\showbox\@cclv |
---|
2651 | \setbox\z@\box\@cclv |
---|
2652 | }% |
---|
2653 | % \end{macrocode} |
---|
2654 | % \end{macro} |
---|
2655 | % |
---|
2656 | % \begin{macro}{\save@column@pen} |
---|
2657 | % The one-off output routine associated with \cmd\penalty\cmd\save@column@pen\ |
---|
2658 | % will be called within a sequence of three such routines by \cmd\execute@message |
---|
2659 | % or its companion routine \cmd\execute@message@insert. |
---|
2660 | % This procedure must save away any the current page and preserve marks. |
---|
2661 | % \begin{macrocode} |
---|
2662 | \mathchardef\save@column@pen=10016 |
---|
2663 | \@namedef{output@-\the\save@column@pen}{\save@column}% |
---|
2664 | % \end{macrocode} |
---|
2665 | % \end{macro} |
---|
2666 | % |
---|
2667 | % \begin{macro}{\@cclv@saved} |
---|
2668 | % We take over the \cmd\@holdpg\ box register. Hereafter, |
---|
2669 | % we no longer use the \cmd\@holdpg\ box register, so let the world know. |
---|
2670 | % This should decisively break packages that assume standard \LaTeX. |
---|
2671 | % Breaking decisively is preferred to quietly proceeding erroneously. |
---|
2672 | % \begin{macrocode} |
---|
2673 | \let \@cclv@saved \@holdpg |
---|
2674 | \let \@holdpg \@undefined |
---|
2675 | % \end{macrocode} |
---|
2676 | % \end{macro} |
---|
2677 | % |
---|
2678 | % \begin{macro}{\save@column} |
---|
2679 | % The procedure \cmd\save@column\ does the actual work of saving away the material |
---|
2680 | % on the page. It is invoked both by \cmd\save@column@pen\ and by \cmd\save@column@insert@pen. |
---|
2681 | % We save \cmd\box\cmd\@cclv\ and the primitive \cmd\@@topmark. |
---|
2682 | % \begin{macrocode} |
---|
2683 | \def\save@column{% |
---|
2684 | \@ifvoid\@cclv@saved{% |
---|
2685 | \set@top@firstmark |
---|
2686 | \global\@topmark@saved\expandafter{\@@topmark}% |
---|
2687 | }{}% |
---|
2688 | \global\setbox\@cclv@saved\vbox{% |
---|
2689 | \@ifvoid\@cclv@saved{}{% |
---|
2690 | \unvbox\@cclv@saved |
---|
2691 | \marry@baselines |
---|
2692 | }% |
---|
2693 | \unvbox\@cclv |
---|
2694 | \lose@breaks |
---|
2695 | \setbox\z@\lastbox |
---|
2696 | }% |
---|
2697 | }% |
---|
2698 | \newtoks\@topmark@saved |
---|
2699 | % \end{macrocode} |
---|
2700 | % \end{macro} |
---|
2701 | % |
---|
2702 | % \begin{macro}{\prep@cclv} |
---|
2703 | % The procedure \cmd\prep@cclv\ is used by message handlers to set up their environment |
---|
2704 | % to ape that of the usual output routine, with the boxed-up page in \cmd\box\cmd\@cclv. |
---|
2705 | % Here, we retrieve the material from \cmd\@cclv@saved, where it was saved away by |
---|
2706 | % the one-off output routine associated with \cmd\save@column@pen. |
---|
2707 | % \begin{macrocode} |
---|
2708 | \def\prep@cclv{% |
---|
2709 | \setbox\z@\box\@cclv |
---|
2710 | \setbox\@cclv\box\@cclv@saved |
---|
2711 | \vbadness\@M |
---|
2712 | }% |
---|
2713 | % \end{macrocode} |
---|
2714 | % \end{macro} |
---|
2715 | % |
---|
2716 | % \begin{macro}{\save@column@insert@pen} |
---|
2717 | % The one-off output routine associated with \cmd\penalty\cmd\save@column@insert@pen\ |
---|
2718 | % is similar to that of \cmd\save@column@pen\ augmented with the processing of insertions. |
---|
2719 | % It is called by \cmd\execute@message@insert\ (i.e., at a grid change) |
---|
2720 | % and saves away the current page and preserves marks. |
---|
2721 | % In addition, it saves away any insertions that fall on the current page. |
---|
2722 | % As with the regular output routine, it executes in two phases, |
---|
2723 | % first with \cmd\holdinginserts\ set, then with it cleared. |
---|
2724 | % \begin{macrocode} |
---|
2725 | \mathchardef\save@column@insert@pen=10017 |
---|
2726 | \@namedef{output@-\the\save@column@insert@pen}{\toggle@insert\savecolumn@holding\savecolumn@moving}% |
---|
2727 | % \end{macrocode} |
---|
2728 | % The procedure \cmd\savecolumn@holding\ is the first phase of saving a column with its inserts. |
---|
2729 | % This phase must detect and remedy the one circumstance that will confound our efforts to propagate marks. |
---|
2730 | % It is similar to \cmd\output@holding, except that we have to deal with the protection box, which must |
---|
2731 | % remain, because the messaging mechanism is being used. |
---|
2732 | % |
---|
2733 | % If it appears that we have the pathological ``Big Bad Box'' case at hand, we use the \cmd\dead@cycle@repair@protected\ |
---|
2734 | % procedure instead of \cmd\dead@cycle\ to do our dead cycle. |
---|
2735 | % \begin{macrocode} |
---|
2736 | \def\savecolumn@holding{% |
---|
2737 | \@if@exceed@pagegoal{\unvcopy\@cclv\setbox\z@\lastbox}{% |
---|
2738 | \setbox\z@\vbox{\unvcopy\@cclv\setbox\z@\lastbox}% |
---|
2739 | \outputdebug@sw{{\tracingall\scrollmode\showbox\z@}}{}% |
---|
2740 | \dimen@\ht\@cclv\advance\dimen@-\ht\z@ |
---|
2741 | \dead@cycle@repair@protected\dimen@ |
---|
2742 | }{% |
---|
2743 | \dead@cycle |
---|
2744 | }% |
---|
2745 | }% |
---|
2746 | % \end{macrocode} |
---|
2747 | % The procedure \cmd\save@column@moving\ is the second phase of saving a column with its inserts. |
---|
2748 | % Now that \cmd\holdinginserts\ is cleared, we can look in the various \cmd\insert\ registers for |
---|
2749 | % our inserts (at present there is only one, \cmd\footins). |
---|
2750 | % if anything is there, we save it away and ask for another cycle (because it may have split). |
---|
2751 | % |
---|
2752 | % Note that the message that is about to be executed had better deal properly with the contents of |
---|
2753 | % the \cmd\footins@saved\ box. |
---|
2754 | % \begin{macrocode} |
---|
2755 | \def\savecolumn@moving{% |
---|
2756 | \@cclv@nontrivial@sw{% |
---|
2757 | \save@column |
---|
2758 | }{% |
---|
2759 | {\setbox\z@\box\@cclv}% |
---|
2760 | }% |
---|
2761 | \@ifvoid\footins{}{% |
---|
2762 | \outputdebug@sw{{\tracingall\scrollmode\showbox\footins}}{}% |
---|
2763 | \global\setbox\footins@saved\vbox{\unvbox\footins@saved\marry@baselines\unvbox\footins}% |
---|
2764 | \protect@penalty\save@column@insert@pen |
---|
2765 | }% |
---|
2766 | }% |
---|
2767 | \newbox\footins@saved |
---|
2768 | % \end{macrocode} |
---|
2769 | % \end{macro} |
---|
2770 | % |
---|
2771 | % \begin{macro}{\save@message@pen} |
---|
2772 | % The one-off output routine associated with \cmd\penalty\cmd\save@message@pen\ |
---|
2773 | % saves away the message that has been passed. |
---|
2774 | % This procedure is penultimate in a sequence of one-off output routine calls; |
---|
2775 | % earlier ones have saved away the MVL and preserved marks, the last executes the message. |
---|
2776 | % |
---|
2777 | % Note that we are passing tokens to \TeX's primitive \cmd\mark\ mechanism, so we must ensure |
---|
2778 | % that they are not inappropriately expanded. We use the same mechanism for all such cases, |
---|
2779 | % namely \cmd\let@mark. |
---|
2780 | % |
---|
2781 | % Note: we expect that \cmd\box\cmd\@cclv's contents are well known: |
---|
2782 | % \cmd\topskip, protection box, and a \cmd\mark, the latter havin the |
---|
2783 | % message. |
---|
2784 | % But if we came here via \cmd\penalty 10017, there might be an \cmd\insert\ node here as well, because |
---|
2785 | % a footnote split. |
---|
2786 | % Because this procedure simply voids out \cmd\box\cmd\@cclv, such material would be lost. |
---|
2787 | % Perhaps we can repair things by manipulating the \cmd\insert \ mechanism temporarily. |
---|
2788 | % \begin{macrocode} |
---|
2789 | \mathchardef\save@message@pen=10018 |
---|
2790 | \@namedef{output@-\the\save@message@pen}{\save@message}% |
---|
2791 | \def\save@message{% |
---|
2792 | \setbox\z@\box\@cclv %FIXME: what if \box\@cclv is not empty? |
---|
2793 | \toks@\expandafter{\@@firstmark}% |
---|
2794 | \expandafter\gdef\expandafter\@message@saved\expandafter{\the\toks@}% |
---|
2795 | \expandafter\do@@mark\expandafter{\the\@topmark@saved}% |
---|
2796 | }% |
---|
2797 | \gdef\@message@saved{}% |
---|
2798 | % \end{macrocode} |
---|
2799 | % \end{macro} |
---|
2800 | % |
---|
2801 | % \begin{macro}{\execute@message@pen} |
---|
2802 | % The one-off output routine associated with \cmd\execute@message@pen\ |
---|
2803 | % simply executes the given message. It is last in a sequence of one-off output routine calls; |
---|
2804 | % earlier ones have saved all that require saving. |
---|
2805 | % \begin{macrocode} |
---|
2806 | \mathchardef\execute@message@pen=10019 |
---|
2807 | \@namedef{output@-\the\execute@message@pen}{\@message@saved}% |
---|
2808 | % \end{macrocode} |
---|
2809 | % \end{macro} |
---|
2810 | % |
---|
2811 | % |
---|
2812 | % \subsection{Output messages} |
---|
2813 | % |
---|
2814 | % Message handlers are procedures that execute output messages, tokens that are passed to |
---|
2815 | % the output routine for execution in an environment appropriate to page makeup. |
---|
2816 | % |
---|
2817 | % How it works. We put down three large negative penalties, each of which will be handled by |
---|
2818 | % the output dispatcher (not the output routine), each penalty being protected by |
---|
2819 | % a removable, non-discardable item (i.e., a box). |
---|
2820 | % Either three or four invocations of one-off output routines are involved per message. |
---|
2821 | % |
---|
2822 | % We make the last of the three protection boxes have a depth equal to the value of \cmd\prevdepth\ |
---|
2823 | % that was current when the procedure is called. This effectively restores \cmd\prevdepth. |
---|
2824 | % |
---|
2825 | % In each case, the one-off output routine will remove the extraneous box we have inserted. |
---|
2826 | % And the second and third one-off routines will simply void \cmd\box\cmd\@cclv, because its contents |
---|
2827 | % are entirely artificial. |
---|
2828 | % |
---|
2829 | % FIXME: not so! If \cmd\holdinginserts\ is cleared, that box may have an insert node; it must be preserved, too. |
---|
2830 | % |
---|
2831 | % The first routine saves away the current column contents and remembers the \cmd\topmark\ for later |
---|
2832 | % use. There is a variant routine that first clears \cmd\holdinginserts, so that the message can |
---|
2833 | % handle any inserts present in the boxed-up page; this of course entails yet another |
---|
2834 | % visit to the output routine. |
---|
2835 | % |
---|
2836 | % The penultimate routine saves away the tokens transmitted in via the \cmd\@@mark: the argument of |
---|
2837 | % the macro. These tokens are of course the very thing we wish to execute within the safety |
---|
2838 | % of the output routine. It also puts down a mark containing the \cmd\topmark\ tokens saved |
---|
2839 | % by the first routine. By this means, the mark, which we have clobbered, is restored. |
---|
2840 | % |
---|
2841 | % The last routine simply executes the given tokens. |
---|
2842 | % In the course of doing this, it must take care of \cmd\box\cmd\@cclv, either by shipping it out, |
---|
2843 | % or by \cmd\unvbox ing it onto the MVL. |
---|
2844 | % |
---|
2845 | % \begin{macro}{\execute@message} |
---|
2846 | % The procedure \cmd\execute@message\ simply calls the utility procedure \cmd\@execute@message\ |
---|
2847 | % with a penalty value for the standard treatment. |
---|
2848 | % \begin{macrocode} |
---|
2849 | \def\execute@message{% |
---|
2850 | \@execute@message\save@column@pen %Implicit #2 |
---|
2851 | }% |
---|
2852 | % \end{macrocode} |
---|
2853 | % \end{macro} |
---|
2854 | % |
---|
2855 | % \begin{macro}{\execute@message@insert} |
---|
2856 | % The procedure \cmd\execute@message@insert\ is like \cmd\execute@message\ in all respects |
---|
2857 | % except that the penalty value is \cmd\save@column@insert@pen, which arranges for the |
---|
2858 | % message handler involved to deal with the page's insertions. |
---|
2859 | % At the same time, we prepare the \cmd\footins\ box so that these insertions can be dealt with. |
---|
2860 | % |
---|
2861 | % Note: |
---|
2862 | % If more insertions are added to \LaTeX\ (presumably via \cmd\newinsert), then they |
---|
2863 | % must be dealt with in a way entirely analogous to \cmd\footins. |
---|
2864 | % \begin{macrocode} |
---|
2865 | \def\execute@message@insert#1{% |
---|
2866 | \@execute@message\save@column@insert@pen{\setbox\footins\box\footins@saved#1}% |
---|
2867 | }% |
---|
2868 | % \end{macrocode} |
---|
2869 | % \end{macro} |
---|
2870 | % |
---|
2871 | % \begin{macro}{\@execute@message} |
---|
2872 | % The utility procedure \cmd\@execute@message\ is called by \cmd\execute@message\ and \cmd\execute@message@insert. |
---|
2873 | % We prepare by creating a \cmd\vbox\ containing all the needed nodes and proceed by simply |
---|
2874 | % \cmd\unvbox ing that box onto the MVL. |
---|
2875 | % We ensure that \cmd\box\cmd\@cclv\ is properly set up for the output message handler |
---|
2876 | % by always inserting \cmd\prep@cclv\ in advance of the argument. |
---|
2877 | % |
---|
2878 | % Note that each one-off output routine is invoked effectively the same as |
---|
2879 | % \cmd\protect@penalty, except that the second invocation involves an additional |
---|
2880 | % \cmd\mark\ node, and the third a specially prepared protection box. |
---|
2881 | % |
---|
2882 | % Note also that \TeX's primitive \cmd\mark\ is called here without any expansion protection. |
---|
2883 | % This is the only place where it is called that way, but it's OK because those tokens |
---|
2884 | % have have been pre-expanded by procedures that call \cmd\execute@message. |
---|
2885 | % FIXME: all procedures calling \cmd\execute@message\ must pre-expand their tokens! |
---|
2886 | % \begin{macrocode} |
---|
2887 | \long\def\@execute@message#1#2{% |
---|
2888 | \begingroup |
---|
2889 | \dimen@\prevdepth\@ifdim{\dimen@<\z@}{\dimen@\z@}{}% |
---|
2890 | \setbox\z@\vbox{% |
---|
2891 | \protect@penalty#1% |
---|
2892 | \protection@box |
---|
2893 | \toks@{\prep@cclv#2}% |
---|
2894 | \@@mark{\the\toks@}% |
---|
2895 | \penalty-\save@message@pen |
---|
2896 | % \hbox{\vrule\@height\z@\@width\z@\@depth\dimen@}% |
---|
2897 | \setbox\z@\null\dp\z@\dimen@\ht\z@-\dimen@ |
---|
2898 | \nointerlineskip\box\z@ |
---|
2899 | \penalty-\execute@message@pen |
---|
2900 | }\unvbox\z@ |
---|
2901 | \endgroup |
---|
2902 | }% |
---|
2903 | % \end{macrocode} |
---|
2904 | % \end{macro} |
---|
2905 | % |
---|
2906 | % \begin{macro}{\do@output@cclv} |
---|
2907 | % The procedure \cmd\do@output@cclv\ provides access to message handlers at their simplest. |
---|
2908 | % The message will execute in the usual environment of the output routine, with |
---|
2909 | % the boxed-up page in \cmd\box\cmd\@cclv, and we assume that \cmd\holdinginserts\ remains set. |
---|
2910 | % This procedure must be invoked within main vertical mode; |
---|
2911 | % it is the obligation of the macro writer to ensure that this is the case. |
---|
2912 | % \begin{macrocode} |
---|
2913 | \def\do@output@cclv{\execute@message}% |
---|
2914 | % \end{macrocode} |
---|
2915 | % \end{macro} |
---|
2916 | % |
---|
2917 | % \begin{macro}{\do@output@MVL} |
---|
2918 | % The procedure \cmd\do@output@MVL, like \cmd\do@output@cclv, is an interface for messages, |
---|
2919 | % but provides two additional services: the command may also be invoked in horizontal mode, and |
---|
2920 | % the message handler will execute with the MVL unboxed. |
---|
2921 | % \begin{macrocode} |
---|
2922 | \def\do@output@MVL#1{% |
---|
2923 | \@ifvmode{% |
---|
2924 | \begingroup\execute@message{\unvbox\@cclv#1}\endgroup |
---|
2925 | }{% |
---|
2926 | \@ifhmode{% |
---|
2927 | \vadjust{\execute@message{\unvbox\@cclv#1}}% |
---|
2928 | }{% |
---|
2929 | \@latexerr{\string\do@output@MVL\space cannot be executed in this mode!}\@eha |
---|
2930 | }% |
---|
2931 | }% |
---|
2932 | }% |
---|
2933 | % \end{macrocode} |
---|
2934 | % \end{macro} |
---|
2935 | % |
---|
2936 | % \begin{macro}{\lose@breaks} |
---|
2937 | % The purpose of this procedure is to get rid of all the extraneous |
---|
2938 | % \cmd\penalty\cmd\@M\ nodes that tend to build up in the MVL. |
---|
2939 | % \begin{macrocode} |
---|
2940 | \def\lose@breaks{% |
---|
2941 | \loopwhile{% |
---|
2942 | \count@\lastpenalty |
---|
2943 | \@ifnum{\count@=\@M}{% 10000 is a TeX magic number! |
---|
2944 | \unpenalty\true@sw |
---|
2945 | }{% |
---|
2946 | \false@sw |
---|
2947 | }% |
---|
2948 | }% |
---|
2949 | }% |
---|
2950 | % \end{macrocode} |
---|
2951 | % \end{macro} |
---|
2952 | % |
---|
2953 | % \begin{macro}{\removestuff} |
---|
2954 | % \cmd\removestuff\ is a document-level command that removes the bottom skip glue item |
---|
2955 | % from the MVL. |
---|
2956 | % \begin{macrocode} |
---|
2957 | \def\removestuff{\do@output@MVL{\unskip\unpenalty}}% |
---|
2958 | % \end{macrocode} |
---|
2959 | % \end{macro} |
---|
2960 | % |
---|
2961 | % \begin{macro}{\removephantombox} |
---|
2962 | % The procedure \cmd\removephantombox\ is a special-purpose message handler exclusively for |
---|
2963 | % preventing incorrect spacing above display math. It must be issued in |
---|
2964 | % horizontal mode within the phantom paragraph generated when display math starts up in |
---|
2965 | % vertical mode. |
---|
2966 | % \begin{macrocode} |
---|
2967 | \def\removephantombox{% |
---|
2968 | \vadjust{% |
---|
2969 | \execute@message{% |
---|
2970 | \unvbox\@cclv |
---|
2971 | \setbox\z@\lastbox |
---|
2972 | \unskip |
---|
2973 | \unskip |
---|
2974 | \unpenalty |
---|
2975 | \penalty\predisplaypenalty |
---|
2976 | \vskip\abovedisplayskip |
---|
2977 | }% |
---|
2978 | }% |
---|
2979 | }% |
---|
2980 | % \end{macrocode} |
---|
2981 | % \end{macro} |
---|
2982 | % |
---|
2983 | % \begin{macro}{\addstuff} |
---|
2984 | % \cmd\addstuff\ is a document-level command that adds penalty, glue, or both to the |
---|
2985 | % MVL. The penalty and glue items are rearranged so that all penalties nodes precede all the glue nodes, |
---|
2986 | % which is the canonical arrangement. |
---|
2987 | % \begin{macrocode} |
---|
2988 | \def\addstuff#1#2{\edef\@tempa{\noexpand\do@output@MVL{\noexpand\@addstuff{#1}{#2}}}\@tempa}% |
---|
2989 | \def\@addstuff#1#2{% |
---|
2990 | \skip@\lastskip\unskip |
---|
2991 | \count@\lastpenalty\unpenalty |
---|
2992 | \@if@empty{#1}{}{\penalty#1\relax}% |
---|
2993 | \@ifnum{\count@=\z@}{}{\penalty\count@}% |
---|
2994 | \vskip\skip@ |
---|
2995 | \@if@empty{#2}{}{\vskip#2\relax}% |
---|
2996 | }% |
---|
2997 | % \end{macrocode} |
---|
2998 | % \end{macro} |
---|
2999 | % |
---|
3000 | % \begin{macro}{\replacestuff} |
---|
3001 | % \cmd\replacestuff\ is a document-level command similar to \cmd\addstuff; |
---|
3002 | % but it replaces penalty, glue, or both in the MVL. |
---|
3003 | % The penalty and glue items are rearranged so that all penalties nodes precede all the glue nodes, |
---|
3004 | % which is the canonical arrangement. |
---|
3005 | % \begin{macrocode} |
---|
3006 | \def\replacestuff#1#2{\edef\@tempa{\noexpand\do@output@MVL{\noexpand\@replacestuff{#1}{#2}}}\@tempa}% |
---|
3007 | \def\@replacestuff#1#2{% |
---|
3008 | \skip@\lastskip\unskip |
---|
3009 | \count@\lastpenalty\unpenalty |
---|
3010 | \@if@empty{#1}{}{% |
---|
3011 | \@ifnum{\count@>\@M}{}{% |
---|
3012 | \@ifnum{\count@=\z@}{\count@=#1\relax}{% |
---|
3013 | \@ifnum{\count@<#1\relax}{}{% |
---|
3014 | \count@=#1\relax |
---|
3015 | }% |
---|
3016 | }% |
---|
3017 | }% |
---|
3018 | }% |
---|
3019 | \@ifnum{\count@=\z@}{}{\penalty\count@}% |
---|
3020 | \@if@empty{#2}{}{% |
---|
3021 | \@tempskipa#2\relax |
---|
3022 | \@ifdim{\z@>\@tempskipa}{% |
---|
3023 | \advance\skip@-\@tempskipa |
---|
3024 | }{% |
---|
3025 | \@ifdim{\skip@>\@tempskipa}{}{% |
---|
3026 | \skip@\@tempskipa |
---|
3027 | }% |
---|
3028 | }% |
---|
3029 | }% |
---|
3030 | \vskip\skip@ |
---|
3031 | }% |
---|
3032 | % \end{macrocode} |
---|
3033 | % \end{macro} |
---|
3034 | % |
---|
3035 | % \begin{macro}{\move@insertions} |
---|
3036 | % \begin{macro}{\hold@insertions} |
---|
3037 | % \begin{macro}{\move@insert@sw} |
---|
3038 | % In order to avoid bolluxing up \cmd\insert\ registers by our one-off |
---|
3039 | % output routines, we set \cmd\holdinginserts\ to zero by default and only |
---|
3040 | % clear it (briefly) while we handle cases where we want inserts to show up. |
---|
3041 | % \begin{macrocode} |
---|
3042 | \def\move@insertions{\global\holdinginserts\z@}% |
---|
3043 | \def\hold@insertions{\global\holdinginserts\@ne}% |
---|
3044 | \hold@insertions |
---|
3045 | \def\move@insert@sw{\@ifnum{\holdinginserts=\z@}}% |
---|
3046 | \def\toggle@insert#1#2{% |
---|
3047 | \@ifnum{\holdinginserts=\z@}{\hold@insertions#2}{\move@insertions#1}% |
---|
3048 | }% |
---|
3049 | % \end{macrocode} |
---|
3050 | % \end{macro} |
---|
3051 | % \end{macro} |
---|
3052 | % \end{macro} |
---|
3053 | % |
---|
3054 | % |
---|
3055 | % \subsection{Messages to alter the page grid}% |
---|
3056 | % |
---|
3057 | % Here is the implementation of the grid-switching procedures. |
---|
3058 | % We perform two checks when changing the page grid; first to ensure that |
---|
3059 | % the target page grid is known (defensive programming), second to ensure that |
---|
3060 | % the switch is a non-trivial one. The latter check must be performed within |
---|
3061 | % the safety of the output routine, so requires using an output message. |
---|
3062 | % Thus, a grid change requires two messages, for a total of six visits to the output routine. |
---|
3063 | % |
---|
3064 | % \begin{macro}{\do@columngrid} |
---|
3065 | % Utility procedure \cmd\do@columngrid\ changes the page grid. |
---|
3066 | % Note that this command forces an end to the current paragraph. This is necessary, because |
---|
3067 | % a page grid change makes no sense unless we can alter the \cmd\hsize\ before commencing to |
---|
3068 | % typeset the following paragraph. So the command should never be executed in horizontal mode |
---|
3069 | % anyway. |
---|
3070 | % \begin{macrocode} |
---|
3071 | \def\do@columngrid#1#2{% |
---|
3072 | \par |
---|
3073 | \expandafter\let\expandafter\@tempa\csname open@column@#1\endcsname |
---|
3074 | \@ifx{\relax\@tempa}{% |
---|
3075 | \ltxgrid@warn{Unknown page grid #1. No action taken}% |
---|
3076 | }{% |
---|
3077 | \do@output@MVL{\start@column{#1}{#2}}% |
---|
3078 | }% |
---|
3079 | }% |
---|
3080 | % \end{macrocode} |
---|
3081 | % \end{macro} |
---|
3082 | % |
---|
3083 | % \begin{macro}{\start@column} |
---|
3084 | % Procedure \cmd\start@column\ lays down the interrupts to switch the page grid. |
---|
3085 | % If the change to the page grid would have been trivial, it bails out. |
---|
3086 | % It seems a reasonable tradeoff of processing versus security: once we commit |
---|
3087 | % to changing the page grid, we clear \cmd\holdinginserts, so there is no turning back. |
---|
3088 | % |
---|
3089 | % Note that the second argument to the macro allows us to pass an argument to the |
---|
3090 | % page grid that is starting up. This can be handy, because a single procedure can |
---|
3091 | % handle multiple page grids, differing only by the value of a parameter. |
---|
3092 | % |
---|
3093 | % FIXME: this means that you cannot switch between mlt page grids in a single step. |
---|
3094 | % But do we want to do this, at all, at all? |
---|
3095 | % \begin{macrocode} |
---|
3096 | \def\start@column#1#2{% |
---|
3097 | \def\@tempa{#1}\@ifx{\@tempa\thepagegrid}{% |
---|
3098 | \ltxgrid@info{Already in page grid \thepagegrid. No action taken}% |
---|
3099 | }{% |
---|
3100 | \expandafter\execute@message@insert |
---|
3101 | \expandafter{% |
---|
3102 | \csname shut@column@\thepagegrid\expandafter\endcsname |
---|
3103 | \csname open@column@#1\endcsname{#2}% |
---|
3104 | \set@vsize |
---|
3105 | }% |
---|
3106 | }% |
---|
3107 | }% |
---|
3108 | % \end{macrocode} |
---|
3109 | % \end{macro} |
---|
3110 | % |
---|
3111 | % \begin{macro}{\thepagegrid} |
---|
3112 | % The macro \cmd\thepagegrid\ tracks what kind of page grid we are in. |
---|
3113 | % |
---|
3114 | % Note: Access \cmd\thepagegrid\ only within the safety of the output routine. |
---|
3115 | % |
---|
3116 | % Warning: The page grid should be changed only within the safety of the output routine. |
---|
3117 | % People who write multicol page grid mechanisms appear not to understand the matter, so they |
---|
3118 | % should particularly heed this warning. Think about it: obviously Lamport did so, which is why |
---|
3119 | % his \cmd\twocolumn\ command forced a pagebreak, which is limiting, but safe. |
---|
3120 | % \begin{macrocode} |
---|
3121 | \def\thepagegrid{one}% |
---|
3122 | % \end{macrocode} |
---|
3123 | % \end{macro} |
---|
3124 | % |
---|
3125 | % |
---|
3126 | % \subsection{Application Note: implementing a page grid} |
---|
3127 | % |
---|
3128 | % If you want to create a new page grid for \LaTeX, |
---|
3129 | % you must define five procedures with specific names: |
---|
3130 | % \cmd\open@column@ name, \cmd\shut@column@ name, \cmd\end@column@ name, |
---|
3131 | % \cmd\output@column@ name, and \cmd\@addmarginpar@ name, where ``name'' is the |
---|
3132 | % name of your page grid. |
---|
3133 | % |
---|
3134 | % The procedure \cmd\open@column@ name starts the new page grid. It should define \cmd\thepagegrid, |
---|
3135 | % deal with \cmd\box\cmd\pagesofar\ and \cmd\box\cmd\footbox\ (perhaps by leaving them alone), |
---|
3136 | % and it should set the values of \LaTeX's page layout parameters for the column size and height. |
---|
3137 | % |
---|
3138 | % The procedure \cmd\shut@column@ name should expect to be called with \cmd\holdinginserts\ |
---|
3139 | % cleared (it can assume that \cmd\holdinginserts\ will automatically be restored). |
---|
3140 | % It should properly deal with insertions (like footnotes); calling \cmd\@makecol\ |
---|
3141 | % is a good way to do this. It should know that the page grid is being terminated |
---|
3142 | % in the middle of a page, so it should make arrangements to carry the footnotes down to the |
---|
3143 | % bottom of the column or page, and it should possibly salt away the material for later |
---|
3144 | % incorporation into the page. The box registers \cmd\footbox\ and \cmd\pagesofar\ are customarily used |
---|
3145 | % for this purpose. |
---|
3146 | % |
---|
3147 | % The procedure \cmd\end@column@ name should kick out a possibly short page containing all the |
---|
3148 | % floats committed to the page. It will be invoked during \cmd\clearpage\ processing. |
---|
3149 | % After that, it should \cmd\unvbox\cmd\@cclv. |
---|
3150 | % |
---|
3151 | % The procedure \cmd\output@column@ name should ship out or commit the current \cmd\@outputbox. |
---|
3152 | % In a one-column layout, you ship out; in a multicolumn layout, you commit the box as the contents |
---|
3153 | % of a particular column, and if that column is the last, you ship out. |
---|
3154 | % |
---|
3155 | % The procedure \cmd\@addmarginpar@ name should return a boolean (either \cmd\true@sw\ or \cmd\false@sw\ or an equivalent) |
---|
3156 | % to tell the marginpar mechanism to place the marginal material to the right or left, respectively. |
---|
3157 | % |
---|
3158 | % You can use the existing page grids ``one'' and ``mlt'' as a point of departure for creating others. |
---|
3159 | % The former can be the basis for, say, a single-column page grid with a side column. |
---|
3160 | % |
---|
3161 | % \begin{macro}{\pagesofar} |
---|
3162 | % \begin{macro}{\footbox} |
---|
3163 | % \begin{macrocode} |
---|
3164 | \newbox\pagesofar |
---|
3165 | \newbox\footbox |
---|
3166 | % \end{macrocode} |
---|
3167 | % \end{macro} |
---|
3168 | % \end{macro} |
---|
3169 | % |
---|
3170 | % |
---|
3171 | % \subsubsection{One-column page grid} |
---|
3172 | % |
---|
3173 | % \begin{macro}{\onecolumngrid} |
---|
3174 | % \begin{macro}{\open@column@one} |
---|
3175 | % \begin{macro}{\shut@column@one} |
---|
3176 | % \begin{macro}{\float@column@one} |
---|
3177 | % \begin{macro}{\end@column@one} |
---|
3178 | % \begin{macro}{\output@column@one} |
---|
3179 | % \begin{macro}{\@addmarginpar@one} |
---|
3180 | % Here are all the procedures necessary for the standard page grid named ``one'': |
---|
3181 | % a single column layout. It is, of course, \LaTeX's familiar \cmd\onecolumn\ layout. |
---|
3182 | % We begin with the procedure exposed to the style writer. |
---|
3183 | % This is, however, not a \LaTeX\ command; users should not change the page grid. |
---|
3184 | % \begin{macrocode} |
---|
3185 | \newcommand\onecolumngrid{\do@columngrid{one}{\@ne}}% |
---|
3186 | % \end{macrocode} |
---|
3187 | % |
---|
3188 | % Note that a document class that issues the command \cmd\onecolumn\ will break. This includes |
---|
3189 | % \LaTeX's standard classes.dtx-based classes: if your class descends from one of these, you |
---|
3190 | % must expunge it of all such commands. |
---|
3191 | % \begin{macrocode} |
---|
3192 | \let\onecolumn\@undefined |
---|
3193 | % \end{macrocode} |
---|
3194 | % |
---|
3195 | % The procedure \cmd\open@column@one\ takes advantage of the special nature of the one-column |
---|
3196 | % page grid to deal with \cmd\box\cmd\pagesofar, therefore it must also reset \cmd\@colroom. |
---|
3197 | % \begin{macrocode} |
---|
3198 | \def\open@column@one#1{% |
---|
3199 | \unvbox\pagesofar |
---|
3200 | \gdef\thepagegrid{one}% |
---|
3201 | \global\pagegrid@col#1% |
---|
3202 | \global\pagegrid@cur\@ne |
---|
3203 | \set@colht |
---|
3204 | %\set@colroom |
---|
3205 | \set@column@hsize\pagegrid@col |
---|
3206 | }% |
---|
3207 | % \end{macrocode} |
---|
3208 | % |
---|
3209 | % The procedure \cmd\shut@column@one\ saves away the one-column material into the box register \cmd\pagesofar. |
---|
3210 | % Because it is called from a message handler, we are assured that marks are properly taken care of. |
---|
3211 | % \begin{macrocode} |
---|
3212 | \def\shut@column@one{% |
---|
3213 | \@makecol |
---|
3214 | \global\setbox\pagesofar\vbox{\unvbox\@outputbox\recover@footins}% |
---|
3215 | \set@colht |
---|
3216 | %\set@colroom |
---|
3217 | }% |
---|
3218 | % \end{macrocode} |
---|
3219 | % |
---|
3220 | % The procedure \cmd\float@column@one\ takes care of a float column that has been built by \cmd\@tryfcolumn, |
---|
3221 | % in the single-column page grid. |
---|
3222 | % \begin{macrocode} |
---|
3223 | \def\float@column@one{% |
---|
3224 | \@makecol |
---|
3225 | \@outputpage |
---|
3226 | }% |
---|
3227 | % \end{macrocode} |
---|
3228 | % |
---|
3229 | % The procedure \cmd\end@column@one\ is executed at the end of \cmd\clearpage\ processing, |
---|
3230 | % if we were in a one-column page grid, once all permissive float pages have been shipped out. |
---|
3231 | % At this point, one could perhaps |
---|
3232 | % assume that nothing more need be done, but let us anyway test for committed floats and force a shipout. |
---|
3233 | % |
---|
3234 | % FIXME: this procedure does the same as \cmd\end@column@mlt |
---|
3235 | % (except for the test of \cmd\@ifx@empty\cmd\@dbltoplist): |
---|
3236 | % the two could almost be the same procedure. |
---|
3237 | % |
---|
3238 | % I have changed this procedure to avoid the testing it once did: it simply puts down interrupts, |
---|
3239 | % upon which it relies to correctly do what \cmd\clearpage\ requires. |
---|
3240 | % \begin{macrocode} |
---|
3241 | \def\end@column@one{% |
---|
3242 | \unvbox\@cclv\setbox\z@\lastbox |
---|
3243 | \protect@penalty\do@newpage@pen |
---|
3244 | }% |
---|
3245 | % \end{macrocode} |
---|
3246 | % |
---|
3247 | % The procedure \cmd\output@column@one\ is dispatched from the output routine when |
---|
3248 | % we have completed a page (that is, a column in a one-column page grid). |
---|
3249 | % It ships out the page using the \cmd\@outputpage\ of standard \LaTeX, |
---|
3250 | % which has been retained (it is needed also in \cmd\output@column@mlt, |
---|
3251 | % and in any case should remain as the sole procedure in \LaTeX\ where \cmd\shipout\ is performed). |
---|
3252 | % It will be followed up with an output routine message to prepare a new column. |
---|
3253 | % \begin{macrocode} |
---|
3254 | \def\output@column@one{% |
---|
3255 | \@outputpage |
---|
3256 | }% |
---|
3257 | % \end{macrocode} |
---|
3258 | % |
---|
3259 | % The following procedure determines which side of the page a marginpar will appear. |
---|
3260 | % It reproduces the behavior of standard \LaTeX. |
---|
3261 | % \begin{macrocode} |
---|
3262 | \def\@addmarginpar@one{% |
---|
3263 | \@if@sw\if@mparswitch\fi{% |
---|
3264 | \@ifodd\c@page{\false@sw}{\true@sw}% |
---|
3265 | }{\false@sw}{% |
---|
3266 | \@if@sw\if@reversemargin\fi{\false@sw}{\true@sw}% |
---|
3267 | }{% |
---|
3268 | \@if@sw\if@reversemargin\fi{\true@sw}{\false@sw}% |
---|
3269 | }% |
---|
3270 | }% |
---|
3271 | % \end{macrocode} |
---|
3272 | % |
---|
3273 | % The following procedure yields a Boolean value; it determines whether a float in the deferred queue |
---|
3274 | % is appropriate for placing. In the one-column grid, all floats are so. |
---|
3275 | % \begin{macrocode} |
---|
3276 | \def\@floatselect@sw@one#1{\true@sw}% |
---|
3277 | % \end{macrocode} |
---|
3278 | % |
---|
3279 | % \begin{macrocode} |
---|
3280 | \def\onecolumngrid@push{% |
---|
3281 | \do@output@MVL{% |
---|
3282 | \@ifnum{\pagegrid@col=\@ne}{% |
---|
3283 | \global\let\restorecolumngrid\@empty |
---|
3284 | }{% |
---|
3285 | \xdef\restorecolumngrid{% |
---|
3286 | \noexpand\start@column{\thepagegrid}{\the\pagegrid@col}% |
---|
3287 | }% |
---|
3288 | \start@column{one}{\@ne}% |
---|
3289 | }% |
---|
3290 | }% |
---|
3291 | }% |
---|
3292 | \def\onecolumngrid@pop{% |
---|
3293 | \do@output@MVL{\restorecolumngrid}% |
---|
3294 | }% |
---|
3295 | % \end{macrocode} |
---|
3296 | % \end{macro} |
---|
3297 | % \end{macro} |
---|
3298 | % \end{macro} |
---|
3299 | % \end{macro} |
---|
3300 | % \end{macro} |
---|
3301 | % \end{macro} |
---|
3302 | % \end{macro} |
---|
3303 | % |
---|
3304 | % |
---|
3305 | % \subsubsection{Two-column page grid} |
---|
3306 | % |
---|
3307 | % \begin{macro}{\twocolumngrid} |
---|
3308 | % \begin{macro}{\open@column@mlt} |
---|
3309 | % \begin{macro}{\shut@column@mlt} |
---|
3310 | % \begin{macro}{\end@column@mlt} |
---|
3311 | % \begin{macro}{\output@column@mlt} |
---|
3312 | % \begin{macro}{\@addmarginpar@mlt} |
---|
3313 | % Here are all the procedures necessary for the standard page grid named ``mlt'': |
---|
3314 | % the multi-column page grid. With an argument of "2", it is, |
---|
3315 | % of course, \LaTeX's familiar \cmd\twocolumn\ layout. |
---|
3316 | % |
---|
3317 | % We start with the procedure to switch to the two-column page grid. |
---|
3318 | % \begin{macrocode} |
---|
3319 | \newcommand\twocolumngrid{\do@columngrid{mlt}{\tw@}}% |
---|
3320 | % \end{macrocode} |
---|
3321 | % |
---|
3322 | % The corresponding command of \LaTeX\ is obsolete. |
---|
3323 | % \begin{macrocode} |
---|
3324 | \let\twocolumn\@undefined |
---|
3325 | % \end{macrocode} |
---|
3326 | % |
---|
3327 | % Of course, \cmd\@topnewpage\ is also obsolete. Just do |
---|
3328 | %\begin{quote} |
---|
3329 | % \cmd\clearpage\cmd\onecolumngrid<vertical mode material>\cmd\twocolumngrid. |
---|
3330 | %\end{quote} |
---|
3331 | % \begin{macrocode} |
---|
3332 | \let\@topnewpage\@undefined |
---|
3333 | % \end{macrocode} |
---|
3334 | % |
---|
3335 | % If your document class descends from one of \LaTeX's standard classes.dtx-derived |
---|
3336 | % classes, it will break. You must expunge from it all such commands. |
---|
3337 | % |
---|
3338 | % \begin{macrocode} |
---|
3339 | \def\open@column@mlt#1{% |
---|
3340 | \gdef\thepagegrid{mlt}% |
---|
3341 | \global\pagegrid@col#1% |
---|
3342 | \global\pagegrid@cur\@ne |
---|
3343 | \set@column@hsize\pagegrid@col |
---|
3344 | \set@colht |
---|
3345 | %\set@colroom |
---|
3346 | }% |
---|
3347 | % \end{macrocode} |
---|
3348 | % |
---|
3349 | % The procedure \cmd\shut@column@mlt\ ends the current column, balances the columns, and |
---|
3350 | % salts away all in \cmd\pagesofar. Because it is called in a message handler, |
---|
3351 | % we are assured that marks are handled properly. |
---|
3352 | % Attention: because this procedure balances columns, all footnotes are |
---|
3353 | % held aside in \cmd\footbox\ for placement at the bottom of the page. |
---|
3354 | % |
---|
3355 | % Bug note: the last macro executed by this procedure is \cmd\set@colht, but had been erroneously \cmd\set@colroom. |
---|
3356 | % I now believe that the latter should be changed pretty much everywhere to the former. |
---|
3357 | % \begin{macrocode} |
---|
3358 | \def\shut@column@mlt{% |
---|
3359 | \@cclv@nontrivial@sw{% |
---|
3360 | \@makecol |
---|
3361 | \@ifnum{\pagegrid@cur<\pagegrid@col}{% |
---|
3362 | \expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox |
---|
3363 | \global\advance\pagegrid@cur\@ne |
---|
3364 | }{}% |
---|
3365 | }{% |
---|
3366 | {\setbox\z@\box\@cclv}% |
---|
3367 | }% |
---|
3368 | \@ifnum{\pagegrid@cur>\@ne}{% |
---|
3369 | \csname balance@\the\pagegrid@col\endcsname |
---|
3370 | \grid@column{}% |
---|
3371 | \@combinepage |
---|
3372 | \@combinedblfloats |
---|
3373 | \global\setbox\pagesofar\box\@outputbox |
---|
3374 | }{}% |
---|
3375 | \set@colht |
---|
3376 | }% |
---|
3377 | % \end{macrocode} |
---|
3378 | % |
---|
3379 | % The procedure \cmd\float@column@mlt\ takes care of a float page that has been built by \cmd\@tryfcolumn, |
---|
3380 | % in the multi-column page grid. |
---|
3381 | % \begin{macrocode} |
---|
3382 | \def\float@column@mlt{% |
---|
3383 | \@combinepage |
---|
3384 | \@combinedblfloats |
---|
3385 | \@outputpage |
---|
3386 | \global\pagegrid@cur\@ne |
---|
3387 | \protect@penalty\do@startpage@pen |
---|
3388 | }% |
---|
3389 | % \end{macrocode} |
---|
3390 | % |
---|
3391 | % The procedure \cmd\end@column@mlt\ is executed at the end of \cmd\clearpage\ processing, |
---|
3392 | % if we were in a multi-column page grid, once all permissive float pages have been shipped out. |
---|
3393 | % If no floats are committed and if no columns are yet filled, we have nothing to do. |
---|
3394 | % Otherwise, we kick out a column and try again. |
---|
3395 | % |
---|
3396 | % Note that in our code to kick out a column, we must deal properly with the case where the column |
---|
3397 | % is trivial: it will have nothing but \cmd\topskip\ glue plus a protection box. We substitute an ordinary |
---|
3398 | % \cmd\null\ for the protection box. |
---|
3399 | % |
---|
3400 | % \begin{macrocode} |
---|
3401 | \def\end@column@mlt{% |
---|
3402 | \@ifx@empty\@toplist{% |
---|
3403 | \@ifx@empty\@botlist{% |
---|
3404 | \@ifx@empty\@dbltoplist{% |
---|
3405 | \@ifx@empty\@deferlist{% |
---|
3406 | \@ifnum{\pagegrid@cur=\@ne}{% |
---|
3407 | \false@sw |
---|
3408 | }{% |
---|
3409 | \true@sw |
---|
3410 | }% |
---|
3411 | }{% |
---|
3412 | \true@sw |
---|
3413 | }% |
---|
3414 | }{% |
---|
3415 | \true@sw |
---|
3416 | }% |
---|
3417 | }{% |
---|
3418 | \true@sw |
---|
3419 | }% |
---|
3420 | }{% |
---|
3421 | \true@sw |
---|
3422 | }% |
---|
3423 | % true = kick out a column and try again |
---|
3424 | {% |
---|
3425 | \@cclv@nontrivial@sw{% |
---|
3426 | \unvbox\@cclv\setbox\z@\lastbox |
---|
3427 | }{% |
---|
3428 | \unvbox\@cclv\setbox\z@\lastbox\unskip\null |
---|
3429 | }% |
---|
3430 | \protect@penalty\do@newpage@pen |
---|
3431 | \protect@penalty\do@endpage@pen |
---|
3432 | }{% |
---|
3433 | \unvbox\@cclv\setbox\z@\lastbox |
---|
3434 | }% |
---|
3435 | }% |
---|
3436 | % \end{macrocode} |
---|
3437 | % The procedure \cmd\output@column@mlt (cf. \cmd\output@column@one) |
---|
3438 | % is dispatched from the output routine when |
---|
3439 | % we have completed a column in a multi-column page grid). |
---|
3440 | % (It replaces the \cmd\@outputdblcol\ of standard \LaTeX.) |
---|
3441 | % If a complete set of columns is at hand, it ships out the page and |
---|
3442 | % lays down an interrupt for \cmd\do@startpage@pen, which will commit the |
---|
3443 | % full-page-width floats to the next page. |
---|
3444 | % Like \cmd\output@column@mlt, this is followed by |
---|
3445 | % an output routine message to prepare a new column. |
---|
3446 | % \begin{macrocode} |
---|
3447 | \def\output@column@mlt{% |
---|
3448 | \@ifnum{\pagegrid@cur<\pagegrid@col}{% |
---|
3449 | \expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox |
---|
3450 | \global\advance\pagegrid@cur\@ne |
---|
3451 | }{% |
---|
3452 | \set@adj@colht\dimen@ |
---|
3453 | % \advance\dimen@-\topskip |
---|
3454 | \grid@column{}%{\dimen@}% |
---|
3455 | \@combinepage |
---|
3456 | \@combinedblfloats |
---|
3457 | \@outputpage |
---|
3458 | \global\pagegrid@cur\@ne |
---|
3459 | \protect@penalty\do@startpage@pen |
---|
3460 | }% |
---|
3461 | }% |
---|
3462 | % \end{macrocode} |
---|
3463 | % The procedure \cmd\output@column@mlt\ obsoletes \LaTeX's \cmd\@outputdblcol |
---|
3464 | % \begin{macrocode} |
---|
3465 | \let\@outputdblcol\@undefined |
---|
3466 | % \end{macrocode} |
---|
3467 | % |
---|
3468 | % The following procedure yields a Boolean value; it determines whether a float in the deferred queue |
---|
3469 | % is appropriate for placement in the column. In the multi-column grid, only those narrower than \cmd\textwidth\ are so. |
---|
3470 | % \begin{macrocode} |
---|
3471 | \def\@floatselect@sw@mlt#1{\@if@notdblfloat{#1}}% |
---|
3472 | % \end{macrocode} |
---|
3473 | % |
---|
3474 | % The following procedure determines which side of the page a marginpar will appear. |
---|
3475 | % It reproduces the behavior of standard \LaTeX. |
---|
3476 | % \begin{macrocode} |
---|
3477 | \def\@addmarginpar@mlt{% emits a boolean |
---|
3478 | \@ifnum{\pagegrid@cur=\@ne}% |
---|
3479 | }% |
---|
3480 | % \end{macrocode} |
---|
3481 | % \end{macro} |
---|
3482 | % \end{macro} |
---|
3483 | % \end{macro} |
---|
3484 | % \end{macro} |
---|
3485 | % \end{macro} |
---|
3486 | % \end{macro} |
---|
3487 | % |
---|
3488 | % |
---|
3489 | % \subsubsection{Page grid utility procedures} |
---|
3490 | % |
---|
3491 | % \begin{macro}{\pagegrid@cur} |
---|
3492 | % \begin{macro}{\pagegrid@col} |
---|
3493 | % \begin{macro}{\col@} |
---|
3494 | % \begin{macro}{\pagegrid@init} |
---|
3495 | % We take over \LaTeX's \cmd\col@number\ and \cmd\@leftcolumn, which are obsolete. |
---|
3496 | % We create two counters to hold the columns in the page grid and the current column within. |
---|
3497 | % We also create the first of a set of box registers to hold the committted columns. |
---|
3498 | % \begin{macrocode} |
---|
3499 | \let\pagegrid@cur\col@number |
---|
3500 | \let\col@number\@undefined |
---|
3501 | \newcount\pagegrid@col |
---|
3502 | \pagegrid@cur\@ne |
---|
3503 | \expandafter\let\csname col@\the\pagegrid@cur\endcsname\@leftcolumn |
---|
3504 | \let\@leftcolumn\@undefined |
---|
3505 | % \end{macrocode} |
---|
3506 | % |
---|
3507 | % The default is for maximum two columns. |
---|
3508 | % If your class will require more columns, assign that number to \cmd\pagegrid@col\ |
---|
3509 | % before \envb{document} time. |
---|
3510 | % \begin{macrocode} |
---|
3511 | \pagegrid@col\tw@ |
---|
3512 | % \end{macrocode} |
---|
3513 | % |
---|
3514 | % The procedure \cmd\pagegrid@init\ exercises \cmd\newbox\ sufficiently to create the |
---|
3515 | % boxes for holding the columns in the page grid. |
---|
3516 | % \begin{macrocode} |
---|
3517 | \def\pagegrid@init{% |
---|
3518 | \advance\pagegrid@cur\@ne |
---|
3519 | \@ifnum{\pagegrid@cur<\pagegrid@col}{% |
---|
3520 | \csname newbox\expandafter\endcsname\csname col@\the\pagegrid@cur\endcsname |
---|
3521 | \pagegrid@init |
---|
3522 | }{% |
---|
3523 | }% |
---|
3524 | }% |
---|
3525 | \appdef\class@documenthook{% |
---|
3526 | \pagegrid@init |
---|
3527 | }% |
---|
3528 | % \end{macrocode} |
---|
3529 | % \end{macro} |
---|
3530 | % \end{macro} |
---|
3531 | % \end{macro} |
---|
3532 | % \end{macro} |
---|
3533 | % |
---|
3534 | % \begin{macro}{\grid@column} |
---|
3535 | % The procedure \cmd\grid@column\ knows how to lay up the columns in a multi-column page grid. |
---|
3536 | % It uses utility procedures \cmd\append@column\ and \cmd\box@column. |
---|
3537 | % |
---|
3538 | % \begin{macrocode} |
---|
3539 | \def\grid@column#1{% |
---|
3540 | \global\setbox\@outputbox\vbox{% |
---|
3541 | \hb@xt@\textwidth{% |
---|
3542 | \vrule\@height\z@\@width\z@\@if@empty{#1}{}{\@depth#1}% |
---|
3543 | \pagegrid@cur\@ne |
---|
3544 | \append@column |
---|
3545 | \box@column\@outputbox |
---|
3546 | }% |
---|
3547 | \vskip\z@skip % FIXME: page depth! |
---|
3548 | }% |
---|
3549 | }% |
---|
3550 | % \end{macrocode} |
---|
3551 | % \end{macro} |
---|
3552 | % |
---|
3553 | % \begin{macro}{\append@column} |
---|
3554 | % \begin{macro}{\box@column} |
---|
3555 | % \begin{macro}{\marry@baselines} |
---|
3556 | % The procedure \cmd\append@column\ appends columns for \cmd\grid@column, |
---|
3557 | % \cmd\box@column\ builds the columns for \cmd\append@column, |
---|
3558 | % and \cmd\marry@baselines\ pastes vertical things back together. |
---|
3559 | % \changes{v4.0rc1}{2001/06/18} |
---|
3560 | % {Introoduce \cs{marry@height} } |
---|
3561 | % |
---|
3562 | % Note that \cmd\box@column\ makes an attempt to prevent excessive \cmd\topskip\ |
---|
3563 | % or \cmd\baselineskip\ glue |
---|
3564 | % from being applied by \TeX\ when \cmd\@outputbox\ is contributed to the MVL. |
---|
3565 | % If this is not done, it is possible to get into an infinite loop in the corner case, |
---|
3566 | % wherein the page grid is changed to one column and the balanced-up columns are |
---|
3567 | % already sufficient to fill the page. |
---|
3568 | % |
---|
3569 | % Note (AO 0920): I have changed the dimension involved with \cmd\box@column\ from |
---|
3570 | % \cmd\vsize\ to \cmd\textheight, because the former is certainly not the correct value |
---|
3571 | % to use: it will change if floats have been placed in the last column of the page. |
---|
3572 | % I believe \cmd\textheight\ is the correct parameter to use here. |
---|
3573 | % |
---|
3574 | % A REVTeX4 beta user, Sergey Strelkov (strelkov@maik.rssi.ru), wants the option |
---|
3575 | % of ragged-bottom columns. Implementing this feature properly means reboxing the |
---|
3576 | % columns to their natural height only if \cmd\raggedcolumn@sw\ is true. |
---|
3577 | % Otherwise, they get reboxed to their common height (\cmd\@colht?). |
---|
3578 | % |
---|
3579 | % Note that the default has hereby changed from ragged to flush. |
---|
3580 | % It's not clear that anyone but Sergey will notice. |
---|
3581 | % |
---|
3582 | % The macro \cmd\marry@skip\ addresses (in a limited way) |
---|
3583 | % the fact that neither the value of \cmd\baselineskip\ nor that of \cmd\topskip\ |
---|
3584 | % can be relied upon for the purpose of marrying the baselines of two split columns. |
---|
3585 | % (Because there might have been a local change to their values at the point where |
---|
3586 | % the output routine got triggered.) |
---|
3587 | % |
---|
3588 | % For best results, your document class should call for grid changes only when in basal text |
---|
3589 | % settings. The \cmd\marry@baselines\ procedure will use the values appropriate to that point |
---|
3590 | % when attempting to put the columns back together. |
---|
3591 | % |
---|
3592 | % In any case, we are not attempting to solve the more general problem of how to marry baselines |
---|
3593 | % where the leading can change arbitrarily within the galley or where glue could have been trimmed |
---|
3594 | % at a page top. |
---|
3595 | % \begin{macrocode} |
---|
3596 | \def\append@column{% |
---|
3597 | \@ifnum{\pagegrid@cur<\pagegrid@col}{% |
---|
3598 | \expandafter\box@column\csname col@\the\pagegrid@cur\endcsname |
---|
3599 | \hfil |
---|
3600 | \vrule \@width\columnseprule |
---|
3601 | \hfil |
---|
3602 | \advance\pagegrid@cur\@ne |
---|
3603 | \append@column |
---|
3604 | }{% |
---|
3605 | }% |
---|
3606 | }% |
---|
3607 | \def\box@column#1{% |
---|
3608 | \raise\topskip |
---|
3609 | \hb@xt@\columnwidth{% |
---|
3610 | \dimen@\ht#1\@ifdim{\dimen@>\@colht}{\dimen@\@colht}{}% |
---|
3611 | % \advance\dimen@-\topskip |
---|
3612 | \count@\vbadness\vbadness\@M |
---|
3613 | \dimen@ii\vfuzz\vfuzz\maxdimen |
---|
3614 | \outputdebug@sw{\saythe\@colht\saythe\dimen@}{}% |
---|
3615 | \vtop to\dimen@ |
---|
3616 | % \@ifdim{\ht#1>\textheight}{to\textheight}{}% |
---|
3617 | {\hrule\@height\z@ |
---|
3618 | \unvbox#1% |
---|
3619 | \raggedcolumn@skip |
---|
3620 | }% |
---|
3621 | \vfuzz\dimen@ii |
---|
3622 | \vbadness\count@ |
---|
3623 | \hss |
---|
3624 | }% |
---|
3625 | }% |
---|
3626 | \def\marry@baselines{% |
---|
3627 | %{\tracingall\scrollmode\showlists}% |
---|
3628 | %\skip@\baselineskip\advance\skip@-\topskip %FIXME: cannot assume \baselineskip nor \topskip |
---|
3629 | \vskip\marry@skip\relax |
---|
3630 | }% |
---|
3631 | \gdef\marry@skip{\z@skip}% |
---|
3632 | \def\set@marry@skip{% |
---|
3633 | \begingroup |
---|
3634 | \skip@\baselineskip\advance\skip@-\topskip |
---|
3635 | \@ifdim{\skip@>\z@}{% |
---|
3636 | \xdef\marry@skip{\the\skip@}% |
---|
3637 | }{}% |
---|
3638 | \endgroup |
---|
3639 | }% |
---|
3640 | \AtBeginDocument{% |
---|
3641 | \@ifxundefined\raggedcolumn@sw{\@booleanfalse\raggedcolumn@sw}{}% |
---|
3642 | }% |
---|
3643 | \def\raggedcolumn@skip{% |
---|
3644 | \vskip\z@\raggedcolumn@sw{\@plus.0001fil\@minus.0001fil}{}\relax |
---|
3645 | }% |
---|
3646 | % \end{macrocode} |
---|
3647 | % \end{macro} |
---|
3648 | % \end{macro} |
---|
3649 | % \end{macro} |
---|
3650 | % |
---|
3651 | % \begin{macro}{\@combinepage} |
---|
3652 | % The procedure \cmd\@combinepage\ prepends the stored page to \cmd\@outputbox. |
---|
3653 | % \begin{macrocode} |
---|
3654 | \def\@combinepage{% |
---|
3655 | \@ifvoid\pagesofar{}{% |
---|
3656 | \setbox\@outputbox\vbox{% |
---|
3657 | \unvbox\pagesofar |
---|
3658 | \marry@baselines |
---|
3659 | \unvbox\@outputbox |
---|
3660 | }% |
---|
3661 | }% |
---|
3662 | \@ifvoid\footbox{}{% |
---|
3663 | \setbox\@outputbox\vbox{% |
---|
3664 | \unvbox\@outputbox |
---|
3665 | \marry@baselines |
---|
3666 | \unvbox\footbox |
---|
3667 | }% |
---|
3668 | }% |
---|
3669 | }% |
---|
3670 | % \end{macrocode} |
---|
3671 | % \end{macro} |
---|
3672 | % |
---|
3673 | % \begin{macro}{\@combinedblfloats} |
---|
3674 | % We modify \LaTeX's \cmd\@combinedblfloats\ to be more appropriate for incremental page building: |
---|
3675 | % we \cmd\unvbox\ the \cmd\@outputbox. |
---|
3676 | % \begin{macrocode} |
---|
3677 | \def\@combinedblfloats{% |
---|
3678 | \@ifx@empty\@dbltoplist{}{% |
---|
3679 | \setbox\@tempboxa\vbox{}% |
---|
3680 | \let\@elt\@comdblflelt\@dbltoplist |
---|
3681 | \let\@elt\relax\xdef\@freelist{\@freelist\@dbltoplist}% |
---|
3682 | \global\let\@dbltoplist\@empty |
---|
3683 | \setbox\@outputbox\vbox{% |
---|
3684 | %\boxmaxdepth\maxdepth %% probably not needed, CAR |
---|
3685 | \unvbox\@tempboxa\unskip |
---|
3686 | \@ifnum{\@dbltopnum>\m@ne}{\dblfigrule}{}%FIXME: how is \@dbltopnum maintained? |
---|
3687 | \vskip\dbltextfloatsep |
---|
3688 | \unvbox\@outputbox |
---|
3689 | }% |
---|
3690 | }% |
---|
3691 | }% |
---|
3692 | % \end{macrocode} |
---|
3693 | % \end{macro} |
---|
3694 | % |
---|
3695 | % \begin{macro}{\set@column@hsize}% |
---|
3696 | % The procedure \cmd\set@column@hsize\ takes care of setting up the horizontal dimensions |
---|
3697 | % for the current page grid. The present routine will certainly not be adequate for more |
---|
3698 | % complex page layouts (e.g., with a side column), but works for the common ones. |
---|
3699 | % \changes{v4.0rc1}{2001/06/18} |
---|
3700 | % {Introoduce \cs{set@marry@height} } |
---|
3701 | % \begin{macrocode} |
---|
3702 | \def\set@column@hsize#1{% |
---|
3703 | \pagegrid@col#1% |
---|
3704 | \global\columnwidth\textwidth |
---|
3705 | \global\advance\columnwidth\columnsep |
---|
3706 | \global\divide\columnwidth\pagegrid@col |
---|
3707 | \global\advance\columnwidth-\columnsep |
---|
3708 | \global\hsize\columnwidth |
---|
3709 | \global\linewidth\columnwidth |
---|
3710 | \skip@\baselineskip\advance\skip@-\topskip |
---|
3711 | \@ifnum{\pagegrid@col>\@ne}{\set@marry@skip}{}% |
---|
3712 | }% |
---|
3713 | % \end{macrocode} |
---|
3714 | % \end{macro} |
---|
3715 | % |
---|
3716 | % \begin{macro}{\set@colht}% |
---|
3717 | % \begin{macro}{\set@colroom}% |
---|
3718 | % \begin{macro}{\set@vsize}% |
---|
3719 | % \begin{macro}{\set@adj@colht}% |
---|
3720 | % The story of \cmd\textheight, \cmd\@colht, \cmd\@colroom, and \cmd\vsize. |
---|
3721 | % |
---|
3722 | % \cmd\textheight---height of the text column. Not a running parameter, however, each time a page is |
---|
3723 | % shipped out, the \cmd\textheight\ could in principle be altered. This must be done before |
---|
3724 | % |
---|
3725 | % \cmd\@colht---\cmd\textheight\ minus the height of any full-page-width floats. The latter are committed |
---|
3726 | % only just after shipping out, and only if we are in a multicolumn page grid. |
---|
3727 | % Therefore, \cmd\@colht\ should be set after a \cmd\shipout\ (by \cmd\@outputpage) and |
---|
3728 | % will be adjusted when full-page-width floats are committed to the fresh page by \cmd\do@startpage. |
---|
3729 | % |
---|
3730 | % \cmd\@colroom---\cmd\@colht\ (adjusted by \cmd\pagesofar) minus the height of any column-width floats. |
---|
3731 | % The latter are committed anywhere on the page, at which point \cmd\@colroom\ must be adjusted. |
---|
3732 | % Therefore, \cmd\@colroom\ should be set (by \cmd\set@colroom) whenever a column is prepared (by ). |
---|
3733 | %FIXME: committed (by \cmd\output@column@) and |
---|
3734 | % will be adjusted (by \cmd\@add@float\ or \cmd\do@startcolumn) whenever a float is committted to the column. |
---|
3735 | % |
---|
3736 | % \cmd\vsize---\cmd\@colroom. |
---|
3737 | % Therefore, \cmd\vsize\ should be set (by \cmd\set@vsize) whenever |
---|
3738 | % the \cmd\@colroom\ is set (by \cmd\set@colroom) or adjusted (by \cmd\@add@float\ or \cmd\do@startcolumn) |
---|
3739 | %FIXME: or when the \cmd\pagesofar\ box is changed (after invoking \cmd\open@column@). |
---|
3740 | % |
---|
3741 | % Question: what if there are committed floats? Footnotes? |
---|
3742 | % Answer: full-page-width floats are only committed at top, and they are already reckoned with in \cmd\@colht. |
---|
3743 | % Column-width committed floats are incorporated by \cmd\@makecol; footnotes need help. |
---|
3744 | % |
---|
3745 | % Note: FIXME: adjusting for \cmd\pagesofar\ is done at not quite the right time. I need to reexamine \cmd\set@colht, |
---|
3746 | % because \cmd\@dbltoplist\ and \cmd\pagesofar\ really should be on the same footing. |
---|
3747 | % Perhaps \cmd\@colht\ and \cmd\@colroom\ should both deal with their respective ``lists'' in the same way? |
---|
3748 | % |
---|
3749 | % These concerns will be particularly germane if we ever extend this package to deal with full-page-width floats |
---|
3750 | % placed at the bottom of the page, or committed on the same page as called out. |
---|
3751 | % |
---|
3752 | % It occurs to me that we should ditch \cmd\set@colroom\ and only ever execute \cmd\set@colht, which sets \cmd\@colroom\ as a side effect. |
---|
3753 | % If so, we can make \cmd\@colht\ take \cmd\pagesofar\ into account, as it should. Then \cmd\@colht\ will return to its |
---|
3754 | % original significance as the value that \cmd\@colroom\ is set to after a column is committed. |
---|
3755 | % |
---|
3756 | % On the other hand, why not simply forget all this caching and (re-)calculate \cmd\vsize\ as late as possible? |
---|
3757 | % Paticularly, \cmd\@colht\ is an artifact of the old way of doing things, where once it was set, it would never change. |
---|
3758 | % |
---|
3759 | % \begin{macrocode} |
---|
3760 | \def\set@colht{% |
---|
3761 | \set@adj@textheight\@colht |
---|
3762 | \global\let\enlarge@colroom\@empty |
---|
3763 | \set@colroom |
---|
3764 | }% |
---|
3765 | \def\set@adj@textheight#1{% |
---|
3766 | #1\textheight |
---|
3767 | \def\@elt{\adj@page#1}% |
---|
3768 | \@booleantrue\firsttime@sw\@dbltoplist |
---|
3769 | \let\@elt\relax |
---|
3770 | %\@ifvoid\pagesofar{}{% |
---|
3771 | % \advance#1-\ht\pagesofar\advance#1-\dp\pagesofar |
---|
3772 | %}% |
---|
3773 | \global#1#1\relax |
---|
3774 | \outputdebug@sw{\saythe#1}{}% |
---|
3775 | }% |
---|
3776 | \def\set@colroom{% |
---|
3777 | \set@adj@colht\@colroom |
---|
3778 | \@if@empty\enlarge@colroom{}{% |
---|
3779 | \global\advance\@colroom\enlarge@colroom\relax |
---|
3780 | }% |
---|
3781 | \outputdebug@sw{\saythe\@colroom}{}% |
---|
3782 | \@ifdim{\@colroom>\topskip}{}{% |
---|
3783 | \ltxgrid@info{Not enough room: \string\@colroom=\the\@colroom; increasing to \the\topskip}% |
---|
3784 | \@colroom\topskip |
---|
3785 | }% |
---|
3786 | \global\@colroom\@colroom |
---|
3787 | \set@vsize |
---|
3788 | }% |
---|
3789 | % |
---|
3790 | \def\set@vsize{% |
---|
3791 | \global\vsize\@colroom |
---|
3792 | \outputdebug@sw{\saythe\vsize}{}% |
---|
3793 | }% |
---|
3794 | % |
---|
3795 | \def\set@adj@colht#1{% |
---|
3796 | #1\@colht |
---|
3797 | \@ifvoid\pagesofar{}{% |
---|
3798 | \advance#1-\ht\pagesofar\advance#1-\dp\pagesofar |
---|
3799 | }% |
---|
3800 | \@ifvoid\footbox{}{% |
---|
3801 | \advance#1-\ht\footbox\advance#1-\dp\footbox |
---|
3802 | }% |
---|
3803 | \def\@elt{\adj@column#1}% |
---|
3804 | \@booleantrue\firsttime@sw\@toplist |
---|
3805 | \@booleantrue\firsttime@sw\@botlist |
---|
3806 | \let\@elt\relax |
---|
3807 | \outputdebug@sw{\saythe#1}{}% |
---|
3808 | }% |
---|
3809 | \def\adj@column#1#2{% |
---|
3810 | \advance#1-\ht#2% |
---|
3811 | \advance#1-\firsttime@sw{\textfloatsep\@booleanfalse\firsttime@sw}{\floatsep}% |
---|
3812 | }% |
---|
3813 | \def\adj@page#1#2{% |
---|
3814 | \advance#1-\ht#2% |
---|
3815 | \advance#1-\firsttime@sw{\dbltextfloatsep\@booleanfalse\firsttime@sw}{\dblfloatsep}% |
---|
3816 | }% |
---|
3817 | % \end{macrocode} |
---|
3818 | % \end{macro} |
---|
3819 | % \end{macro} |
---|
3820 | % \end{macro} |
---|
3821 | % \end{macro} |
---|
3822 | % |
---|
3823 | % \begin{macro}{\@outputpage}% |
---|
3824 | % At the tail of \cmd\@outputpage, we set \cmd\@colht\ and the float placement parameters |
---|
3825 | % (this is the one point where it is appropriate to set \cmd\@colht). |
---|
3826 | % At \cmd\do@startpage\ time, we adjust \cmd\@colht's value to reflect committed |
---|
3827 | % full-page-width floats. |
---|
3828 | % |
---|
3829 | % Note: with a correctly written output routine, a call to \cmd\@outputpage\ will inevitably be |
---|
3830 | % followed by a call to \cmd\do@startpage, so these procedure calls would be unneeded. |
---|
3831 | % \begin{macrocode} |
---|
3832 | \appdef\@outputpage{% |
---|
3833 | \set@colht % FIXME: needed? |
---|
3834 | \@floatplacement % FIXME: needed? |
---|
3835 | \@dblfloatplacement % FIXME: needed? |
---|
3836 | }% |
---|
3837 | % \end{macrocode} |
---|
3838 | % \end{macro} |
---|
3839 | % |
---|
3840 | % \begin{macro}{balance@2} |
---|
3841 | % We define procedures for balancing columns in a multicolumn layout. |
---|
3842 | % For now, we define only one: a procedure for the two-column grid. |
---|
3843 | % All others will simply \cmd\relax\ out. |
---|
3844 | % \begin{macrocode} |
---|
3845 | \@namedef{balance@2}{% |
---|
3846 | \expandafter\balance@two\csname col@1\endcsname\@outputbox |
---|
3847 | % Avoid a bug by preventing a restore when leaving this group |
---|
3848 | \global\setbox\csname col@1\endcsname\box\csname col@1\endcsname |
---|
3849 | \@ifvoid\footbox{}{% |
---|
3850 | \global\setbox\footbox\vbox{% |
---|
3851 | \setbox\z@\box\@tempboxa |
---|
3852 | \let\recover@footins\relax |
---|
3853 | \balance@two\footbox\@tempboxa |
---|
3854 | \hb@xt@\textwidth{\box\footbox\hfil\box\@tempboxa}% |
---|
3855 | }% |
---|
3856 | }% |
---|
3857 | }% |
---|
3858 | % \end{macrocode} |
---|
3859 | % \end{macro} |
---|
3860 | % |
---|
3861 | % \begin{macro}{\balance@two} |
---|
3862 | % The procedure \cmd\balance@two\ takes two columns and balances them; in the process it removes |
---|
3863 | % any footnotes that may be present to a place of safety, for later placement at the foot of the |
---|
3864 | % shipped-out page. |
---|
3865 | % The box register \cmd\box\cmd\@ne\ is the aggregate of all columns. |
---|
3866 | % The box register \cmd\box\cmd \z@\ is the last column. |
---|
3867 | % The box register \cmd\box\cmd\tw@\ is the first column. |
---|
3868 | % The \cmd\dimen\ register \cmd\dimen@\ is the trial value to balance to, |
---|
3869 | % initially half the height of \cmd\box\cmd\@ne. |
---|
3870 | % The \cmd\dimen\ register \cmd\dimen@i\ is the increment for the next trial; |
---|
3871 | % its initial value is equal to the initial value of \cmd\dimen@. |
---|
3872 | % The \cmd\dimen\ register \cmd\dimen@ii\ is the difference of the heights of the two columns. |
---|
3873 | % |
---|
3874 | % The procedure uses a binary search for that value of \cmd\dimen@\ which is stable to within .5\cmd\p@\ and which |
---|
3875 | % makes the last column be shorter than the others. |
---|
3876 | % |
---|
3877 | % This procedure can be extended to multiple columns simply by changing it to execute \cmd\vsplit\ multiple |
---|
3878 | % times (one less than the total number of columns in the page layout) and to calculating \cmd\dimen@ii\ |
---|
3879 | % to be the difference of the heights of last column and the \cmd\dimen@. |
---|
3880 | % Upon termination of the search, one would excute the \cmd\vsplit s once again, this time |
---|
3881 | % using the actual \cmd\col@\ box registers to store the |
---|
3882 | % balanced columns, thereby clobbering their former contents. |
---|
3883 | % |
---|
3884 | % Bug Note: |
---|
3885 | % as originally written, this macro had a bug, which is well worth avoiding under similar circumstances anywhere. |
---|
3886 | % So, learn from the mistakes of others, as they say. |
---|
3887 | % In trying to remove the depth of the boxes created via \cmd\vsplit\ within the \cmd\loopwhile\ control, |
---|
3888 | % I originally coded |
---|
3889 | % \cmd\unvbox |
---|
3890 | % \cmd\z@\ |
---|
3891 | % \cmd\setbox |
---|
3892 | % \cmd\z@ |
---|
3893 | % \cmd\lastbox\ |
---|
3894 | % \cmd\dimen@ |
---|
3895 | % \cmd\dp |
---|
3896 | % \cmd\z@\ |
---|
3897 | % \cmd\box |
---|
3898 | % \cmd\z@\ |
---|
3899 | % \cmd\vskip-% |
---|
3900 | % \cmd\dimen@. |
---|
3901 | % The error here is that the shift of the last box in the vertical list will be lost in the process. |
---|
3902 | % Simply put, \cmd\setbox\cmd\z@\cmd\lastbox\ fails to retain the shift of the box node in the vertical list, |
---|
3903 | % and when it is put down again via \cmd\box\cmd\z@, it will no longer have the correct shift. |
---|
3904 | % |
---|
3905 | % This bug affected things placed in the MVL with \cmd\moveleft, \cmd\moveright, \cmd\parshape, and |
---|
3906 | % \cmd\hangindent, as well as things shifted by \TeX's primitive mechanisms. |
---|
3907 | % |
---|
3908 | % A superior strategy for removing the depth of the last line of the list is more expensive, but safer: |
---|
3909 | % make a separate copy of the list, measure the depth of the last box as above, but then discard |
---|
3910 | % the list, retaining only the value of the dimension. |
---|
3911 | % |
---|
3912 | % Note that this procedure will not work if the material within is excessively chunky. |
---|
3913 | % A particular failure mode exists where none of the material is allocated to the last (right) column. |
---|
3914 | % We detect this case and revert to unbalanced columns. |
---|
3915 | % |
---|
3916 | % Another failure mode is where a large chunk occurs at the beginning of the composite box. |
---|
3917 | % In this case, the left column may fill up even when \cmd\dimen@\ is very small. |
---|
3918 | % If this configuration leaves the left column longer than the right, then we are done, |
---|
3919 | % but \cmd\dimen@\ by no means represents the height of either finished box. |
---|
3920 | % |
---|
3921 | % Therefore the last step in the process is to rebox the two columns to a common height determined |
---|
3922 | % independently of the balancing process. |
---|
3923 | % |
---|
3924 | % The dimension involved is checked against the current \cmd\@colroom\ to guard against the case where |
---|
3925 | % excessive material happens to fall in either column. |
---|
3926 | % \begin{macrocode} |
---|
3927 | \def\balance@two#1#2{% |
---|
3928 | \outputdebug@sw{{\tracingall\scrollmode\showbox#1\showbox#2}}{}% |
---|
3929 | \setbox\@ne\vbox{% |
---|
3930 | \@ifvoid#1{}{% |
---|
3931 | \unvcopy#1\recover@footins |
---|
3932 | \@ifvoid#2{}{\marry@baselines}% |
---|
3933 | }% |
---|
3934 | \@ifvoid#2{}{% |
---|
3935 | \unvcopy#2\recover@footins |
---|
3936 | }% |
---|
3937 | }% |
---|
3938 | \dimen@\ht\@ne\divide\dimen@\tw@ |
---|
3939 | \dimen@i\dimen@ |
---|
3940 | \vbadness\@M |
---|
3941 | \vfuzz\maxdimen |
---|
3942 | \loopwhile{% |
---|
3943 | \dimen@i=.5\dimen@i |
---|
3944 | \outputdebug@sw{\saythe\dimen@\saythe\dimen@i\saythe\dimen@ii}{}% |
---|
3945 | \setbox\z@\copy\@ne\setbox\tw@\vsplit\z@ to\dimen@ |
---|
3946 | \setbox\z@ \vbox{% |
---|
3947 | \unvcopy\z@ |
---|
3948 | \setbox\z@\vbox{\unvbox\z@ \setbox\z@\lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax |
---|
3949 | }% |
---|
3950 | \setbox\tw@\vbox{% |
---|
3951 | \unvcopy\tw@ |
---|
3952 | \setbox\z@\vbox{\unvbox\tw@\setbox\z@\lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax |
---|
3953 | }% |
---|
3954 | \dimen@ii\ht\tw@\advance\dimen@ii-\ht\z@ |
---|
3955 | \@ifdim{\dimen@i>.5\p@}{% |
---|
3956 | \advance\dimen@\@ifdim{\dimen@ii<\z@}{}{-}\dimen@i |
---|
3957 | \true@sw |
---|
3958 | }{% |
---|
3959 | \@ifdim{\dimen@ii<\z@}{% |
---|
3960 | \advance\dimen@\tw@\dimen@i |
---|
3961 | \true@sw |
---|
3962 | }{% |
---|
3963 | \false@sw |
---|
3964 | }% |
---|
3965 | }% |
---|
3966 | }% |
---|
3967 | \outputdebug@sw{\saythe\dimen@\saythe\dimen@i\saythe\dimen@ii}{}% |
---|
3968 | \@ifdim{\ht\z@=\z@}{% |
---|
3969 | \@ifdim{\ht\tw@=\z@}{% |
---|
3970 | \true@sw |
---|
3971 | }{% |
---|
3972 | \false@sw |
---|
3973 | }% |
---|
3974 | }{% |
---|
3975 | \true@sw |
---|
3976 | }% |
---|
3977 | {% |
---|
3978 | }{% |
---|
3979 | \ltxgrid@info{Unsatifactorily balanced columns: giving up}% |
---|
3980 | \setbox\tw@\box#1% |
---|
3981 | \setbox\z@ \box#2% |
---|
3982 | }% |
---|
3983 | \setbox\tw@\vbox{\unvbox\tw@\vskip\z@skip}% |
---|
3984 | \setbox\z@ \vbox{\unvbox\z@ \vskip\z@skip}% |
---|
3985 | \set@colroom |
---|
3986 | \dimen@\ht\z@\@ifdim{\dimen@<\ht\tw@}{\dimen@\ht\tw@}{}% |
---|
3987 | \@ifdim{\dimen@>\@colroom}{\dimen@\@colroom}{}% |
---|
3988 | \outputdebug@sw{\saythe{\ht\z@}\saythe{\ht\tw@}\saythe\@colroom\saythe\dimen@}{}% |
---|
3989 | \setbox#1\vbox to\dimen@{\unvbox\tw@\unskip\raggedcolumn@skip}% |
---|
3990 | \setbox#2\vbox to\dimen@{\unvbox\z@ \unskip\raggedcolumn@skip}% |
---|
3991 | \outputdebug@sw{{\tracingall\scrollmode\showbox#1\showbox#2}}{}% |
---|
3992 | }% |
---|
3993 | % \end{macrocode} |
---|
3994 | % \end{macro} |
---|
3995 | % |
---|
3996 | % \begin{macro}{\recover@footins} |
---|
3997 | % The procedure \cmd\recover@footins\ is the utility procedure for recovering the footnotes |
---|
3998 | % from the bottom of a column. It is used when the page grid is changed, so that footnotes can be |
---|
3999 | % set at the bottom of the shipped out page. |
---|
4000 | % \begin{macrocode} |
---|
4001 | \def\recover@footins{% |
---|
4002 | \skip\z@ \lastskip\unskip |
---|
4003 | \skip\@ne\lastskip\unskip |
---|
4004 | \setbox\z@\lastbox |
---|
4005 | \@ifvbox\z@{% |
---|
4006 | \setbox\z@\vbox{% |
---|
4007 | \unvbox\z@ |
---|
4008 | \setbox\z@\lastbox |
---|
4009 | % \outputdebug@sw{{\tracingall\showbox\lastbox}}{}% |
---|
4010 | \@ifvoid\z@{}{% |
---|
4011 | \global\setbox\footbox\vbox{% |
---|
4012 | \unvbox\footbox |
---|
4013 | \@ifvbox\z@{% |
---|
4014 | \unvbox\z@ |
---|
4015 | }{% |
---|
4016 | \box\z@ |
---|
4017 | }% |
---|
4018 | }% |
---|
4019 | }% |
---|
4020 | }% |
---|
4021 | }{}% |
---|
4022 | \outputdebug@sw{{\tracingall\scrollmode\showbox\footbox}}{}% |
---|
4023 | }% |
---|
4024 | % \end{macrocode} |
---|
4025 | % \end{macro} |
---|
4026 | % |
---|
4027 | % \begin{macro}{\@begindocumenthook} |
---|
4028 | % Initialization: |
---|
4029 | % we initialize to the page grid named ``one''. |
---|
4030 | % If the class decides to initially set type in a different grid, it |
---|
4031 | % should execute these same commands, but changing the first to the appropriate procedure. |
---|
4032 | % |
---|
4033 | % Note that the point where this sequence is executed would be an excellent place to arrange for |
---|
4034 | % floats to be committed to the first page of a document. |
---|
4035 | % That is, we execute \cmd\do@startpage, which triggers \cmd\do@startcolumn. |
---|
4036 | % |
---|
4037 | % FIXME: it should be the job of the page grid to determine the procedure to execute at |
---|
4038 | % the start of the job. Make this a hook. |
---|
4039 | % \begin{macrocode} |
---|
4040 | \prepdef\@begindocumenthook{% |
---|
4041 | \open@column@one\@ne |
---|
4042 | \set@colht |
---|
4043 | \@floatplacement |
---|
4044 | \@dblfloatplacement |
---|
4045 | }% |
---|
4046 | % \end{macrocode} |
---|
4047 | % \end{macro} |
---|
4048 | % |
---|
4049 | % Comment: our technique of balancing columns is severely limited, because it cannot properly work |
---|
4050 | % with \env{longtable}, which places material at the bottom and top of the column break. |
---|
4051 | % |
---|
4052 | % The proper way to handle a grid change in the middle of the page is to accumulate all the material for |
---|
4053 | % an entire article (or chapter) and then assemble finished pages therefrom. This approach is fundamentally |
---|
4054 | % superior for complex layouts: it corresponds to real-world workflows. |
---|
4055 | % Such a scheme is an excellent subject for another \LaTeX\ package. |
---|
4056 | % |
---|
4057 | % |
---|
4058 | % \subsection{Patches for the longtable package}% |
---|
4059 | % |
---|
4060 | % \LaTeX's ``required'' package \classname{longtable} (written by David P. Carlilsle), |
---|
4061 | % which is part of /latex/required/tools, is incmpatible with both |
---|
4062 | % \LaTeX's ``required'' package \classname{multicol} and with |
---|
4063 | % \LaTeX's native \cmd\twocolumn\ capability. There is no essential reason |
---|
4064 | % for this incompatability, aside from implementation details, and the |
---|
4065 | % \classname{ltxgrid} package gives us the ability to lift them. |
---|
4066 | % |
---|
4067 | % Only four of \classname{longtable}'s procedures require rewriting: |
---|
4068 | % \cmd\longtable, |
---|
4069 | % \cmd\endlongtable, |
---|
4070 | % \cmd\LT@start, and |
---|
4071 | % \cmd\LT@end@hd@ft. |
---|
4072 | % The procedure \cmd\switch@longtable\ checks against their expected meanings |
---|
4073 | % and, if all is as expected, applies the patches. |
---|
4074 | % In the process, we simplify things considerably and also make them more |
---|
4075 | % secure. |
---|
4076 | % |
---|
4077 | % Why does \classname{longtable} need to access the output routine, anyway? |
---|
4078 | % What it comes down to, is what happens when a pagebreak falls within a |
---|
4079 | % long table. If this happens, we would like to append a row at the bottom of |
---|
4080 | % the broken table and add a row at the top of the next page. |
---|
4081 | % |
---|
4082 | % These things can be accomodated easily by the \classname{ltxgrid} output |
---|
4083 | % routine hooks. |
---|
4084 | % |
---|
4085 | % |
---|
4086 | % \begin{macro}{\longtable} |
---|
4087 | % \begin{macrocode} |
---|
4088 | \def\longtable@longtable{% |
---|
4089 | \par |
---|
4090 | \ifx\multicols\@undefined\else\ifnum\col@number>\@ne\@twocolumntrue\fi\fi |
---|
4091 | \if@twocolumn\LT@err{longtable not in 1-column mode}\@ehc\fi |
---|
4092 | \begingroup |
---|
4093 | \@ifnextchar[\LT@array{\LT@array[x]}% |
---|
4094 | }% |
---|
4095 | \def\longtable@new{% |
---|
4096 | \par |
---|
4097 | \@ifnextchar[\LT@array{\LT@array[x]}% |
---|
4098 | }% |
---|
4099 | % \end{macrocode} |
---|
4100 | % \end{macro} |
---|
4101 | % |
---|
4102 | % \begin{macro}{\endlongtable} |
---|
4103 | % \begin{macrocode} |
---|
4104 | \def\endlongtable@longtable{% |
---|
4105 | \crcr |
---|
4106 | \noalign{% |
---|
4107 | \let\LT@entry\LT@entry@chop |
---|
4108 | \xdef\LT@save@row{\LT@save@row}}% |
---|
4109 | \LT@echunk |
---|
4110 | \LT@start |
---|
4111 | \unvbox\z@ |
---|
4112 | \LT@get@widths |
---|
4113 | \if@filesw |
---|
4114 | {\let\LT@entry\LT@entry@write\immediate\write\@auxout{% |
---|
4115 | \gdef\expandafter\noexpand |
---|
4116 | \csname LT@\romannumeral\c@LT@tables\endcsname |
---|
4117 | {\LT@save@row}}}% |
---|
4118 | \fi |
---|
4119 | \ifx\LT@save@row\LT@@save@row |
---|
4120 | \else |
---|
4121 | \LT@warn{Column \@width s have changed\MessageBreak |
---|
4122 | in table \thetable}% |
---|
4123 | \LT@final@warn |
---|
4124 | \fi |
---|
4125 | \endgraf\penalty -\LT@end@pen |
---|
4126 | \endgroup |
---|
4127 | \global\@mparbottom\z@ |
---|
4128 | \pagegoal\vsize |
---|
4129 | \endgraf\penalty\z@\addvspace\LTpost |
---|
4130 | \ifvoid\footins\else\insert\footins{}\fi |
---|
4131 | }% |
---|
4132 | \def\endlongtable@new{% |
---|
4133 | \crcr |
---|
4134 | \noalign{% |
---|
4135 | \let\LT@entry\LT@entry@chop |
---|
4136 | \xdef\LT@save@row{\LT@save@row}% |
---|
4137 | }% |
---|
4138 | \LT@echunk |
---|
4139 | \LT@start |
---|
4140 | \unvbox\z@ |
---|
4141 | \LT@get@widths |
---|
4142 | \@if@sw\if@filesw\fi{% |
---|
4143 | {% |
---|
4144 | \let\LT@entry\LT@entry@write |
---|
4145 | \immediate\write\@auxout{% |
---|
4146 | \gdef\expandafter\noexpand\csname LT@\romannumeral\c@LT@tables\endcsname |
---|
4147 | {\LT@save@row}% |
---|
4148 | }% |
---|
4149 | }% |
---|
4150 | }{}% |
---|
4151 | \@ifx\LT@save@row\LT@@save@row{}{% |
---|
4152 | \LT@warn{% |
---|
4153 | Column \@width s have changed\MessageBreak in table \thetable |
---|
4154 | }\LT@final@warn |
---|
4155 | }% |
---|
4156 | \endgraf |
---|
4157 | \nobreak |
---|
4158 | \box\@ifvoid\LT@lastfoot{\LT@foot}{\LT@lastfoot}% |
---|
4159 | \global\@mparbottom\z@ |
---|
4160 | \endgraf |
---|
4161 | \LT@post |
---|
4162 | }% |
---|
4163 | % \end{macrocode} |
---|
4164 | % \end{macro} |
---|
4165 | % |
---|
4166 | % \begin{macro}{\LT@start} |
---|
4167 | % \begin{macrocode} |
---|
4168 | \def\LT@start@longtable{% |
---|
4169 | \let\LT@start\endgraf |
---|
4170 | \endgraf |
---|
4171 | \penalty\z@ |
---|
4172 | \vskip\LTpre |
---|
4173 | \dimen@\pagetotal |
---|
4174 | \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
---|
4175 | \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
---|
4176 | \advance\dimen@ \ht\LT@foot |
---|
4177 | \dimen@ii\vfuzz\vfuzz\maxdimen |
---|
4178 | \setbox\tw@\copy\z@ |
---|
4179 | \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox |
---|
4180 | \setbox\tw@\vbox{\unvbox\tw@}% |
---|
4181 | \vfuzz\dimen@ii |
---|
4182 | \advance\dimen@ \ht |
---|
4183 | \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi |
---|
4184 | \advance\dimen@\dp |
---|
4185 | \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi |
---|
4186 | \advance\dimen@ -\pagegoal |
---|
4187 | \ifdim \dimen@>\z@\vfil\break\fi |
---|
4188 | \global\@colroom\@colht |
---|
4189 | \ifvoid\LT@foot\else |
---|
4190 | \advance\vsize-\ht\LT@foot |
---|
4191 | \global\advance\@colroom-\ht\LT@foot |
---|
4192 | \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@ |
---|
4193 | \maxdepth\z@ |
---|
4194 | \fi |
---|
4195 | \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi |
---|
4196 | \output{\LT@output}% |
---|
4197 | }% |
---|
4198 | \def\LT@start@new{% |
---|
4199 | \let\LT@start\endgraf |
---|
4200 | \endgraf |
---|
4201 | \markthr@@{}% |
---|
4202 | \LT@pre |
---|
4203 | \@ifvoid\LT@firsthead{\LT@top}{\box\LT@firsthead\nobreak}% |
---|
4204 | \mark@envir{longtable}% |
---|
4205 | }% |
---|
4206 | % \end{macrocode} |
---|
4207 | % \end{macro} |
---|
4208 | % |
---|
4209 | % \begin{macro}{\LT@end} |
---|
4210 | % \begin{macrocode} |
---|
4211 | \def\LT@end@hd@ft@longtable#1{% |
---|
4212 | \LT@echunk |
---|
4213 | \ifx\LT@start\endgraf |
---|
4214 | \LT@err{Longtable head or foot not at start of table}{Increase LTchunksize}% |
---|
4215 | \fi |
---|
4216 | \setbox#1\box\z@ |
---|
4217 | \LT@get@widths\LT@bchunk |
---|
4218 | }% |
---|
4219 | \def\LT@end@hd@ft@new#1{% |
---|
4220 | \LT@echunk |
---|
4221 | \@ifx{\LT@start\endgraf}{% |
---|
4222 | \LT@err{Longtable head or foot not at start of table}{Increase LTchunksize}% |
---|
4223 | }% |
---|
4224 | \global\setbox#1\box\z@ |
---|
4225 | \LT@get@widths |
---|
4226 | \LT@bchunk |
---|
4227 | }% |
---|
4228 | % \end{macrocode} |
---|
4229 | % \end{macro} |
---|
4230 | % |
---|
4231 | % \begin{macro}{\LT@array} |
---|
4232 | % \begin{macrocode} |
---|
4233 | \def\LT@array@longtable[#1]#2{% |
---|
4234 | \refstepcounter{table}\stepcounter{LT@tables}% |
---|
4235 | \if l#1% |
---|
4236 | \LTleft\z@ \LTright\fill |
---|
4237 | \else\if r#1% |
---|
4238 | \LTleft\fill \LTright\z@ |
---|
4239 | \else\if c#1% |
---|
4240 | \LTleft\fill \LTright\fill |
---|
4241 | \fi\fi\fi |
---|
4242 | \let\LT@mcol\multicolumn |
---|
4243 | \let\LT@@tabarray\@tabarray |
---|
4244 | \let\LT@@hl\hline |
---|
4245 | \def\@tabarray{% |
---|
4246 | \let\hline\LT@@hl |
---|
4247 | \LT@@tabarray}% |
---|
4248 | \let\\\LT@tabularcr\let\tabularnewline\\% |
---|
4249 | \def\newpage{\noalign{\break}}% |
---|
4250 | \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% |
---|
4251 | \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% |
---|
4252 | \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption |
---|
4253 | \@tempdima\ht\strutbox |
---|
4254 | \let\@endpbox\LT@endpbox |
---|
4255 | \ifx\extrarowheight\@undefined |
---|
4256 | \let\@acol\@tabacol |
---|
4257 | \let\@classz\@tabclassz \let\@classiv\@tabclassiv |
---|
4258 | \def\@startpbox{\vtop\LT@startpbox}% |
---|
4259 | \let\@@startpbox\@startpbox |
---|
4260 | \let\@@endpbox\@endpbox |
---|
4261 | \let\LT@LL@FM@cr\@tabularcr |
---|
4262 | \else |
---|
4263 | \advance\@tempdima\extrarowheight |
---|
4264 | \col@sep\tabcolsep |
---|
4265 | \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr |
---|
4266 | \fi |
---|
4267 | \setbox\@arstrutbox\hbox{\vrule |
---|
4268 | \@height \arraystretch \@tempdima |
---|
4269 | \@depth \arraystretch \dp \strutbox |
---|
4270 | \@width \z@}% |
---|
4271 | \let\@sharp##\let\protect\relax |
---|
4272 | \begingroup |
---|
4273 | \@mkpream{#2}% |
---|
4274 | \xdef\LT@bchunk{% |
---|
4275 | \global\advance\c@LT@chunks\@ne |
---|
4276 | \global\LT@rows\z@\setbox\z@\vbox\bgroup |
---|
4277 | \LT@setprevdepth |
---|
4278 | \tabskip\LTleft\halign to\hsize\bgroup |
---|
4279 | \tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}% |
---|
4280 | \endgroup |
---|
4281 | \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols |
---|
4282 | \LT@make@row |
---|
4283 | \m@th\let\par\@empty |
---|
4284 | \everycr{}\lineskip\z@\baselineskip\z@ |
---|
4285 | \LT@bchunk |
---|
4286 | }% |
---|
4287 | \def\LT@LR@l{\LTleft\z@ \LTright\fill}% |
---|
4288 | \def\LT@LR@r{\LTleft\fill \LTright\z@ }% |
---|
4289 | \def\LT@LR@c{\LTleft\fill \LTright\fill}% |
---|
4290 | \def\LT@array@new[#1]#2{% |
---|
4291 | \refstepcounter{table}\stepcounter{LT@tables}% |
---|
4292 | \table@hook |
---|
4293 | \LTleft\fill \LTright\fill |
---|
4294 | \csname LT@LR@#1\endcsname |
---|
4295 | \let\LT@mcol\multicolumn |
---|
4296 | \let\LT@@hl\hline |
---|
4297 | \prepdef\@tabarray{\let\hline\LT@@hl}% |
---|
4298 | \let\\\LT@tabularcr |
---|
4299 | \let\tabularnewline\\% |
---|
4300 | \def\newpage{\noalign{\break}}% |
---|
4301 | \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% |
---|
4302 | \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% |
---|
4303 | \let\hline\LT@hline |
---|
4304 | \let\kill\LT@kill |
---|
4305 | \let\caption\LT@caption |
---|
4306 | \@tempdima\ht\strutbox |
---|
4307 | \let\@endpbox\LT@endpbox |
---|
4308 | \@ifxundefined\extrarowheight{% |
---|
4309 | \let\@acol\@tabacol |
---|
4310 | \let\@classz\@tabclassz |
---|
4311 | \let\@classiv\@tabclassiv |
---|
4312 | \def\@startpbox{\vtop\LT@startpbox}% |
---|
4313 | \let\@@startpbox\@startpbox |
---|
4314 | \let\@@endpbox\@endpbox |
---|
4315 | \let\LT@LL@FM@cr\@tabularcr |
---|
4316 | }{% |
---|
4317 | \advance\@tempdima\extrarowheight |
---|
4318 | \col@sep\tabcolsep |
---|
4319 | \let\@startpbox\LT@startpbox |
---|
4320 | \let\LT@LL@FM@cr\@arraycr |
---|
4321 | }% |
---|
4322 | % |
---|
4323 | \let\@acoll\@tabacoll |
---|
4324 | \let\@acolr\@tabacolr |
---|
4325 | \let\@acol\@tabacol |
---|
4326 | % |
---|
4327 | \setbox\@arstrutbox\hbox{% |
---|
4328 | \vrule |
---|
4329 | \@height \arraystretch \@tempdima |
---|
4330 | \@depth \arraystretch \dp \strutbox |
---|
4331 | \@width \z@ |
---|
4332 | }% |
---|
4333 | \let\@sharp##% |
---|
4334 | \let\protect\relax |
---|
4335 | \begingroup |
---|
4336 | \@mkpream{#2}% |
---|
4337 | \@mkpream@relax |
---|
4338 | \edef\@preamble{\@preamble}% |
---|
4339 | \prepdef\@preamble{% |
---|
4340 | \global\advance\c@LT@chunks\@ne |
---|
4341 | \global\LT@rows\z@ |
---|
4342 | \setbox\z@\vbox\bgroup |
---|
4343 | \LT@setprevdepth |
---|
4344 | \tabskip\LTleft |
---|
4345 | \halign to\hsize\bgroup |
---|
4346 | \tabskip\z@ |
---|
4347 | \@arstrut |
---|
4348 | }% |
---|
4349 | \appdef\@preamble{% |
---|
4350 | \tabskip\LTright |
---|
4351 | \cr |
---|
4352 | }% |
---|
4353 | \global\let\LT@bchunk\@preamble |
---|
4354 | \endgroup |
---|
4355 | \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols |
---|
4356 | \LT@make@row |
---|
4357 | \m@th |
---|
4358 | \let\par\@empty |
---|
4359 | \everycr{}% |
---|
4360 | \lineskip\z@ |
---|
4361 | \baselineskip\z@ |
---|
4362 | \LT@bchunk |
---|
4363 | }% |
---|
4364 | \appdef\table@hook{}% |
---|
4365 | % \end{macrocode} |
---|
4366 | % \end{macro} |
---|
4367 | % |
---|
4368 | % \begin{macro}{\switch@longtable} |
---|
4369 | % |
---|
4370 | % Here is the switch from standard \classname{longtable} to the new, \classname{ltxgrid}-compatible values. |
---|
4371 | % |
---|
4372 | % At this point, we extend \env{longtable} with a \env{longtable*} form, which signifies that we want to |
---|
4373 | % use the full page width for setting the table. |
---|
4374 | % You can think this way: \env{longtable*} is to \env{longtable} as \env{table*} is to \env{table}. |
---|
4375 | % |
---|
4376 | %FIXME: the following is no longer true: |
---|
4377 | %% Note that it is not enough to define the environment itself; we also have to create the corresponding |
---|
4378 | %% \cmd\output\ routine procedures, which provide for continued footers and headers |
---|
4379 | %% (the very feature of \env{longtable} requiring support in the output routine). |
---|
4380 | % |
---|
4381 | %% This same consideration would arise in defining any syntactic extension to \env{longtable}, because |
---|
4382 | %% the environment name itself is exposed in the output routine. |
---|
4383 | % |
---|
4384 | % \begin{macrocode} |
---|
4385 | \def\switch@longtable{% |
---|
4386 | \@ifpackageloaded{longtable}{% |
---|
4387 | \@ifx{\longtable\longtable@longtable}{% |
---|
4388 | \@ifx{\endlongtable\endlongtable@longtable}{% |
---|
4389 | \@ifx{\LT@start\LT@start@longtable}{% |
---|
4390 | \@ifx{\LT@end@hd@ft\LT@end@hd@ft@longtable}{% |
---|
4391 | \@ifx{\LT@array\LT@array@longtable}{% |
---|
4392 | \true@sw |
---|
4393 | }{\false@sw}% |
---|
4394 | }{\false@sw}% |
---|
4395 | }{\false@sw}% |
---|
4396 | }{\false@sw}% |
---|
4397 | }{\false@sw}% |
---|
4398 | {% |
---|
4399 | \class@info{Patching longtable package}% |
---|
4400 | }{% |
---|
4401 | \class@info{Patching unrecognized longtable package. (Proceeding with fingers crossed)}% |
---|
4402 | }% |
---|
4403 | \let\longtable\longtable@new |
---|
4404 | \let\endlongtable\endlongtable@new |
---|
4405 | \let\LT@start\LT@start@new |
---|
4406 | \let\LT@end@hd@ft\LT@end@hd@ft@new |
---|
4407 | \let\LT@array\LT@array@new |
---|
4408 | \newenvironment{longtable*}{% |
---|
4409 | \onecolumngrid@push |
---|
4410 | \longtable |
---|
4411 | }{% |
---|
4412 | \endlongtable |
---|
4413 | \onecolumngrid@pop |
---|
4414 | }% |
---|
4415 | % \expandafter\let\csname output@init@longtable*\endcsname\output@init@longtable |
---|
4416 | % \expandafter\let\csname output@prep@longtable*\endcsname\output@prep@longtable |
---|
4417 | % \expandafter\let\csname output@post@longtable*\endcsname\output@post@longtable |
---|
4418 | }{}% |
---|
4419 | }% |
---|
4420 | % \end{macrocode} |
---|
4421 | % \end{macro} |
---|
4422 | % |
---|
4423 | % \begin{macro}{\LT@pre} |
---|
4424 | % \begin{macro}{\LT@bot} |
---|
4425 | % \begin{macro}{\LT@top} |
---|
4426 | % \begin{macro}{\LT@post} |
---|
4427 | % \begin{macro}{\LT@adj} |
---|
4428 | % Note that at the end of the longtable environment, we reestablish the \cmd\mark@envir\ of the |
---|
4429 | % containing environment. We have left \cmd\curr@envir\ alone, so this will work. |
---|
4430 | % \begin{macrocode} |
---|
4431 | \def\LT@pre{\penalty\z@\vskip\LTpre}% |
---|
4432 | \def\LT@bot{\nobreak\copy\LT@foot\vfil}% |
---|
4433 | \def\LT@top{\copy\LT@head\nobreak}% |
---|
4434 | \def\LT@post{\penalty\z@\addvspace\LTpost\mark@envir{\curr@envir}}% |
---|
4435 | \def\LT@adj{% |
---|
4436 | \setbox\z@\vbox{\null}\dimen@-\ht\z@ |
---|
4437 | \setbox\z@\vbox{\unvbox\z@\LT@bot}\advance\dimen@\ht\z@ |
---|
4438 | \global\advance\vsize-\dimen@ |
---|
4439 | }% |
---|
4440 | % \end{macrocode} |
---|
4441 | % \end{macro} |
---|
4442 | % \end{macro} |
---|
4443 | % \end{macro} |
---|
4444 | % \end{macro} |
---|
4445 | % \end{macro} |
---|
4446 | % |
---|
4447 | % \begin{macro}{output@init} |
---|
4448 | % \begin{macro}{output@prep} |
---|
4449 | % \begin{macro}{output@post} |
---|
4450 | % \begin{macrocode} |
---|
4451 | \def\output@init@longtable{\LT@adj}% |
---|
4452 | \def\output@prep@longtable{\setbox\@cclv\vbox{\unvbox\@cclv\LT@bot}}% |
---|
4453 | \def\output@post@longtable{\LT@top}% |
---|
4454 | % \end{macrocode} |
---|
4455 | % \end{macro} |
---|
4456 | % \end{macro} |
---|
4457 | % \end{macro} |
---|
4458 | % |
---|
4459 | % |
---|
4460 | % \subsection{Patches for index processing}% |
---|
4461 | % |
---|
4462 | % Another feature that uses the output routine hooks occurs within |
---|
4463 | % an index, where one wishes to apply a ``continue head'' when a |
---|
4464 | % column breaks within a primary index entry. |
---|
4465 | % Some book designs call for the continue head to only be applied |
---|
4466 | % at a turnpage break. |
---|
4467 | % |
---|
4468 | % In any case, it is easy enough for \cmd\output@post@theindex\ |
---|
4469 | % to do this in conjunction with component marks. |
---|
4470 | % Only the bare outlines are shown here. |
---|
4471 | % |
---|
4472 | % \begin{macro}{\output@init} |
---|
4473 | % \begin{macro}{\output@prep} |
---|
4474 | % \begin{macro}{\output@post} |
---|
4475 | % \begin{macrocode} |
---|
4476 | \let\output@init@theindex\@empty |
---|
4477 | \let\output@prep@theindex\@empty |
---|
4478 | \def\output@post@theindex{% |
---|
4479 | \@ifodd\c@page{}{% |
---|
4480 | \@ifnum{\pagegrid@cur=\@ne}{% we have the leftmost column of a verso page |
---|
4481 | % insert the current top-level continued head |
---|
4482 | }% |
---|
4483 | }% |
---|
4484 | }% |
---|
4485 | % \end{macrocode} |
---|
4486 | % \end{macro} |
---|
4487 | % \end{macro} |
---|
4488 | % \end{macro} |
---|
4489 | % |
---|
4490 | % |
---|
4491 | % \subsection{Checking the auxiliary file}% |
---|
4492 | % |
---|
4493 | % We relegate the checking of the auxiliary file to the output routine. |
---|
4494 | % This task must wait until the last page is shipped out, because otherwise |
---|
4495 | % the stream might get closed before the last page is shipped out. |
---|
4496 | % Obviously, we must use \cmd\do@output@MVL\ for the job. |
---|
4497 | % |
---|
4498 | % \begin{macro}{\check@aux} |
---|
4499 | % \begin{macrocode} |
---|
4500 | \def\check@aux{\do@output@MVL{\do@check@aux}}% |
---|
4501 | % \end{macrocode} |
---|
4502 | % \end{macro} |
---|
4503 | % |
---|
4504 | % |
---|
4505 | % |
---|
4506 | % \subsection{Dealing with stuck floats and stalled float dequeueing}% |
---|
4507 | % |
---|
4508 | % \LaTeX's float placement mechanism is fundamentally flawed, as evidenced by |
---|
4509 | % its warning message ``too many unprocessed floats'', which users understandably find frustrating. |
---|
4510 | % The \classname{ltxgrid} package provides tools for ameliorating the situation somewhat. |
---|
4511 | % |
---|
4512 | % Two cases require detection and rectification: |
---|
4513 | % \begin{enumerate} |
---|
4514 | % \item |
---|
4515 | % A float is ``stuck'' in the \cmd\@deferlist: for whatever reason, the float fails to be committed, |
---|
4516 | % even at the start of a fresh page. |
---|
4517 | % Once this condition prevails, following floats can never be committed, subsequently all of \LaTeX's |
---|
4518 | % float registers are used up. |
---|
4519 | % |
---|
4520 | % If this condition is detected, we reconsider float dequeueing under permissive (\cmd\clearpage-style) processing. |
---|
4521 | % |
---|
4522 | % \item |
---|
4523 | % The \cmd\@freelist\ is exhausted: |
---|
4524 | % a large concentration of floats, say, uses up all of \LaTeX's float registers all at once. |
---|
4525 | % This condition commonly occurs when the user collects floats at the end of the document, for some reason. |
---|
4526 | % |
---|
4527 | % When a float is encountered, \LaTeX\ uses a float register (allocated from a pool of free registers) to contain it until it can be placed. |
---|
4528 | % However, no further action is taken until the pagebuilder is visited, so floats can accumulate. |
---|
4529 | % Also, even after the pagebuilder is visited, deferred floats can accumulate, and these are not committed |
---|
4530 | % until a column (or page) of text is completed. |
---|
4531 | % |
---|
4532 | % Once the last free float register is used, action should be taken that will commit some of the deferred floats, |
---|
4533 | % even if this might require ending the page right where we are (resulting in a short page). |
---|
4534 | % |
---|
4535 | % Perhaps, committed floats should be stored using some mechanism other than a list, as is currently done. |
---|
4536 | % A feasible alternative storage method would be to use a \cmd\box\ register in place of |
---|
4537 | % \cmd\@toplist, |
---|
4538 | % \cmd\@botlist, and |
---|
4539 | % \cmd\@dbltoplist. |
---|
4540 | % This is probably just fine, since such committed floats are not reconsidered (I think). |
---|
4541 | % |
---|
4542 | % \end{enumerate} |
---|
4543 | % |
---|
4544 | % The emergency processing implemented here immediately ends the current page and begins to output float pages under (\cmd\clearpage-style) rules. |
---|
4545 | % It proceeds until all deferred floats have been flushed. |
---|
4546 | % |
---|
4547 | % Users should expect non-optimal page makeup under these circumstances. |
---|
4548 | % |
---|
4549 | % Note that there is a weakness in our approach that we have not attempted to repair: if floats are being |
---|
4550 | % added as part of a paragraph, we will not be able to take these remedial steps until the paragraph ends. |
---|
4551 | % This means that the approach implemented here cannot fix all \LaTeX\ documents. Users can still construct |
---|
4552 | % documents that exhaust \LaTeX's pool of float registers! |
---|
4553 | % |
---|
4554 | % \begin{macro}{\check@deferlist@stuck} |
---|
4555 | % \begin{macro}{\@outputpage} |
---|
4556 | % We detect the case where, at the start of a fresh page, there are deferred floats, but none are |
---|
4557 | % committed. We memorize the \cmd\@deferlist\ at \cmd\shipout\ time, then examine it at the point where |
---|
4558 | % our efforts to commit floats to the new page are complete. |
---|
4559 | % If it has not changed, the first float must be stuck, and we |
---|
4560 | % attempt to fix things via \cmd\force@deferlist@stuck. |
---|
4561 | % |
---|
4562 | % This simple approach is comp[letely effective in for typical documents. |
---|
4563 | % |
---|
4564 | % Note that we try to avoid an infinite loop by examining the value of \cmd\clearpage@sw: |
---|
4565 | % if we come here with that boolean true, we are in a loop. |
---|
4566 | % \begin{macrocode} |
---|
4567 | \def\check@deferlist@stuck#1{% |
---|
4568 | \@ifx{\@deferlist@postshipout\@empty}{}{% |
---|
4569 | \@ifx{\@deferlist@postshipout\@deferlist}{% |
---|
4570 | \@fltstk |
---|
4571 | \clearpage@sw{% |
---|
4572 | \ltxgrid@warn{Deferred float stuck during \string\clearpage\space processing}% |
---|
4573 | }{% |
---|
4574 | \force@deferlist@stuck#1% |
---|
4575 | }% |
---|
4576 | }{% |
---|
4577 | %Successfully committed float(s) |
---|
4578 | }% |
---|
4579 | \global\let\@deferlist@postshipout\@empty |
---|
4580 | }% |
---|
4581 | }% |
---|
4582 | \def\@fltstk{% |
---|
4583 | \@latex@warning{A float is stuck (cannot be placed without \string\clearpage)}% |
---|
4584 | }% |
---|
4585 | \appdef\@outputpage{% |
---|
4586 | \global\let\@deferlist@postshipout\@deferlist |
---|
4587 | }% |
---|
4588 | % \end{macrocode} |
---|
4589 | % \end{macro} |
---|
4590 | % \end{macro} |
---|
4591 | % |
---|
4592 | % \begin{macro}{\@next} |
---|
4593 | % \begin{macro}{\@xnext} |
---|
4594 | % We rewrite the \LaTeX\ kernel macros that dequeue float registers from, e.g., \cmd\@deferlist, |
---|
4595 | % providing a test for the condition where the pool of free registers is about to underflow. |
---|
4596 | % |
---|
4597 | % In this case, we attempt to fix things via \cmd\force@deferlist@empty. |
---|
4598 | % \begin{macrocode} |
---|
4599 | \def\@next#1#2{% |
---|
4600 | \@ifx{#2\@empty}{\false@sw}{% |
---|
4601 | \expandafter\@xnext#2\@@#1#2% |
---|
4602 | \true@sw |
---|
4603 | }% |
---|
4604 | }% |
---|
4605 | \def\@xnext\@elt#1#2\@@#3#4{% |
---|
4606 | \def#3{#1}% |
---|
4607 | \gdef#4{#2}% |
---|
4608 | \def\@tempa{#4}\def\@tempb{\@freelist}% |
---|
4609 | \@ifx{\@tempa\@tempb}{% |
---|
4610 | \@ifx{#4\@empty}{% |
---|
4611 | \force@deferlist@empty%{Float register pool exhausted}% |
---|
4612 | }{}% |
---|
4613 | }{}% |
---|
4614 | }% |
---|
4615 | % \end{macrocode} |
---|
4616 | % \end{macro} |
---|
4617 | % \end{macro} |
---|
4618 | % |
---|
4619 | % \begin{macro}{\force@deferlist@stuck} |
---|
4620 | % \begin{macro}{\force@deferlist@empty} |
---|
4621 | % \begin{macro}{\force@deferlist@sw} |
---|
4622 | % \begin{macro}{\do@forcecolumn@pen} |
---|
4623 | % \begin{macro}{\do@forcecolumn} |
---|
4624 | % The procedure \cmd\force@deferlist@empty\ is an attempt to rectify a situation where \LaTeX's float placement mechanism |
---|
4625 | % may fail (``too many unprocessed floats''). |
---|
4626 | % |
---|
4627 | % We put down interrupts that call for the float placement to be redone, but under permissive conditions, |
---|
4628 | % just the same as if \cmd\clearpage\ had been invoked. |
---|
4629 | % |
---|
4630 | % Note that the attempt to rectify the error is contingent on the setting of \cmd\force@deferlist@sw, |
---|
4631 | % default false. A document class using this package that wishes to enable this error recovery mechanism should |
---|
4632 | % set this boolean to true. |
---|
4633 | % |
---|
4634 | % The interrupt \cmd\do@forcecolumn@pen, which invokes the procedure \cmd\do@forcecolumn, |
---|
4635 | % does the same as \cmd\do@startcolumn, except under permissive conditions: |
---|
4636 | % we are trying to empty out the float registers completely. |
---|
4637 | % |
---|
4638 | % In order to properly with the case where there is material in \cmd\box\cmd\@cclv, |
---|
4639 | % \cmd\@toplist, \cmd\@botlist, \cmd\@dbltoplist, etc, |
---|
4640 | % we do what amounts to \cmd\newpage\ to get things rolling. |
---|
4641 | % |
---|
4642 | % In \cmd\force@deferlist@stuck, we take advantage of already being in the output routine: |
---|
4643 | % simply reinvoke \cmd\do@startcolumn\ under permissive conditions. |
---|
4644 | % |
---|
4645 | % \begin{macrocode} |
---|
4646 | \def\force@deferlist@stuck#1{% |
---|
4647 | \force@deferlist@sw{% |
---|
4648 | \@booleantrue\clearpage@sw |
---|
4649 | \@booleantrue\forcefloats@sw |
---|
4650 | #1% |
---|
4651 | }{% |
---|
4652 | }% |
---|
4653 | }% |
---|
4654 | \def\force@deferlist@empty{% |
---|
4655 | \force@deferlist@sw{% |
---|
4656 | % \ltxgrid@info{#1, attempting rectification}% |
---|
4657 | \penalty-\pagebreak@pen |
---|
4658 | \protect@penalty\do@forcecolumn@pen |
---|
4659 | }{% |
---|
4660 | % \ltxgrid@info{#1}% |
---|
4661 | }% |
---|
4662 | }% |
---|
4663 | \@booleanfalse\force@deferlist@sw |
---|
4664 | \mathchardef\do@forcecolumn@pen=10009 |
---|
4665 | \@namedef{output@-\the\do@forcecolumn@pen}{\do@forcecolumn}% |
---|
4666 | \def\do@forcecolumn{% |
---|
4667 | \@booleantrue\clearpage@sw |
---|
4668 | \@booleantrue\forcefloats@sw |
---|
4669 | %\unvbox\@cclv |
---|
4670 | %\vfil |
---|
4671 | %\penalty-\pagebreak@pen |
---|
4672 | \do@startcolumn |
---|
4673 | }% |
---|
4674 | % \end{macrocode} |
---|
4675 | % \end{macro} |
---|
4676 | % \end{macro} |
---|
4677 | % \end{macro} |
---|
4678 | % \end{macro} |
---|
4679 | % \end{macro} |
---|
4680 | % |
---|
4681 | % A more thorough revision of \LaTeX's float placement mechanism would involve substituting a single \cmd\box\ |
---|
4682 | % register for the \cmd\@deferlist. This way, \LaTeX's ability to have latent floats would be limited by |
---|
4683 | % box memory alone. |
---|
4684 | % |
---|
4685 | % Because only the \cmd\box\ and \cmd\count\ components of the float box register are actually used by \LaTeX, |
---|
4686 | % our scheme can be accomplished if we can find a way to encode the information held in the \cmd\count\ component. |
---|
4687 | % |
---|
4688 | % A first-in, first-out mechanism exists, wherein a box-penalty pair is dequeued by \cmd\lastbox\cmd\lastpenalty\cmd\unpenalty\ and enqueued |
---|
4689 | % by \cmd\setbox\cmd\foo=\cmd\hbox\cmd\bgroup\cmd\penalty\cmd\floatpenalty\cmd\box\cmd\floatbox\cmd\unhbox\cmd\foo\cmd\egroup. |
---|
4690 | % |
---|
4691 | % Note that this scheme is made possible by our change to \LaTeX's float placement mechanism, |
---|
4692 | % wherein we consolidated the two \cmd\@deferlist s into one. |
---|
4693 | % |
---|
4694 | % \section{Support for legacy \LaTeX\ commands} |
---|
4695 | % |
---|
4696 | % We provide support for the \cmd\enlargethispage\ command. |
---|
4697 | % |
---|
4698 | % Note: using a command of this sort is questionable. |
---|
4699 | % Instead, people should enlarge the entire spread. |
---|
4700 | % |
---|
4701 | % Timing Note: In a multicolumn page grid, the user should issue the \cmd\enlargethispage\ command |
---|
4702 | % while the first column of the page is being typeset. |
---|
4703 | % We provide a helpful message if the timing is wrong. |
---|
4704 | % |
---|
4705 | % This code can serve as a model for introducing commands that need to execute within the safety of the output routine. |
---|
4706 | % We ensure that the arguments are fully expanded, then execute \cmd\do@output@MVL\ to cause an output procedure, |
---|
4707 | % \cmd\@@enlargethispage, to execute. When it does execute, the MVL will be exposed. |
---|
4708 | % |
---|
4709 | % The \cmd\@@enlargethispage\ procedure simply adjusts the vertical dimensions of the page. |
---|
4710 | % The adjustment will persist until the column is committed, at which point the page dimension |
---|
4711 | % will revert to its standard value. |
---|
4712 | % \begin{macrocode} |
---|
4713 | \def\enlargethispage{% |
---|
4714 | \@ifstar{% |
---|
4715 | \@enlargethispage{}% |
---|
4716 | }{% |
---|
4717 | \@enlargethispage{}% |
---|
4718 | }% |
---|
4719 | }% |
---|
4720 | \def\@enlargethispage#1#2{% |
---|
4721 | \begingroup |
---|
4722 | \dimen@#2\relax |
---|
4723 | \edef\@tempa{#1}% |
---|
4724 | \edef\@tempa{\noexpand\@@enlargethispage{\@tempa}{\the\dimen@}}% |
---|
4725 | \expandafter\do@output@MVL\expandafter{\@tempa}% |
---|
4726 | \endgroup |
---|
4727 | }% |
---|
4728 | \def\@@enlargethispage#1#2{% |
---|
4729 | \def\@tempa{one}% |
---|
4730 | \@ifx{\thepagegrid\@tempa}{% |
---|
4731 | \true@sw |
---|
4732 | }{% |
---|
4733 | \def\@tempa{mlt}% |
---|
4734 | \@ifx{\thepagegrid\@tempa}{% |
---|
4735 | \@ifnum{\pagegrid@cur=\@ne}{% OK to adjust this page |
---|
4736 | \gdef\enlarge@colroom{#2}% |
---|
4737 | \true@sw |
---|
4738 | }{% Can only adjust this column; give up |
---|
4739 | \ltxgrid@warn{Too late to enlarge this page; move the command to the first column.}% |
---|
4740 | \false@sw |
---|
4741 | }% |
---|
4742 | }{% Unknown page grid |
---|
4743 | \ltxgrid@warn{Unable to enlarge a page of this kind.}% |
---|
4744 | \false@sw |
---|
4745 | }% |
---|
4746 | }% |
---|
4747 | {% |
---|
4748 | \class@info{Enlarging page \thepage\space by #2}% |
---|
4749 | \global\advance\@colroom#2\relax |
---|
4750 | \set@vsize |
---|
4751 | }{% |
---|
4752 | % Could not adjust this page |
---|
4753 | }% |
---|
4754 | }% |
---|
4755 | \let\enlarge@colroom\@empty |
---|
4756 | % \end{macrocode} |
---|
4757 | % The \cmd\@kludgeins\ insert register is now unneeded. |
---|
4758 | % Ensure that packages using this mechanism break (preferrable to subtle bugs). |
---|
4759 | % \begin{macrocode} |
---|
4760 | \let\@kludgeins\@undefined |
---|
4761 | % \end{macrocode} |
---|
4762 | % |
---|
4763 | % \subsubsection{Building the page for shipout} |
---|
4764 | % |
---|
4765 | % \begin{macro}{\@outputpage} |
---|
4766 | % The procedures that build \cmd\@outputbox\ just before a page is shipped out by \cmd\@outputpage\ are: |
---|
4767 | % \cmd\@makecol, |
---|
4768 | % \cmd\@combinepage, and |
---|
4769 | % \cmd\@combinedblfloats. |
---|
4770 | % We headpatch \cmd\@outputpage\ to make the \cmd\@outputbox\ be of fixed height. |
---|
4771 | % \begin{macrocode} |
---|
4772 | \@booleantrue\textheight@sw |
---|
4773 | \prepdef\@outputpage{% |
---|
4774 | \textheight@sw{% |
---|
4775 | \count@\vbadness\vbadness\@M |
---|
4776 | \dimen@\vfuzz\vfuzz\maxdimen |
---|
4777 | \setbox\@outputbox\vbox to\textheight{\unvbox\@outputbox}% |
---|
4778 | \vfuzz\dimen@ |
---|
4779 | \vbadness\count@ |
---|
4780 | }{}% |
---|
4781 | }% |
---|
4782 | % \end{macrocode} |
---|
4783 | % \end{macro} |
---|
4784 | % |
---|
4785 | % \subsubsection{Warning message} |
---|
4786 | % |
---|
4787 | % \begin{macro}{\ltxgrid@info} |
---|
4788 | % \begin{macro}{\ltxgrid@warn} |
---|
4789 | % Something has happened that the user might be interested in. |
---|
4790 | % Print a message to the log, but only if the user selected the verbose option. |
---|
4791 | % \begin{macrocode} |
---|
4792 | \def\ltxgrid@info{% |
---|
4793 | \ltxgrid@info@sw{\class@info}{\@gobble}% |
---|
4794 | }% |
---|
4795 | \@booleanfalse\ltxgrid@info@sw |
---|
4796 | \def\ltxgrid@warn{% |
---|
4797 | \ltxgrid@warn@sw{\class@warn}{\@gobble}% |
---|
4798 | }% |
---|
4799 | \@booleantrue\ltxgrid@warn@sw |
---|
4800 | % \end{macrocode} |
---|
4801 | % \end{macro} |
---|
4802 | % \end{macro} |
---|
4803 | % |
---|
4804 | % \section{End of the \file{ltxgrid} {\sc docstrip} module} |
---|
4805 | % Here ends the module. |
---|
4806 | % \begin{macrocode} |
---|
4807 | %</ltxgrid-krn> |
---|
4808 | % \end{macrocode} |
---|
4809 | % |
---|
4810 | % \Finale |
---|
4811 | % %Here ends the programmer's documentation. |
---|
4812 | % \endinput |
---|
4813 | % |
---|
4814 | \endinput |
---|
4815 | %%EOF |
---|