| 1 |
% \iffalse meta-comment balanced on line 109 |
| 2 |
% ltxgrid.dtx: package to change page grid, MVL. |
| 3 |
% Copyright (c) 2009 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 |
% License |
| 10 |
% You may distribute this file under the conditions of the |
| 11 |
% LaTeX Project Public License 1.3c or later |
| 12 |
% (http://www.latex-project.org/lppl.txt). |
| 13 |
% ReadMe |
| 14 |
% For the documentation and more detailed instructions for |
| 15 |
% installation, typeset this document with \LaTeX. |
| 16 |
% Maintenance Status |
| 17 |
% This work has the LPPL maintenance status "maintained"; |
| 18 |
% Current Maintainer of this work is Arthur Ogawa |
| 19 |
% changes for version 4.2d--4.2f by Phelype Oleinik. |
| 20 |
% |
| 21 |
% This work consists of the main source file ltxgrid.dtx |
| 22 |
% and the derived files |
| 23 |
% ltxgrid.sty, ltxgrid.pdf |
| 24 |
% Distribution: |
| 25 |
% CTAN:macros/latex/contrib/revtex/ |
| 26 |
% |
| 27 |
% Unpacking: |
| 28 |
% tex ltxgrid.dtx |
| 29 |
% |
| 30 |
% Documentation: |
| 31 |
% latex ltxgrid.dtx; ... |
| 32 |
% |
| 33 |
% Programm calls to get the documentation (example): |
| 34 |
% pdflatex ltxgrid.dtx |
| 35 |
% makeindex -s gind.ist ltxgrid |
| 36 |
% makeindex -s gglo.ist -o ltxgrid.gls ltxgrid.glo |
| 37 |
% pdflatex ltxgrid.dtx |
| 38 |
% makeindex -s gind.ist ltxgrid.idx |
| 39 |
% pdflatex ltxgrid.dtx |
| 40 |
% |
| 41 |
% Installation: |
| 42 |
% TDS:doc/latex/revtex/ |
| 43 |
% TDS:tex/latex/revtex/ |
| 44 |
% TDS:source/latex/revtex/ |
| 45 |
% |
| 46 |
% Thanks, Heiko! |
| 47 |
% This method of letting a single .dtx file serve as both |
| 48 |
% documentation (via latex) and installer (via tex) follows |
| 49 |
% the example of Heiko Oberdiek. Thanks! |
| 50 |
%<*ignore> |
| 51 |
\begingroup |
| 52 |
\def\x{LaTeX2e}% |
| 53 |
\expandafter\endgroup |
| 54 |
\ifcase |
| 55 |
0\expandafter\ifx\csname processbatchFile\endcsname\relax\else1\fi\ifx\fmtname\x\else 1\fi |
| 56 |
\relax |
| 57 |
\else |
| 58 |
\csname fi\endcsname |
| 59 |
%</ignore> |
| 60 |
%<*install> |
| 61 |
%% This file will generate documentation and runtime files |
| 62 |
%% from ltxgrid.dtx when run through LaTeX or TeX. |
| 63 |
\input docstrip |
| 64 |
\preamble |
| 65 |
|
| 66 |
This is a generated file; |
| 67 |
altering it directly is inadvisable; |
| 68 |
instead, modify the original source file. |
| 69 |
See the URL in the file README-LTXGRID.tex. |
| 70 |
|
| 71 |
License |
| 72 |
You may distribute this file under the conditions of the |
| 73 |
LaTeX Project Public License 1.3c or later |
| 74 |
(http://www.latex-project.org/lppl.txt). |
| 75 |
|
| 76 |
This file is distributed WITHOUT ANY WARRANTY; |
| 77 |
without even the implied warranty of MERCHANTABILITY |
| 78 |
or FITNESS FOR A PARTICULAR PURPOSE. |
| 79 |
|
| 80 |
\endpreamble |
| 81 |
\askforoverwritefalse |
| 82 |
\keepsilent |
| 83 |
\generate{% |
| 84 |
%{ignore} |
| 85 |
% \usedir{tex/latex/revtex}% |
| 86 |
\file{ltxgrid.sty}{% |
| 87 |
\from{ltxgrid.dtx}{package,kernel}% |
| 88 |
}% |
| 89 |
}% |
| 90 |
\ifToplevel{ |
| 91 |
\Msg{***********************************************************} |
| 92 |
\Msg{*} |
| 93 |
\Msg{* To finish the installation, please move} |
| 94 |
\Msg{* ltxgrid.sty} |
| 95 |
\Msg{* into a directory searched by TeX;} |
| 96 |
\Msg{* in a TDS-compliant installation:} |
| 97 |
\Msg{* texmf/tex/macros/latex/revtex/.} |
| 98 |
\Msg{*} |
| 99 |
\Msg{* To produce the documentation, |
| 100 |
run ltxgrid.dtx through LaTeX.} |
| 101 |
\Msg{*} |
| 102 |
\Msg{* Happy TeXing} |
| 103 |
\Msg{***********************************************************} |
| 104 |
} |
| 105 |
\endbatchfile |
| 106 |
%</install> |
| 107 |
%<*ignore> |
| 108 |
\fi |
| 109 |
%</ignore> |
| 110 |
% \fi |
| 111 |
% |
| 112 |
% \GetFileInfo{ltxgrid.dtx} |
| 113 |
% |
| 114 |
% \iffalse ltxdoc klootch |
| 115 |
%<*package> |
| 116 |
%%% @LaTeX-file{ |
| 117 |
%%% filename = "ltxgrid.dtx", |
| 118 |
%%% version = "4.2f", |
| 119 |
%%% date = "2022/06/05", |
| 120 |
%%% author = "Arthur Ogawa (mailto:arthur_ogawa at sbcglobal.net), |
| 121 |
%%% Phelype Oleinik (mailto:phelype.oleinik at latex-project.org), |
| 122 |
%%% commissioned by the American Physical Society. |
| 123 |
%%% ", |
| 124 |
%%% copyright = "Copyright (C) 1999, 2009 Arthur Ogawa, |
| 125 |
%%% distributed under the terms of the |
| 126 |
%%% LaTeX Project Public License 1.3c, see |
| 127 |
%%% ftp://ctan.tug.org/macros/latex/base/lppl.txt |
| 128 |
%%% ", |
| 129 |
%%% address = "Arthur Ogawa, |
| 130 |
%%% USA", |
| 131 |
%%% telephone = "", |
| 132 |
%%% FAX = "", |
| 133 |
%%% email = "mailto colon arthur_ogawa at sbcglobal.net", |
| 134 |
%%% codetable = "ISO/ASCII", |
| 135 |
%%% keywords = "latex, page grid, main vertical list", |
| 136 |
%%% supported = "yes", |
| 137 |
%%% abstract = "package to change page grid, MVL", |
| 138 |
%%% } |
| 139 |
%</package> |
| 140 |
% \fi |
| 141 |
% |
| 142 |
% \iffalse ltxdoc klootch |
| 143 |
% The following references the \file{README-LTXGRID} file, |
| 144 |
% which contains basic information about this package. |
| 145 |
% The contents of this file are generated when |
| 146 |
% you typeset the programmer's documentation. |
| 147 |
% Search on "{filecontents*}{README-LTXGRID}" to locate it. |
| 148 |
% \fi\input{README-LTXGRID}% |
| 149 |
% |
| 150 |
% \subsection{Bill of Materials} |
| 151 |
% |
| 152 |
% Following is a list of the files in this distribution arranged |
| 153 |
% according to provenance. |
| 154 |
% |
| 155 |
% \subsubsection{Primary Source}% |
| 156 |
% One single file generates all. |
| 157 |
%\begin{verbatim} |
| 158 |
%ltxgrid.dtx |
| 159 |
%\end{verbatim} |
| 160 |
% |
| 161 |
% \subsubsection{Generated by \texttt{latex ltxgrid.dtx}}% |
| 162 |
% Typesetting the source file under \LaTeX\ |
| 163 |
% generates the readme and the installer. |
| 164 |
%\begin{verbatim} |
| 165 |
%README-LTXGRID ltxgrid.ins |
| 166 |
%\end{verbatim} |
| 167 |
% |
| 168 |
% \subsubsection{Generated by \texttt{tex ltxgrid.ins}}% |
| 169 |
% Typesetting the installer generates |
| 170 |
% the package files. |
| 171 |
%\begin{verbatim} |
| 172 |
%ltxgrid.sty |
| 173 |
%\end{verbatim} |
| 174 |
% |
| 175 |
% \subsubsection{Documentation}% |
| 176 |
% The following are the online documentation: |
| 177 |
% \begin{verbatim} |
| 178 |
%ltxgrid.pdf |
| 179 |
% \end{verbatim} |
| 180 |
% |
| 181 |
% \subsubsection{Auxiliary}% |
| 182 |
% The following are auxiliary files generated |
| 183 |
% in the course of running \LaTeX: |
| 184 |
% \begin{verbatim} |
| 185 |
%ltxgrid.aux ltxgrid.idx ltxgrid.ind ltxgrid.log ltxgrid.toc |
| 186 |
% \end{verbatim} |
| 187 |
% |
| 188 |
% \section{Code common to all modules}% |
| 189 |
% |
| 190 |
% The following may look a bit klootchy, but we |
| 191 |
% want to require only one place in this file |
| 192 |
% where the version number is stated, |
| 193 |
% and we also want to ensure that the version |
| 194 |
% number is embedded into every generated file. |
| 195 |
% |
| 196 |
% Now we declare that |
| 197 |
% these files can only be used with \LaTeXe. |
| 198 |
% An appropriate message is displayed if |
| 199 |
% a different \TeX{} format is used. |
| 200 |
% \begin{macrocode} |
| 201 |
%<*driver|package> |
| 202 |
\NeedsTeXFormat{LaTeX2e}[1995/12/01]% |
| 203 |
%</driver|package> |
| 204 |
% \end{macrocode} |
| 205 |
% As desired, the following modules all |
| 206 |
% take common version information: |
| 207 |
% \begin{macrocode} |
| 208 |
%<kernel&!package&!doc>\typeout{% |
| 209 |
%<*package|doc> |
| 210 |
\ProvidesFile{% |
| 211 |
%</package|doc> |
| 212 |
%<*kernel|package|doc> |
| 213 |
ltxgrid% |
| 214 |
%</kernel|package|doc> |
| 215 |
%<*doc> |
| 216 |
.dtx% |
| 217 |
%</doc> |
| 218 |
%<package>.sty% |
| 219 |
%<*package|doc> |
| 220 |
}% |
| 221 |
%</package|doc> |
| 222 |
% \end{macrocode} |
| 223 |
% |
| 224 |
% The following line contains, for once and for all, |
| 225 |
% the version and date information. |
| 226 |
% By various means, this information is reproduced |
| 227 |
% consistently in all generated files and in the |
| 228 |
% typeset documentation. |
| 229 |
% Give credit where due. |
| 230 |
% \begin{macrocode} |
| 231 |
%<*doc|package|kernel> |
| 232 |
%<version> |
| 233 |
[2022/06/05 4.2f page grid package (portions licensed from W. E. Baxter web at superscript.com)]% \fileversion |
| 234 |
%</doc|package|kernel> |
| 235 |
%<kernel&!package&!doc>}% |
| 236 |
% \end{macrocode} |
| 237 |
% |
| 238 |
% |
| 239 |
% \section{The driver module \texttt{doc}} |
| 240 |
% |
| 241 |
% This module, consisting of the present section, |
| 242 |
% typesets the programmer's documentation, |
| 243 |
% generating the \file{.ins} installer and \file{README-LTXGRID} as required. |
| 244 |
% |
| 245 |
% Because the only uncommented-out lines of code at the beginning of |
| 246 |
% this file constitute the \file{doc} module itself, |
| 247 |
% we can simply typeset the \file{.dtx} file directly, |
| 248 |
% and there is thus rarely any need to |
| 249 |
% generate the ``doc'' {\sc docstrip} module. |
| 250 |
% Module delimiters are nonetheless required so that |
| 251 |
% this code does not find its way into the other modules. |
| 252 |
% |
| 253 |
% The \enve{document} command concludes the typesetting run. |
| 254 |
% |
| 255 |
% \begin{macrocode} |
| 256 |
%<*driver> |
| 257 |
% \end{macrocode} |
| 258 |
% |
| 259 |
% \subsection{The Preamble} |
| 260 |
% The programmers documentation is formatted |
| 261 |
% with the \classname{ltxdoc} class with local customizations, |
| 262 |
% and with the usual code line indexing. |
| 263 |
% \begin{macrocode} |
| 264 |
\documentclass{ltxdoc} |
| 265 |
\RequirePackage{ltxdocext}% |
| 266 |
\RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}% |
| 267 |
%\ifx\package@font\@undefined\else |
| 268 |
% \expandafter\expandafter |
| 269 |
% \expandafter\RequirePackage |
| 270 |
% \expandafter\expandafter |
| 271 |
% \expandafter{% |
| 272 |
% \csname package@font\endcsname |
| 273 |
% }% |
| 274 |
%\fi |
| 275 |
\CodelineIndex\EnableCrossrefs % makeindex -s gind.ist ltxgrid |
| 276 |
\RecordChanges % makeindex -s gglo.ist -o ltxgrid.gls ltxgrid.glo |
| 277 |
% \end{macrocode} |
| 278 |
% |
| 279 |
% \subsubsection{Docstrip and info directives} |
| 280 |
% We use so many {\sc docstrip} modules that we set the |
| 281 |
% \texttt{StandardModuleDepth} counter to 1. |
| 282 |
% \begin{macrocode} |
| 283 |
\setcounter{StandardModuleDepth}{1} |
| 284 |
% \end{macrocode} |
| 285 |
% The following command retrieves the date and version information |
| 286 |
% from this file. |
| 287 |
% \begin{macrocode} |
| 288 |
\expandafter\GetFileInfo\expandafter{\jobname.dtx}% |
| 289 |
% \end{macrocode} |
| 290 |
% |
| 291 |
% \subsection{The ``Read Me'' File} |
| 292 |
% As promised above, here is the contents of the |
| 293 |
% ``Read Me'' file. That file serves a double purpose, |
| 294 |
% since it also constitutes the beginining of the |
| 295 |
% programmer's documentation. What better thing, after |
| 296 |
% all, to have appear at the beginning of the |
| 297 |
% typeset documentation? |
| 298 |
% |
| 299 |
% A good discussion of how to write a ReadMe file can be found in |
| 300 |
% Engst, Tonya, ``Writing a ReadMe File? Read This'' |
| 301 |
% \emph{MacTech} October 1998, p. 58. |
| 302 |
% |
| 303 |
% Note the appearance of the |
| 304 |
% \cmd\StopEventually\ command, which marks the |
| 305 |
% dividing line between the user documentation |
| 306 |
% and the programmer documentation. |
| 307 |
% |
| 308 |
% The usual user will not be asked to |
| 309 |
% do a full build, not to speak |
| 310 |
% of the bootstrap. |
| 311 |
% Instructions for carrying these processes |
| 312 |
% begin the programmer's manual. |
| 313 |
% |
| 314 |
% \begin{macrocode} |
| 315 |
\begin{filecontents*}{README-LTXGRID} |
| 316 |
\title{% |
| 317 |
A \LaTeX\ Package for changing the page grid and MVL% |
| 318 |
\thanks{% |
| 319 |
This file has version number \fileversion, |
| 320 |
last revised \filedate.% |
| 321 |
}% |
| 322 |
\thanks{% |
| 323 |
Version \fileversion\ \copyright\ 2019--2022 American Physical Society |
| 324 |
}% |
| 325 |
}% |
| 326 |
\author{% |
| 327 |
Arthur Ogawa% |
| 328 |
\thanks{\texttt{mailto:arthur\_ogawa at sbcglobal.net}}% |
| 329 |
}% |
| 330 |
%\iffalse |
| 331 |
% For version number and date, |
| 332 |
% search on "\fileversion" in the .dtx file, |
| 333 |
% or see the end of the README-LTXGRID file. |
| 334 |
%\fi |
| 335 |
\maketitle |
| 336 |
|
| 337 |
This file embodies the \classname{ltxgrid} package, |
| 338 |
the implementation and its user documentation. |
| 339 |
|
| 340 |
The distribution point for this work is |
| 341 |
\url{journals.aps.org/revtex}, |
| 342 |
which contains the REV\TeX\ package, and includes source and documentation for this package. |
| 343 |
|
| 344 |
The \classname{ltxgrid} package was commissioned by the American Physical Society |
| 345 |
and is distributed under the terms of the \LaTeX\ Project Public License 1.3c, |
| 346 |
the same license under which all the portions of \LaTeX\ itself is distributed. |
| 347 |
Please see \url{http://ctan.tug.org/macros/latex/base/lppl.txt} for details. |
| 348 |
|
| 349 |
To use this document class, you must have a working |
| 350 |
\TeX\ installation equipped with \LaTeXe\ |
| 351 |
and possibly pdftex and Adobe Acrobat Reader or equivalent. |
| 352 |
|
| 353 |
To install, retrieve the distribution, |
| 354 |
unpack it into a directory on the target computer, |
| 355 |
into a location in your filesystem where it will be found by \LaTeX; |
| 356 |
in a TDS-compliant installation this would be: |
| 357 |
\file{texmf/tex/macros/latex/revtex/.} |
| 358 |
|
| 359 |
To use, read the user documentation \file{src/ltxgrid.pdf}. |
| 360 |
|
| 361 |
\tableofcontents |
| 362 |
|
| 363 |
\section{Processing Instructions} |
| 364 |
|
| 365 |
The package file \file{ltxgrid.sty} |
| 366 |
is generated from this file, \file{ltxgrid.dtx}, |
| 367 |
using the {\sc docstrip} facility of \LaTeX |
| 368 |
via |tex ltxgrid.dtx|. |
| 369 |
The typeset documentation that you are now reading is generated from |
| 370 |
this same file by typesetting it with \LaTeX\ or pdftex |
| 371 |
via |latex ltxgrid.dtx| or |pdflatex ltxgrid.dtx|. |
| 372 |
|
| 373 |
\subsection{Build Instructions} |
| 374 |
|
| 375 |
You may bootstrap this suite of files solely from \file{ltxgrid.dtx}. |
| 376 |
Prepare by installing \LaTeXe\ (and either tex or pdftex) on your computer, |
| 377 |
then carry out the following steps: |
| 378 |
\begin{enumerate} |
| 379 |
\item |
| 380 |
Within an otherwise empty directory, |
| 381 |
typeset \file{ltxgrid.dtx} with \TeX\ or pdftex; |
| 382 |
thereby generating the package file \file{ltxgrid.sty}. |
| 383 |
|
| 384 |
\item |
| 385 |
Now typeset \file{ltxgrid.dtx} with \LaTeX\ or pdflatex; |
| 386 |
you will obtain the typeset documentation you are now reading, |
| 387 |
along with the file \file{README-LTXGRID}. |
| 388 |
|
| 389 |
Note: you will have to run \LaTeX\ twice, then \file{makeindex}, then |
| 390 |
\LaTeX\ again in order to obtain a valid index and table of contents. |
| 391 |
|
| 392 |
\item |
| 393 |
Install the following files into indicated locations within your |
| 394 |
TDS-compliant \texttt{texmf} tree (you may need root access): |
| 395 |
\begin{itemize} |
| 396 |
\item |
| 397 |
\file{$TEXMF/}\file{tex/}\file{latex/}\file{revtex/}\classname{ltxgrid.sty} |
| 398 |
\item |
| 399 |
\file{$TEXMF/}\file{source/}\file{latex/}\file{revtex/}\classname{ltxgrid.dtx} |
| 400 |
\item |
| 401 |
\file{$TEXMF/}\file{doc/}\file{latex/}\file{revtex/}\classname{ltxgrid.pdf} |
| 402 |
\end{itemize} |
| 403 |
where \file{TEXMF/} stands for \file{texmf-local/}, or some other \texttt{texmf} tree in your installation. |
| 404 |
\item |
| 405 |
Run \texttt{mktexlsr} on directory \file{$TEXMF/} (you may need root access). |
| 406 |
\item |
| 407 |
Build and installation are now complete; |
| 408 |
now put a \cmd\usepackage\texttt{\{ltxgrid\}} in your document preamble! |
| 409 |
(Note: \texttt{ltxgrid} requires package \texttt{ltxutil}.) |
| 410 |
\end{enumerate} |
| 411 |
|
| 412 |
\subsection{Change Log} |
| 413 |
\changes{4.0a}{2001/06/18}{Introduce \cs{marry@height} } |
| 414 |
\changes{4.0a}{2001/06/18}{Introduce \cs{set@marry@height} } |
| 415 |
\changes{4.0a}{2008/06/26 }{\cs{@yfloat}: de-fang \cs{set@footnotewidth} (see ltxutil.dtx): we have already done its job. } |
| 416 |
\changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: restore \cs{@tabularcr} and \cs{@xtabularcr}} |
| 417 |
\changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: set \cs{LT@LL@FM@cr} to \cs{@arraycr@array} instead of \cs{@arraycr}} |
| 418 |
\changes{4.1a}{2008/06/29}{Repair error in \cs{endlongtable@new} involving \cs{@ifx}: argument not delimited.} |
| 419 |
\changes{4.1b}{2008/08/04}{Get rid of the \cs{reserved@a} idiom} |
| 420 |
\changes{4.1b}{2008/08/04}{Turn off the \cs{set@footnotewidth} mechanism; a float `knows' its proper typesetting context} |
| 421 |
\changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.} |
| 422 |
\changes{4.1b}{2008/08/04}{(AO, 456) Compatibility with other packages that override the output routine, following suggestion by David Kastrup.} |
| 423 |
\changes{4.1b}{2008/08/04}{} |
| 424 |
\changes{4.1b}{2008/08/04}{Box \cs{footbox} changed to box \cs{footsofar}} |
| 425 |
\changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument} |
| 426 |
\changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 427 |
\changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 428 |
\changes{4.1b}{2008/08/04}{New procedure \cs{@iffpsbit} replaces \cs{@getfpsbit}} |
| 429 |
\changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}} |
| 430 |
\changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}} |
| 431 |
\changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}% |
| 432 |
\changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}% |
| 433 |
\changes{4.1b}{2008/08/04}{Procedure \cs{balance@2} defined more transparently}% |
| 434 |
\changes{4.1b}{2008/08/04}{Tally the height of the float} |
| 435 |
\changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}} |
| 436 |
\changes{4.1b}{2008/08/04}{Use \cs{trace@box} instead of \cs{showbox}} |
| 437 |
\changes{4.1f}{2009/07/07}{(AO, 515) Prevent line numbering within a footnote} |
| 438 |
\changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long} |
| 439 |
\changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated} |
| 440 |
\changes{4.1f}{2009/07/15}{(AO, 519) Preserve footnotes that are in \cs{footsofar} across a page grid change} |
| 441 |
\changes{4.1g}{2009/10/06}{(AO, 531) Fix package \classname{float} } |
| 442 |
\changes{4.1n}{2009/12/02}{Restore the \cs{lastbox} if it is not a footnote} |
| 443 |
\changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 444 |
\changes{4.1n}{2009/12/18}{(AO, 571) Deconstruct balanced footnotes when needed} |
| 445 |
\changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}% |
| 446 |
\changes{4.1n}{2010/01/02}{(AO, 571) Footnotes, when columns are balanced or when they are composed with their column}% |
| 447 |
\changes{4.1n}{2010/01/02}{(AO, 571) Abandon \cs{recover@footins} in favor of \cs{recover@column}}% |
| 448 |
\changes{4.1n}{2010/01/02}{(AO, 571) Use procedures \cs{output@do@prep} and \cs{output@column@do} as dispatchers} |
| 449 |
\changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 450 |
\changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 451 |
\changes{4.1n}{2010/01/02}{(AO, 571) footnote rule is leaders, so that it may be removed by \cs{vsplit}; mechanism of \cs{kern} signals to indicate footnote height}% |
| 452 |
\changes{4.1o}{2010/02/02}{(AO, 576) Allow \classname{lscape} to act on \cs{@outputbox} at the right time}% |
| 453 |
\changes{4.1p}{2010/02/24}{(AO, 583) Provide setup code also for footnotes in a one-column document}% |
| 454 |
\changes{4.2a}{2018/12/12}{(MD) Updated name of README file and use standard fonts when typesetting}% |
| 455 |
\changes{4.2d}{2020/09/19}{(PHO) Adapt \cs{document} and \cs{enddocument} hooks to the 2020-10-01 \LaTeX{} release.}% |
| 456 |
\changes{4.2d}{2020/09/30}{(PHO) Correct \cs{@normalcr} patch for \LaTeX{} 2020-02-02 and later.}% |
| 457 |
\end{filecontents*} |
| 458 |
% \end{macrocode} |
| 459 |
% |
| 460 |
% \subsection{The Document Body} |
| 461 |
% |
| 462 |
% Here is the document body, containing only a |
| 463 |
% \cmd\DocInput\ directive---referring to this very file. |
| 464 |
% This very cute self-reference is a common \classname{ltxdoc} idiom. |
| 465 |
% \begin{macrocode} |
| 466 |
\begin{document}% |
| 467 |
\def\revtex{REV\TeX}% |
| 468 |
\expandafter\DocInput\expandafter{\jobname.dtx}% |
| 469 |
\end{document} |
| 470 |
%</driver> |
| 471 |
% \end{macrocode} |
| 472 |
% |
| 473 |
% \section{Using this package} |
| 474 |
% Once this package is installed on your filesystem, you can employ it in |
| 475 |
% adding functionality to \LaTeX\ by invoking it in your document or document class. |
| 476 |
% |
| 477 |
% \subsection{Invoking the package} |
| 478 |
% In your document, you can simply call it up in your preamble: |
| 479 |
% \begin{verbatim} |
| 480 |
%\documentclass{book}% |
| 481 |
%\usepackage{ltxgrid}% |
| 482 |
%\begin{document} |
| 483 |
%<your document here> |
| 484 |
%\end{document} |
| 485 |
% \end{verbatim} |
| 486 |
% However, the preferred way is to invoke this package from within your |
| 487 |
% customized document class: |
| 488 |
% \begin{verbatim} |
| 489 |
%\NeedsTeXFormat{LaTeX2e}[1995/12/01]% |
| 490 |
%\ProvidesClass{myclass}% |
| 491 |
%\LoadClass{book}% |
| 492 |
%\RequirePackage{ltxgrid}% |
| 493 |
%<class customization commands> |
| 494 |
%\endinput |
| 495 |
% \end{verbatim} |
| 496 |
% |
| 497 |
% Note that this package requires the features of the \classname{ltxutil} package, |
| 498 |
% available at |
| 499 |
% \url{publish.aps.org/revtex}. |
| 500 |
% |
| 501 |
% Once loaded, the package gives you acccess to certain procedures, |
| 502 |
% usually to be invoked by a \LaTeX\ command or environment, but not at the document level. |
| 503 |
% |
| 504 |
% \subsection{Changing the page grid}% |
| 505 |
% This package provides two procedures, \cmd\onecolumngrid, \cmd\twocolumngrid, |
| 506 |
% that change the page grid (it can be extended to more columns and to other page grids). |
| 507 |
% |
| 508 |
% They differ from standard \LaTeX's \cmd\onecolumn\ and \cmd\twocolumn\ commands in that |
| 509 |
% they do not force a page break. Also, upon leaving a multiple-column grid, the columns are balanced. |
| 510 |
% In other respects they work same. |
| 511 |
% |
| 512 |
% They differ from the grid-changing commands of Frank Mittelbach's \classname{multicol} package |
| 513 |
% in that they allow floats of all types (single- and double column floats, that is) and |
| 514 |
% preserve compatability with the \classname{longtable} package. |
| 515 |
% |
| 516 |
% These commands must be issued in vertical mode (conceivably via a \cmd\vadjust) such that |
| 517 |
% they are ultimately present in the MVL, where they can do their work. |
| 518 |
% Because they do not work in \LaTeX's left-right mode, they are unsuitable at the |
| 519 |
% document level. |
| 520 |
% Furthermore, packaging a grid command in a \cmd\vadjust, although possible, will probably |
| 521 |
% not acheive satisfactory page layout. |
| 522 |
% |
| 523 |
% Page grid commands are not intended to be issued unnecessarily: only the first of |
| 524 |
% two successive \cmd\onecolumngrid\ commands is effective; the second will be silently ignored. |
| 525 |
% |
| 526 |
% \DescribeMacro\onecolumngrid |
| 527 |
% You command \LaTeX\ to return to the one-column grid with the |
| 528 |
% \cmd\onecolumngrid\ command. If you are already in the one-column grid, this |
| 529 |
% is a no-op. The one-column grid is considered special of all page grids, in that |
| 530 |
% no portion of the page is held back (in \cmd\pagesofar); all items that might go |
| 531 |
% on the current page (with the exception of floats and footnotes) are on the MVL. |
| 532 |
% |
| 533 |
% \DescribeMacro\twocolumngrid |
| 534 |
% You command \LaTeX\ to return to the two-column grid with the |
| 535 |
% \cmd\twocolumngrid\ command. If you are already in the two-column grid, this |
| 536 |
% is a no-op. |
| 537 |
% |
| 538 |
% These two commands should be issued by a macro procedure that can ensure that |
| 539 |
% \TeX\ is in outer vertical mode. |
| 540 |
% |
| 541 |
% \subsection{Changing the MVL}% |
| 542 |
% |
| 543 |
% This package also provides commands to modify the main vertical list (MVL) in a safe way. |
| 544 |
% The scheme here is to structure, insofar possible, \TeX's MVL as follows: |
| 545 |
%\begin{quotation} |
| 546 |
%box or boxes\\ |
| 547 |
%penalty\\ |
| 548 |
%glue |
| 549 |
%\end{quotation} |
| 550 |
% This should be a familiar sequence. It is the prototype sequence for a vertical list, |
| 551 |
% and is followed when \TeX\ breaks paragraphs into lines, and when \TeX\ generates |
| 552 |
% a display math equation. |
| 553 |
% |
| 554 |
% If you (as a macro programmer) wish to modify the value of the penalty or glue item, |
| 555 |
% you can use one of the MVL-altering commands to do so. Certain operations are implemented |
| 556 |
% here; you can make up your own. |
| 557 |
% |
| 558 |
% Note that these commands must be issued in vertical mode, perhaps via a \cmd\vadjust\ or a \cmd\noalign. |
| 559 |
% They can work directly if you are in inner mode (say within a parbox or a minipage). |
| 560 |
% |
| 561 |
% \DescribeMacro\removestuff |
| 562 |
% You instruct \LaTeX\ to remove both the penalty and the glue item with this command. |
| 563 |
% |
| 564 |
% \DescribeMacro\addstuff |
| 565 |
% You issue the \cmd\addstuff\arg{penalty}\arg{glue} command to add a penalty, glue, or both. |
| 566 |
% If you do not wish to add one or the other, the corresponding argument should be nil. |
| 567 |
% Note that the effect of \cmd\addstuff\ is to stack the penalties and glue items. |
| 568 |
% Therefore, the lesser of the two penalties takes effect, |
| 569 |
% and the two glue items add together. |
| 570 |
% |
| 571 |
% \cmd\addstuff\ is limited because once applied, it cannot be applied again with correct results. |
| 572 |
% |
| 573 |
% \DescribeMacro\replacestuff |
| 574 |
% The \cmd\replacestuff\ command is syntactically the same as \cmd\addstuff, but works |
| 575 |
% differently: the existing penalty and glue are replaced or modified. |
| 576 |
% |
| 577 |
% The specified penalty is not inserted if the existing penalty is greater than 10000 |
| 578 |
% (that is, in case of a \cmd\nobreak), otherwise, the lower (non-zero) of the two penalties is inserted. |
| 579 |
% |
| 580 |
% If the specified glue has a larger natural component than the existing glue, we replace the glue. |
| 581 |
% However, if the specified glue's natural component is negative, then the existing glue's natural component is |
| 582 |
% changed by that amount. |
| 583 |
% |
| 584 |
% \cmd\replacestuff\ can be applied mutiple times bceause it retains the list structure in the canonical form. |
| 585 |
% |
| 586 |
% Note that we treat two penalties specially (as does \TeX): a penalty of 10000 is considered |
| 587 |
% a garbage value, to be replaced if found. This is the signal value that \TeX\ inserts on |
| 588 |
% the MVL replacing the penalty that caused the page break (if the page break occurred at a penalty). |
| 589 |
% Also, a penalty of zero is indistinguishable from no penalty at all, so it will always |
| 590 |
% be replaced by the given value. |
| 591 |
% |
| 592 |
% Therefore, it is highly recommended to never set any of \TeX's penalty parameters to |
| 593 |
% zero (a value of, say, 1, is practically the same), nor should a skip parameter be set to zero |
| 594 |
% (instead, use, say, 1sp). Also, to prevent a pagebreak, do not use a penalty of 10000, use, say |
| 595 |
% 10001 instead. |
| 596 |
% |
| 597 |
% You can define your own construct that modifies the MVL: |
| 598 |
% Define a command, say, \cmd\myadjust, as follows: |
| 599 |
%\begin{verbatim} |
| 600 |
%\def\myadjust#1{\noexpand\do@main@vlist{\noexpand\@myadjust{#1}}\@tempa}% |
| 601 |
%\end{verbatim} |
| 602 |
% that is, \cmd\myadjust\ invokes \cmd\do@main@vlist, passing it the procedure name |
| 603 |
% \cmd\@myadjust\ along with the arguments thereof pre-expanded. |
| 604 |
% Next, define the procedure \cmd\@myadjust: |
| 605 |
%\begin{verbatim} |
| 606 |
%\def\@myadjust#1{<meddle with the MVL>}% |
| 607 |
%\end{verbatim} |
| 608 |
% when \cmd\@myadjust\ executes, you will be in the output routine (in inner vertical mode) |
| 609 |
% and the MVL will be that very vertical list. |
| 610 |
% |
| 611 |
% |
| 612 |
% |
| 613 |
% |
| 614 |
% \section{Compatability with \LaTeX's Required Packages} |
| 615 |
% Certain packages, usually ones written by members of the |
| 616 |
% \LaTeX\ Project itself, have been designated ``required'' and |
| 617 |
% are distributed as part of standard \LaTeX. |
| 618 |
% These packages have been placed in a priviledged position |
| 619 |
% vis \'a vis the \LaTeX\ kernel in that they override the definitions of certain kernel macros. |
| 620 |
% |
| 621 |
% Compatability between \classname{ltxgrid} and these packages is complicated |
| 622 |
% by a number of factors. First is that \classname{ltxgrid} alters the meaning of some of the same |
| 623 |
% kernel macros as certain of the ``required'' packages. |
| 624 |
% Second is that fact that certain of the ``required'' packages of \LaTeX\ are incompatible with |
| 625 |
% each other. |
| 626 |
% |
| 627 |
% Examples of the first kind are the \classname{ftnright}, \classname{multicol}, and \classname{longtable} |
| 628 |
% packages. |
| 629 |
% The \classname{ltxgrid} package is not compatible with \classname{multicol}, |
| 630 |
% but if you are using \classname{ltxgrid}, you do not need to use \classname{ftnright} or \classname{multicol} |
| 631 |
% anyway. The \classname{ltxgrid} package does however attempt to be compatible with \classname{longtable}. |
| 632 |
% |
| 633 |
% Among the ``required'' packages that are mutually incompatible are \classname{multicol} and \classname{longtable}, |
| 634 |
% the incompatibility arising because both packages replace \LaTeX's output routine: |
| 635 |
% if one package is active, the other must not be so. |
| 636 |
% This state of affairs has remained essentially unchanged since the introduction of the two as \LaTeX2.09 packages in the late 1980s. |
| 637 |
% |
| 638 |
% The reason that \classname{ltxgrid} can remain compatible with \classname{longtable} is due to the |
| 639 |
% introduction of a more modern architecture, the ``output routine dispatcher'', which allows all macro packages access to the |
| 640 |
% safe processing environment of the output routine, on an equal footing. |
| 641 |
% The relevant portions of the \classname{longtable} package are reimplemented in \classname{ltxgrid} |
| 642 |
% to take advantage of this mechanism. |
| 643 |
% |
| 644 |
% Timing is critical: |
| 645 |
% the \classname{ltxgrid} package will be incompatible with any package that |
| 646 |
% redefines any of the kernel macros that \classname{ltxgrid} patches---if that |
| 647 |
% package is loaded \emph{after} \classname{ltxgrid}. |
| 648 |
% |
| 649 |
% Hereinafter follows some notes on specific \LaTeX\ packages. |
| 650 |
% |
| 651 |
% \subsection{ftnright} |
| 652 |
% Frank Mittelbach's \classname{ftnright} package effects a change to \LaTeX's |
| 653 |
% \cmd\twocolumn\ mode such that footnotes are set at the bottom of the right-hand |
| 654 |
% column instead of at the foot of each of the two columns. |
| 655 |
% |
| 656 |
% Note that it overwrites three \LaTeX\ kernel macros: \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecolumn. |
| 657 |
% Fortunately none of the three are patched by \classname{ltxgrid}, so that compatability |
| 658 |
% is not excluded on this basis. |
| 659 |
% |
| 660 |
% At the same time, it changes the meaning of \cmd\footnotesize, the macro that is automatically |
| 661 |
% invoked when setting a document's footnote into type. |
| 662 |
% One might well argue that it is an error for the meaning of \cmd\footnotesize\ to be determined by |
| 663 |
% a package such as \classname{ftnright}, that indeed such a choice should be made in the |
| 664 |
% document class, or in a file such as \file{bk10.clo}. |
| 665 |
% |
| 666 |
% To avoid being tripped up by this misfeature in \classname{ftnright}, it is only necessary to |
| 667 |
% reassert our meaning for \cmd\footnotesize\ later on, after \classname{ftnright} has been loaded. |
| 668 |
% |
| 669 |
% Note that \classname{ftnright} inserts code that demands that \LaTeX's flag \cmd\if@twocolumn\ |
| 670 |
% is true, that is, it will complain if deployed in a \cmd\onecolumn\ document. |
| 671 |
% It is therefore necessary for any other multicolumn package to assert that flag in order to |
| 672 |
% avoid this package's complaint. It is an interesting question exactly why this package has |
| 673 |
% this limitation. After all, a one-column page grid is just a degenerate case of the |
| 674 |
% two column. |
| 675 |
% |
| 676 |
% \subsection{longtable} |
| 677 |
% David Carlisle's \classname{longtable} package sets tables that can be so long as to break over pages. |
| 678 |
% According to its author, it uses the same override of \LaTeX's output routine as |
| 679 |
% Frank Mittelbach's \classname{multicol} package. By implication, then, it has a hard |
| 680 |
% incompatability with the latter. |
| 681 |
% |
| 682 |
% The \classname{longtable} package also performs a check of whether the document is in |
| 683 |
% \cmd\twocolumn\ mode, and declines to work if this is the case. It is not clear, however, |
| 684 |
% that there is any true incompatability present if so. It's just that David did not see any reason |
| 685 |
% anyone would want to set such long tables in a multicolumn document, hence the check. |
| 686 |
% |
| 687 |
% There does not appear to be any indication that \classname{longtable} would work less |
| 688 |
% well under \classname{ltxgrid} than under standard \LaTeX's \cmd\twocolumn\ mode. |
| 689 |
% Therefore, this \classname{ltxgrid} patches \classname{longtable} (if loaded) so as to provide |
| 690 |
% compatability. In the course of which, \classname{longtable} becomes more robust |
| 691 |
% (\classname{longtable} has mumerous bugs and incompatabilities of long standing, |
| 692 |
% some of which are repaired by \classname{ltxgrid}). |
| 693 |
% |
| 694 |
% One problem remains, namely that, if a \env{longtable} environment breaks over columns |
| 695 |
% and thereby inserts its special headers and footers at that break, and those columms are then |
| 696 |
% balanced (due to a return to the one-column page grid), then those inserted rows |
| 697 |
% will remain, and may no longer fall at the column break. This will, of course look |
| 698 |
% wrong. |
| 699 |
% |
| 700 |
% The only way to fix this problem is to avoid doing column balancing in the way |
| 701 |
% I have implemented here; such an enhancement to this package is possible. |
| 702 |
% |
| 703 |
% \subsection{multicol} |
| 704 |
% Frank Mittelbach's \classname{multicol} package provides a page grid with many columns, |
| 705 |
% albeit denies the placement of floats in individual columns. |
| 706 |
% |
| 707 |
% It establishes its own \cmd\output\ routine, which is the reason it runs afoul of |
| 708 |
% the \classname{longtable} package. On the other hand, \classname{ltxgrid} specifically |
| 709 |
% allows for the case where a package installs its own \cmd\output\ routine, so |
| 710 |
% there is no incompatability on that basis. |
| 711 |
% |
| 712 |
% Still, it is pointless to use \classname{multicol} if you are using \classname{ltxgrid}, |
| 713 |
% since both packages provide multicolumn page layouts. |
| 714 |
% Therefore, \classname{multicol} is not supported by \classname{ltxgrid}. |
| 715 |
% |
| 716 |
% \subsection{ltxgrid} |
| 717 |
% It has been pointed out that one of the disadvantages of adopting the \classname{ltxgrid} package is that |
| 718 |
% it does alter the \LaTeX\ kernel. |
| 719 |
% Any package that itself alters the \LaTeX\ kernel may be incompatible with \classname{ltxgrid}, and new packages |
| 720 |
% (destined perhaps to become part of the successor to \LaTeXe) may break \classname{ltxgrid}. |
| 721 |
% |
| 722 |
% The consequence is that packages introduced in future, and future changes to \LaTeX\ may be incompatible |
| 723 |
% with \classname{ltxgrid}. |
| 724 |
% This is, of course, true. |
| 725 |
% The development plan for \classname{ltxgrid} is that when such packages and \LaTeX\ kernel changes come about, |
| 726 |
% the burden will be on \classname{ltxgrid} to change in a way that provides for continued compatability with |
| 727 |
% those packages and \LaTeX\ kernel changes. |
| 728 |
% |
| 729 |
% |
| 730 |
% \section{How \classname{ltxgrid} places footnotes} |
| 731 |
% |
| 732 |
% In conventional multicolumn layouts, a footnote will appear at the bottom of the column in which it is called out. |
| 733 |
% The \classname{ltxgrid} package implements this conventional layout choice by default. |
| 734 |
% However, other choices are possible (a la \classname{ftnright}, whose compatability with \classname{ltxgrid} has not been tested). |
| 735 |
% |
| 736 |
% One unusual feature of \classname{ltxgrid}'s default implementation must be mentioned, though, |
| 737 |
% namely the case in a two-column page grid, where a footnote is followed by a temporary change to the one-column page grid |
| 738 |
% (e.g., for a wide equation). |
| 739 |
% In such a case, the material above the wide material is split into two columns, and a footnote whose callout |
| 740 |
% appears in the right-hand column will nonetheless be set at the base of the left column. |
| 741 |
% |
| 742 |
% This arrangement was chosen because it ensures that the footnotes at the bottom of any page will appear in |
| 743 |
% numerical order. It can be argued that this choice is ``incorrect'', but be that as it may, |
| 744 |
% the \classname{ltxgrid} package does not foreclose on other arrangements for the footnotes. |
| 745 |
% The package can be adapted to accomodate any page design desired. |
| 746 |
% |
| 747 |
% \section{Limitations in \classname{ltxgrid}'s default column balancing method}% |
| 748 |
% |
| 749 |
% In a multicolumn page grid, when encountering a page that is not completely full, |
| 750 |
% it is customary to set the material in balanced columns (typically with the last column no longer than any of the others). |
| 751 |
% Such a case also crops up when temporarily interrupting the multicolumn grid to set material on the full width of the page: |
| 752 |
% the material on the page above the break is customarily set in balanced columns. |
| 753 |
% |
| 754 |
% An awkward case arises when we have already set one or more complete columns of type before encountering the need to |
| 755 |
% balance columns. In this subset of cases, the default in \classname{ltxgrid} is to |
| 756 |
% do an operation I call ``re-balancing'': |
| 757 |
% the material on the page so far is pasted back together into a single column, and new, balanced column breaks are |
| 758 |
% calculated. |
| 759 |
% |
| 760 |
% This scheme typically works fine, but it has a significant vulnerability: |
| 761 |
% any discardable items trimmed at the original column break are lost, never to be retrieved. |
| 762 |
% Consequently, after re-balancing, an element like, say, a section head can fail to have the correct amount of whitespace above. |
| 763 |
% |
| 764 |
% This problem is due to an unfortunate optimization in \TeX, wherein a certain class of nodes is trimmed from the |
| 765 |
% top of main vertical list upon returning from the output routine: |
| 766 |
% any penalty, glue, or leader node falls in to this class of discardable nodes, |
| 767 |
% and trimming proceeds until a non-discardable node (such as a box, or rule) is encountered. |
| 768 |
% It gets better: a third class of nodes is transparent to this trimming process; |
| 769 |
% they are neither discarded nor do they halt the process of trimming: |
| 770 |
% mark nodes and all whatsits fall into this class of transparent nodes; |
| 771 |
% they are quietly passed over during trimming. |
| 772 |
% |
| 773 |
% An alternative approach for \TeX\ to take would have been, |
| 774 |
% rather than discarding the node entirely, to simply \emph{mark} it as discarded. |
| 775 |
% (Implementors of extended \TeX, please note!) |
| 776 |
% Then, upon shipping out, such nodes would not make it into the DVI. |
| 777 |
% \TeX's optimization, driven by the small computer architectures current when it was developed, |
| 778 |
% does save mem, but at the cost of revisiting page breaks in a reliable way. |
| 779 |
% |
| 780 |
% FIXME: how to fix a column break in the above case? Widetext? |
| 781 |
% |
| 782 |
%\StopEventually{} |
| 783 |
% |
| 784 |
% \section{Implementation of package} |
| 785 |
% |
| 786 |
% Special acknowledgment: this package uses concepts pioneered |
| 787 |
% and first realized by William Baxter (mailto:web at superscript.com) |
| 788 |
% in his SuperScript line of commercial typesetting tools, and |
| 789 |
% which are used here with his permission. His thorough understanding |
| 790 |
% of \TeX's output routine underpins the entire \classname{ltxgrid} |
| 791 |
% package. |
| 792 |
% |
| 793 |
% \subsection{Beginning of the \file{ltxgrid} {\sc docstrip} module} |
| 794 |
% Requires the underpinnings of the \classname{ltxkrnext} package. |
| 795 |
% \begin{macrocode} |
| 796 |
%<*package> |
| 797 |
\def\package@name{ltxgrid}% |
| 798 |
\expandafter\PackageInfo\expandafter{\package@name}{% |
| 799 |
Page grid for \protect\LaTeXe, |
| 800 |
by A. Ogawa (arthur_ogawa at sbcglobal.net)% |
| 801 |
}% |
| 802 |
\RequirePackage{ltxutil}% |
| 803 |
%</package> |
| 804 |
% \end{macrocode} |
| 805 |
% |
| 806 |
% \subsection{Banner}% |
| 807 |
% \begin{macrocode} |
| 808 |
%<*kernel> |
| 809 |
% \end{macrocode} |
| 810 |
% |
| 811 |
% \subsection{Sundry}% |
| 812 |
% Here are assorted macro definitions. |
| 813 |
% \begin{macro}{\lineloop} |
| 814 |
% \begin{macro}{\linefoot} |
| 815 |
% The (document-level) command \cmd\lineloop\ sets numbered lines until the |
| 816 |
% specified count is reached. |
| 817 |
% The command \cmd\linefoot\ sets a single, automatically numbered line, but with a footnote (with the specified label); |
| 818 |
% it automatically increments the line counter. |
| 819 |
% These commands are typically used to construct test documents. |
| 820 |
% |
| 821 |
% Because the counter is globally advanced and never reset, successive |
| 822 |
% calls to \cmd\lineloop\ should have an argument ever larger. |
| 823 |
% The formatted output will have each line labeled with its ordinal number. |
| 824 |
% \begin{macrocode} |
| 825 |
\newcounter{linecount} |
| 826 |
\def\loop@line#1#2{% |
| 827 |
\par |
| 828 |
\hb@xt@\hsize{% |
| 829 |
\global\advance#1\@ne |
| 830 |
\edef\@tempa{\@ifnum{100>#1}{0}{}\@ifnum{10>#1}{0}{}\number#1}% |
| 831 |
\@tempa\edef\@tempa{\special{line:\@tempa}}\@tempa |
| 832 |
\vrule depth2.5\p@#2\leaders\hrule\hfil |
| 833 |
}% |
| 834 |
}% |
| 835 |
\def\lineloop#1{% |
| 836 |
\loopwhile{\loop@line\c@linecount{}\@ifnum{#1>\c@linecount}}% |
| 837 |
}% |
| 838 |
\def\linefoot#1{% |
| 839 |
\loop@line\c@linecount{% |
| 840 |
\footnote{% |
| 841 |
#1\special{foot:#1}\vrule depth2.5\p@\leaders\hrule\hfill |
| 842 |
}% |
| 843 |
}% |
| 844 |
}% |
| 845 |
% \end{macrocode} |
| 846 |
% \end{macro} |
| 847 |
% \end{macro} |
| 848 |
% |
| 849 |
% |
| 850 |
% \subsection{Mark Components}% |
| 851 |
% |
| 852 |
% Override LaTeX's mark macros to allow more components. |
| 853 |
% |
| 854 |
% We remain bound by the weakness of LaTeX's scheme in that |
| 855 |
% one cannot emulate the action of \TeX\ whereby |
| 856 |
% material with marks can be inserted in the middle of |
| 857 |
% a vertical list such that the marks are reliably calculated. |
| 858 |
% If we did that, \cmd\@themark\ would no longer be utilized. |
| 859 |
% |
| 860 |
% A more robust scheme involves placing all marks (component and value) |
| 861 |
% into a list (using global scoping, i.e., \cmd\gdef), |
| 862 |
% and using \cmd\@@mark to place an index on that list into the MVL. |
| 863 |
% Then, e.g., \cmd\@@botmark signifies the place where that list is to be cut, |
| 864 |
% and the \cmd\botmark\ of any component is |
| 865 |
% the value of the last element of the cut |
| 866 |
% list having the given component. The \cmd\firstmark\ and \cmd\topmark\ |
| 867 |
% can likewise be defined relative to \cmd\@@firstmark\ and \cmd\@@topmark, |
| 868 |
% except in the latter case, we want the first following the cut instead of the last |
| 869 |
% preceding the cut. |
| 870 |
% |
| 871 |
% The limitation of this scheme is its demands upon \TeX's mem. |
| 872 |
% The list of marks would need to be trimmed back to, effectively, |
| 873 |
% \cmd\topmark\ at the beginning of every page. |
| 874 |
% |
| 875 |
% This approach is not yet part of the extended LaTeX kernel. |
| 876 |
% |
| 877 |
% \begin{macro}{\@@mark} |
| 878 |
% \begin{macro}{\@@topmark} |
| 879 |
% \begin{macro}{\@@firstmark} |
| 880 |
% \begin{macro}{\@@botmark} |
| 881 |
% \begin{macro}{\@@splitfirstmark} |
| 882 |
% \begin{macro}{\@@splitbotmark} |
| 883 |
% Remember primitives under a new set of names. |
| 884 |
% \begin{macrocode} |
| 885 |
\let\@@mark\mark |
| 886 |
\let\@@topmark\topmark |
| 887 |
\let\@@firstmark\firstmark |
| 888 |
\let\@@botmark\botmark |
| 889 |
\let\@@splitfirstmark\splitfirstmark |
| 890 |
\let\@@splitbotmark\splitbotmark |
| 891 |
% \end{macrocode} |
| 892 |
% \end{macro} |
| 893 |
% \end{macro} |
| 894 |
% \end{macro} |
| 895 |
% \end{macro} |
| 896 |
% \end{macro} |
| 897 |
% \end{macro} |
| 898 |
% |
| 899 |
% \subsubsection{Procedures that expose the component data structure}% |
| 900 |
% This portion of the code exposes the internal representation of |
| 901 |
% the mark components. If we wish to add more components, we will have to revise |
| 902 |
% these macro definitions: |
| 903 |
% \cmd\@themark, |
| 904 |
% \cmd\nul@mark, |
| 905 |
% \cmd\set@mark@netw@, |
| 906 |
% \cmd\set@marktw@, |
| 907 |
% \cmd\set@markthr@@, |
| 908 |
% \cmd\get@mark@@ne, |
| 909 |
% \cmd\get@mark@tw@, |
| 910 |
% \cmd\get@mark@thr@@, |
| 911 |
% \cmd\get@mark@f@ur. |
| 912 |
% |
| 913 |
% \begin{macro}{\@themark} |
| 914 |
%FIXME: is it safer to eliminate \cmd\@themark\ in favor of a message that evaluates \cmd\@@botmark? |
| 915 |
% |
| 916 |
% Note: these definitions expose the data structure of mark components. |
| 917 |
% \begin{macrocode} |
| 918 |
\def\@themark{{}{}{}{}}% |
| 919 |
\def\nul@mark{{}{}{}{}\@@nul}% |
| 920 |
% \end{macrocode} |
| 921 |
% \end{macro} |
| 922 |
% |
| 923 |
% \begin{macro}{\set@mark@netw@} |
| 924 |
% \begin{macro}{\set@marktw@} |
| 925 |
% \begin{macro}{\set@markthr@@} |
| 926 |
% These procedures insert the new value of a particular mark component into the given argument. |
| 927 |
% They expose the data structure of mark components. |
| 928 |
% |
| 929 |
% \begin{macrocode} |
| 930 |
\def\set@mark@netw@#1#2#3#4#5#6#7{\gdef#1{{#6}{#7}{#4}{#5}}\do@mark}% |
| 931 |
\def\set@marktw@#1#2#3#4#5#6{\gdef#1{{#2}{#6}{#4}{#5}}\do@mark}% |
| 932 |
\def\set@markthr@@#1#2#3#4#5#6{\gdef#1{{#2}{#3}{#6}{#5}}\do@mark}% |
| 933 |
% \end{macrocode} |
| 934 |
% \end{macro} |
| 935 |
% \end{macro} |
| 936 |
% \end{macro} |
| 937 |
% |
| 938 |
% \begin{macro}{\get@mark@@ne} |
| 939 |
% \begin{macro}{\get@mark@tw@} |
| 940 |
% \begin{macro}{\get@mark@thr@@} |
| 941 |
% \begin{macro}{\get@mark@f@ur} |
| 942 |
% These procedures retreive the value of a particular mark component. |
| 943 |
% They expose the data structure of mark components. |
| 944 |
% \begin{macrocode} |
| 945 |
\def\get@mark@@ne#1#2#3#4#5\@@nul{#1}% |
| 946 |
\def\get@mark@tw@#1#2#3#4#5\@@nul{#2}% |
| 947 |
\def\get@mark@thr@@#1#2#3#4#5\@@nul{#3}% |
| 948 |
\def\get@mark@f@ur#1#2#3#4#5\@@nul{#4}% |
| 949 |
% \end{macrocode} |
| 950 |
% \end{macro} |
| 951 |
% \end{macro} |
| 952 |
% \end{macro} |
| 953 |
% \end{macro} |
| 954 |
% |
| 955 |
% |
| 956 |
% \subsubsection{Procedures that do not expose the component data structure}% |
| 957 |
% |
| 958 |
% \begin{macro}{\mark@netw@} |
| 959 |
% \begin{macro}{\marktw@} |
| 960 |
% \begin{macro}{\markthr@@} |
| 961 |
% These procedures insert the new value of a particular mark component into \cmd\@themark, |
| 962 |
% then execute \cmd\do@mark. |
| 963 |
% They constitute the implementation layer for mark components one, two, and three. |
| 964 |
% An analogous procedure for component four could be defined; call it \cmd\markf@ur. |
| 965 |
% |
| 966 |
% \begin{macrocode} |
| 967 |
\def\mark@netw@{\expandafter\set@mark@netw@\expandafter\@themark\@themark}% |
| 968 |
\def\marktw@{\expandafter\set@marktw@\expandafter\@themark\@themark}% |
| 969 |
\def\markthr@@{\expandafter\set@markthr@@\expandafter\@themark\@themark}% |
| 970 |
% \end{macrocode} |
| 971 |
% \end{macro} |
| 972 |
% \end{macro} |
| 973 |
% \end{macro} |
| 974 |
% |
| 975 |
% \begin{macro}{\do@mark} |
| 976 |
% \begin{macro}{\do@@mark} |
| 977 |
% Access procedures \cmd\mark (AKA \cmd\@@mark). |
| 978 |
% The \cmd\do@mark\ procedure is used when a mark is being put down into the MVL; |
| 979 |
% \cmd\do@@mark\ when this happens in the output routine. |
| 980 |
% \begin{macrocode} |
| 981 |
\def\do@mark{\do@@mark\@themark\nobreak@mark}% |
| 982 |
\def\do@@mark#1{% |
| 983 |
\begingroup |
| 984 |
\let@mark |
| 985 |
\@@mark{#1}% |
| 986 |
\endgroup |
| 987 |
}% |
| 988 |
% \end{macrocode} |
| 989 |
% \end{macro} |
| 990 |
% \end{macro} |
| 991 |
% |
| 992 |
% \begin{macro}{\let@mark} |
| 993 |
% \begin{macro}{\nobreak@mark}% |
| 994 |
% The procedure that makes \cmd\csname s robust within a mark. |
| 995 |
% Use \cmd\appdef\ and \cmd\robust@\ to extend the list. |
| 996 |
% \begin{macrocode} |
| 997 |
\def\let@mark{% |
| 998 |
\let\protect\@unexpandable@protect |
| 999 |
\let\label\relax |
| 1000 |
\let\index\relax |
| 1001 |
\let\glossary\relax |
| 1002 |
}% |
| 1003 |
\def\nobreak@mark{% |
| 1004 |
\@if@sw\if@nobreak\fi{\@ifvmode{\nobreak}{}}{}% |
| 1005 |
}% |
| 1006 |
% \end{macrocode} |
| 1007 |
% \end{macro} |
| 1008 |
% \end{macro} |
| 1009 |
% |
| 1010 |
% |
| 1011 |
% \subsubsection{Using mark components}% |
| 1012 |
% |
| 1013 |
% These procedures use the component mark mechanism to implement |
| 1014 |
% a mark component that remembers the current environment (used in page makeup) |
| 1015 |
% and the the two mark components left over from the original \LaTeX. |
| 1016 |
% The fourth component is presently unused. |
| 1017 |
% |
| 1018 |
% \begin{macro}{\mark@envir} |
| 1019 |
% The third mark component's access procedures. |
| 1020 |
% The \cmd\mark@envir\ and \cmd\bot@envir\ commands are a good model of how to write |
| 1021 |
% access procedures for a new mark component. |
| 1022 |
% \begin{macrocode} |
| 1023 |
\def\mark@envir{\markthr@@}% |
| 1024 |
\def\bot@envir{% |
| 1025 |
\expandafter\expandafter |
| 1026 |
\expandafter\get@mark@thr@@ |
| 1027 |
\expandafter\@@botmark |
| 1028 |
\nul@mark |
| 1029 |
}% |
| 1030 |
% \end{macrocode} |
| 1031 |
% \end{macro} |
| 1032 |
% |
| 1033 |
% \begin{macro}{\markboth} |
| 1034 |
% \begin{macro}{\markright} |
| 1035 |
% \begin{macro}{\leftmark} |
| 1036 |
% \begin{macro}{\rightmark} |
| 1037 |
% Set procedures for legacy components. |
| 1038 |
% \begin{macrocode} |
| 1039 |
\def\markboth{\mark@netw@}% |
| 1040 |
\def\markright{\marktw@}% |
| 1041 |
% \end{macrocode} |
| 1042 |
% |
| 1043 |
% Retrieval procedures for legacy mark components. |
| 1044 |
% The procedure for retrieving the first component from \cmd\botmark\ |
| 1045 |
% and the second component from \cmd\firstmark have names in \LaTeX; |
| 1046 |
% they are called, respectively, \cmd\leftmark\ and \cmd\rightmark. |
| 1047 |
% |
| 1048 |
% It is possible to retrieve the components of \cmd\topmark\ |
| 1049 |
% as well: use \cmd\saved@@topmark. |
| 1050 |
% \begin{macrocode} |
| 1051 |
\def\leftmark{% |
| 1052 |
\expandafter\expandafter |
| 1053 |
\expandafter\get@mark@@ne |
| 1054 |
\expandafter\saved@@botmark |
| 1055 |
\nul@mark |
| 1056 |
}% |
| 1057 |
\def\rightmark{% |
| 1058 |
\expandafter\expandafter |
| 1059 |
\expandafter\get@mark@tw@ |
| 1060 |
\expandafter\saved@@firstmark |
| 1061 |
\nul@mark |
| 1062 |
}% |
| 1063 |
% \end{macrocode} |
| 1064 |
% \end{macro} |
| 1065 |
% \end{macro} |
| 1066 |
% \end{macro} |
| 1067 |
% \end{macro} |
| 1068 |
% |
| 1069 |
% |
| 1070 |
% |
| 1071 |
% \subsection{Output Super-routine}% |
| 1072 |
% |
| 1073 |
% We want to change \LaTeX's output routine, but do not wish to remain vulnerable |
| 1074 |
% to interference from such ``required'' packages as |
| 1075 |
% \classname{multicol} (authored by Frank Mittelbach) |
| 1076 |
% and \classname{longtable} (authored by David P. Carlisle), which |
| 1077 |
% swap in their own output routines when the respective package is active. |
| 1078 |
% |
| 1079 |
% The better mechanism, used here, is due to William Baxter (web at superscript.com), |
| 1080 |
% who has allowed his several ideas to be used in this package. |
| 1081 |
% |
| 1082 |
% In what follows, we effectively wrap up the old \LaTeX\ output routine inside |
| 1083 |
% a new, more flexible ``super routine''. When the output routine is called, |
| 1084 |
% the ``super routine'' acts as a dispatcher. If the old routine is needed, it is called. |
| 1085 |
% |
| 1086 |
% If a package attempts to substitute in their own output routine, they will effectively |
| 1087 |
% be modifying a token register by the name of \cmd\output. |
| 1088 |
% The primitive \cmd\output\ is now known by a different name, which should no longer be |
| 1089 |
% necessary to use. |
| 1090 |
% |
| 1091 |
% Usage note: to make a visit to the output routine employing the dispatcher, enter |
| 1092 |
% with a value of \cmd\outputpenalty\ that corresponds to a macro. Defining as follows: |
| 1093 |
%\begin{verbatim} |
| 1094 |
%\@namedef{output@10000}{<your code here>}% |
| 1095 |
%\end{verbatim} |
| 1096 |
% by convention, your output routine should void out \cmd\box\cmd\@cclv. |
| 1097 |
% |
| 1098 |
% In rewriting \LaTeX's output dispatcher |
| 1099 |
% in a much simpler form, we also avoid the sin of multiple \cmd\shipout s |
| 1100 |
% within a single visit to the output routine. |
| 1101 |
% |
| 1102 |
% Conceptually, we divide visits to the output routine into two classes. |
| 1103 |
% The first involves natural page breaks |
| 1104 |
% (at a \cmd\newpage\ or when \cmd\pagetotal $>$ \cmd\pagegoal) |
| 1105 |
% and usually resulting in \cmd\box\cmd\@cclv\ either being shipped out or |
| 1106 |
% salted away (e.g., each column in a multicolumn layout). |
| 1107 |
% We might call this class the ``natural output routines''; the \cmd\outputpenalty\ |
| 1108 |
% will never be less than $-10000$. |
| 1109 |
% Furthermore, we ensure that \cmd\holdinginserts\ is cleared when |
| 1110 |
% calling such routines. |
| 1111 |
% |
| 1112 |
% The other class involves a forced visit to the output routine |
| 1113 |
% via a large negative penalty ($< -10000$). They do not generally |
| 1114 |
% result in a \cmd\shipout\ of \cmd\box\cmd\@cclv: they may be dead cycles. |
| 1115 |
% We provide a mechanism (call it a ``one-off'' output routine) that allows |
| 1116 |
% us to specify certain processing to be done when \TeX\ reaches |
| 1117 |
% the current position on the page. |
| 1118 |
% |
| 1119 |
% One-off output routines themselves fall into two divisions, ones |
| 1120 |
% that process \cmd\box\cmd\@cclv, and ones that work on the main vertical list (MVL). |
| 1121 |
% The former are typified by changes to the page grid, perhaps |
| 1122 |
% even column balancing. |
| 1123 |
% The latter involve the insertion of penalties or glue and the processing of floats. |
| 1124 |
% |
| 1125 |
% The natural output routine is a single procedure. We have not introduced multiple |
| 1126 |
% natural output routines based on the \cmd\outputpenalty\ because \TeX\ does not |
| 1127 |
% support such a thing: \TeX\ sometimes lays down a penalty whose value is the sum |
| 1128 |
% of other penalties. Because of this, we cannot depend on the value of \cmd\outputpenalty\ |
| 1129 |
% in such areas. |
| 1130 |
% |
| 1131 |
% We do introduce flexibility in the form of a mechanism for patching into the |
| 1132 |
% natural output routine. Three hooks are offered, allowing a procedure |
| 1133 |
% to prepare for the upcoming visit to the output routine, |
| 1134 |
% access to \cmd\box\cmd\@cclv, and after doing \cmd\shipout\ (or otherwise |
| 1135 |
% committing the material to the page). |
| 1136 |
% |
| 1137 |
% Environments, commands, and even packages can install their |
| 1138 |
% own procedures into these hooks. |
| 1139 |
% For instance, if the longtable package is loaded, it will install |
| 1140 |
% its procedures, but those procedures will punt if the page break |
| 1141 |
% being processed does not actually fall within a longtable environment. |
| 1142 |
% |
| 1143 |
% \begin{macro}{\primitive@output} |
| 1144 |
% Here we remember the \TeX\ primitive \cmd\output\ and its value, |
| 1145 |
% and then proceed to take over the \cmd\csname\ of \cmd\output, |
| 1146 |
% making it a \cmd\toks\ register and installing the old value of |
| 1147 |
% the output routine. |
| 1148 |
% \begin{macrocode} |
| 1149 |
\let\primitive@output\output |
| 1150 |
% \end{macrocode} |
| 1151 |
% \end{macro} |
| 1152 |
% |
| 1153 |
% \begin{macro}{\output@latex} |
| 1154 |
% \begin{macro}{\output} |
| 1155 |
% Grab the tokens in \cmd\the\cmd\output\ (but without the extra set of braces). |
| 1156 |
% The value of \cmd\toks@\ must remain untouched until loaded into the appropriate token |
| 1157 |
% register; this is done a few lines below. |
| 1158 |
% \begin{macrocode} |
| 1159 |
\long\def\@tempa#1\@@nil{#1}% |
| 1160 |
\toks@ |
| 1161 |
\expandafter\expandafter |
| 1162 |
\expandafter{% |
| 1163 |
\expandafter \@tempa |
| 1164 |
\the\primitive@output |
| 1165 |
\@@nil |
| 1166 |
}% |
| 1167 |
\newtoks\output@latex |
| 1168 |
\output@latex\expandafter{\the\toks@}% |
| 1169 |
\let\output\output@latex |
| 1170 |
% \end{macrocode} |
| 1171 |
% |
| 1172 |
% A comment on compatibility with other packages that co-opt the output routine. |
| 1173 |
% |
| 1174 |
% Somewhere on the LaTeX-L list, David Kastrup has urged macro writers to take over |
| 1175 |
% the output routine in such a way that others can do likewise. How is this to be |
| 1176 |
% accomplished? |
| 1177 |
% |
| 1178 |
% Consider what the \classname{lineno} package does when it loads. |
| 1179 |
% \begin{enumerate} |
| 1180 |
% \item |
| 1181 |
% It does \cmd\let\ cmd\@tempa\ \cmd\output. |
| 1182 |
% This has the effect of identifying \cmd\@tempa\ with the |
| 1183 |
% \cmd\toks\ register we created above to hold the old output routine of \LaTeX. |
| 1184 |
% Let us say that was \cmd\toks14. |
| 1185 |
% \item |
| 1186 |
% \classname{lineno} itself effectively does \cmd\newtoks\ \cmd\@LN@output, |
| 1187 |
% which assigns that \cmd\csname\ to \cmd\toks 15. |
| 1188 |
% \item |
| 1189 |
% It loads \cmd\@LN@output\ with the contents of \cmd\@tempa |
| 1190 |
% (that is, \cmd\toks14, our copy of \LaTeX's output routine). |
| 1191 |
% \item |
| 1192 |
% Then it loads \cmd\@tempa\ with its own desired procedure, |
| 1193 |
% to be executed at \cmd\output\ time, thereby taking over what it thinks is the output routine, |
| 1194 |
% but which is in reality the procedure \revtex\ executes when it wants to pass control |
| 1195 |
% to \LaTeX's original output routine. |
| 1196 |
% \item |
| 1197 |
% It then does \cmd\let\ \cmd\output\ \cmd\@LN@output, |
| 1198 |
% which now identifies \cmd\output\ with \cmd\toks15, the output routine of \classname{lineno}. |
| 1199 |
% \item |
| 1200 |
% When the \cmd\output\ routine is triggered, |
| 1201 |
% the primitive output routine \cmd\primitive@output\ is executed, and if |
| 1202 |
% appropriate, control is passed to \cmd\output@latex, which \revtex\ had loaded with the old |
| 1203 |
% \LaTeX\ output routine, but which is presently loaded with that of \classname{lineno}. |
| 1204 |
% \item |
| 1205 |
% The output routine of \classname{lineno} is executed, and if appropriate control is passed |
| 1206 |
% to \cmd\@LN@output, the old output routine of \LaTeX. |
| 1207 |
% \item |
| 1208 |
% Furthermore, the \cmd\csname\ \cmd\output\ now points to \cmd\@LN@output\ (\cmd\toks15). |
| 1209 |
% This means that someone coming in after \classname{lineno} to take over the output routine |
| 1210 |
% will actually get executed after that of \classname{lineno}, but before \LaTeX. |
| 1211 |
% \end{enumerate} |
| 1212 |
% As you can see, the process of taking over the output routine may continue until all of the |
| 1213 |
% \cmd\toks\ registers have been allocated. |
| 1214 |
% If, say, \classname{newpackage} would itself like to take over the output routine, |
| 1215 |
% and if it uses the above set of steps, then when the output routine is triggered, the order |
| 1216 |
% of execution is \revtex, then \classname{lineno}, then \classname{newpackage}, then \LaTeX. |
| 1217 |
% Each new package inserts itself on front of \LaTeX. |
| 1218 |
% \end{macro} |
| 1219 |
% \end{macro} |
| 1220 |
% |
| 1221 |
% \begin{macro}{\dispatch@output} |
| 1222 |
% \changes{4.1b}{2008/08/04}{(AO, 456) Compatibility with other packages that override the output routine, following suggestion by David Kastrup.} |
| 1223 |
% We now install our own output routine in place of the original |
| 1224 |
% output routine of \LaTeX, which is still available as \cmd\the\ \cmd\output. |
| 1225 |
% |
| 1226 |
% The output routine is simply the procedure \cmd\dispatch@output. |
| 1227 |
% It either dispatches to a procedure based on a particular value of |
| 1228 |
% \cmd\outputpenalty\ or it executes \cmd\the\cmd\output@latex\ tokens. |
| 1229 |
% \begin{macrocode} |
| 1230 |
\primitive@output{\dispatch@output}% |
| 1231 |
\def\dispatch@output{% |
| 1232 |
\let\par\@@par |
| 1233 |
% \end{macrocode} |
| 1234 |
% Try to interpret \cmd\outputpenalty\ as a dispatcher to a message handler, |
| 1235 |
% its value is, e.g., \cmd\do@startpage@pen. |
| 1236 |
% \begin{macrocode} |
| 1237 |
\expandafter\let\expandafter\output@procedure\csname output@\the\outputpenalty\endcsname |
| 1238 |
% \end{macrocode} |
| 1239 |
% If we have failed to find a dispatcher, then settle for \cmd\output@latex. |
| 1240 |
% \begin{macrocode} |
| 1241 |
\@ifnotrelax\output@procedure{}{% |
| 1242 |
\expandafter\def\expandafter\output@procedure\expandafter{\the\output@latex}% |
| 1243 |
}% |
| 1244 |
% \end{macrocode} |
| 1245 |
% Now test if the dispatcher is the special case of \cmd\execute@message@pen, in which case execute the \cmd\@message@saved. |
| 1246 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 1247 |
% \begin{macrocode} |
| 1248 |
\expandafter\@ifx\expandafter{\csname output@-\the\execute@message@pen\endcsname\output@procedure}{% |
| 1249 |
\let\output@procedure\@message@saved |
| 1250 |
}{}% |
| 1251 |
\ltxgrid@info@sw{\class@info{\string\dispatch@output}\say\output@procedure\saythe\holdinginserts}{}% |
| 1252 |
\outputdebug@sw{\output@debug}{}% |
| 1253 |
\output@procedure |
| 1254 |
}% |
| 1255 |
% \end{macrocode} |
| 1256 |
% |
| 1257 |
% \begin{macrocode} |
| 1258 |
\def\set@output@procedure#1#2{% |
| 1259 |
\count@\outputpenalty\advance\count@-#2% |
| 1260 |
\expandafter\let\expandafter#1\csname output@\the\count@\endcsname |
| 1261 |
}% |
| 1262 |
% \end{macrocode} |
| 1263 |
% |
| 1264 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 1265 |
% The following procedure is executed at the beginning of each visit to the output routine, |
| 1266 |
% contingent on the level of diagnostics specified. |
| 1267 |
% However, it bails out when the visit is part of a tight sequence of visits to the output routine. |
| 1268 |
% \begin{macrocode} |
| 1269 |
\def\output@debug{% |
| 1270 |
\def\@tempa{\save@message}% |
| 1271 |
\@ifx{\output@procedure\@tempa}{% |
| 1272 |
\true@sw |
| 1273 |
}{% |
| 1274 |
\@ifnum{\outputpenalty=-\save@column@insert@pen}{% |
| 1275 |
\@ifnum{\holdinginserts>\z@}% |
| 1276 |
}{% |
| 1277 |
\false@sw |
| 1278 |
}% |
| 1279 |
}% |
| 1280 |
{}{\output@debug@}% |
| 1281 |
}% |
| 1282 |
\def\output@debug@{% |
| 1283 |
%<ignore> \saythe\inputlineno |
| 1284 |
\saythe\outputpenalty |
| 1285 |
\saythe\interlinepenalty |
| 1286 |
\saythe\brokenpenalty |
| 1287 |
\saythe\clubpenalty |
| 1288 |
\saythe\widowpenalty |
| 1289 |
\saythe\displaywidowpenalty |
| 1290 |
\saythe\predisplaypenalty |
| 1291 |
\saythe\interdisplaylinepenalty |
| 1292 |
\saythe\postdisplaypenalty |
| 1293 |
\saythe\badness |
| 1294 |
\say\thepagegrid |
| 1295 |
\saythe\pagegrid@col |
| 1296 |
\saythe\pagegrid@cur |
| 1297 |
%<ignore> \say\bot@envir |
| 1298 |
\saythe\insertpenalties |
| 1299 |
%<ignore> \say\@@topmark |
| 1300 |
%<ignore> \say\saved@@topmark |
| 1301 |
%<ignore> \say\@@firstmark |
| 1302 |
%<ignore> \say\saved@@firstmark |
| 1303 |
\say\@@botmark |
| 1304 |
%<ignore> \say\saved@@botmark |
| 1305 |
\saythe\pagegoal |
| 1306 |
\saythe\pagetotal |
| 1307 |
\saythe{\badness\@cclv}% |
| 1308 |
\say\@toplist |
| 1309 |
\say\@botlist |
| 1310 |
\say\@dbltoplist |
| 1311 |
\say\@deferlist |
| 1312 |
\trace@scroll{% |
| 1313 |
\showbox\@cclv |
| 1314 |
\showbox\@cclv@saved |
| 1315 |
\showbox\pagesofar |
| 1316 |
% \end{macrocode} |
| 1317 |
% Klootch! The following line provides only for two-column page grid; if debugging more columns, you must |
| 1318 |
% add more statements here. |
| 1319 |
% \begin{macrocode} |
| 1320 |
\showbox\csname col@1\endcsname |
| 1321 |
\showbox\footsofar |
| 1322 |
\showbox\footins |
| 1323 |
\showbox\footins@saved |
| 1324 |
\showlists |
| 1325 |
}% |
| 1326 |
}% |
| 1327 |
\@ifxundefined{\outputdebug@sw}{% |
| 1328 |
\@booleanfalse\outputdebug@sw |
| 1329 |
}{}% |
| 1330 |
\def\trace@scroll#1{\begingroup\showboxbreadth\maxdimen\showboxdepth\maxdimen\scrollmode#1\endgroup}% |
| 1331 |
\def\trace@box#1{\trace@scroll{\showbox#1}}% |
| 1332 |
% \end{macrocode} |
| 1333 |
% \end{macro} |
| 1334 |
% |
| 1335 |
% \begin{macro}{\@outputpage} |
| 1336 |
% \begin{macro}{\@outputpage@head} |
| 1337 |
% \begin{macro}{\@outputpage@tail} |
| 1338 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}% |
| 1339 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}% |
| 1340 |
% The procedure \cmd\@outputpage\ of standard \LaTeX\ is the sole place where a \cmd\shipout\ is carried out. |
| 1341 |
% The procedures that build \cmd\@outputbox\ just before a page is shipped out by \cmd\@outputpage\ are: |
| 1342 |
% \cmd\@makecolumn, |
| 1343 |
% \cmd\@combinepage, and |
| 1344 |
% \cmd\@combinedblfloats. |
| 1345 |
% |
| 1346 |
% We need to head- and tailpatch this procedure, so we perform here |
| 1347 |
% the only modifications to that procedure that are essential. |
| 1348 |
% Elsewhere, we will build up the meanings of \cmd\@outputpage@head\ and \cmd\@outputpage@tail. |
| 1349 |
% \begin{macrocode} |
| 1350 |
\prepdef\@outputpage{\@outputpage@head}% |
| 1351 |
\let\@outputpage@head\@empty |
| 1352 |
\appdef\@outputpage{\@outputpage@tail}% |
| 1353 |
\let\@outputpage@tail\@empty |
| 1354 |
% \end{macrocode} |
| 1355 |
% \end{macro} |
| 1356 |
% \end{macro} |
| 1357 |
% \end{macro} |
| 1358 |
% |
| 1359 |
% \begin{macro}{\show@box@size} |
| 1360 |
% \begin{macro}{\show@text@box@size} |
| 1361 |
% \begin{macro}{\show@pagesofar@size} |
| 1362 |
% \begin{macro}{\show@box@size@sw} |
| 1363 |
% \begin{macro}{\total@text} |
| 1364 |
% \changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.} |
| 1365 |
% Procedure \cmd\show@box@size\ is a diagnostic for the sizes of boxes; |
| 1366 |
% the boolean \cmd\show@box@size@sw\ turns it on and off. |
| 1367 |
% \begin{macrocode} |
| 1368 |
\def\show@box@size#1#2{% |
| 1369 |
\show@box@size@sw{% |
| 1370 |
\begingroup |
| 1371 |
\setbox\z@\vbox{\unvcopy#2\hrule}% |
| 1372 |
\class@info{Show box size: #1^^J% |
| 1373 |
(\the\ht\z@\space X \the\wd\z@) |
| 1374 |
\the\c@page\space\space\the\pagegrid@cur\space\the\pagegrid@col |
| 1375 |
}% |
| 1376 |
\endgroup |
| 1377 |
}{}% |
| 1378 |
}% |
| 1379 |
% \end{macrocode} |
| 1380 |
% Procedure \cmd\show@text@box@size\ tallies the size of the indicated column. |
| 1381 |
% If \cmd\box\ \cmd\pagesofar\ is a factor, then its height has been memorized |
| 1382 |
% in the depth of the tally box. |
| 1383 |
% |
| 1384 |
% \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long} |
| 1385 |
% \begin{macrocode} |
| 1386 |
\def\show@text@box@size{% |
| 1387 |
\show@box@size{Text column}\@outputbox |
| 1388 |
\tally@box@size@sw{% |
| 1389 |
\@ifdim{\wd\@outputbox>\z@}{% |
| 1390 |
\dimen@\ht\@outputbox\divide\dimen@\@twopowerfourteen |
| 1391 |
\advance\dimen@-\dp\csname box@size@\the\pagegrid@col\endcsname |
| 1392 |
\@ifdim{\dimen@>\z@}{% |
| 1393 |
\advance\dimen@ \ht\csname box@size@\the\pagegrid@col\endcsname |
| 1394 |
\global\ht\csname box@size@\the\pagegrid@col\endcsname\dimen@ |
| 1395 |
\show@box@size@sw{% |
| 1396 |
\class@info{Column: \the\dimen@}% |
| 1397 |
}{}% |
| 1398 |
}{}% |
| 1399 |
}{}% |
| 1400 |
\global\dp\csname box@size@\the\pagegrid@col\endcsname\z@ |
| 1401 |
}{}% |
| 1402 |
}% |
| 1403 |
% \end{macrocode} |
| 1404 |
% Take the height of \cmd\box\ \cmd\pagesofar\ into account. |
| 1405 |
% \begin{macrocode} |
| 1406 |
\def\show@pagesofar@size{% |
| 1407 |
\show@box@size{Page so far}\pagesofar |
| 1408 |
\dimen@\ht\pagesofar\divide\dimen@\@twopowerfourteen |
| 1409 |
\global\dp\csname box@size@1\endcsname\dimen@ |
| 1410 |
\show@box@size@sw{% |
| 1411 |
\class@info{Pagesofar: \the\dimen@}% |
| 1412 |
}{}% |
| 1413 |
}% |
| 1414 |
\@booleanfalse\tally@box@size@sw |
| 1415 |
\@booleanfalse\show@box@size@sw |
| 1416 |
\expandafter\newbox\csname box@size@1\endcsname |
| 1417 |
\expandafter\setbox\csname box@size@1\endcsname\hbox{}% |
| 1418 |
\expandafter\newbox\csname box@size@2\endcsname |
| 1419 |
\expandafter\setbox\csname box@size@2\endcsname\hbox{}% |
| 1420 |
\def\total@text{% |
| 1421 |
\@tempdima\the\ht\csname box@size@2\endcsname\divide\@tempdima\@twopowertwo\@tempcnta\@tempdima |
| 1422 |
\@tempdimb\the\ht\csname box@size@1\endcsname\divide\@tempdimb\@twopowertwo\@tempcntb\@tempdimb |
| 1423 |
\class@info{Total text: Column(\the\@tempcnta pt), Page(\the\@tempcntb pt)}% |
| 1424 |
}% |
| 1425 |
% \end{macrocode} |
| 1426 |
% \end{macro} |
| 1427 |
% \end{macro} |
| 1428 |
% \end{macro} |
| 1429 |
% \end{macro} |
| 1430 |
% \end{macro} |
| 1431 |
% |
| 1432 |
% |
| 1433 |
% \subsection{Further thoughts about inserts} |
| 1434 |
% |
| 1435 |
% The only safe way to deal with inserts is to either set \cmd\holdininserts\ or |
| 1436 |
% to commit to using whatever insert comes your way: you cannot change your mind |
| 1437 |
% once you see a non-void \cmd\box\cmd\footins, say. |
| 1438 |
% |
| 1439 |
% Therefore all output routine processing must proceed with \cmd\holdinginserts\ set |
| 1440 |
% until you are sure of the material to be committed to the page. At that point, you |
| 1441 |
% can clear \cmd\holdinginserts, spew \cmd\box\cmd\@cclv, put down the appropriate penalty, |
| 1442 |
% and exit, with the knowledge that \TeX\ will re-find the same pagebreak, this time |
| 1443 |
% visiting the output routine with everything, including inserts, in their proper |
| 1444 |
% place. |
| 1445 |
% This technique applies to split elements (screens, longtable, index) as well as to |
| 1446 |
% manufactured pages (float pages and clearpage pages). |
| 1447 |
% |
| 1448 |
% Therefore, the output routine must not make assumptions about whether \cmd\holdinginserts\ |
| 1449 |
% should be cleared; instead this must be left to the one-off output routines or the natural output routine. |
| 1450 |
% |
| 1451 |
% If we are manufacturing pages (``float page processing''), and if \cmd\pagegoal\ is not equal to |
| 1452 |
% \cmd\vsize, then inserts are at hand, and our criterion should take into account the insert |
| 1453 |
% material, even though we cannot measure its height based on the size of \cmd\box\cmd\footins\ |
| 1454 |
% (because \cmd\holdinginserts\ is set, you see). |
| 1455 |
% |
| 1456 |
% It would be better to take the complement of \cmd\floatpagefraction\ and use that |
| 1457 |
% as a standard for the looseness of the page. Since \cmd\pagegoal\ reflects the inserted material, |
| 1458 |
% the criterion becomes the difference of the aggregate height of the floats and the \cmd\pagegoal\ |
| 1459 |
% versus this "page looseness" standard. |
| 1460 |
% |
| 1461 |
% As a check, consider what happens if we bail out: \cmd\@deferlist\ has never been touched, so it |
| 1462 |
% requires no attention. Also, \cmd\holdinginserts\ has never been cleared, so inserts require |
| 1463 |
% no attention. So we only have to ensure that marks are preserved, which is already taken |
| 1464 |
% care of by the message handler mechanism. |
| 1465 |
% |
| 1466 |
% If we are doing ordinary page cutting, then the scheme would be to detect whether we are within |
| 1467 |
% a screen (or longtable as may be), do the adjustment to the page height, and return, but this time |
| 1468 |
% with \cmd\holdinginserts\ cleared. Upon reentering the output routine, we may or may not be within |
| 1469 |
% the screen environment, but we are now sure to have a final page break, and we can commit this |
| 1470 |
% material (by shipping out or by saving it out as a full column). |
| 1471 |
% |
| 1472 |
% In the above, the first of the two visits to the output routine is a dead cycle and requires |
| 1473 |
% propagation of marks, but nothing else. |
| 1474 |
% |
| 1475 |
% \subsection{The difference between inserts and floats} |
| 1476 |
% |
| 1477 |
% While revisiting this package in 2008, I needed to clarify under what circumstances inserts |
| 1478 |
% would be added to the \cmd\pagesofar. My conclusion is that I had been treating them |
| 1479 |
% exactly the same as floats, but that was a mistake. |
| 1480 |
% |
| 1481 |
% Floats can be committed at the top of a column, in the middle, or at the bottom. |
| 1482 |
% Footnotes (the only \cmd\insert\ that is used in \LaTeX) may only be committed at the bottom |
| 1483 |
% of a column. So, it was necessary to provide two versions of \cmd\@combinepage, one |
| 1484 |
% that committed \cmd\insert s, and the other that did not, the former used only when |
| 1485 |
% a column of text was committed. Note that even after a column is committed, we could change our minds: |
| 1486 |
% for instance if in multicolumn grid and we decide to balance the columns. |
| 1487 |
% |
| 1488 |
% |
| 1489 |
% \subsection{The natural output routine} |
| 1490 |
% |
| 1491 |
% Here is the portion of the output routine that fields cases not handled by |
| 1492 |
% the dispatcher. |
| 1493 |
% |
| 1494 |
% The default is to ship out a page and then look around for more material |
| 1495 |
% that might constitute a ``float page''. However, because \cmd\holdinginserts\ |
| 1496 |
% is normally set, this output routine must first have a dead cycle and |
| 1497 |
% come back again with \cmd\holdinginserts\ cleared. |
| 1498 |
% Then, after shipping out, it puts down a message that |
| 1499 |
% will manufacture zero or more float pages, finally terminating |
| 1500 |
% with a procedure that commits floats to a new unfinished page. |
| 1501 |
% |
| 1502 |
% To accomodate special processing, we execute hooks whose name is based |
| 1503 |
% on the value of the "envir" mark component. The default is "document", |
| 1504 |
% ensured by an initial mark of that value; the associated procedures |
| 1505 |
% are all nil. Any unknown envir value will "\cmd\relax\ out". |
| 1506 |
% |
| 1507 |
% The test made by \cmd\toggle@insert\ tells whether we are on our first visit to |
| 1508 |
% the output routine (with \cmd\holdinginserts\ still positive), or our second |
| 1509 |
% (with \cmd\holdinginserts\ zeroed). The output routine will toggle the setting. |
| 1510 |
% |
| 1511 |
% The commands \cmd\hold@insertions\ and \cmd\move@insertions\ respectively |
| 1512 |
% clear and set \cmd\holdinginserts, so this procedure effectively |
| 1513 |
% clears \cmd\holdinginserts\ just long enough to pick up the insertions. |
| 1514 |
% Important: any output routine that clears \cmd\holdinginserts\ |
| 1515 |
% must guarentee that it is restored on the subsequent visit to the output routine. |
| 1516 |
% Or, to put it another way, if an output routine detects that \cmd\holdinginserts\ |
| 1517 |
% is cleared, it should take it upon itself to restore it to a positive value before exiting. |
| 1518 |
% |
| 1519 |
% The branch with \cmd\holdinginserts\ set is executed first; the other |
| 1520 |
% branch follows on practically immediately thereafter. In the first branch, |
| 1521 |
% we simply execute the appropriate hook and then execute a dead cycle. |
| 1522 |
% |
| 1523 |
% In the branch with \cmd\holdinginserts\ cleared, the procedure |
| 1524 |
% builds up the current column, which is now complete, with \cmd\@makecolumn, then |
| 1525 |
% dispatches to the shipout routine associated with the current page grid, \cmd\output@column@. |
| 1526 |
% At the end, it triggers the execution of an output routine to prepare the next column (or page). |
| 1527 |
% |
| 1528 |
% \subsection{Natural output routine}% |
| 1529 |
% |
| 1530 |
% \begin{macro}{\natural@output} |
| 1531 |
% \begin{macro}{\output} |
| 1532 |
% Here is the output routine that handles natural pagebreaks: |
| 1533 |
% we now have page that needs to be shipped out or a portion of a page that is ready to be committed to the page grid. |
| 1534 |
% Processing is of necessity divided into phases, \cmd\output@holding\ is executed upon first encountering the natural page-breaking point, while inserts are being held. |
| 1535 |
% 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, |
| 1536 |
% and the insertions (e.g., footnotes) are split off into their assigned box registers. |
| 1537 |
% \begin{macrocode} |
| 1538 |
\def\natural@output{\toggle@insert{\output@holding}{\output@moving}}% |
| 1539 |
\output@latex{\natural@output}% |
| 1540 |
% \end{macrocode} |
| 1541 |
% |
| 1542 |
% In accordance with the scheme suggested by David Kastrup for allowing another output routine |
| 1543 |
% to slip itself into ours, we use a token register called \cmd\output. |
| 1544 |
% However, we reserve the ability to restore things if we so desire. |
| 1545 |
% This we must do in the case of the \filename{lineno.sty} package, because its functionality |
| 1546 |
% is best served by being integrated into our own dispatcher-based output routine. |
| 1547 |
% |
| 1548 |
% To restore our own output routine, we can repeat the above assignment, |
| 1549 |
% \begin{verbatim} |
| 1550 |
%\output@latex{\natural@output}% |
| 1551 |
% \end{verbatim} |
| 1552 |
% some time before the document begins. |
| 1553 |
% \end{macro} |
| 1554 |
% \end{macro} |
| 1555 |
% |
| 1556 |
% \begin{macro}{\output@holding} |
| 1557 |
% \begin{macro}{\@if@exceed@pagegoal} |
| 1558 |
% The procedure \cmd\output@holding\ |
| 1559 |
% is our first cycle through the output routine; \cmd\holdinginserts\ is still set. |
| 1560 |
% We give the current environment a heads up |
| 1561 |
% (it is through this means that \classname{longtable} sets its running header and footer), |
| 1562 |
% then we execute a dead cycle, which should propagate marks. |
| 1563 |
% |
| 1564 |
% One corner case that can crop up is the presence of a single unbreakable chunk whose size is larger |
| 1565 |
% than \cmd\vsize. |
| 1566 |
% Doing a dead cycle under such circumstances will not find the same breakpoint as this time |
| 1567 |
% (remember we threw in a \cmd\mark\ node). |
| 1568 |
% Instead, we attempt to remove the excess height of the material, so we can continue to propagate marks. |
| 1569 |
% |
| 1570 |
% The corner case is at hand if the natural size of \cmd\box\cmd\@cclv\ exceeds \cmd\pagegoal\ and |
| 1571 |
% the contents cannot be shrunk to fit. |
| 1572 |
% |
| 1573 |
% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}} |
| 1574 |
% \begin{macrocode} |
| 1575 |
\def\output@holding{% |
| 1576 |
\csname output@init@\bot@envir\endcsname |
| 1577 |
\@if@exceed@pagegoal{\unvcopy\@cclv}{% |
| 1578 |
\setbox\z@\vbox{\unvcopy\@cclv}% |
| 1579 |
\outputdebug@sw{\trace@box\z@}{}% |
| 1580 |
\dimen@\ht\@cclv\advance\dimen@-\ht\z@ |
| 1581 |
\dead@cycle@repair\dimen@ |
| 1582 |
}{% |
| 1583 |
\dead@cycle |
| 1584 |
}% |
| 1585 |
}% |
| 1586 |
\def\@if@exceed@pagegoal#1{% |
| 1587 |
\begingroup |
| 1588 |
\setbox\z@\vbox{#1}% |
| 1589 |
\dimen@\ht\z@\advance\dimen@\dp\z@ |
| 1590 |
\outputdebug@sw{\saythe\dimen@}{}% |
| 1591 |
\@ifdim{\dimen@>\pagegoal}{% |
| 1592 |
\setbox\z@\vbox{\@@mark{}\unvbox\z@}% |
| 1593 |
\splittopskip\topskip |
| 1594 |
\splitmaxdepth\maxdepth |
| 1595 |
\vbadness\@M |
| 1596 |
\vfuzz\maxdimen |
| 1597 |
\setbox\tw@\vsplit\z@ to\pagegoal |
| 1598 |
\outputdebug@sw{\trace@scroll{\showbox\tw@\showbox\z@}}{}% |
| 1599 |
\setbox\tw@\vbox{\unvbox\tw@}% |
| 1600 |
\@ifdim{\ht\tw@=\z@}{% |
| 1601 |
\ltxgrid@info{Found overly large chunk while preparing to move insertions. Attempting repairs}% |
| 1602 |
\aftergroup\true@sw |
| 1603 |
}{% |
| 1604 |
\aftergroup\false@sw |
| 1605 |
}% |
| 1606 |
}{% |
| 1607 |
\aftergroup\false@sw |
| 1608 |
}% |
| 1609 |
\endgroup |
| 1610 |
}% |
| 1611 |
% \end{macrocode} |
| 1612 |
% \end{macro} |
| 1613 |
% \end{macro} |
| 1614 |
% |
| 1615 |
% \begin{macro}{\output@moving} |
| 1616 |
% \begin{macro}{\@cclv@nontrivial@sw} |
| 1617 |
% The procedure \cmd\output@moving\ |
| 1618 |
% is our second cycle through the output routine; \cmd\holdinginserts\ is now cleared, |
| 1619 |
% and \cmd\insert s will have been split off into their respective box registers, like \cmd\footins. |
| 1620 |
% |
| 1621 |
% \begin{enumerate} |
| 1622 |
% \item |
| 1623 |
% Set the values of \cmd\topmark\ and \cmd\firstmark. |
| 1624 |
% \item |
| 1625 |
% If we got here because of a \cmd\clearpage\ command, remove the protection box that this mechanism has left on the MVL. |
| 1626 |
% \item |
| 1627 |
% If the contents of \cmd\box\cmd\@cclv\ are non-trivial, commit it to the current page (as a column) or ship it out, as the case may call for. |
| 1628 |
% \item |
| 1629 |
% If not, discard it (we are at the end of \cmd\clearpage\ processing). |
| 1630 |
% \item |
| 1631 |
% Set various values, including the available space for setting type on the next column (\cmd\@colroom). |
| 1632 |
% \end{enumerate} |
| 1633 |
% |
| 1634 |
% The processing for a non-trivial \cmd\box\cmd\@cclv\ are: |
| 1635 |
% \begin{enumerate} |
| 1636 |
% \item |
| 1637 |
% Execute the head procedure for the current environment. |
| 1638 |
% \item |
| 1639 |
% Make up a column and ship it out (or commit it to the current page) via a procedure keyed to the current page grid. |
| 1640 |
% \item |
| 1641 |
% Put down an interrupt for \cmd\do@startcolumn@pen: this will force a visit to the output routine for the |
| 1642 |
% purpose of committing floats to the next column. |
| 1643 |
% \item |
| 1644 |
% Possibly put down an interrupt to continue \cmd\clearpage\ proccessing. |
| 1645 |
% \item |
| 1646 |
% Execute the tail procedure for the current environment. |
| 1647 |
% \end{enumerate} |
| 1648 |
% |
| 1649 |
% |
| 1650 |
% The processing for a trivial \cmd\box\cmd\@cclv\ are: |
| 1651 |
% \begin{enumerate} |
| 1652 |
% \item |
| 1653 |
% Void out \cmd\box\cmd\@cclv\ and give appropriate warning messages and diagnostics. |
| 1654 |
% \item |
| 1655 |
% Put down the same interrupts as for the non-trivial case above. |
| 1656 |
% \end{enumerate} |
| 1657 |
% |
| 1658 |
% This instance of \cmd\@makecolumn\ is followed by \cmd\output@column@, |
| 1659 |
% that is, it builds a column for \cmd\shipout\ rather than for adding to \cmd\pagesofar. |
| 1660 |
% |
| 1661 |
% We need to handle cases where the \cmd\output@pre@, \cmd\output@column@, or \cmd\output@post@\ |
| 1662 |
% dispatchers come up \cmd\relax ed out: the default is to execute the corresponding |
| 1663 |
% procedures from the \env{docuemnt} environment and the one-column grid respectively. |
| 1664 |
% |
| 1665 |
% One such case comes up with frequency: at the end of the document, where the \cmd\botmark\ is |
| 1666 |
% now empty. |
| 1667 |
% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 1668 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 1669 |
% \changes{4.1n}{2010/01/02}{(AO, 571) Use procedures \cs{output@do@prep} and \cs{output@column@do} as dispatchers} |
| 1670 |
% \begin{macrocode} |
| 1671 |
\def\output@moving{% |
| 1672 |
\set@top@firstmark |
| 1673 |
\@ifnum{\outputpenalty=\do@newpage@pen}{% |
| 1674 |
\setbox\@cclv\vbox{% |
| 1675 |
\unvbox\@cclv |
| 1676 |
\remove@lastbox |
| 1677 |
\@ifdim{\ht\z@=\ht\@protection@box}{\box\lastbox}{\unskip}% |
| 1678 |
}% |
| 1679 |
}{}% |
| 1680 |
\@cclv@nontrivial@sw{% |
| 1681 |
\expandafter\output@do@prep\csname output@prep@\bot@envir \endcsname |
| 1682 |
\@makecolumn\true@sw |
| 1683 |
\expandafter\output@column@do\csname output@column@\thepagegrid\endcsname |
| 1684 |
\protect@penalty\do@startcolumn@pen |
| 1685 |
\clearpage@sw{% |
| 1686 |
\protect@penalty\do@endpage@pen |
| 1687 |
}{}% |
| 1688 |
\expandafter\let\expandafter\output@post@\csname output@post@\bot@envir \endcsname |
| 1689 |
\outputdebug@sw{\say\output@post@}{}% |
| 1690 |
\@ifx{\output@post@\relax}{\output@post@document}{\output@post@}% |
| 1691 |
}{% |
| 1692 |
\void@cclv |
| 1693 |
}% |
| 1694 |
\set@colht |
| 1695 |
\global\@mparbottom\z@ |
| 1696 |
\global\@textfloatsheight\z@ |
| 1697 |
}% |
| 1698 |
% \end{macrocode} |
| 1699 |
% Procedure \cmd\output@do@prep\ dispatches to the proper procedure to prepare page. |
| 1700 |
% \begin{macrocode} |
| 1701 |
\def\output@do@prep#1{% |
| 1702 |
\outputdebug@sw{\class@info{Prep: \string#1}}{}% |
| 1703 |
\@ifx{#1\relax}{\output@prep@document}{#1}% |
| 1704 |
}% |
| 1705 |
% \end{macrocode} |
| 1706 |
% Procedure \cmd\output@column@do\ dispatches to the proper procedure to output column or page. |
| 1707 |
% \begin{macrocode} |
| 1708 |
\def\output@column@do#1{% |
| 1709 |
\outputdebug@sw{\class@info{Output column: \string#1}}{}% |
| 1710 |
\@ifx{#1\relax}{\output@column@one}{#1}% |
| 1711 |
}% |
| 1712 |
\def\void@cclv{\begingroup\setbox\z@\box\@cclv\endgroup}% |
| 1713 |
\def\remove@lastbox{\setbox\z@\lastbox}% |
| 1714 |
% \end{macrocode} |
| 1715 |
% |
| 1716 |
% The procedure \cmd\@cclv@nontrivial@sw\ determines if this visit to \cmd\output@moving\ |
| 1717 |
% is a trivial one, which happens at the end of \cmd\clearpage\ processing and under some pathological circumstances. |
| 1718 |
% It emits a Boolean, so it is syntactically like \cmd\true@sw, albeit does not execute solely via expansion. |
| 1719 |
% |
| 1720 |
% Note: the case where \cmd\box\cmd\@cclv\ is void comes up at the very beginning of the job, when |
| 1721 |
% typesetting a (full-page-width) title block in a two-column layout. |
| 1722 |
% |
| 1723 |
% Note: the code that removes the last box and skip from the output is intended to detect the case |
| 1724 |
% where the output has whatsit nodes followed by topskip and a protection box. |
| 1725 |
% This is what happens under normal circumstances at the end of \cmd\clearpage\ processing. |
| 1726 |
% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}} |
| 1727 |
% \begin{macrocode} |
| 1728 |
\def\@cclv@nontrivial@sw{% |
| 1729 |
\@ifx@empty\@toplist{% |
| 1730 |
\@ifx@empty\@botlist{% |
| 1731 |
\@ifvoid\footins{% |
| 1732 |
\@ifvoid\@cclv{% |
| 1733 |
\false@sw |
| 1734 |
}{% |
| 1735 |
\setbox\z@\vbox{\unvcopy\@cclv}% |
| 1736 |
\@ifdim{\ht\z@=\topskip}{% |
| 1737 |
\setbox\z@\vbox\bgroup |
| 1738 |
\unvbox\z@ |
| 1739 |
\remove@lastbox |
| 1740 |
\dimen@\lastskip\unskip |
| 1741 |
\@ifdim{\ht\z@=\ht\@protection@box}{% |
| 1742 |
\advance\dimen@\ht\z@ |
| 1743 |
\@ifdim{\dimen@=\topskip}{% |
| 1744 |
\aftergroup\true@sw |
| 1745 |
}{% |
| 1746 |
\aftergroup\false@sw |
| 1747 |
}% |
| 1748 |
}{% |
| 1749 |
\aftergroup\false@sw |
| 1750 |
}% |
| 1751 |
% \end{macrocode} |
| 1752 |
% End of \cmd\box\cmd\z@. |
| 1753 |
% \begin{macrocode} |
| 1754 |
\egroup |
| 1755 |
{% |
| 1756 |
% \end{macrocode} |
| 1757 |
% Normal for \clearpage |
| 1758 |
% \begin{macrocode} |
| 1759 |
\false@sw |
| 1760 |
}{% |
| 1761 |
\true@sw |
| 1762 |
}% |
| 1763 |
}{% |
| 1764 |
\@ifdim{\ht\z@=\z@}{% |
| 1765 |
\ltxgrid@info{Found trivial column. Discarding it}% |
| 1766 |
\outputdebug@sw{\trace@box\@cclv}{}% |
| 1767 |
\false@sw |
| 1768 |
}{% |
| 1769 |
\true@sw |
| 1770 |
}% |
| 1771 |
}% |
| 1772 |
}% |
| 1773 |
}{% |
| 1774 |
\true@sw |
| 1775 |
}% |
| 1776 |
}{% |
| 1777 |
\true@sw |
| 1778 |
}% |
| 1779 |
}{% |
| 1780 |
\true@sw |
| 1781 |
}% |
| 1782 |
}% |
| 1783 |
% \end{macrocode} |
| 1784 |
% |
| 1785 |
% |
| 1786 |
% \end{macro} |
| 1787 |
% \end{macro} |
| 1788 |
% |
| 1789 |
% \begin{macro}{\protect@penalty} |
| 1790 |
% The procedure \cmd\protect@penalty\ is the utility procedure for invoking a |
| 1791 |
% one-off output routine. Such a routine can expect to find the protection box |
| 1792 |
% above it in \cmd\box\cmd\@cclv: it should remove that box. |
| 1793 |
% |
| 1794 |
% Note that \cmd\execute@message\ does the same thing as \cmd\protect@penalty, but |
| 1795 |
% in a slightly different way. |
| 1796 |
% |
| 1797 |
% We create a specially formulated box that will be universally used when a protection box is needed. |
| 1798 |
% In this way, we can always recognize when \cmd\box\cmd\@cclv\ is trivial: |
| 1799 |
% it will consist of whatsits followed by \cmd\topskip\ glue and the \cmd\@protection@box. |
| 1800 |
% \begin{macrocode} |
| 1801 |
\def\protect@penalty#1{\protection@box\penalty-#1\relax}% |
| 1802 |
\newbox\@protection@box |
| 1803 |
\setbox\@protection@box\vbox to1986sp{\vfil}% |
| 1804 |
\def\protection@box{\nointerlineskip\copy\@protection@box}% |
| 1805 |
% \end{macrocode} |
| 1806 |
% \end{macro} |
| 1807 |
% |
| 1808 |
% \begin{macro}{\dead@cycle} |
| 1809 |
% \begin{macro}{\dead@cycle@repair} |
| 1810 |
% The procedure \cmd\dead@cycle\ is defined separately as a utility which can be used by |
| 1811 |
% any output processing routine to emulate what takes place in the standard output routine. |
| 1812 |
% |
| 1813 |
% Here, we have entered the output routine with \cmd\holdinginserts\ enabled, which means that we |
| 1814 |
% are not yet ready to ship out material, because the \cmd\insert\ registers are being held. |
| 1815 |
% We want to clear \cmd\holdinginserts\ and come back here with the same page break as before, whereupon |
| 1816 |
% we may properly proceed with page makeup. |
| 1817 |
% |
| 1818 |
% To do this, we |
| 1819 |
% propagate marks, then spew the contents of \cmd\box\cmd\@cclv\ followed by the |
| 1820 |
% original output penalty that landed us here (but only if it is not 10000, |
| 1821 |
% the flag value for a pagebreak not at a penalty). |
| 1822 |
% |
| 1823 |
% However, the natural output routine should do this only if \cmd\box\cmd\@cclv\ is nontrivial. |
| 1824 |
% A pathological case exists wherein a box of height greater than \cmd\textheight\ would cause an infinite loop involving the output routine. |
| 1825 |
% The procedure \cmd\dead@cycle@repair, attempts to catch this case and avoid the loop. |
| 1826 |
% |
| 1827 |
% The test of the height of \cmd\box\cmd\@cclv\ is not the correct one, because this test will run afoul in |
| 1828 |
% the case where \cmd\box\cmd\@cclv\ contains nothing but an \cmd\insert\ node. What to do? |
| 1829 |
% |
| 1830 |
% It is possible that the pathological case can be detected by looking at \cmd\pagetotal. If that quantity is |
| 1831 |
% zero, then \cmd\box\cmd\@cclv\ really is trivial. |
| 1832 |
% |
| 1833 |
% In the procedure \cmd\dead@cycle@repair, if \cmd\box\cmd\@cclv\ is nontrivial, we execute \cmd\dead@cycle, |
| 1834 |
% otherwise it contains nothing but a mark, so we dispense with propagating marks |
| 1835 |
% and we simply spew out \cmd\box\cmd\@cclv\ without an accompanying mark. |
| 1836 |
% This has the effect of failing to propagate marks, but this problem is preferrable to the infinite loop, |
| 1837 |
% which in principle could crash even a robust operating system by filling up the file system. |
| 1838 |
% |
| 1839 |
% If a document has such a large chunk, it should be fixed, so we give a message in the log. |
| 1840 |
% |
| 1841 |
% You ask, ``In what way does this infinite loop come about?'' Good question! |
| 1842 |
% |
| 1843 |
% The setup is a chunk in the MVL that is taller than \cmd\textheight. |
| 1844 |
% (Yes, it's that simple.) |
| 1845 |
% As soon as the previous page ships out, the MVL will contain a mark (propagated from the previous page) followed |
| 1846 |
% by that large chunk (call it the `big bad box', albeit does not need to be a single box). |
| 1847 |
% The next visit to the output routine will be a natural page break, but |
| 1848 |
% \TeX\ will select the juncture between the mark and the big bad box as the least-cost page break. |
| 1849 |
% Unless the test in \cmd\dead@cycle\ is done, the cycle is perpetuated when the macro |
| 1850 |
% reinserts the mark. |
| 1851 |
% |
| 1852 |
% The crux matter is achieving, in a robust way, the goal of going from a \cmd\holdinginserts\ state to one |
| 1853 |
% where the insertions are moving. |
| 1854 |
% |
| 1855 |
% \begin{macrocode} |
| 1856 |
\def\dead@cycle@repair#1{% |
| 1857 |
\expandafter\do@@mark |
| 1858 |
\expandafter{% |
| 1859 |
\@@botmark |
| 1860 |
}% |
| 1861 |
\unvbox\@cclv |
| 1862 |
\nointerlineskip |
| 1863 |
\vbox to#1{\vss}% |
| 1864 |
\@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
| 1865 |
}% |
| 1866 |
\def\dead@cycle@repair@protected#1{% |
| 1867 |
\expandafter\do@@mark |
| 1868 |
\expandafter{% |
| 1869 |
\@@botmark |
| 1870 |
}% |
| 1871 |
\begingroup |
| 1872 |
\unvbox\@cclv |
| 1873 |
% \end{macrocode} |
| 1874 |
% Remove the protection box |
| 1875 |
% \begin{macrocode} |
| 1876 |
\remove@lastbox |
| 1877 |
\nointerlineskip |
| 1878 |
\advance#1-\ht\@protection@box |
| 1879 |
\vbox to#1{\vss}% |
| 1880 |
\protection@box % Reinsert protection box |
| 1881 |
\@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
| 1882 |
\endgroup |
| 1883 |
}% |
| 1884 |
\def\dead@cycle{% |
| 1885 |
\expandafter\do@@mark |
| 1886 |
\expandafter{% |
| 1887 |
\@@botmark |
| 1888 |
}% |
| 1889 |
\unvbox\@cclv |
| 1890 |
\@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}% |
| 1891 |
}% |
| 1892 |
% \end{macrocode} |
| 1893 |
% \end{macro} |
| 1894 |
% \end{macro} |
| 1895 |
% |
| 1896 |
% \begin{macro}{\output@init@document} |
| 1897 |
% \begin{macro}{\output@prep@document} |
| 1898 |
% \begin{macro}{\output@post@document} |
| 1899 |
% The default processing simply provides for insertion of held-over footnotes. |
| 1900 |
% At a natural page break, we are either at the bottom of a column or at the bottom |
| 1901 |
% of a page. In either case, the \cmd\output@init@\ processing adjusts for the height |
| 1902 |
% of the held-over footnotes and bails out. |
| 1903 |
% Upon our return, at \cmd\output@prep@\ time, the page break will accomodate the material; |
| 1904 |
% it is now actually inserted by concatenating it with the contents of \cmd\footins. |
| 1905 |
% The default processing for \cmd\output@post@\ is nil. |
| 1906 |
% \changes{4.1b}{2008/08/04}{Box \cs{footbox} changed to box \cs{footsofar}} |
| 1907 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 1908 |
% \begin{macrocode} |
| 1909 |
\def\output@init@document{% |
| 1910 |
\ltxgrid@info@sw{\class@info{\string\output@init@document}}{}% |
| 1911 |
\global\vsize\vsize |
| 1912 |
}% |
| 1913 |
% \end{macrocode} |
| 1914 |
% QUERY: the following procedure is very like \cmd\combine@foot@inserts. Should it be the same? |
| 1915 |
% Answer: no, the two differ: this procedure makes a local assignment of \cmd\footins; |
| 1916 |
% the latter makes a global assignment of \cmd\footsofar. |
| 1917 |
% |
| 1918 |
% Note: In a multicolumn document, footnotes must \emph{not} be balanced at this point. |
| 1919 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 1920 |
% \begin{macrocode} |
| 1921 |
\def\output@prep@document{% |
| 1922 |
\ltxgrid@foot@info@sw{\class@info{\string\output@prep@document}\trace@scroll{\showbox\footins\showbox\footsofar}}{}% |
| 1923 |
\@ifvoid\footsofar{% |
| 1924 |
}{% |
| 1925 |
\global\setbox\footins\vbox\bgroup |
| 1926 |
\unvbox\footsofar |
| 1927 |
\@ifvoid\footins{}{% |
| 1928 |
\marry@baselines |
| 1929 |
\unvbox\footins |
| 1930 |
}% |
| 1931 |
\egroup |
| 1932 |
\ltxgrid@foot@info@sw{\trace@box\footins}{}% |
| 1933 |
}% |
| 1934 |
}% |
| 1935 |
\def\output@post@document{}% |
| 1936 |
% \end{macrocode} |
| 1937 |
% \end{macro} |
| 1938 |
% \end{macro} |
| 1939 |
% \end{macro} |
| 1940 |
% |
| 1941 |
% \begin{macro}{\@opcol} |
| 1942 |
% The standard \LaTeX\ procedure \cmd\@opcol\ is now completely obsoleted. |
| 1943 |
% \begin{macrocode} |
| 1944 |
\let\@opcol\@undefined |
| 1945 |
% \end{macrocode} |
| 1946 |
% \end{macro} |
| 1947 |
% |
| 1948 |
% \begin{macro}{\@makecolumn} |
| 1949 |
% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 1950 |
% The procedure \cmd\@makecolumn\ packages up a page along with all its insertions and floats. |
| 1951 |
% Therefore it is essential that it be executed with \cmd\holdininserts\ cleared. |
| 1952 |
% |
| 1953 |
% Note that there is a corner case when in a multi-column grid, where the change back to |
| 1954 |
% one-column grid occurs just after a complete page ships out. We want to detect when |
| 1955 |
% \cmd\@cclv\ contains nothing but a \cmd\mark, but this is a \TeX\ impossibility. |
| 1956 |
% |
| 1957 |
% Note on \cmd\@kludgeins: we have removed this mechanism from \LaTeX, because the implementation |
| 1958 |
% of \cmd\enlargethispage\ no longer requires it. |
| 1959 |
% Here, for consistency sake, we remove \cmd\@makespecialcolbox. |
| 1960 |
% |
| 1961 |
% The argument of \cmd\@makecolumn\ is a Boolean and determines if we combine the footnote material |
| 1962 |
% into the present column. If the procedure is building a column for shipping out, then we will |
| 1963 |
% combine the footnote material, if not, we return with the \cmd\footins\ box unchanged. |
| 1964 |
% |
| 1965 |
% \changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated} |
| 1966 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 1967 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 1968 |
% \changes{4.1n}{2010/01/02}{(AO, 571) change calling sequence of \cs{combine@foot@inserts} to expose box registers}% |
| 1969 |
% I changed the behavior of this procedure in the case where the argument is \cmd\false@sw: |
| 1970 |
% send the unused footnote material to \cmd\footsofar. |
| 1971 |
% \begin{macrocode} |
| 1972 |
\def\@makecolumn#1{% |
| 1973 |
\ltxgrid@foot@info@sw{\class@info{\string\@makecolumn\string#1}}{}% |
| 1974 |
\setbox\@outputbox\vbox\bgroup |
| 1975 |
\boxmaxdepth\@maxdepth |
| 1976 |
\@tempdima\dp\@cclv |
| 1977 |
\unvbox\@cclv |
| 1978 |
\vskip-\@tempdima |
| 1979 |
\egroup |
| 1980 |
\xdef\@freelist{\@freelist\@midlist}\global\let\@midlist\@empty |
| 1981 |
\show@text@box@size |
| 1982 |
\@combinefloats |
| 1983 |
#1{% |
| 1984 |
\@combineinserts\@outputbox\footins |
| 1985 |
}{% |
| 1986 |
\combine@foot@inserts\footsofar\footins |
| 1987 |
}% |
| 1988 |
\set@adj@colht\dimen@ |
| 1989 |
\count@\vbadness |
| 1990 |
\vbadness\@M |
| 1991 |
\setbox\@outputbox\vbox to\dimen@\bgroup |
| 1992 |
\@texttop |
| 1993 |
\dimen@\dp\@outputbox |
| 1994 |
\unvbox\@outputbox |
| 1995 |
\vskip-\dimen@ |
| 1996 |
\@textbottom |
| 1997 |
\egroup |
| 1998 |
\vbadness\count@ |
| 1999 |
\global\maxdepth\@maxdepth |
| 2000 |
}% |
| 2001 |
\let\@makespecialcolbox\@undefined |
| 2002 |
% \end{macrocode} |
| 2003 |
% \end{macro} |
| 2004 |
% |
| 2005 |
% \begin{macro}{\@combineinserts} |
| 2006 |
% The procedure to add the specified insertions to the packaged-up page. |
| 2007 |
% All other classes of insertions should also be dealt with at this time. |
| 2008 |
% |
| 2009 |
% Note that the second argument must be a \cmd\newinsert\ register: we access the \cmd\box\ along with the \cmd\skip. |
| 2010 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 2011 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 2012 |
% \changes{4.1n}{2010/01/02}{(AO, 571) footnote rule is leaders, so that it may be removed by \cs{vsplit}; mechanism of \cs{kern} signals to indicate footnote height}% |
| 2013 |
% \begin{macrocode} |
| 2014 |
\def\@combineinserts#1#2{% |
| 2015 |
\ltxgrid@foot@info@sw{\class@info{\string\@combineinserts\string#1\string#2}\trace@box#2}{}% |
| 2016 |
\setbox#1\vbox\bgroup |
| 2017 |
\unvbox#1% |
| 2018 |
\@ifvoid{#2}{}{% |
| 2019 |
\dimen@\ht#2\advance\dimen@\dp#2\advance\dimen@\skip#2% |
| 2020 |
\show@box@size{Combining inserts}#2% |
| 2021 |
\vskip\skip#2% |
| 2022 |
% \end{macrocode} |
| 2023 |
% The footnote rule is created as leaders, so that it may be removed automatically (via \cmd\vsplit) |
| 2024 |
% in the event the footnote is recovered from this column. |
| 2025 |
% Note that if \cmd\color@begingroup\ or \cmd\normalcolor\ produce marks, this technique will be confounded. |
| 2026 |
% \begin{macrocode} |
| 2027 |
\setbox\z@\vbox{\footnoterule}\dimen@i\ht\z@ |
| 2028 |
\color@begingroup |
| 2029 |
\normalcolor |
| 2030 |
\cleaders\box\z@\vskip\dimen@i\kern-\dimen@i |
| 2031 |
\csname combine@insert@\the\pagegrid@col\endcsname#2% |
| 2032 |
\color@endgroup |
| 2033 |
% \end{macrocode} |
| 2034 |
% The following tells \cmd\recover@column\ the size of the footnotes added here, including the skip glue above. |
| 2035 |
% \begin{macrocode} |
| 2036 |
\kern-\dimen@\kern\dimen@ |
| 2037 |
}% |
| 2038 |
\egroup |
| 2039 |
\ltxgrid@foot@info@sw{\trace@box#1}{}% |
| 2040 |
}% |
| 2041 |
% \end{macrocode} |
| 2042 |
% We provide for a layer of abstraction for the laying down of footnotes at the bottom of this column or page. |
| 2043 |
% \end{macro} |
| 2044 |
% |
| 2045 |
% \begin{macro}{\combine@insert@tw@} |
| 2046 |
% \begin{macro}{\combine@insert@@ne} |
| 2047 |
% \begin{macro}{\twocolumn@grid@setup} |
| 2048 |
% \begin{macro}{\onecolumn@grid@setup} |
| 2049 |
% \begin{macro}{\columngrid@setup} |
| 2050 |
% \changes{4.1p}{2010/02/24}{(AO, 583) Provide setup code also for footnotes in a one-column document}% |
| 2051 |
% The following two definitions cover the cases of a two-column document (with footnotes set on a single-column width), |
| 2052 |
% and a one-column document. |
| 2053 |
% However, the case of a two-column document with footnotes set on full text width is not covered. |
| 2054 |
% |
| 2055 |
% For a document in an overall two-column page grid, execute the commands |
| 2056 |
% \cmd\twocolumn@grid@setup\ followed by \cmd\open@twocolumn; |
| 2057 |
% if on the full page width (one-column grid), the command \cmd\onecolumn@grid@setup. |
| 2058 |
% |
| 2059 |
% The following is the way REVTeX does the initialization. |
| 2060 |
% The procedure \cmd\select@column@grid\ is executed at \cmd\AtBeginDocument\ time; |
| 2061 |
% the boolean \cmd\twocolumn@sw\ selects between the two alternatives. |
| 2062 |
% \begin{verbatim} |
| 2063 |
%\def\select@column@grid{% |
| 2064 |
% \twocolumn@sw{% |
| 2065 |
% \twocolumn@grid@setup |
| 2066 |
% \open@twocolumn |
| 2067 |
% }{% |
| 2068 |
% \onecolumn@grid@setup |
| 2069 |
% }% |
| 2070 |
%}% |
| 2071 |
%\appdef\class@documenthook{% |
| 2072 |
% \select@column@grid |
| 2073 |
%}% |
| 2074 |
% \end{verbatim} |
| 2075 |
% |
| 2076 |
% \begin{macrocode} |
| 2077 |
\def\combine@insert@tw@#1{% |
| 2078 |
\compose@footnotes@two#1\@ifvbox{#1}{\unvbox}{\box}#1% |
| 2079 |
}% |
| 2080 |
\def\combine@insert@@ne#1{% |
| 2081 |
\compose@footnotes@one#1\@ifvbox{#1}{\unvbox}{\box}#1% |
| 2082 |
}% |
| 2083 |
\def\twocolumn@grid@setup{% |
| 2084 |
\expandafter\let\csname combine@insert@1\endcsname\combine@insert@tw@ |
| 2085 |
\expandafter\let\csname combine@insert@2\endcsname\combine@insert@@ne |
| 2086 |
}% |
| 2087 |
\def\onecolumn@grid@setup{% |
| 2088 |
\expandafter\let\csname combine@insert@1\endcsname\combine@insert@@ne |
| 2089 |
\expandafter\let\csname combine@insert@2\endcsname\combine@insert@@ne |
| 2090 |
}% |
| 2091 |
\let\columngrid@setup\onecolumn@grid@setup |
| 2092 |
\columngrid@setup |
| 2093 |
% \end{macrocode} |
| 2094 |
% \end{macro} |
| 2095 |
% \end{macro} |
| 2096 |
% \end{macro} |
| 2097 |
% \end{macro} |
| 2098 |
% \end{macro} |
| 2099 |
% |
| 2100 |
% \begin{macro}{\@floatplacement} |
| 2101 |
% In standard \LaTeX, someone (DPC?) makes the assumption that \cmd\@fpmin\ can be assigned |
| 2102 |
% locally. This is no longer true now that we ship no more than one page per visit to the output routine. |
| 2103 |
% We apply a bandaid. |
| 2104 |
% \begin{macrocode} |
| 2105 |
\appdef\@floatplacement{% |
| 2106 |
\global\@fpmin\@fpmin |
| 2107 |
}% |
| 2108 |
% \end{macrocode} |
| 2109 |
% \end{macro} |
| 2110 |
% |
| 2111 |
% \begin{macro}{\pagebreak@pen} |
| 2112 |
% While we are in the way of registering certain penalty values, |
| 2113 |
% let us register the smallest one that will force a visit to the output routine. |
| 2114 |
% However, this penalty will not have an assciated macro: we wish to execute the |
| 2115 |
% natural output routine instead. |
| 2116 |
% |
| 2117 |
% Note that this penalty is invoked by \cmd\clearpage\ and \cmd\newpage. |
| 2118 |
% \begin{macrocode} |
| 2119 |
\mathchardef\pagebreak@pen=\@M |
| 2120 |
\expandafter\let\csname output@-\the\pagebreak@pen\endcsname\relax |
| 2121 |
% \end{macrocode} |
| 2122 |
% \end{macro} |
| 2123 |
% |
| 2124 |
% |
| 2125 |
% \subsection{Float placement}% |
| 2126 |
% |
| 2127 |
% \begin{macro}{\do@startcolumn@pen} |
| 2128 |
% The procedure \cmd\do@startcolumn@pen\ is executed as a one-off output routine |
| 2129 |
% just after a page is shipped out (or, in a multicolumn page grid, a column is salted away). |
| 2130 |
% |
| 2131 |
% Its job is to either generate a ``float page'' (in reality a column) for shipping out, |
| 2132 |
% or to commit deferred floats to the fresh column, concluding with a dead cycle. |
| 2133 |
% In the former case, we accomodate split footnotes and other insertions (by comparing \cmd\vsize\ and \cmd\pagegoal): |
| 2134 |
% the floats are spewed onto the page, whereupon \LaTeX's output routine will place the footnotes and ship out, |
| 2135 |
% iterating the process once again. |
| 2136 |
% |
| 2137 |
% Note that when this procedure is invoked, \cmd\box\cmd\@cclv\ still has within it the protection box, so we |
| 2138 |
% start by removing it. Note also that if there was a split insertion held over from the previous page, the |
| 2139 |
% insert node will be present in \cmd\box\cmd\@cclv, \emph{prior to} the protection box. For this reason, we cannot |
| 2140 |
% just throw away that box, as we might be tempted to do. |
| 2141 |
% |
| 2142 |
% FIXME: where else do we possibly inappropriately discard \cmd\box\cmd\@cclv? |
| 2143 |
% |
| 2144 |
% Note that, because a column or page page had previously just been completed, |
| 2145 |
% we can assume that there is nothing of importance on the page, |
| 2146 |
% and because no message is being passed, we can preserve marks in a simple way. |
| 2147 |
% |
| 2148 |
% A Note on terminology: |
| 2149 |
% In a single-column page grid, you might expect that we would execute the procedure \cmd\do@startpage. |
| 2150 |
% But this is not so. |
| 2151 |
% \LaTeX\ has a confustion of long standing, |
| 2152 |
% in which the procedures that handle full-page width floats in a two-column page grid all have in their names |
| 2153 |
% the string `dbl', which erroneously suggests having something to do with ``double''. It does not: |
| 2154 |
% when you see `dbl', think ``full page width''. |
| 2155 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 2156 |
% \begin{macrocode} |
| 2157 |
\mathchardef\do@startcolumn@pen=10005 |
| 2158 |
\@namedef{output@-\the\do@startcolumn@pen}{\do@startcolumn}% |
| 2159 |
\def\do@startcolumn{% |
| 2160 |
\setbox\@cclv\vbox{\unvbox\@cclv\remove@lastbox\unskip}% |
| 2161 |
\clearpage@sw{\@clearfloatplacement}{\@floatplacement}% |
| 2162 |
\set@colht |
| 2163 |
\@booleanfalse\pfloat@avail@sw |
| 2164 |
\begingroup |
| 2165 |
\@colht\@colroom |
| 2166 |
\@booleanfalse\float@avail@sw |
| 2167 |
\@tryfcolumn\test@colfloat |
| 2168 |
\float@avail@sw{\aftergroup\@booleantrue\aftergroup\pfloat@avail@sw}{}% |
| 2169 |
\endgroup |
| 2170 |
\fcolmade@sw{% |
| 2171 |
\setbox\@cclv\vbox{\unvbox\@outputbox\unvbox\@cclv}% |
| 2172 |
% \end{macrocode} |
| 2173 |
% Now ask for a return visit, this time with insertions and all. |
| 2174 |
% \begin{macrocode} |
| 2175 |
\outputpenalty-\pagebreak@pen |
| 2176 |
\dead@cycle |
| 2177 |
}{% |
| 2178 |
\begingroup |
| 2179 |
\let\@elt\@scolelt |
| 2180 |
\let\reserved@b\@deferlist\global\let\@deferlist\@empty\reserved@b |
| 2181 |
\endgroup |
| 2182 |
\clearpage@sw{% |
| 2183 |
\outputpenalty\@M |
| 2184 |
}{% |
| 2185 |
\outputpenalty\do@newpage@pen |
| 2186 |
}% |
| 2187 |
\dead@cycle |
| 2188 |
}% |
| 2189 |
\check@deferlist@stuck\do@startcolumn |
| 2190 |
\set@vsize |
| 2191 |
}% |
| 2192 |
\def\@scolelt#1{\def\@currbox{#1}\@addtonextcol}% |
| 2193 |
\def\test@colfloat#1{% |
| 2194 |
\csname @floatselect@sw@\thepagegrid\endcsname#1{}{\@testtrue}% |
| 2195 |
\@if@sw\if@test\fi{}{\aftergroup\@booleantrue\aftergroup\float@avail@sw}% |
| 2196 |
}% |
| 2197 |
% \end{macrocode} |
| 2198 |
% \end{macro} |
| 2199 |
% |
| 2200 |
% \begin{macro}{\@addtonextcol} |
| 2201 |
% We must adjust \cmd\@addtonextcol\ to take held-over inserts into account. |
| 2202 |
% Now that all deferred floats are queued up together (in order), we must have a way of |
| 2203 |
% differentiating them; this is done by the page grid-dependent procedure \cmd\@floatselect@sw@. |
| 2204 |
% \begin{macrocode} |
| 2205 |
\def\@addtonextcol{% |
| 2206 |
\begingroup |
| 2207 |
\@insertfalse |
| 2208 |
\@setfloattypecounts |
| 2209 |
\csname @floatselect@sw@\thepagegrid\endcsname\@currbox{% |
| 2210 |
\@ifnum{\@fpstype=8 }{}{% |
| 2211 |
\@ifnum{\@fpstype=24 }{}{% |
| 2212 |
\@flsettextmin |
| 2213 |
\@reqcolroom \ht\@currbox |
| 2214 |
\advance \@reqcolroom \@textmin |
| 2215 |
\advance \@reqcolroom \vsize % take into account split insertions |
| 2216 |
\advance \@reqcolroom -\pagegoal |
| 2217 |
\@ifdim{\@colroom>\@reqcolroom}{% |
| 2218 |
\@flsetnum \@colnum |
| 2219 |
\@ifnum{\@colnum>\z@}{% |
| 2220 |
\@bitor\@currtype\@deferlist |
| 2221 |
\@if@sw\if@test\fi{}{% |
| 2222 |
\@addtotoporbot |
| 2223 |
}% |
| 2224 |
}{}% |
| 2225 |
}{}% |
| 2226 |
}% |
| 2227 |
}% |
| 2228 |
}{}% |
| 2229 |
\@if@sw\if@insert\fi{}{% |
| 2230 |
\@cons\@deferlist\@currbox |
| 2231 |
}% |
| 2232 |
\endgroup |
| 2233 |
}% |
| 2234 |
% \end{macrocode} |
| 2235 |
% \end{macro} |
| 2236 |
% |
| 2237 |
% \begin{macro}{\do@startpage@pen} |
| 2238 |
% \begin{macro}{\forcefloats@sw} |
| 2239 |
% \begin{macro}{\@output@combined@page} |
| 2240 |
% \begin{macro}{\@sdblcolelt} |
| 2241 |
% \begin{macro}{\test@dblfloat} |
| 2242 |
% \begin{macro}{\@if@notdblfloat} |
| 2243 |
% Similar to \cmd\do@startcolumn, |
| 2244 |
% the procedure \cmd\do@startpage\ starts up a new page (not column) in a multi-column page grid. |
| 2245 |
% It is invoked after a page is shipped out in a multi-column page grid, and |
| 2246 |
% it commits full-page-width floats to the fresh page, possibly resulting in a float page. |
| 2247 |
% In implementation, it is similar to \cmd\do@startcolumn, except that |
| 2248 |
% it commits effectively via \cmd\@addtodblcol\ instead of \cmd\@addtonextcol. |
| 2249 |
% Note that this procedure will inevitably be followed by \cmd\do@startcolumn. |
| 2250 |
% |
| 2251 |
% Some details of the procedure: |
| 2252 |
% |
| 2253 |
% We begin by removing the protection box from \cmd\box\cmd\@cclv, then setting the values of the |
| 2254 |
% float placement parameters appropriately, and resetting \cmd\@colht, \cmd\@colroom, and \cmd\vsize\ to base values. |
| 2255 |
% |
| 2256 |
% Next we attempt to compose a float page, a page consisting entirely of floats. If successful, |
| 2257 |
% we ship out the float page and lay down an interrupt that will send us back here for another try. |
| 2258 |
% |
| 2259 |
% If no float page is formed, we attempt to commit full-page-width floats to the text page, and return with a dead cycle. |
| 2260 |
% We are now ready to compose columns of text. |
| 2261 |
% |
| 2262 |
% Note that all floats (both column floats and full-page-width floats) move through a single queue. |
| 2263 |
% To differentiate between the two, the width of the float is compared to \cmd\textwidth. |
| 2264 |
% This comparison is encapsulated in the macro \cmd\@if@notdblfloat, which should be used whenever |
| 2265 |
% such a determination must be made. This procedure returns a Boolean. |
| 2266 |
% |
| 2267 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 2268 |
% \begin{macrocode} |
| 2269 |
\mathchardef\do@startpage@pen=10006 |
| 2270 |
\@namedef{output@-\the\do@startpage@pen}{\do@startpage}% |
| 2271 |
\def\do@startpage{% |
| 2272 |
\setbox\@cclv\vbox{\unvbox\@cclv\remove@lastbox\unskip}% |
| 2273 |
\clearpage@sw{\@clearfloatplacement}{\@dblfloatplacement}% |
| 2274 |
\set@colht |
| 2275 |
\@booleanfalse\pfloat@avail@sw |
| 2276 |
\begingroup |
| 2277 |
\@booleanfalse\float@avail@sw |
| 2278 |
\@tryfcolumn\test@dblfloat |
| 2279 |
\float@avail@sw{\aftergroup\@booleantrue\aftergroup\pfloat@avail@sw}{}% |
| 2280 |
\endgroup |
| 2281 |
\fcolmade@sw{% |
| 2282 |
\global\setbox\pagesofar\vbox{\unvbox\pagesofar\unvbox\@outputbox}% |
| 2283 |
\@output@combined@page |
| 2284 |
}{% |
| 2285 |
\begingroup |
| 2286 |
\@booleanfalse\float@avail@sw |
| 2287 |
\let\@elt\@sdblcolelt |
| 2288 |
\let\reserved@b\@deferlist\global\let\@deferlist\@empty\reserved@b |
| 2289 |
\endgroup |
| 2290 |
\@ifdim{\@colht=\textheight}{% No luck... |
| 2291 |
\pfloat@avail@sw{% ...but a float *was* available! |
| 2292 |
\forcefloats@sw{% |
| 2293 |
\ltxgrid@warn{Forced dequeueing of floats stalled}% |
| 2294 |
}{% |
| 2295 |
\ltxgrid@warn{Dequeueing of floats stalled}% |
| 2296 |
}% |
| 2297 |
}{}% |
| 2298 |
}{}% |
| 2299 |
\outputpenalty\@M |
| 2300 |
\dead@cycle |
| 2301 |
}% |
| 2302 |
\check@deferlist@stuck\do@startpage |
| 2303 |
\set@colht |
| 2304 |
}% |
| 2305 |
% \end{macrocode} |
| 2306 |
% |
| 2307 |
% Procedure \cmd\@output@combined@page\ is a utility that ships out a page consisting of the |
| 2308 |
% result of \cmd\@combinepage\ and \cmd\@combinedblfloats, after which it prepares for |
| 2309 |
% the process to repeat. |
| 2310 |
% |
| 2311 |
% It is coincidentally identical to what needs to happen with |
| 2312 |
% a float page that has been built by \cmd\@tryfcolumn, in the multi-column page grid, |
| 2313 |
% and also handles the case where a page needs to be shipped out when in multicolumn mode. |
| 2314 |
% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}} |
| 2315 |
% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument} |
| 2316 |
% \begin{macrocode} |
| 2317 |
\def\@output@combined@page{% |
| 2318 |
\@combinepage\true@sw |
| 2319 |
\@combinedblfloats |
| 2320 |
\@outputpage |
| 2321 |
\global\pagegrid@cur\@ne |
| 2322 |
\protect@penalty\do@startpage@pen |
| 2323 |
}% |
| 2324 |
\def\@sdblcolelt#1{\def\@currbox{#1}\@addtodblcol}% |
| 2325 |
\def\test@dblfloat#1{% |
| 2326 |
\@if@notdblfloat{#1}{\@testtrue}{}% |
| 2327 |
\@if@sw\if@test\fi{}{\aftergroup\@booleantrue\aftergroup\float@avail@sw}% |
| 2328 |
}% |
| 2329 |
\def\@if@notdblfloat#1{\@ifdim{\wd#1<\textwidth}}% |
| 2330 |
\@booleanfalse\forcefloats@sw |
| 2331 |
% \end{macrocode} |
| 2332 |
% \end{macro} |
| 2333 |
% \end{macro} |
| 2334 |
% \end{macro} |
| 2335 |
% \end{macro} |
| 2336 |
% \end{macro} |
| 2337 |
% \end{macro} |
| 2338 |
% |
| 2339 |
% \begin{macro}{\@addtodblcol} |
| 2340 |
% |
| 2341 |
% The procedure \cmd\@addtodblcol\ is called into play at the beginning of each fresh page |
| 2342 |
% and operates on each deferred float, in the hopes of placing one or more such floats |
| 2343 |
% at the top of the current page. |
| 2344 |
% |
| 2345 |
% We alter the procedure of standard \LaTeX\ by putting failed floats into |
| 2346 |
% \cmd\@deferlist\ instead of \cmd\@dbldeferlist. Having done so, we must have a means |
| 2347 |
% of differentiating full-page-width floats from column-width floats. |
| 2348 |
% We assume that the latter will always be narrower than \cmd\textwidth. |
| 2349 |
% |
| 2350 |
% In aid of detecting a stalled float flushing process, we set a Boolean if we encounter |
| 2351 |
% a qualified full-page-width float here. Any that qualify but fail the rest of the tests |
| 2352 |
% might still pass when reconsidered on an otherwise blank page. |
| 2353 |
% \begin{macrocode} |
| 2354 |
\def\@addtodblcol{% |
| 2355 |
\begingroup |
| 2356 |
\@if@notdblfloat{\@currbox}{% |
| 2357 |
\false@sw |
| 2358 |
}{% |
| 2359 |
\@setfloattypecounts |
| 2360 |
\@getfpsbit \tw@ |
| 2361 |
\@bitor \@currtype \@deferlist |
| 2362 |
\@if@sw\if@test\fi{% |
| 2363 |
\false@sw |
| 2364 |
}{% |
| 2365 |
\@ifodd\@tempcnta{% |
| 2366 |
\aftergroup\@booleantrue\aftergroup\float@avail@sw |
| 2367 |
\@flsetnum \@dbltopnum |
| 2368 |
\@ifnum{\@dbltopnum>\z@}{% |
| 2369 |
\@ifdim{\@dbltoproom>\ht\@currbox}{% |
| 2370 |
\true@sw |
| 2371 |
}{% |
| 2372 |
\@ifnum{\@fpstype<\sixt@@n}{% |
| 2373 |
\begingroup |
| 2374 |
\advance \@dbltoproom \@textmin |
| 2375 |
\@ifdim{\@dbltoproom>\ht\@currbox}{% |
| 2376 |
\endgroup\true@sw |
| 2377 |
}{% |
| 2378 |
\endgroup\false@sw |
| 2379 |
}% |
| 2380 |
}{% |
| 2381 |
\false@sw |
| 2382 |
}% |
| 2383 |
}% |
| 2384 |
}{% |
| 2385 |
\false@sw |
| 2386 |
}% |
| 2387 |
}{% |
| 2388 |
\false@sw |
| 2389 |
}% |
| 2390 |
}% |
| 2391 |
}% |
| 2392 |
{% |
| 2393 |
\@tempdima -\ht\@currbox |
| 2394 |
\advance\@tempdima |
| 2395 |
-\@ifx{\@dbltoplist\@empty}{\dbltextfloatsep}{\dblfloatsep}% |
| 2396 |
\global \advance \@dbltoproom \@tempdima |
| 2397 |
\global \advance \@colht \@tempdima |
| 2398 |
\global \advance \@dbltopnum \m@ne |
| 2399 |
\@cons \@dbltoplist \@currbox |
| 2400 |
}{% |
| 2401 |
\@cons \@deferlist \@currbox |
| 2402 |
}% |
| 2403 |
\endgroup |
| 2404 |
}% |
| 2405 |
% \end{macrocode} |
| 2406 |
% \end{macro} |
| 2407 |
% |
| 2408 |
% \begin{macro}{\@tryfcolumn} |
| 2409 |
% \begin{macro}{\@wtryfc} |
| 2410 |
% \begin{macro}{\@xtryfc} |
| 2411 |
% \begin{macro}{\@ztryfc} |
| 2412 |
% Whenever a page is shipped out, \LaTeX\ automatically tries out a float column: |
| 2413 |
% a page containing nothing but floats (and, as we have added here, split footnotes). |
| 2414 |
% |
| 2415 |
% The following four procedures employ certain macros to communicate between each other: |
| 2416 |
% |
| 2417 |
% \cmd\fcolmade@sw, a boolean, says whether we were successful in making a float column. |
| 2418 |
% |
| 2419 |
% \cmd\if@test, a \cmd\newif\ switch, says a float has failed some test. |
| 2420 |
% |
| 2421 |
% \cmd\@deferlist, is the input to the process, a list, of deferred floats. |
| 2422 |
% |
| 2423 |
% \cmd\@trylist, a list, stores the deferred floats to be tried out on the float column. |
| 2424 |
% |
| 2425 |
% \cmd\@failedlist, a list of floats that have failed the selection for the float column. |
| 2426 |
% |
| 2427 |
% \cmd\@flfail, a list of floats that have failed the second selection for the float column. |
| 2428 |
% |
| 2429 |
% \cmd\@flsucceed, a list, the floats that have been successfully placed on the float column. |
| 2430 |
% |
| 2431 |
% \cmd\@freelist, a list, receives any freed floats. |
| 2432 |
% |
| 2433 |
% \cmd\@colht, a dimen, the available space for the column, including column floats and insertions (footnotes). |
| 2434 |
% |
| 2435 |
% \cmd\@fpmin, a dimen, the required minimum height for the float column. |
| 2436 |
% |
| 2437 |
% \cmd\@outputbox, a box, the output of the process. |
| 2438 |
% |
| 2439 |
% \cmd\@fptop, \cmd\@fpsep, \cmd\@fpbot, glue, placed above, between, and below floats on the float column. |
| 2440 |
% |
| 2441 |
% \cmd\@currtype, a count, used temporarily for the float's bits. |
| 2442 |
% |
| 2443 |
% \cmd\@tempcnta, a count, used temporarily for the float's bits. |
| 2444 |
% |
| 2445 |
% In \cmd\@tryfcolumn, we alter the criterion for a float page, because if footnotes are present at this point |
| 2446 |
% (presumably due to a split insertion) then \cmd\@fpmin is no longer the right threshold to apply. |
| 2447 |
% |
| 2448 |
% Note that we have changed \cmd\@tryfcolumn, \cmd\@xtryfc, and \cmd\@ztryfc\ syntactically so that the procedure |
| 2449 |
% to test for the float's being a column float versus a full-page-width float is passed in as an |
| 2450 |
% argument. |
| 2451 |
% |
| 2452 |
% \begin{macrocode} |
| 2453 |
\def\@tryfcolumn#1{% |
| 2454 |
\global\@booleanfalse\fcolmade@sw |
| 2455 |
\@ifx@empty\@deferlist{}{% |
| 2456 |
\global\let\@trylist\@deferlist |
| 2457 |
\global\let\@failedlist\@empty |
| 2458 |
\begingroup |
| 2459 |
\dimen@\vsize\advance\dimen@-\pagegoal\@ifdim{\dimen@>\z@}{% |
| 2460 |
\advance\@fpmin-\dimen@ |
| 2461 |
}{}% |
| 2462 |
\def\@elt{\@xtryfc#1}\@trylist |
| 2463 |
\endgroup |
| 2464 |
\fcolmade@sw{% |
| 2465 |
\global\setbox\@outputbox\vbox{\vskip \@fptop}% |
| 2466 |
\let \@elt \@wtryfc \@flsucceed |
| 2467 |
\global\setbox\@outputbox\vbox{\unvbox\@outputbox |
| 2468 |
\unskip \vskip \@fpbot |
| 2469 |
}% |
| 2470 |
\let \@elt \relax |
| 2471 |
\xdef\@deferlist{\@failedlist\@flfail}% |
| 2472 |
\xdef\@freelist{\@freelist\@flsucceed}% |
| 2473 |
}{}% |
| 2474 |
}% |
| 2475 |
}% |
| 2476 |
\def\@wtryfc #1{% |
| 2477 |
\global\setbox\@outputbox\vbox{\unvbox\@outputbox |
| 2478 |
\box #1\vskip\@fpsep |
| 2479 |
}% |
| 2480 |
}% |
| 2481 |
\def\@xtryfc#1#2{% |
| 2482 |
\@next\reserved@a\@trylist{}{}% trim \@trylist. Ugly! |
| 2483 |
\@currtype \count #2% |
| 2484 |
\divide\@currtype\@xxxii\multiply\@currtype\@xxxii |
| 2485 |
\@bitor \@currtype \@failedlist |
| 2486 |
\@testfp #2% |
| 2487 |
#1#2% |
| 2488 |
\@ifdim{\ht #2>\@colht }{\@testtrue}{}% |
| 2489 |
\@if@sw\if@test\fi{% |
| 2490 |
\@cons\@failedlist #2% |
| 2491 |
}{% |
| 2492 |
\begingroup |
| 2493 |
\gdef\@flsucceed{\@elt #2}% |
| 2494 |
\global\let\@flfail\@empty |
| 2495 |
\@tempdima\ht #2% |
| 2496 |
\def \@elt {\@ztryfc#1}\@trylist |
| 2497 |
\@ifdim{\@tempdima >\@fpmin}{% |
| 2498 |
\global\@booleantrue\fcolmade@sw |
| 2499 |
}{% |
| 2500 |
\@cons\@failedlist #2% |
| 2501 |
}% |
| 2502 |
\endgroup |
| 2503 |
\fcolmade@sw{% |
| 2504 |
\let \@elt \@gobble |
| 2505 |
}{}% |
| 2506 |
}% |
| 2507 |
}% |
| 2508 |
\def\@ztryfc #1#2{% |
| 2509 |
\@tempcnta \count#2% |
| 2510 |
\divide\@tempcnta\@xxxii\multiply\@tempcnta\@xxxii |
| 2511 |
\@bitor \@tempcnta {\@failedlist \@flfail}% |
| 2512 |
\@testfp #2% |
| 2513 |
#1#2% |
| 2514 |
\@tempdimb\@tempdima |
| 2515 |
\advance\@tempdimb \ht#2\advance\@tempdimb\@fpsep |
| 2516 |
\@ifdim{\@tempdimb >\@colht}{% |
| 2517 |
\@testtrue |
| 2518 |
}{}% |
| 2519 |
\@if@sw\if@test\fi{% |
| 2520 |
\@cons\@flfail #2% |
| 2521 |
}{% |
| 2522 |
\@cons\@flsucceed #2% |
| 2523 |
\@tempdima\@tempdimb |
| 2524 |
}% |
| 2525 |
}% |
| 2526 |
% \end{macrocode} |
| 2527 |
% \end{macro} |
| 2528 |
% \end{macro} |
| 2529 |
% \end{macro} |
| 2530 |
% \end{macro} |
| 2531 |
% |
| 2532 |
% |
| 2533 |
% \subsection{Clearing pages}% |
| 2534 |
% |
| 2535 |
% Clearing the page is an elaboration of ending the page: it entails flushing all floats. |
| 2536 |
% |
| 2537 |
% This package might make number of float flushing algorithms available, |
| 2538 |
% a very simple one that does not try to produce excellent pages, |
| 2539 |
% another that tries to make the best use of space, |
| 2540 |
% and a more complex one that tries to balance columns. |
| 2541 |
% |
| 2542 |
% 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. |
| 2543 |
% There may be material in \cmd\pagesofar, and (in a multi-column page grid) any number of columns of the page have been composed. |
| 2544 |
% Also, there might be footnote material saved up in \cmd\footsofar. |
| 2545 |
% |
| 2546 |
% Because we did not want to perform multiple \cmd\shipout s per visit to the output routine, |
| 2547 |
% our multi-column page makeup will not compose multiple columns per visit. |
| 2548 |
% This implementation detail may not require alteration, but it is not a limitation that is truly necessary: |
| 2549 |
% it is only multiple \cmd\shipout s per visit that must be avoided. |
| 2550 |
% |
| 2551 |
% The crux matter is how to continue with flushing floats even after the material in the MVL is exhausted. |
| 2552 |
% At that point, we must, upon completion of the output routine, |
| 2553 |
% insert into the MVL an interrupt that triggers the next step in the processing. |
| 2554 |
% |
| 2555 |
% Therefore, after processing a \cmd\do@startcolumn\ interrupt, we must somehow force the completion of that column. |
| 2556 |
% This could be done by inserting a \cmd\do@newpage@pen\ interrupt. |
| 2557 |
% |
| 2558 |
% And after processing a \cmd\do@startpage@pen\ interrupt, that results in \cmd\@dbltopinsert s, |
| 2559 |
% we must ensure that the multiple columns on the page get completed, so that the page itself finally gets shipped out. |
| 2560 |
% This part will proceed automatically given that \cmd\do@startcolumn\ processing completes successfully. |
| 2561 |
% |
| 2562 |
% The process will not be complete until all deferred floats have been placed and shipped out, and all saved-up footnotes have been inserted. |
| 2563 |
% |
| 2564 |
% 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. |
| 2565 |
% We therefore stop using \cmd\@dbldeferlist\ entirely, and all of the procedures that formerly used it have been rewritten to |
| 2566 |
% 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. |
| 2567 |
% This selector is different depending on the page grid. |
| 2568 |
% |
| 2569 |
% 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. |
| 2570 |
% Here, we must terminate processing, to avoid disordering the floats. This we do by the usual means. |
| 2571 |
% |
| 2572 |
% The system has a Boolean that says we are clearing pages: \cmd\clearpage@sw; if it is true, |
| 2573 |
% then at the tail of \cmd\do@startcolumn\ processing, we should put down a (\cmd\vfil?) \cmd\do@newpage@pen\ interrupt. |
| 2574 |
% This is because the MVL is now empty, so we have to force the columns to complete. |
| 2575 |
% |
| 2576 |
% One potential very pathological case would be where there is one or more deferred floats that never successfully get placed: |
| 2577 |
% placing floats has stalled, and we will ship out blank pages indefinitely. How to detect this case? |
| 2578 |
% |
| 2579 |
% First, \cmd\do@startpage\ will evidently be stalled if the following are all true: |
| 2580 |
% a) \cmd\@tryfcolumn\ and \cmd\@sdblcolelt\ both fail, |
| 2581 |
% b) there are deferred floats available for page placement, and |
| 2582 |
% c) the \cmd\@colht=\cmd\textheight, that is, the full page height is available for placement of column floats. |
| 2583 |
% |
| 2584 |
% Second, \cmd\do@startcolumn\ will evidently be stalled if the following are all true: |
| 2585 |
% a) tryfcolumn fails, |
| 2586 |
% b) there are deferred floats available for column placement, and |
| 2587 |
% a) the \cmd\@colroom=\cmd\textheight, that is, the full page height is available for placement of column floats. |
| 2588 |
% |
| 2589 |
% |
| 2590 |
% \begin{macro}{\cleardoublepage} |
| 2591 |
% \begin{macro}{\clearpage} |
| 2592 |
% \begin{macro}{\newpage} |
| 2593 |
% \begin{macro}{\newpage@prep} |
| 2594 |
% The function of \cmd\clearpage\ is to end the current page with \cmd\newpage\ and then |
| 2595 |
% ship out additional pages until (\footins) inserts and (deferred) floats are exhausted. |
| 2596 |
% |
| 2597 |
% The method involves setting the float placement parameters to completely permissive values |
| 2598 |
% and kicking out the current page (using a non-discardable penalty). |
| 2599 |
% A possibly short page will be shipped out, followed |
| 2600 |
% by any number of float pages. However these float pages, because using permissive float placement, |
| 2601 |
% will exhaust all inserts and deferred floats. |
| 2602 |
% |
| 2603 |
% Bug Note: in the code for \cmd\clearpage, the first penalty we output is an unprotected \cmd\pagebreak@pen. |
| 2604 |
% I tried using a protected \cmd\do@newpage@pen, but that gave rise to a corner case where a blank page |
| 2605 |
% was output. |
| 2606 |
% |
| 2607 |
% At present, the \cmd\clearpage\ procedure does the same as \cmd\newpage, |
| 2608 |
% except that \cmd\clearpage@sw\ is turned on, |
| 2609 |
% and the (discardable) \cmd\newpage\ is inevitably followed by the same procedures |
| 2610 |
% that are executed if a page is shipped out. |
| 2611 |
% |
| 2612 |
% FIXME: it seems that better than \cmd\pagebreak@pen\ would be an unprotected penalty of a special value that would |
| 2613 |
% entail output routine processing consisting of the following steps: |
| 2614 |
% 3) \cmd\unvbox\cmd\@cclv, |
| 2615 |
% 1) set \cmd\clearpage@sw\ to \cmd\true@sw, |
| 2616 |
% 2) put down a protected \cmd\do@startcolumn@pen, |
| 2617 |
% 4) take a dead cycle. |
| 2618 |
% |
| 2619 |
% 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. |
| 2620 |
% Of course, it would still be necessary to set \cmd\clearpage@sw\ again via an interrupt. |
| 2621 |
% |
| 2622 |
% An optimization might be to clear \cmd\clearpage@sw\ as part of the same interrupt, |
| 2623 |
% but that would actually not work properly, because it is necessary for \cmd\do@endpage\ to |
| 2624 |
% possibly invoke further visits to the output routine before clearpage processing ceases. |
| 2625 |
% \begin{macrocode} |
| 2626 |
\def\newpage@prep{% |
| 2627 |
\if@noskipsec |
| 2628 |
\ifx \@nodocument\relax |
| 2629 |
\leavevmode |
| 2630 |
\global \@noskipsecfalse |
| 2631 |
\fi |
| 2632 |
\fi |
| 2633 |
\if@inlabel |
| 2634 |
\leavevmode |
| 2635 |
\global \@inlabelfalse |
| 2636 |
\fi |
| 2637 |
\if@nobreak \@nobreakfalse \everypar{}\fi |
| 2638 |
\par |
| 2639 |
}% |
| 2640 |
\def \newpage {% |
| 2641 |
\newpage@prep |
| 2642 |
\do@output@MVL{% |
| 2643 |
\vfil |
| 2644 |
\penalty-\pagebreak@pen |
| 2645 |
}% |
| 2646 |
}% |
| 2647 |
\def\clearpage{% |
| 2648 |
\newpage@prep |
| 2649 |
\do@output@MVL{% |
| 2650 |
\vfil |
| 2651 |
\penalty-\pagebreak@pen |
| 2652 |
\global\@booleantrue\clearpage@sw |
| 2653 |
\protect@penalty\do@startcolumn@pen |
| 2654 |
\protect@penalty\do@endpage@pen |
| 2655 |
}% |
| 2656 |
\do@output@MVL{% |
| 2657 |
\global\@booleanfalse\clearpage@sw |
| 2658 |
}% |
| 2659 |
}% |
| 2660 |
\def\cleardoublepage{% |
| 2661 |
\clearpage |
| 2662 |
\@if@sw\if@twoside\fi{% |
| 2663 |
\@ifodd\c@page{}{% |
| 2664 |
\null\clearpage |
| 2665 |
}% |
| 2666 |
}{}% |
| 2667 |
}% |
| 2668 |
\@booleanfalse\clearpage@sw |
| 2669 |
% \end{macrocode} |
| 2670 |
% \end{macro} |
| 2671 |
% \end{macro} |
| 2672 |
% \end{macro} |
| 2673 |
% \end{macro} |
| 2674 |
% |
| 2675 |
% \begin{macro}{\do@endpage@pen} |
| 2676 |
% The penalty \cmd\do@endpage@pen\ simply dispatches to the page grid procedure that forces an end page. |
| 2677 |
% That procedure should test whether there is anything to ship out (say committed floats), then act accordingly. |
| 2678 |
% Note that as part of this work, it should \cmd\unvbox\cmd\@cclv, which has been left boxed up so it can be |
| 2679 |
% measured. |
| 2680 |
% \begin{macrocode} |
| 2681 |
\mathchardef\do@endpage@pen=10007 |
| 2682 |
\@namedef{output@-\the\do@endpage@pen}{\csname end@column@\thepagegrid\endcsname}% |
| 2683 |
% \end{macrocode} |
| 2684 |
% \end{macro} |
| 2685 |
% |
| 2686 |
% \begin{macro}{\do@newpage@pen} |
| 2687 |
% The penalty \cmd\do@newpage@pen\ allows a ``non-discardable \cmd\newpage'' command: |
| 2688 |
% a \cmd\newpage\ command that will not disappear at a pagebreak. |
| 2689 |
% This visit to the output routine will not be dispatched to an interrupt, |
| 2690 |
% rather the natural output routine will be executed, where it |
| 2691 |
% will remove the protection box. |
| 2692 |
% |
| 2693 |
% Call this routine by executing \cmd\protect@penalty\cmd\do@newpage@pen. |
| 2694 |
% \begin{macrocode} |
| 2695 |
\mathchardef\do@newpage@pen=10001 |
| 2696 |
\expandafter\let\csname output@-\the\do@newpage@pen\endcsname\relax |
| 2697 |
% \end{macrocode} |
| 2698 |
% \end{macro} |
| 2699 |
% |
| 2700 |
% \begin{macro}{\@clearfloatplacement} |
| 2701 |
% The procedure \cmd\@clearfloatplacement\ sets the float placement parameters |
| 2702 |
% to completely permissive values (except for \cmd\@fpmin). The standard values are: |
| 2703 |
% |
| 2704 |
% \begin{tabular}{ll} |
| 2705 |
%\cmd\@topnum &\cmd\c@topnumber\\ |
| 2706 |
%\cmd\@toproom &\cmd\topfraction\cmd\@colht\\ |
| 2707 |
%\cmd\@botnum &\cmd\c@bottomnumber\\ |
| 2708 |
%\cmd\@botroom &\cmd\bottomfraction\cmd\@colht\\ |
| 2709 |
%\cmd\@colnum &\cmd\c@totalnumber\\ |
| 2710 |
%\cmd\@fpmin &\cmd\floatpagefraction\cmd\@colht\\ |
| 2711 |
%\cmd\@dbltopnum &\cmd\c@dbltopnumber\\ |
| 2712 |
%\cmd\@dbltoproom &\cmd\dbltopfraction\cmd\@colht\\ |
| 2713 |
%\cmd\@textmin &\cmd\@colht\cmd\advance\cmd\@textmin -\cmd\@dbltoproom\\ |
| 2714 |
%\cmd\@fpmin &\cmd\dblfloatpagefraction\cmd\textheight |
| 2715 |
% \end{tabular} |
| 2716 |
% \begin{macrocode} |
| 2717 |
\def\@clearfloatplacement{% |
| 2718 |
\global\@topnum \maxdimen |
| 2719 |
\global\@toproom \maxdimen |
| 2720 |
\global\@botnum \maxdimen |
| 2721 |
\global\@botroom \maxdimen |
| 2722 |
\global\@colnum \maxdimen |
| 2723 |
\global\@dbltopnum \maxdimen |
| 2724 |
\global\@dbltoproom \maxdimen |
| 2725 |
\global\@textmin \z@ |
| 2726 |
\global\@fpmin \z@ |
| 2727 |
\let\@testfp\@gobble |
| 2728 |
\appdef\@setfloattypecounts{\@fpstype16\advance\@fpstype\m@ne}% |
| 2729 |
}% |
| 2730 |
% \end{macrocode} |
| 2731 |
% \end{macro} |
| 2732 |
% |
| 2733 |
% \begin{macro}{\@doclearpage} |
| 2734 |
% \begin{macro}{\@makefcolumn} |
| 2735 |
% \begin{macro}{\@makecol} |
| 2736 |
% The \cmd\@doclearpage\ procedure is now obsoleted, as is \cmd\@makefcolumn, which it invoked. |
| 2737 |
% We also completely avoid using \cmd\@makecol\ (in favor of \cmd\@makecolumn). |
| 2738 |
% \begin{macrocode} |
| 2739 |
\let\@doclearpage\@undefined |
| 2740 |
\let\@makefcolumn\@undefined |
| 2741 |
\let\@makecol\@undefined |
| 2742 |
% \end{macrocode} |
| 2743 |
% \end{macro} |
| 2744 |
% \end{macro} |
| 2745 |
% \end{macro} |
| 2746 |
% |
| 2747 |
% \begin{macro}{\clr@top@firstmark} |
| 2748 |
% \begin{macro}{\set@top@firstmark} |
| 2749 |
% \begin{macro}{\@outputpage@tail} |
| 2750 |
% We want accurate values of \cmd\topmark\ and \cmd\firstmark, but we must deal with |
| 2751 |
% the fact that there are many different ways of contributing material |
| 2752 |
% to the page. Only upon the first contribution to the page is the value of \cmd\topmark\ |
| 2753 |
% accurate. However, with \cmd\firstmark\ we must potentially examine each contribution |
| 2754 |
% because the first mark on the page may happen to fall in the last piece of material contributed. |
| 2755 |
% |
| 2756 |
% To begin, we define the procedure that initializes the macros to appropriate flag values. |
| 2757 |
% \begin{macrocode} |
| 2758 |
\def\clr@top@firstmark{% |
| 2759 |
\global\let\saved@@topmark\@undefined |
| 2760 |
\global\let\saved@@firstmark\@empty |
| 2761 |
\global\let\saved@@botmark\@empty |
| 2762 |
}% |
| 2763 |
\clr@top@firstmark |
| 2764 |
% \end{macrocode} |
| 2765 |
% |
| 2766 |
% Note that the flag value for \cmd\saved@@topmark\ is \cmd\@undefined, just as one would |
| 2767 |
% expect. But that for \cmd\saved@@firstmark\ and \cmd\saved@@botmark\ is \cmd\@empty. |
| 2768 |
% |
| 2769 |
% Next, we define procedure \cmd\set@top@firstmark; it will be exercised everywhere material is contributed, |
| 2770 |
% capturing the mark values if appropriate. |
| 2771 |
% \begin{macrocode} |
| 2772 |
\def\set@top@firstmark{% |
| 2773 |
\@ifxundefined\saved@@topmark{\expandafter\gdef\expandafter\saved@@topmark\expandafter{\@@topmark}}{}% |
| 2774 |
\@if@empty\saved@@firstmark{\expandafter\gdef\expandafter\saved@@firstmark\expandafter{\@@firstmark}}{}% |
| 2775 |
\@if@empty\@@botmark{}{\expandafter\gdef\expandafter\saved@@botmark\expandafter{\@@botmark}}% |
| 2776 |
}% |
| 2777 |
% \end{macrocode} |
| 2778 |
% When should \cmd\set@top@firstmark\ be called? |
| 2779 |
% A good candidate for a universal procedure for handling contributed material is |
| 2780 |
% the natural output routine; are any other calls needed? |
| 2781 |
% |
| 2782 |
% Yes, in \cmd\save@column\ we must execute \cmd\set@top@firstmark\ because we are about to |
| 2783 |
% save away \cmd\box\cmd\@cclv, and we will never see its marks again (unless it is unboxed into the MVL), |
| 2784 |
% because \TeX\ lets one access a box's marks only within an output routine that has put that box into \cmd\box\cmd\@cclv. |
| 2785 |
% |
| 2786 |
% As soon as a page is shipped out, we initialize the two macros that |
| 2787 |
% hold the values of \cmd\topmark\ and \cmd\firstmark, respectively. |
| 2788 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}% |
| 2789 |
% \begin{macrocode} |
| 2790 |
\appdef\@outputpage@tail{% |
| 2791 |
\clr@top@firstmark |
| 2792 |
}% |
| 2793 |
% \end{macrocode} |
| 2794 |
% \end{macro} |
| 2795 |
% \end{macro} |
| 2796 |
% \end{macro} |
| 2797 |
% |
| 2798 |
% |
| 2799 |
% \subsection{Other interfaces to \LaTeX}% |
| 2800 |
% |
| 2801 |
% \begin{macro}{\@float} |
| 2802 |
% \begin{macro}{\@dblfloat} |
| 2803 |
% \begin{macro}{\@yfloat} |
| 2804 |
% \begin{macro}{\fps@} |
| 2805 |
% \begin{macro}{\fpsd@} |
| 2806 |
% The \LaTeX\ kernel procedures \cmd\@float\ and \cmd\@dblfloat\ are treated on an equal footing. |
| 2807 |
% Each now takes environment-specific float placement defaults. |
| 2808 |
% If none are defined for the calling environment, we apply a default. |
| 2809 |
% |
| 2810 |
% A parameter is passed that will set the width of text within the float, normally \cmd\columnwidth, |
| 2811 |
% and in the "dbl" version, \cmd\textwidth. However, an environment such as \env{turnpage} |
| 2812 |
% may change the meanings of these macros to allow turnpage floats. |
| 2813 |
% |
| 2814 |
% \changes{4.0a}{2008/06/26 }{\cs{@yfloat}: de-fang \cs{set@footnotewidth} (see ltxutil.dtx): we have already done its job. } |
| 2815 |
% |
| 2816 |
% Note on \cmd\@xfloat: the optional argument must come to it fully expanded, because the macro |
| 2817 |
% does a weird procedure on this argument, involving \cmd\@onelevel@sanitize, which I do not |
| 2818 |
% understand, and which does not work if not so expanded. |
| 2819 |
% \changes{4.1b}{2008/08/04}{Get rid of the \cs{reserved@a} idiom} |
| 2820 |
% \begin{macrocode} |
| 2821 |
\def\@float#1{% |
| 2822 |
\@ifnextchar[{% |
| 2823 |
% \end{macrocode} |
| 2824 |
% \verb+}]{+Brace-matching klootch |
| 2825 |
% \begin{macrocode} |
| 2826 |
\@yfloat\width@float{#1}% |
| 2827 |
}{% |
| 2828 |
\@ifxundefined@cs{fps@#1}{}{\expandafter\let\expandafter\fps@\csname fps@#1\endcsname}% |
| 2829 |
\expandafter\@argswap\expandafter{\expandafter[\fps@]}{\@yfloat\width@float{#1}}% |
| 2830 |
}% |
| 2831 |
}% |
| 2832 |
\def\@dblfloat#1{% |
| 2833 |
\@ifnum{\pagegrid@col=\@ne}{% |
| 2834 |
\@float{#1}% |
| 2835 |
}{% |
| 2836 |
\@ifnextchar[{% |
| 2837 |
% \end{macrocode} |
| 2838 |
% \verb+}]{+Brace-matching klootch |
| 2839 |
% \begin{macrocode} |
| 2840 |
\@yfloat\widthd@float{#1}% |
| 2841 |
}{% |
| 2842 |
\@ifxundefined@cs{fpsd@#1}{}{\expandafter\let\expandafter\fpsd@\csname fpsd@#1\endcsname}% |
| 2843 |
\expandafter\@argswap\expandafter{\expandafter[\fpsd@]}{\@yfloat\widthd@float{#1}}% |
| 2844 |
}% |
| 2845 |
}% |
| 2846 |
}% |
| 2847 |
% \end{macrocode} |
| 2848 |
% \changes{4.1b}{2008/08/04}{Turn off the \cs{set@footnotewidth} mechanism; a float `knows' its proper typesetting context} |
| 2849 |
% \changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}% |
| 2850 |
% \cmd\@yfloat\ is the go-to procdure for creating the proper environment for the content of a float. |
| 2851 |
% Argument \verb+#1+ is the width of the float environment (we disable \cmd\set@footnotewidth), and |
| 2852 |
% we establish a self-contained (minipage) environment for footnotes. |
| 2853 |
% \begin{macrocode} |
| 2854 |
\def\@yfloat#1#2[#3]{% |
| 2855 |
\@xfloat{#2}[#3]% |
| 2856 |
\hsize#1\linewidth\hsize |
| 2857 |
\let\set@footnotewidth\@empty |
| 2858 |
\minipagefootnote@init |
| 2859 |
}% |
| 2860 |
\def\fps@{tbp}% |
| 2861 |
\def\fpsd@{tp}% |
| 2862 |
\def\width@float{\columnwidth}% |
| 2863 |
\def\widthd@float{\textwidth}% |
| 2864 |
% \end{macrocode} |
| 2865 |
% \end{macro} |
| 2866 |
% \end{macro} |
| 2867 |
% \end{macro} |
| 2868 |
% \end{macro} |
| 2869 |
% \end{macro} |
| 2870 |
% |
| 2871 |
% \begin{macro}{\end@float} |
| 2872 |
% \begin{macro}{\end@dblfloat} |
| 2873 |
% \begin{macro}{\end@@float} |
| 2874 |
% \begin{macro}{\check@currbox@count} |
| 2875 |
% \begin{macro}{\minipagefootnote@init} |
| 2876 |
% \begin{macro}{\minipagefootnote@here} |
| 2877 |
% \LaTeX\ kernel procedures \cmd\end@float\ and \cmd\end@dblfloat\ |
| 2878 |
% have been changed to work alike; in particular, floats of both classes |
| 2879 |
% are deferred into the same queue. |
| 2880 |
% This measure ensures that they will be placed in their original order, |
| 2881 |
% an aspect in which \LaTeX\ is broken. |
| 2882 |
% |
| 2883 |
% Note: when retrieving floats from the queues, we can differentiate those of the two categories |
| 2884 |
% by the width of the box. |
| 2885 |
% |
| 2886 |
% Floats are processed via an output routine message, and are checked for |
| 2887 |
% sanity in re the float placement options. In the case of full-page-width floats, |
| 2888 |
% we ensure that the h and b float placement options are never asserted, because they |
| 2889 |
% make no sense. |
| 2890 |
% |
| 2891 |
% Note that if we get to the end of the float box and still have pending |
| 2892 |
% footnotes, we put then out. |
| 2893 |
% |
| 2894 |
% LaTeX Bug note: if a user types \cmd\begin{table*}[h], the float will never succeed in being placed! |
| 2895 |
% we try to catch such cases. |
| 2896 |
% |
| 2897 |
% Note that the macro \cmd\check@currbox@count\ tries to catch cases where the float placement options |
| 2898 |
% are such that the float can never be placed. |
| 2899 |
% |
| 2900 |
% The calls to \cmd\@iffpsbit\ are part of a procedure to deny certain of the float placement |
| 2901 |
% parameters: ``h'' and ``b'' are not possible, the former because the \cmd\marginpar\ mechanism |
| 2902 |
% cannot place a full-page-width float within a multicolumn page grid, the latter because nobody |
| 2903 |
% has yet written the code to do so (pretty bad reason, I know). |
| 2904 |
% \changes{4.1b}{2008/08/04}{New procedure \cs{@iffpsbit} replaces \cs{@getfpsbit}} |
| 2905 |
% \begin{macrocode} |
| 2906 |
\def\end@float{% |
| 2907 |
\end@@float{% |
| 2908 |
\check@currbox@count |
| 2909 |
}% |
| 2910 |
}% |
| 2911 |
\def\end@dblfloat{% |
| 2912 |
\@ifnum{\pagegrid@col=\@ne}{% |
| 2913 |
\end@float |
| 2914 |
}{% |
| 2915 |
\end@@float{% |
| 2916 |
\@iffpsbit\@ne{\global\advance\count\@currbox\m@ne}{}% |
| 2917 |
\@iffpsbit\f@ur{\global\advance\count\@currbox-4\relax}{}% |
| 2918 |
\global\wd\@currbox\textwidth % Klootch |
| 2919 |
\check@currbox@count |
| 2920 |
}% |
| 2921 |
}% |
| 2922 |
}% |
| 2923 |
\def\end@@float#1{% |
| 2924 |
\minipagefootnote@here |
| 2925 |
\@endfloatbox |
| 2926 |
#1% |
| 2927 |
\@ifnum{\@floatpenalty <\z@}{% |
| 2928 |
\@largefloatcheck |
| 2929 |
\@cons\@currlist\@currbox |
| 2930 |
\@ifnum{\@floatpenalty <-\@Mii}{% |
| 2931 |
\do@output@cclv{\@add@float}% |
| 2932 |
}{% |
| 2933 |
\vadjust{\do@output@cclv{\@add@float}}% |
| 2934 |
\@Esphack |
| 2935 |
}% |
| 2936 |
}{}% |
| 2937 |
}% |
| 2938 |
% \end{macrocode} |
| 2939 |
% The \classname{float} package of Anselm Lingnau fails when used under \classname{ltxgrid}, but |
| 2940 |
% we can fix things. |
| 2941 |
% We also repair a bug in that package. |
| 2942 |
% |
| 2943 |
% \changes{4.1g}{2009/10/06}{(AO, 531) Fix package \classname{float} } |
| 2944 |
% \begin{macrocode} |
| 2945 |
\newcommand\float@end@float{% |
| 2946 |
\@endfloatbox |
| 2947 |
\global\setbox\@currbox\float@makebox\columnwidth |
| 2948 |
\let\@endfloatbox\relax |
| 2949 |
\end@float |
| 2950 |
}% |
| 2951 |
\newcommand\float@end@ltx{% |
| 2952 |
\end@@float{% |
| 2953 |
\global\setbox\@currbox\float@makebox\columnwidth |
| 2954 |
\check@currbox@count |
| 2955 |
}% |
| 2956 |
}% |
| 2957 |
\newcommand\newfloat@float[3]{% |
| 2958 |
\@namedef{ext@#1}{#3} %! |
| 2959 |
\let\float@do=\relax |
| 2960 |
\xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}% |
| 2961 |
\@tempa |
| 2962 |
\floatplacement{#1}{#2}% |
| 2963 |
\@ifundefined{fname@#1}{\floatname{#1}{#1}}{} %! |
| 2964 |
\expandafter\edef\csname ftype@#1\endcsname{\value{float@type}}% |
| 2965 |
\addtocounter{float@type}{\value{float@type}} %! |
| 2966 |
\restylefloat{#1}% |
| 2967 |
\expandafter\edef\csname fnum@#1\endcsname{% |
| 2968 |
\expandafter\noexpand\csname fname@#1\endcsname{} %! |
| 2969 |
\expandafter\noexpand\csname the#1\endcsname |
| 2970 |
} |
| 2971 |
\@ifnextchar[%] |
| 2972 |
{% |
| 2973 |
\float@newx{#1}% |
| 2974 |
}{% |
| 2975 |
\@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}{}% |
| 2976 |
}% |
| 2977 |
}% |
| 2978 |
\newcommand\newfloat@ltx[3]{% |
| 2979 |
\@namedef{ext@#1}{#3}% |
| 2980 |
\let\float@do=\relax |
| 2981 |
\xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}% |
| 2982 |
\@tempa |
| 2983 |
\floatplacement{#1}{#2}% |
| 2984 |
\@ifundefined{fname@#1}{\floatname{#1}{#1}}{}% |
| 2985 |
\expandafter\edef\csname ftype@#1\expandafter\endcsname\expandafter{\the\c@float@type}% |
| 2986 |
\addtocounter{float@type}{\value{float@type}}% |
| 2987 |
\restylefloat{#1}% |
| 2988 |
\expandafter\edef\csname fnum@#1\endcsname{% |
| 2989 |
\expandafter\noexpand\csname fname@#1\endcsname{}% |
| 2990 |
\expandafter\noexpand\csname the#1\endcsname |
| 2991 |
} |
| 2992 |
\@ifnextchar[%] |
| 2993 |
{% |
| 2994 |
\float@newx{#1}% |
| 2995 |
}{% |
| 2996 |
\@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}{}% |
| 2997 |
}% |
| 2998 |
}% |
| 2999 |
\appdef\document@inithook{% |
| 3000 |
\@ifxundefined\newfloat{}{% |
| 3001 |
\@ifx{\float@end\float@end@float}{% |
| 3002 |
\@ifx{\newfloat\newfloat@float}{\true@sw}{\false@sw}% |
| 3003 |
}{\false@sw}% |
| 3004 |
{% |
| 3005 |
\class@warn{Repair the float package}% |
| 3006 |
\let\float@end\float@end@ltx |
| 3007 |
\let\newfloat\newfloat@ltx |
| 3008 |
}{% |
| 3009 |
\class@warn{Failed to patch the float package}% |
| 3010 |
}% |
| 3011 |
}% |
| 3012 |
}% |
| 3013 |
% \end{macrocode} |
| 3014 |
% |
| 3015 |
% Boolean procedure \cmd\@iffpsbit\ is similar to the \cmd\@getfpsbit\ of \LaTeX, except |
| 3016 |
% that we do not expose the scratch count register or even change its value. |
| 3017 |
% \begin{macrocode} |
| 3018 |
\def\@iffpsbit#1{% |
| 3019 |
\begingroup |
| 3020 |
\@tempcnta\count\@currbox |
| 3021 |
\divide\@tempcnta#1\relax |
| 3022 |
\@ifodd\@tempcnta{\aftergroup\true@sw}{\aftergroup\false@sw}% |
| 3023 |
\endgroup |
| 3024 |
}% |
| 3025 |
% \end{macrocode} |
| 3026 |
% |
| 3027 |
% In procedure \cmd\check@currbox@count, we calculate the net float placement |
| 3028 |
% directive (encoded into \cmd\count\ \cmd\@currbox's least significant four bits). |
| 3029 |
% If zero, issue a warning. |
| 3030 |
% \changes{4.1b}{2008/08/04}{Tally the height of the float} |
| 3031 |
% \begin{macrocode} |
| 3032 |
\def\check@currbox@count{% |
| 3033 |
\@ifnum{\count\@currbox>\z@}{% |
| 3034 |
\count@\count\@currbox\divide\count@\sixt@@n\multiply\count@\sixt@@n |
| 3035 |
\@tempcnta\count\@currbox\advance\@tempcnta-\count@ |
| 3036 |
\@ifnum{\@tempcnta=\z@}{% |
| 3037 |
\ltxgrid@warn{Float cannot be placed}% |
| 3038 |
}{}% |
| 3039 |
\expandafter\tally@float\expandafter{\@captype}% |
| 3040 |
}{% |
| 3041 |
% \end{macrocode} |
| 3042 |
% In this case, the float is a \cmd\marginpar. |
| 3043 |
% \begin{macrocode} |
| 3044 |
}% |
| 3045 |
}% |
| 3046 |
\providecommand\minipagefootnote@init{}% |
| 3047 |
\providecommand\minipagefootnote@here{}% |
| 3048 |
\providecommand\tally@float[1]{}% |
| 3049 |
% \end{macrocode} |
| 3050 |
% \end{macro} |
| 3051 |
% \end{macro} |
| 3052 |
% \end{macro} |
| 3053 |
% \end{macro} |
| 3054 |
% \end{macro} |
| 3055 |
% \end{macro} |
| 3056 |
% |
| 3057 |
% \begin{macro}{\@specialoutput} |
| 3058 |
% The \cmd\@add@float\ procedure used to reside in standard \LaTeX's \cmd\@specialoutput, |
| 3059 |
% which is no more. |
| 3060 |
% |
| 3061 |
% Historical Note: \cmd\@specialoutput\ and Lamport's method of an output routine dispatcher |
| 3062 |
% is the genesis of our more powerful and refined way of using \TeX's output routine to |
| 3063 |
% safely accomplish page makeup tasks. To it and to him we owe acknowledgement and thanks. |
| 3064 |
% \begin{macrocode} |
| 3065 |
\let\@specialoutput\@undefined |
| 3066 |
% \end{macrocode} |
| 3067 |
% \end{macro} |
| 3068 |
% |
| 3069 |
% \begin{macro}{\@add@float} |
| 3070 |
% In the following, we do not need to execute \cmd\@reinserts, which was wrong anyway, as you cannot |
| 3071 |
% reliably recover insertions when they split (unless you have a way of reinserting the captured insertion |
| 3072 |
% ahead of the split-off part). |
| 3073 |
% |
| 3074 |
% Now that full-page-width floats are being processed the same as column floats, we |
| 3075 |
% have to nip in here and cause them always to be deferred. |
| 3076 |
% |
| 3077 |
% At the very end, the \cmd\vsize\ is adjusted for any newly committed float. |
| 3078 |
% \begin{macrocode} |
| 3079 |
\def\@add@float{% |
| 3080 |
\@pageht\ht\@cclv\@pagedp\dp\@cclv |
| 3081 |
\unvbox\@cclv |
| 3082 |
\@next\@currbox\@currlist{% |
| 3083 |
\csname @floatselect@sw@\thepagegrid\endcsname\@currbox{% |
| 3084 |
\@ifnum{\count\@currbox>\z@}{% |
| 3085 |
\advance \@pageht \@pagedp |
| 3086 |
% \end{macrocode} |
| 3087 |
% Do not assume \cmd\holdinginserts is cleared: |
| 3088 |
% \begin{macrocode} |
| 3089 |
\advance \@pageht \vsize \advance \@pageht -\pagegoal |
| 3090 |
% \end{macrocode} |
| 3091 |
% Commit an `h' float: |
| 3092 |
% \begin{macrocode} |
| 3093 |
\@addtocurcol |
| 3094 |
}{% |
| 3095 |
\@addmarginpar |
| 3096 |
}% |
| 3097 |
}{% |
| 3098 |
\@resethfps |
| 3099 |
\@cons\@deferlist\@currbox |
| 3100 |
}% |
| 3101 |
}{\@latexbug}% |
| 3102 |
\@ifnum{\outputpenalty<\z@}{% |
| 3103 |
\@if@sw\if@nobreak\fi{% |
| 3104 |
\nobreak |
| 3105 |
}{% |
| 3106 |
\addpenalty \interlinepenalty |
| 3107 |
}% |
| 3108 |
}{}% |
| 3109 |
\set@vsize |
| 3110 |
}% |
| 3111 |
% \end{macrocode} |
| 3112 |
% \end{macro} |
| 3113 |
% |
| 3114 |
% \begin{macro}{\@reinserts} |
| 3115 |
% The \cmd\@reinserts\ procedure of standard \LaTeX\ is now obsoleted (it had been erroneous anyway). |
| 3116 |
% \begin{macrocode} |
| 3117 |
\let\@reinserts\@undefined |
| 3118 |
% \end{macrocode} |
| 3119 |
% \end{macro} |
| 3120 |
% |
| 3121 |
% \begin{macro}{\@addtocurcol} |
| 3122 |
% We modify the \cmd\@addtocurcol\ procedure of standard \LaTeX\ |
| 3123 |
% so that a float placed ``here'' may break over pages. |
| 3124 |
% \begin{macrocode} |
| 3125 |
\def \@addtocurcol {% |
| 3126 |
\@insertfalse |
| 3127 |
\@setfloattypecounts |
| 3128 |
\ifnum \@fpstype=8 |
| 3129 |
\else |
| 3130 |
\ifnum \@fpstype=24 |
| 3131 |
\else |
| 3132 |
\@flsettextmin |
| 3133 |
\advance \@textmin \@textfloatsheight |
| 3134 |
\@reqcolroom \@pageht |
| 3135 |
\ifdim \@textmin>\@reqcolroom |
| 3136 |
\@reqcolroom \@textmin |
| 3137 |
\fi |
| 3138 |
\advance \@reqcolroom \ht\@currbox |
| 3139 |
\ifdim \@colroom>\@reqcolroom |
| 3140 |
\@flsetnum \@colnum |
| 3141 |
\ifnum \@colnum>\z@ |
| 3142 |
\@bitor\@currtype\@deferlist |
| 3143 |
\if@test |
| 3144 |
\else |
| 3145 |
\@bitor\@currtype\@botlist |
| 3146 |
\if@test |
| 3147 |
\@addtobot |
| 3148 |
\else |
| 3149 |
\ifodd \count\@currbox |
| 3150 |
\advance \@reqcolroom \intextsep |
| 3151 |
\ifdim \@colroom>\@reqcolroom |
| 3152 |
\global \advance \@colnum \m@ne |
| 3153 |
\global \advance \@textfloatsheight \ht\@currbox |
| 3154 |
\global \advance \@textfloatsheight 2\intextsep |
| 3155 |
\@cons \@midlist \@currbox |
| 3156 |
\if@nobreak |
| 3157 |
\nobreak |
| 3158 |
\@nobreakfalse |
| 3159 |
\everypar{}% |
| 3160 |
\else |
| 3161 |
\addpenalty \interlinepenalty |
| 3162 |
\fi |
| 3163 |
\vskip \intextsep |
| 3164 |
\unvbox\@currbox %AO |
| 3165 |
\penalty\interlinepenalty |
| 3166 |
\vskip\intextsep |
| 3167 |
\ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi |
| 3168 |
\outputpenalty \z@ |
| 3169 |
\@inserttrue |
| 3170 |
\fi |
| 3171 |
\fi |
| 3172 |
\if@insert |
| 3173 |
\else |
| 3174 |
\@addtotoporbot |
| 3175 |
\fi |
| 3176 |
\fi |
| 3177 |
\fi |
| 3178 |
\fi |
| 3179 |
\fi |
| 3180 |
\fi |
| 3181 |
\fi |
| 3182 |
\if@insert |
| 3183 |
\else |
| 3184 |
\@resethfps |
| 3185 |
\@cons\@deferlist\@currbox |
| 3186 |
\fi |
| 3187 |
}% |
| 3188 |
% \end{macrocode} |
| 3189 |
% \end{macro} |
| 3190 |
% |
| 3191 |
% \begin{macro}{\if@twocolumn} |
| 3192 |
% The \cmd\newif\ switch \cmd\if@twocolumn\ is entirely unused. However its access words are invoked by |
| 3193 |
% \LaTeX's \cmd\document\ procedure, so we de-fang it. |
| 3194 |
% \begin{macrocode} |
| 3195 |
\@twocolumnfalse |
| 3196 |
\let\@twocolumntrue\@twocolumnfalse |
| 3197 |
% \end{macrocode} |
| 3198 |
% \end{macro} |
| 3199 |
% |
| 3200 |
% \begin{macro}{\@addmarginpar} |
| 3201 |
% The procedure \cmd\@addmarginpar\ used to access \cmd\if@twocolumn, but that switch is not reliable; |
| 3202 |
% the better way is to use \cmd\thepagegrid. We establish a convention for a page-grid-oriented |
| 3203 |
% procedure, e.g., \cmd\@addmarginpar@one, that emits a boolean, telling this procedure |
| 3204 |
% whether to set the marginpar on the left or right. |
| 3205 |
% \begin{macrocode} |
| 3206 |
\def\@addmarginpar{% |
| 3207 |
\@next\@marbox\@currlist{% |
| 3208 |
\@cons\@freelist\@marbox\@cons\@freelist\@currbox |
| 3209 |
}\@latexbug |
| 3210 |
\setbox\@marbox\hb@xt@\columnwidth{% |
| 3211 |
\csname @addmarginpar@\thepagegrid\endcsname{% |
| 3212 |
\hskip-\marginparsep\hskip-\marginparwidth |
| 3213 |
\box\@currbox |
| 3214 |
}{% |
| 3215 |
\hskip\columnwidth\hskip\marginparsep |
| 3216 |
\box\@marbox |
| 3217 |
}% |
| 3218 |
\hss |
| 3219 |
}% |
| 3220 |
\setbox\z@\box\@currbox |
| 3221 |
\@tempdima\@mparbottom |
| 3222 |
\advance\@tempdima -\@pageht |
| 3223 |
\advance\@tempdima\ht\@marbox |
| 3224 |
\@ifdim{\@tempdima >\z@}{% |
| 3225 |
\@latex@warning@no@line {Marginpar on page \thepage\space moved}% |
| 3226 |
}{% |
| 3227 |
\@tempdima\z@ |
| 3228 |
}% |
| 3229 |
\global\@mparbottom\@pageht |
| 3230 |
\global\advance\@mparbottom\@tempdima |
| 3231 |
\global\advance\@mparbottom\dp\@marbox |
| 3232 |
\global\advance\@mparbottom\marginparpush |
| 3233 |
\advance\@tempdima -\ht\@marbox |
| 3234 |
\global\setbox \@marbox |
| 3235 |
\vbox {\vskip \@tempdima |
| 3236 |
\box \@marbox}% |
| 3237 |
\global \ht\@marbox \z@ |
| 3238 |
\global \dp\@marbox \z@ |
| 3239 |
\kern -\@pagedp |
| 3240 |
\nointerlineskip |
| 3241 |
\box\@marbox |
| 3242 |
\nointerlineskip |
| 3243 |
\hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}% |
| 3244 |
}% |
| 3245 |
% \end{macrocode} |
| 3246 |
% \end{macro} |
| 3247 |
% |
| 3248 |
% \begin{environment}{turnpage} |
| 3249 |
% Any float (viz., \env{figure} or \env{table}) within the scope of this environment |
| 3250 |
% will be a turnpage float: It will be assumed to occupy an entire page (constitute a float page), |
| 3251 |
% the width will be \cmd\textheight, the height \cmd\textwidth, and the entire float will be presented |
| 3252 |
% rotated 90 degrees. |
| 3253 |
% |
| 3254 |
% The implementation requires the services of the \cmd\rotatebox\ command, so we supply a dummy definition |
| 3255 |
% that explains things to the user. |
| 3256 |
% \begin{macrocode} |
| 3257 |
\newenvironment{turnpage}{% |
| 3258 |
\def\width@float{\textheight}% |
| 3259 |
\def\widthd@float{\textheight}% |
| 3260 |
\appdef\@endfloatbox{% |
| 3261 |
\@ifxundefined\@currbox{% |
| 3262 |
\ltxgrid@warn{Cannot rotate! Not a float}% |
| 3263 |
}{% |
| 3264 |
\setbox\@currbox\vbox to\textwidth{\vfil\unvbox\@currbox\vfil}% |
| 3265 |
\global\setbox\@currbox\vbox{\rotatebox{90}{\box\@currbox}}% |
| 3266 |
}% |
| 3267 |
}% |
| 3268 |
}{% |
| 3269 |
}% |
| 3270 |
\def\rotatebox@dummy#1#2{% |
| 3271 |
\ltxgrid@warn{You must load the graphics or graphicx package in order to use the turnpage environment}% |
| 3272 |
#2% |
| 3273 |
}% |
| 3274 |
% \end{macrocode} |
| 3275 |
% \changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}} |
| 3276 |
% \begin{macrocode} |
| 3277 |
\appdef\document@inithook{% |
| 3278 |
\@ifxundefined\rotatebox{\let\rotatebox\rotatebox@dummy}{}% |
| 3279 |
}% |
| 3280 |
% \end{macrocode} |
| 3281 |
% \end{environment} |
| 3282 |
% |
| 3283 |
% |
| 3284 |
% \subsection{One-off output routines} |
| 3285 |
% |
| 3286 |
% These procedures are executed in lieu of \cmd\the\cmd\output\ when the output penalty has the associated flag value. |
| 3287 |
% |
| 3288 |
% \begin{macro}{output@-1073741824} |
| 3289 |
% The first one-off output routine handles the end of the job, wherein |
| 3290 |
% \LaTeX\ executes \cmd\@@end, and breaks to the output with a penalty of |
| 3291 |
% $"40000000 = 2^{32}/4 = 1073741824$. |
| 3292 |
% We simply discard \cmd\box\cmd\@cclv\ and leave. |
| 3293 |
% This means that \LaTeX\ is obligated to do \cmd\clearpage\ as part of |
| 3294 |
% its \enve{document} processing, otherwise material will be lost. |
| 3295 |
% \begin{macrocode} |
| 3296 |
\@namedef{output@-1073741824}{% |
| 3297 |
\deadcycles\z@ |
| 3298 |
% \end{macrocode} |
| 3299 |
% \begin{verbatim} |
| 3300 |
%\showbox\@cclv |
| 3301 |
% \end{verbatim} |
| 3302 |
% \begin{macrocode} |
| 3303 |
\void@cclv |
| 3304 |
}% |
| 3305 |
% \end{macrocode} |
| 3306 |
% \end{macro} |
| 3307 |
% |
| 3308 |
% \begin{macro}{\save@column@pen} |
| 3309 |
% The one-off output routine associated with \cmd\penalty\cmd\save@column@pen\ |
| 3310 |
% will be called within a sequence of three such routines by \cmd\execute@message |
| 3311 |
% or its companion routine \cmd\execute@message@insert. |
| 3312 |
% This procedure must save away any the current page and preserve marks. |
| 3313 |
% \begin{macrocode} |
| 3314 |
\mathchardef\save@column@pen=10016 |
| 3315 |
\@namedef{output@-\the\save@column@pen}{\save@column}% |
| 3316 |
% \end{macrocode} |
| 3317 |
% \end{macro} |
| 3318 |
% |
| 3319 |
% \begin{macro}{\@cclv@saved} |
| 3320 |
% We take over the \cmd\@holdpg\ box register. Hereafter, |
| 3321 |
% we no longer use the \cmd\@holdpg\ box register, so let the world know. |
| 3322 |
% This should decisively break packages that assume standard \LaTeX. |
| 3323 |
% Breaking decisively is preferred to quietly proceeding erroneously. |
| 3324 |
% \begin{macrocode} |
| 3325 |
\let \@cclv@saved \@holdpg |
| 3326 |
\let \@holdpg \@undefined |
| 3327 |
% \end{macrocode} |
| 3328 |
% \end{macro} |
| 3329 |
% |
| 3330 |
% \begin{macro}{\save@column} |
| 3331 |
% The procedure \cmd\save@column\ does the actual work of saving away the material |
| 3332 |
% on the page. It is invoked both by \cmd\save@column@pen\ and by \cmd\save@column@insert@pen. |
| 3333 |
% We save \cmd\box\cmd\@cclv\ and the primitive \cmd\@@topmark. |
| 3334 |
% \begin{macrocode} |
| 3335 |
\def\save@column{% |
| 3336 |
\@ifvoid\@cclv@saved{% |
| 3337 |
\set@top@firstmark |
| 3338 |
\global\@topmark@saved\expandafter{\@@topmark}% |
| 3339 |
}{}% |
| 3340 |
\global\setbox\@cclv@saved\vbox{% |
| 3341 |
\@ifvoid\@cclv@saved{}{% |
| 3342 |
\unvbox\@cclv@saved |
| 3343 |
\marry@baselines |
| 3344 |
}% |
| 3345 |
\unvbox\@cclv |
| 3346 |
\lose@breaks |
| 3347 |
\remove@lastbox |
| 3348 |
}% |
| 3349 |
}% |
| 3350 |
\newtoks\@topmark@saved |
| 3351 |
% \end{macrocode} |
| 3352 |
% \end{macro} |
| 3353 |
% |
| 3354 |
% \begin{macro}{\prep@cclv} |
| 3355 |
% The procedure \cmd\prep@cclv\ is used by message handlers to set up their environment |
| 3356 |
% to ape that of the usual output routine, with the boxed-up page in \cmd\box\cmd\@cclv. |
| 3357 |
% Here, we retrieve the material from \cmd\@cclv@saved, where it was saved away by |
| 3358 |
% the one-off output routine associated with \cmd\save@column@pen. |
| 3359 |
% \begin{macrocode} |
| 3360 |
\def\prep@cclv{% |
| 3361 |
\void@cclv |
| 3362 |
\setbox\@cclv\box\@cclv@saved |
| 3363 |
\vbadness\@M |
| 3364 |
}% |
| 3365 |
% \end{macrocode} |
| 3366 |
% \end{macro} |
| 3367 |
% |
| 3368 |
% \begin{macro}{\save@column@insert@pen} |
| 3369 |
% The one-off output routine associated with \cmd\penalty\cmd\save@column@insert@pen\ |
| 3370 |
% is similar to that of \cmd\save@column@pen\ augmented with the processing of insertions. |
| 3371 |
% It is called by \cmd\execute@message@insert\ (i.e., at a grid change) |
| 3372 |
% and saves away the current page and preserves marks. |
| 3373 |
% In addition, it saves away any insertions that fall on the current page. |
| 3374 |
% As with the natural output routine, it executes in two phases, |
| 3375 |
% first with \cmd\holdinginserts\ set, then cleared. |
| 3376 |
% \begin{macrocode} |
| 3377 |
\mathchardef\save@column@insert@pen=10017 |
| 3378 |
\@namedef{output@-\the\save@column@insert@pen}{\toggle@insert{\savecolumn@holding}{\savecolumn@moving}}% |
| 3379 |
% \end{macrocode} |
| 3380 |
% The procedure \cmd\savecolumn@holding\ is the first phase of saving a column with its inserts. |
| 3381 |
% This phase must detect and remedy the one circumstance that will confound our efforts to propagate marks. |
| 3382 |
% It is similar to \cmd\output@holding, except that we have to deal with the protection box, which must |
| 3383 |
% remain, because the messaging mechanism is being used. |
| 3384 |
% |
| 3385 |
% If it appears that we have the pathological ``Big Bad Box'' case at hand, we use the \cmd\dead@cycle@repair@protected\ |
| 3386 |
% procedure instead of \cmd\dead@cycle\ to do our dead cycle. |
| 3387 |
% \changes{4.1b}{2008/08/04}{Use \cs{trace@box} instead of \cs{showbox}} |
| 3388 |
% \begin{macrocode} |
| 3389 |
\def\savecolumn@holding{% |
| 3390 |
\@if@exceed@pagegoal{\unvcopy\@cclv\remove@lastbox}{% |
| 3391 |
\setbox\z@\vbox{\unvcopy\@cclv\remove@lastbox}% |
| 3392 |
\outputdebug@sw{\trace@box\z@}{}% |
| 3393 |
\dimen@\ht\@cclv\advance\dimen@-\ht\z@ |
| 3394 |
\dead@cycle@repair@protected\dimen@ |
| 3395 |
}{% |
| 3396 |
\dead@cycle |
| 3397 |
}% |
| 3398 |
}% |
| 3399 |
% \end{macrocode} |
| 3400 |
% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}} |
| 3401 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 3402 |
% The procedure \cmd\save@column@moving\ is the second phase of saving a column with its inserts. |
| 3403 |
% Now that \cmd\holdinginserts\ is cleared, we can look in the various \cmd\insert\ registers for |
| 3404 |
% our inserts (at present there is only one, \cmd\footins, along with \cmd\footins@saved). |
| 3405 |
% if anything is there, we save it away and ask for another cycle (because it may have split). |
| 3406 |
% |
| 3407 |
% Note that the message that is about to be executed had better deal properly with the contents of |
| 3408 |
% the \cmd\footins@saved\ box. |
| 3409 |
% |
| 3410 |
% \begin{macrocode} |
| 3411 |
\def\savecolumn@moving{% |
| 3412 |
\ltxgrid@info@sw{\class@info{\string\savecolumn@moving}}{}% |
| 3413 |
\@cclv@nontrivial@sw{% |
| 3414 |
\save@column |
| 3415 |
}{% |
| 3416 |
\void@cclv |
| 3417 |
}% |
| 3418 |
\@ifvoid\footins{}{% |
| 3419 |
\ltxgrid@foot@info@sw{\class@info{\string\savecolumn@moving}\trace@scroll{\showbox\footins@saved\showbox\footins}}{}% |
| 3420 |
% \end{macrocode} |
| 3421 |
% Save all away in \cmd\footins@saved. Note that if \cmd\footins\ is void, then \cmd\footins@saved\ remains untouched. |
| 3422 |
% \begin{macrocode} |
| 3423 |
\@ifvoid\footins@saved{% |
| 3424 |
\global\setbox\footins@saved\box\footins |
| 3425 |
}{% |
| 3426 |
\global\setbox\footins@saved\vbox\bgroup |
| 3427 |
\unvbox\footins@saved |
| 3428 |
\marry@baselines |
| 3429 |
\unvbox\footins |
| 3430 |
\egroup |
| 3431 |
}% |
| 3432 |
\ltxgrid@foot@info@sw{\trace@box\footins@saved}{}% |
| 3433 |
\protect@penalty\save@column@insert@pen |
| 3434 |
}% |
| 3435 |
}% |
| 3436 |
\newbox\footins@saved |
| 3437 |
\newbox\footins@recovered |
| 3438 |
\newbox\column@recovered |
| 3439 |
% \end{macrocode} |
| 3440 |
% \end{macro} |
| 3441 |
% |
| 3442 |
% \begin{macro}{\save@message@pen} |
| 3443 |
% The one-off output routine associated with \cmd\penalty\cmd\save@message@pen\ |
| 3444 |
% saves away the message that has been passed. |
| 3445 |
% This procedure is penultimate in a sequence of one-off output routine calls; |
| 3446 |
% earlier ones have saved away the MVL and preserved marks, the last executes the message. |
| 3447 |
% |
| 3448 |
% Note that we are passing tokens to \TeX's primitive \cmd\mark\ mechanism, so we must ensure |
| 3449 |
% that they are not inappropriately expanded. We use the same mechanism for all such cases, |
| 3450 |
% namely \cmd\let@mark. |
| 3451 |
% |
| 3452 |
% Note: we expect that \cmd\box\cmd\@cclv's contents are well known: |
| 3453 |
% \cmd\topskip, protection box, and a \cmd\mark, the latter containing the message. |
| 3454 |
% But if we came here via \cmd\penalty 10017, there might be an \cmd\insert\ node present as well, |
| 3455 |
% because a footnote may have split. |
| 3456 |
% Because this procedure simply voids out \cmd\box\cmd\@cclv, such material would be lost. |
| 3457 |
% Perhaps we can repair things by manipulating the \cmd\insert \ mechanism temporarily. |
| 3458 |
% \begin{macrocode} |
| 3459 |
\mathchardef\save@message@pen=10018 |
| 3460 |
\@namedef{output@-\the\save@message@pen}{\save@message}% |
| 3461 |
\def\save@message{% |
| 3462 |
\void@cclv |
| 3463 |
% \end{macrocode} |
| 3464 |
%FIXME: what if \cmd\box\cmd\@cclv is not empty? |
| 3465 |
% \begin{macrocode} |
| 3466 |
\toks@\expandafter{\@@firstmark}% |
| 3467 |
\expandafter\gdef\expandafter\@message@saved\expandafter{\the\toks@}% |
| 3468 |
\expandafter\do@@mark\expandafter{\the\@topmark@saved}% |
| 3469 |
}% |
| 3470 |
\gdef\@message@saved{}% |
| 3471 |
% \end{macrocode} |
| 3472 |
% \end{macro} |
| 3473 |
% |
| 3474 |
% \begin{macro}{\execute@message@pen} |
| 3475 |
% The one-off output routine associated with \cmd\execute@message@pen\ |
| 3476 |
% simply executes the given message. It is last in a sequence of one-off output routine calls; |
| 3477 |
% earlier ones have saved all that require saving. |
| 3478 |
% \begin{macrocode} |
| 3479 |
\mathchardef\execute@message@pen=10019 |
| 3480 |
\@namedef{output@-\the\execute@message@pen}{\@message@saved}% |
| 3481 |
% \end{macrocode} |
| 3482 |
% \end{macro} |
| 3483 |
% |
| 3484 |
% |
| 3485 |
% \subsection{Output messages} |
| 3486 |
% |
| 3487 |
% Message handlers are procedures that execute output messages, tokens that are passed to |
| 3488 |
% the output routine for execution in an environment appropriate to page makeup. |
| 3489 |
% |
| 3490 |
% How it works. We put down three large negative penalties, each of which will be handled by |
| 3491 |
% the output dispatcher (\emph{not} the natural output routine), each penalty being protected by |
| 3492 |
% a removable, non-discardable item (i.e., a box). |
| 3493 |
% Either three or four invocations of one-off output routines are involved per message. |
| 3494 |
% |
| 3495 |
% We make the last of the three protection boxes have a depth equal to the value of \cmd\prevdepth\ |
| 3496 |
% that was current when the procedure is called. This effectively restores \cmd\prevdepth. |
| 3497 |
% |
| 3498 |
% In each case, the one-off output routine will remove the extraneous box we have inserted. |
| 3499 |
% And the second and third one-off routines will simply void \cmd\box\cmd\@cclv, because its contents |
| 3500 |
% are entirely artificial. |
| 3501 |
% |
| 3502 |
% FIXME: not so! If \cmd\holdinginserts\ is cleared, that box may have an insert node; it must be preserved, too. |
| 3503 |
% |
| 3504 |
% The first routine saves away the current column contents and remembers the \cmd\topmark\ for later |
| 3505 |
% use. There is a variant routine that first clears \cmd\holdinginserts, so that the message can |
| 3506 |
% handle any inserts present in the boxed-up page; this of course entails yet another |
| 3507 |
% visit to the output routine. |
| 3508 |
% |
| 3509 |
% The penultimate routine saves away the tokens transmitted in via the \cmd\@@mark: the argument of |
| 3510 |
% the macro. These tokens are of course the very thing we wish to execute within the safety |
| 3511 |
% of the output routine. It also puts down a mark containing the \cmd\topmark\ tokens saved |
| 3512 |
% by the first routine. By this means, the mark, which we have clobbered, is restored. |
| 3513 |
% |
| 3514 |
% The last routine simply executes the given tokens. |
| 3515 |
% In the course of doing this, it must take care of \cmd\box\cmd\@cclv, either by shipping it out, |
| 3516 |
% or by \cmd\unvbox ing it onto the MVL. |
| 3517 |
% |
| 3518 |
% \begin{macro}{\execute@message} |
| 3519 |
% The procedure \cmd\execute@message\ simply calls the utility procedure \cmd\@execute@message\ |
| 3520 |
% with a penalty value for the standard treatment. |
| 3521 |
% \begin{macrocode} |
| 3522 |
\def\execute@message{% |
| 3523 |
\@execute@message\save@column@pen |
| 3524 |
% \end{macrocode} |
| 3525 |
% Implicit second argument |
| 3526 |
% \begin{macrocode} |
| 3527 |
}% |
| 3528 |
% \end{macrocode} |
| 3529 |
% \end{macro} |
| 3530 |
% |
| 3531 |
% \begin{macro}{\execute@message@insert} |
| 3532 |
% The procedure \cmd\execute@message@insert\ is like \cmd\execute@message\ in all respects |
| 3533 |
% except that the penalty value is \cmd\save@column@insert@pen, which arranges for the |
| 3534 |
% message handler involved to deal with the page's insertions. |
| 3535 |
% At the same time, we prepare the \cmd\footins\ box so that these insertions can be dealt with. |
| 3536 |
% |
| 3537 |
% Note: |
| 3538 |
% If more insertions are added to \LaTeX\ (presumably via \cmd\newinsert), then they |
| 3539 |
% must be dealt with in a way entirely analogous to \cmd\footins. |
| 3540 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 3541 |
% \begin{macrocode} |
| 3542 |
\def\execute@message@insert#1{% |
| 3543 |
\@execute@message\save@column@insert@pen{% |
| 3544 |
\setbox \footins \box \footins@saved |
| 3545 |
\ltxgrid@foot@info@sw{\class@info{\string\execute@message@insert}\trace@box\footins}{}% |
| 3546 |
#1% |
| 3547 |
}% |
| 3548 |
}% |
| 3549 |
% \end{macrocode} |
| 3550 |
% \end{macro} |
| 3551 |
% |
| 3552 |
% \begin{macro}{\@execute@message} |
| 3553 |
% The utility procedure \cmd\@execute@message\ is called by \cmd\execute@message\ and \cmd\execute@message@insert. |
| 3554 |
% We prepare by creating a \cmd\vbox\ containing all the needed nodes and proceed by simply |
| 3555 |
% \cmd\unvbox ing that box onto the MVL. |
| 3556 |
% We ensure that \cmd\box\cmd\@cclv\ is properly set up for the output message handler |
| 3557 |
% by always inserting \cmd\prep@cclv\ in advance of the argument. |
| 3558 |
% |
| 3559 |
% Note that each one-off output routine is invoked effectively the same as |
| 3560 |
% \cmd\protect@penalty, except that the second invocation involves an additional |
| 3561 |
% \cmd\mark\ node, and the third a specially prepared protection box. |
| 3562 |
% |
| 3563 |
% Note also that \TeX's primitive \cmd\mark\ is called here without any expansion protection. |
| 3564 |
% This is the only place where it is called that way, but it's OK because those tokens |
| 3565 |
% have have been pre-expanded by procedures that call \cmd\execute@message. |
| 3566 |
% FIXME: all procedures calling \cmd\execute@message\ must pre-expand their tokens! |
| 3567 |
% \begin{macrocode} |
| 3568 |
\long\def\@execute@message#1#2{% |
| 3569 |
\begingroup |
| 3570 |
\dimen@\prevdepth\@ifdim{\dimen@<\z@}{\dimen@\z@}{}% |
| 3571 |
\setbox\z@\vbox{% |
| 3572 |
\protect@penalty#1% |
| 3573 |
\protection@box |
| 3574 |
\toks@{\prep@cclv#2}% |
| 3575 |
\@@mark{\the\toks@}% |
| 3576 |
\penalty-\save@message@pen |
| 3577 |
% \end{macrocode} |
| 3578 |
%\begin{verbatim} |
| 3579 |
% \hbox{\vrule\@height\z@\@width\z@\@depth\dimen@}% |
| 3580 |
%\end{verbatim} |
| 3581 |
% \begin{macrocode} |
| 3582 |
\setbox\z@\null\dp\z@\dimen@\ht\z@-\dimen@ |
| 3583 |
\nointerlineskip\box\z@ |
| 3584 |
\penalty-\execute@message@pen |
| 3585 |
}\unvbox\z@ |
| 3586 |
\endgroup |
| 3587 |
}% |
| 3588 |
% \end{macrocode} |
| 3589 |
% \end{macro} |
| 3590 |
% |
| 3591 |
% \begin{macro}{\do@output@cclv} |
| 3592 |
% The procedure \cmd\do@output@cclv\ provides access to message handlers at their simplest. |
| 3593 |
% The message will execute in the usual environment of the output routine, with |
| 3594 |
% the boxed-up page in \cmd\box\cmd\@cclv, and we assume that \cmd\holdinginserts\ remains set. |
| 3595 |
% This procedure must be invoked within main vertical mode; |
| 3596 |
% it is the obligation of the macro writer to ensure that this is the case. |
| 3597 |
% \begin{macrocode} |
| 3598 |
\def\do@output@cclv{\execute@message}% |
| 3599 |
% \end{macrocode} |
| 3600 |
% \end{macro} |
| 3601 |
% |
| 3602 |
% \begin{macro}{\do@output@MVL} |
| 3603 |
% The procedure \cmd\do@output@MVL, like \cmd\do@output@cclv, is an interface for messages, |
| 3604 |
% but provides two additional services: the command may also be invoked in horizontal mode, and |
| 3605 |
% the message handler will execute with the MVL unboxed. |
| 3606 |
% \begin{macrocode} |
| 3607 |
\def\do@output@MVL#1{% |
| 3608 |
\@ifvmode{% |
| 3609 |
\begingroup\execute@message{\unvbox\@cclv#1}\endgroup |
| 3610 |
}{% |
| 3611 |
\@ifhmode{% |
| 3612 |
\vadjust{\execute@message{\unvbox\@cclv#1}}% |
| 3613 |
}{% |
| 3614 |
\@latexerr{\string\do@output@MVL\space cannot be executed in this mode!}\@eha |
| 3615 |
}% |
| 3616 |
}% |
| 3617 |
}% |
| 3618 |
% \end{macrocode} |
| 3619 |
% \end{macro} |
| 3620 |
% |
| 3621 |
% \begin{macro}{\lose@breaks} |
| 3622 |
% The purpose of this procedure is to get rid of all the extraneous |
| 3623 |
% \cmd\penalty\cmd\@M\ nodes that tend to build up in the MVL. |
| 3624 |
% \begin{macrocode} |
| 3625 |
\def\lose@breaks{% |
| 3626 |
\loopwhile{% |
| 3627 |
\count@\lastpenalty |
| 3628 |
\@ifnum{\count@=\@M}{% |
| 3629 |
% \end{macrocode} |
| 3630 |
% Note: 10000 is a TeX magic number! |
| 3631 |
% \begin{macrocode} |
| 3632 |
\unpenalty\true@sw |
| 3633 |
}{% |
| 3634 |
\false@sw |
| 3635 |
}% |
| 3636 |
}% |
| 3637 |
}% |
| 3638 |
% \end{macrocode} |
| 3639 |
% \end{macro} |
| 3640 |
% |
| 3641 |
% \begin{macro}{\removestuff} |
| 3642 |
% \cmd\removestuff\ is a document-level command that removes the bottom skip glue item |
| 3643 |
% from the MVL. |
| 3644 |
% \begin{macrocode} |
| 3645 |
\def\removestuff{\do@output@MVL{\unskip\unpenalty}}% |
| 3646 |
% \end{macrocode} |
| 3647 |
% \end{macro} |
| 3648 |
% |
| 3649 |
% \begin{macro}{\removephantombox} |
| 3650 |
% The procedure \cmd\removephantombox\ is a special-purpose message handler exclusively for |
| 3651 |
% preventing incorrect spacing above display math. It must be issued in |
| 3652 |
% horizontal mode within the phantom paragraph generated when display math starts up in |
| 3653 |
% vertical mode. |
| 3654 |
% \begin{macrocode} |
| 3655 |
\def\removephantombox{% |
| 3656 |
\vadjust{% |
| 3657 |
\execute@message{% |
| 3658 |
\unvbox\@cclv |
| 3659 |
\remove@lastbox |
| 3660 |
\unskip |
| 3661 |
\unskip |
| 3662 |
\unpenalty |
| 3663 |
\penalty\predisplaypenalty |
| 3664 |
\vskip\abovedisplayskip |
| 3665 |
}% |
| 3666 |
}% |
| 3667 |
}% |
| 3668 |
% \end{macrocode} |
| 3669 |
% \end{macro} |
| 3670 |
% |
| 3671 |
% \begin{macro}{\addstuff} |
| 3672 |
% \cmd\addstuff\ is a document-level command that adds penalty, glue, or both to the |
| 3673 |
% MVL. The penalty and glue items are rearranged so that all penalties nodes precede all the glue nodes, |
| 3674 |
% which is the canonical arrangement. |
| 3675 |
% \begin{macrocode} |
| 3676 |
\def\addstuff#1#2{\edef\@tempa{\noexpand\do@output@MVL{\noexpand\@addstuff{#1}{#2}}}\@tempa}% |
| 3677 |
\def\@addstuff#1#2{% |
| 3678 |
\skip@\lastskip\unskip |
| 3679 |
\count@\lastpenalty\unpenalty |
| 3680 |
\@if@empty{#1}{}{\penalty#1\relax}% |
| 3681 |
\@ifnum{\count@=\z@}{}{\penalty\count@}% |
| 3682 |
\vskip\skip@ |
| 3683 |
\@if@empty{#2}{}{\vskip#2\relax}% |
| 3684 |
}% |
| 3685 |
% \end{macrocode} |
| 3686 |
% \end{macro} |
| 3687 |
% |
| 3688 |
% \begin{macro}{\replacestuff} |
| 3689 |
% \cmd\replacestuff\ is a document-level command similar to \cmd\addstuff; |
| 3690 |
% but it replaces penalty, glue, or both in the MVL. |
| 3691 |
% The penalty and glue items are rearranged so that all penalties nodes precede all the glue nodes, |
| 3692 |
% which is the canonical arrangement. |
| 3693 |
% \begin{macrocode} |
| 3694 |
\def\replacestuff#1#2{\edef\@tempa{\noexpand\do@output@MVL{\noexpand\@replacestuff{#1}{#2}}}\@tempa}% |
| 3695 |
\def\@replacestuff#1#2{% |
| 3696 |
\skip@\lastskip\unskip |
| 3697 |
\count@\lastpenalty\unpenalty |
| 3698 |
\@if@empty{#1}{}{% |
| 3699 |
\@ifnum{\count@>\@M}{}{% |
| 3700 |
\@ifnum{\count@=\z@}{\count@=#1\relax}{% |
| 3701 |
\@ifnum{\count@<#1\relax}{}{% |
| 3702 |
\count@=#1\relax |
| 3703 |
}% |
| 3704 |
}% |
| 3705 |
}% |
| 3706 |
}% |
| 3707 |
\@ifnum{\count@=\z@}{}{\penalty\count@}% |
| 3708 |
\@if@empty{#2}{}{% |
| 3709 |
\@tempskipa#2\relax |
| 3710 |
\@ifdim{\z@>\@tempskipa}{% |
| 3711 |
\advance\skip@-\@tempskipa |
| 3712 |
}{% |
| 3713 |
\@ifdim{\skip@>\@tempskipa}{}{% |
| 3714 |
\skip@\@tempskipa |
| 3715 |
}% |
| 3716 |
}% |
| 3717 |
}% |
| 3718 |
\vskip\skip@ |
| 3719 |
}% |
| 3720 |
% \end{macrocode} |
| 3721 |
% \end{macro} |
| 3722 |
% |
| 3723 |
% \begin{macro}{\move@insertions} |
| 3724 |
% \begin{macro}{\hold@insertions} |
| 3725 |
% In order to avoid bolluxing up \cmd\insert\ registers by our one-off |
| 3726 |
% output routines, we set \cmd\holdinginserts\ to zero by default and only |
| 3727 |
% clear it (briefly) while we handle cases where we want inserts to show up. |
| 3728 |
% \begin{macrocode} |
| 3729 |
\def\move@insertions{\global\holdinginserts\z@}% |
| 3730 |
\def\hold@insertions{\global\holdinginserts\@ne}% |
| 3731 |
\hold@insertions |
| 3732 |
\def\toggle@insert#1#2{% |
| 3733 |
\@ifnum{\holdinginserts>\z@}{\move@insertions#1}{\hold@insertions#2}% |
| 3734 |
}% |
| 3735 |
% \end{macrocode} |
| 3736 |
% \end{macro} |
| 3737 |
% \end{macro} |
| 3738 |
% |
| 3739 |
% |
| 3740 |
% \subsection{Messages to alter the page grid}% |
| 3741 |
% |
| 3742 |
% Here is the implementation of the grid-switching procedures. |
| 3743 |
% We perform two checks when changing the page grid; first to ensure that |
| 3744 |
% the target page grid is known (defensive programming), second to ensure that |
| 3745 |
% the switch is a non-trivial one. The latter check must be performed within |
| 3746 |
% the safety of the output routine, so requires using an output message. |
| 3747 |
% Thus, a grid change requires two messages, for a total of six visits to the output routine. |
| 3748 |
% |
| 3749 |
% \begin{macro}{\do@columngrid} |
| 3750 |
% Utility procedure \cmd\do@columngrid\ changes the page grid. |
| 3751 |
% Note that this command forces an end to the current paragraph. This is necessary, because |
| 3752 |
% a page grid change makes no sense unless we can alter the \cmd\hsize\ before commencing to |
| 3753 |
% typeset the following paragraph. So the command should never be executed in horizontal mode |
| 3754 |
% anyway. |
| 3755 |
% \begin{macrocode} |
| 3756 |
\def\do@columngrid#1#2{% |
| 3757 |
\par |
| 3758 |
\expandafter\let\expandafter\@tempa\csname open@column@#1\endcsname |
| 3759 |
\@ifx{\relax\@tempa}{% |
| 3760 |
\ltxgrid@warn{Unknown page grid #1. No action taken}% |
| 3761 |
}{% |
| 3762 |
\do@output@MVL{\start@column{#1}{#2}}% |
| 3763 |
}% |
| 3764 |
}% |
| 3765 |
% \end{macrocode} |
| 3766 |
% \end{macro} |
| 3767 |
% |
| 3768 |
% \begin{macro}{\start@column} |
| 3769 |
% Procedure \cmd\start@column\ lays down the interrupts to switch the page grid. |
| 3770 |
% If the change to the page grid would have been trivial, it bails out. |
| 3771 |
% It seems a reasonable tradeoff of processing versus security: once we commit |
| 3772 |
% to changing the page grid, we clear \cmd\holdinginserts, so there is no turning back. |
| 3773 |
% |
| 3774 |
% Note that the second argument to the macro allows us to pass an argument to the |
| 3775 |
% page grid that is starting up. This can be handy, because a single procedure can |
| 3776 |
% handle multiple page grids, differing only by the value of a parameter. |
| 3777 |
% |
| 3778 |
% FIXME: this means that you cannot switch between mlt page grids in a single step. |
| 3779 |
% But do we want to do this, at all, at all? |
| 3780 |
% \begin{macrocode} |
| 3781 |
\def\start@column#1#2{% |
| 3782 |
\def\@tempa{#1}\@ifx{\@tempa\thepagegrid}{% |
| 3783 |
\ltxgrid@info{Already in page grid \thepagegrid. No action taken}% |
| 3784 |
}{% |
| 3785 |
\expandafter\execute@message@insert |
| 3786 |
\expandafter{% |
| 3787 |
\csname shut@column@\thepagegrid\expandafter\endcsname |
| 3788 |
\csname open@column@#1\endcsname{#2}% |
| 3789 |
\set@vsize |
| 3790 |
}% |
| 3791 |
}% |
| 3792 |
}% |
| 3793 |
% \end{macrocode} |
| 3794 |
% \end{macro} |
| 3795 |
% |
| 3796 |
% \begin{macro}{\thepagegrid} |
| 3797 |
% The macro \cmd\thepagegrid\ tracks what kind of page grid we are in. |
| 3798 |
% |
| 3799 |
% Note: Access \cmd\thepagegrid\ only within the safety of the output routine. |
| 3800 |
% |
| 3801 |
% Warning: The page grid should be changed only within the safety of the output routine. |
| 3802 |
% People who write multicol page grid mechanisms appear not to understand the matter, so they |
| 3803 |
% should particularly heed this warning. Think about it: obviously Lamport did so, which is why |
| 3804 |
% his \cmd\twocolumn\ command forced a pagebreak, which is limiting, but safe. |
| 3805 |
% \begin{macrocode} |
| 3806 |
\def\thepagegrid{one}% |
| 3807 |
% \end{macrocode} |
| 3808 |
% \end{macro} |
| 3809 |
% |
| 3810 |
% |
| 3811 |
% \subsection{Application Note: implementing a page grid} |
| 3812 |
% |
| 3813 |
% If you want to create a new page grid for \LaTeX, |
| 3814 |
% you must define five procedures with specific names: |
| 3815 |
% \cmd\open@column@ name, \cmd\shut@column@ name, \cmd\end@column@ name, |
| 3816 |
% \cmd\output@column@ name, and \cmd\@addmarginpar@ name, where ``name'' is the |
| 3817 |
% name of your page grid. |
| 3818 |
% |
| 3819 |
% The procedure \cmd\open@column@ name starts the new page grid. It should define \cmd\thepagegrid, |
| 3820 |
% deal with \cmd\box\cmd\pagesofar\ and \cmd\box\cmd\footsofar\ (perhaps by leaving them alone), |
| 3821 |
% and it should set the values of \LaTeX's page layout parameters for the column size and height. |
| 3822 |
% |
| 3823 |
% The procedure \cmd\shut@column@ name should expect to be called with \cmd\holdinginserts\ |
| 3824 |
% cleared (it can assume that \cmd\holdinginserts\ will automatically be restored). |
| 3825 |
% It should properly deal with insertions (like footnotes); calling \cmd\@makecolumn\ |
| 3826 |
% with an argument of \cmd\false@sw\ will do this. |
| 3827 |
% It should know that the page grid is being terminated |
| 3828 |
% in the middle of a page, so it should make arrangements to carry the footnotes down to the |
| 3829 |
% bottom of the column or page, and it should possibly salt away the material for later |
| 3830 |
% incorporation into the page. The box registers \cmd\footsofar\ and \cmd\pagesofar\ are customarily used |
| 3831 |
% for this purpose. |
| 3832 |
% |
| 3833 |
% The procedure \cmd\end@column@ name should kick out a possibly short page containing all the |
| 3834 |
% floats committed to the page. It will be invoked during \cmd\clearpage\ processing. |
| 3835 |
% After that, it should \cmd\unvbox\cmd\@cclv. |
| 3836 |
% |
| 3837 |
% The procedure \cmd\output@column@ name should ship out or commit the current \cmd\@outputbox. |
| 3838 |
% In a one-column layout, you ship out; in a multicolumn layout, you commit the box as the contents |
| 3839 |
% of a particular column, and if that column is the last, you ship out. |
| 3840 |
% |
| 3841 |
% The procedure \cmd\@addmarginpar@ name should return a boolean (either \cmd\true@sw\ or \cmd\false@sw\ or an equivalent) |
| 3842 |
% to tell the marginpar mechanism to place the marginal material to the right or left, respectively. |
| 3843 |
% |
| 3844 |
% You can use the existing page grids ``one'' and ``mlt'' as a point of departure for creating others. |
| 3845 |
% The former can be the basis for, say, a single-column page grid with a side column. |
| 3846 |
% |
| 3847 |
% \begin{macro}{\pagesofar} |
| 3848 |
% \begin{macro}{\footsofar} |
| 3849 |
% The box register \cmd\pagesofar\ holds the portion of the (full-width) page that is already composed into columns. |
| 3850 |
% This, plus the finished columns, each with its floats, plus \cmd\box255 constitute the full galley. |
| 3851 |
% |
| 3852 |
% The box register \cmd\footsofar\ holds all of the footnotes associated with \cmd\pagesofar. |
| 3853 |
% \begin{macrocode} |
| 3854 |
\newbox\pagesofar |
| 3855 |
\newbox\footsofar |
| 3856 |
% \end{macrocode} |
| 3857 |
% \end{macro} |
| 3858 |
% \end{macro} |
| 3859 |
% |
| 3860 |
% \begin{macro}{\combine@foot@inserts} |
| 3861 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 3862 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 3863 |
% The procedure \cmd\combine@foot@inserts\ is for the purpose of merging |
| 3864 |
% the recently contributed footnotes (usually \cmd\box\cmd\footins) |
| 3865 |
% with those saved from earlier on the page (usually \cmd\box\cmd\footsofar). |
| 3866 |
% |
| 3867 |
% It is employed in a number of circumstances. |
| 3868 |
% |
| 3869 |
% \cmd\@makecolumn (when its argument is \cmd\false@sw): |
| 3870 |
% we are not shipping out, so we need to salt away any footnotes there may be. |
| 3871 |
% |
| 3872 |
% \cmd\shut@column@one: we are leaving the one-column page grid, so recover the footnotes from that material |
| 3873 |
% and combine them with those of \cmd\pagesofar. |
| 3874 |
% |
| 3875 |
% \expandafter\cmd\csname balance@2\endcsname: two columns of type have been balanced, so now balance the footnotes. |
| 3876 |
% The \cmd\combine@foot@inserts\ procedure is first used to gather footnotes from the columns balanced with those of \cmd\pagesofar. |
| 3877 |
% |
| 3878 |
% Bug 571 note: if balancing a two-column page grid, and there had been footnotes in the \cmd\pagesofar, |
| 3879 |
% those footnotes will have been balanced into a page-width box, \cmd\box\cmd\footsofar. |
| 3880 |
% We need to now re-cast them into a single, column-width galley, and only then |
| 3881 |
% combine them with those in \cmd\box\cmd\footins. |
| 3882 |
% |
| 3883 |
% \begin{macrocode} |
| 3884 |
\def\combine@foot@inserts#1#2{% |
| 3885 |
\ltxgrid@info@sw{\class@info{\string\combine@foot@inserts\string#1\string#2}}{}% |
| 3886 |
\@ifvoid#1{% |
| 3887 |
\ltxgrid@foot@info@sw{\trace@box#2}{}\global\setbox#1\box#2% |
| 3888 |
}{% |
| 3889 |
\global\setbox#1\vbox\bgroup |
| 3890 |
\ltxgrid@foot@info@sw{\trace@box#1}{}\unvbox#1% |
| 3891 |
\@ifvoid#2{}{% |
| 3892 |
\marry@baselines |
| 3893 |
\ltxgrid@foot@info@sw{\trace@box#2}{}\unvbox#2% |
| 3894 |
}% |
| 3895 |
\egroup |
| 3896 |
}% |
| 3897 |
\ltxgrid@foot@info@sw{\trace@scroll{\showbox#1\showbox#2}}{}% |
| 3898 |
}% |
| 3899 |
% \end{macrocode} |
| 3900 |
% \end{macro} |
| 3901 |
% |
| 3902 |
% |
| 3903 |
% \subsubsection{One-column page grid} |
| 3904 |
% |
| 3905 |
% \begin{macro}{\onecolumngrid} |
| 3906 |
% \begin{macro}{\open@column@one} |
| 3907 |
% \begin{macro}{\shut@column@one} |
| 3908 |
% \begin{macro}{\float@column@one} |
| 3909 |
% \begin{macro}{\end@column@one} |
| 3910 |
% \begin{macro}{\output@column@one} |
| 3911 |
% \begin{macro}{\@addmarginpar@one} |
| 3912 |
% Here are all the procedures necessary for the standard page grid named ``one'': |
| 3913 |
% a single column layout. It is, of course, \LaTeX's familiar \cmd\onecolumn\ layout. |
| 3914 |
% We begin with the procedure exposed to the style writer. |
| 3915 |
% This is, however, not a \LaTeX\ command; users should not change the page grid. |
| 3916 |
% \begin{macrocode} |
| 3917 |
\newcommand\onecolumngrid{\do@columngrid{one}{\@ne}}% |
| 3918 |
% \end{macrocode} |
| 3919 |
% |
| 3920 |
% Note that a document class that issues the command \cmd\onecolumn\ will break. This includes |
| 3921 |
% \LaTeX's standard classes.dtx-based classes: if your class descends from one of these, you |
| 3922 |
% must expunge it of all such commands. |
| 3923 |
% \begin{macrocode} |
| 3924 |
\let\onecolumn\@undefined |
| 3925 |
% \end{macrocode} |
| 3926 |
% |
| 3927 |
% The procedure \cmd\open@column@one\ takes advantage of the special nature of the one-column |
| 3928 |
% page grid to deal with \cmd\box\cmd\pagesofar, therefore it must also reset \cmd\@colroom. |
| 3929 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 3930 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 3931 |
% \begin{macrocode} |
| 3932 |
\def\open@column@one#1{% |
| 3933 |
\ltxgrid@info@sw{\class@info{\string\open@column@one\string#1}}{}% |
| 3934 |
% \end{macrocode} |
| 3935 |
% Throw the \cmd\pagesofar\ back onto the Main Vertical List. |
| 3936 |
% At this point, we must also \cmd\insert\ the footnotes back into the MVL. |
| 3937 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 3938 |
% \begin{macrocode} |
| 3939 |
\unvbox\pagesofar |
| 3940 |
\@ifvoid{\footsofar}{}{% |
| 3941 |
\insert\footins\bgroup\unvbox\footsofar\egroup |
| 3942 |
\penalty\z@ |
| 3943 |
}% |
| 3944 |
% \end{macrocode} |
| 3945 |
% Record which page grid we are using. Then calculate the set width (\cmd\hsize) and the goal height (\cmd\vsize). |
| 3946 |
% |
| 3947 |
% Klootch: we set the \cmd\count\cmd\footins\ to a magic number. This is only correct in the case of a two-column document. |
| 3948 |
% \begin{macrocode} |
| 3949 |
\gdef\thepagegrid{one}% |
| 3950 |
\global\pagegrid@col#1% |
| 3951 |
\global\pagegrid@cur\@ne |
| 3952 |
\global\count\footins\@m |
| 3953 |
\global\divide\count\footins\tw@ |
| 3954 |
\set@column@hsize\pagegrid@col |
| 3955 |
\set@colht |
| 3956 |
}% |
| 3957 |
% \end{macrocode} |
| 3958 |
% |
| 3959 |
% The procedure \cmd\shut@column@one\ saves away the one-column material into the box register \cmd\pagesofar. |
| 3960 |
% Because it is called from a message handler, we are assured that marks are properly taken care of. |
| 3961 |
% |
| 3962 |
% This instance of \cmd\@makecolumn\ is building a column for saving into \cmd\pagesofar. |
| 3963 |
% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 3964 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 3965 |
% \changes{4.1f}{2009/07/15}{(AO, 519) Preserve footnotes that are in \cs{footsofar} across a page grid change} |
| 3966 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 3967 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 3968 |
% We recover the footnotes into \cmd\footsofar\ (globally) and the column into \cmd\pagesofar\ (also globally), voiding \cmd\@outputbox\ by side effect. |
| 3969 |
% \begin{macrocode} |
| 3970 |
\def\shut@column@one{% |
| 3971 |
\ltxgrid@info@sw{\class@info{\string\shut@column@one}}{}% |
| 3972 |
\@makecolumn\false@sw |
| 3973 |
% \end{macrocode} |
| 3974 |
% Split text portion of \cmd\@outputbox\ into \cmd\pagesofar, |
| 3975 |
% and add its footnote portion to \cmd\footsofar. |
| 3976 |
% Then void out \cmd\@outputbox. |
| 3977 |
% \begin{macrocode} |
| 3978 |
\global\setbox\pagesofar\vbox\bgroup |
| 3979 |
\recover@column\@outputbox\footsofar\column@recovered\footins@recovered |
| 3980 |
\egroup |
| 3981 |
\begingroup\setbox\z@\box\@outputbox\endgroup |
| 3982 |
% \end{macrocode} |
| 3983 |
% FIXME: is \cmd\combine@foot@inserts\ needed? |
| 3984 |
% Also: if this procedure is immediately followed by \cmd\open@column@ \texttt{grid}, then \cmd\set@colht\ will be unneeded. |
| 3985 |
% \begin{macrocode} |
| 3986 |
\combine@foot@inserts\footsofar\footins |
| 3987 |
\set@colht |
| 3988 |
}% |
| 3989 |
% \end{macrocode} |
| 3990 |
% |
| 3991 |
%FIXME: the first line of a footnote should have an up-strut, and the last line a down-strut, so that they can marry baselines. |
| 3992 |
% The latter is the case; how about the former? |
| 3993 |
% |
| 3994 |
% The procedure \cmd\float@column@one\ takes care of a float column that has been built by |
| 3995 |
% \cmd\@tryfcolumn, in the single-column page grid. |
| 3996 |
% |
| 3997 |
% This instance of \cmd\@makecolumn\ is followed by \cmd\@outputpage: it is building |
| 3998 |
% a column for \cmd\shipout, rather than for saving into \cmd\pagesofar. |
| 3999 |
% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 4000 |
% \begin{macrocode} |
| 4001 |
\def\float@column@one{% |
| 4002 |
\@makecolumn\true@sw |
| 4003 |
\@outputpage |
| 4004 |
}% |
| 4005 |
% \end{macrocode} |
| 4006 |
% |
| 4007 |
% The procedure \cmd\end@column@one\ is executed at the end of \cmd\clearpage\ processing, |
| 4008 |
% if we were in a one-column page grid, once all permissive float pages have been shipped out. |
| 4009 |
% At this point, one could perhaps |
| 4010 |
% assume that nothing more need be done, but let us anyway test for committed floats and force a shipout. |
| 4011 |
% |
| 4012 |
% FIXME: this procedure does the same as \cmd\end@column@mlt |
| 4013 |
% (except for the test of \cmd\@ifx@empty\cmd\@dbltoplist): |
| 4014 |
% the two could almost be the same procedure. |
| 4015 |
% |
| 4016 |
% I have changed this procedure to avoid the testing it once did: it simply puts down interrupts, |
| 4017 |
% upon which it relies to correctly do what \cmd\clearpage\ requires. |
| 4018 |
% \begin{macrocode} |
| 4019 |
\def\end@column@one{% |
| 4020 |
\unvbox\@cclv\remove@lastbox |
| 4021 |
\protect@penalty\do@newpage@pen |
| 4022 |
}% |
| 4023 |
% \end{macrocode} |
| 4024 |
% |
| 4025 |
% The procedure \cmd\output@column@one\ is dispatched from the output routine when |
| 4026 |
% we have completed a page (that is, a column in a one-column page grid); |
| 4027 |
% it ships out the page using the \cmd\@outputpage. |
| 4028 |
% It will be followed up with an output routine message to prepare a new column. |
| 4029 |
% |
| 4030 |
% Query: by what mechanism do the footnotes get placed onto such a page? |
| 4031 |
% \begin{macrocode} |
| 4032 |
\def\output@column@one{% |
| 4033 |
\@outputpage |
| 4034 |
}% |
| 4035 |
% \end{macrocode} |
| 4036 |
% |
| 4037 |
% The following procedure determines which side of the page a marginpar will appear. |
| 4038 |
% It reproduces the behavior of standard \LaTeX. |
| 4039 |
% \begin{macrocode} |
| 4040 |
\def\@addmarginpar@one{% |
| 4041 |
\@if@sw\if@mparswitch\fi{% |
| 4042 |
\@ifodd\c@page{\false@sw}{\true@sw}% |
| 4043 |
}{\false@sw}{% |
| 4044 |
\@if@sw\if@reversemargin\fi{\false@sw}{\true@sw}% |
| 4045 |
}{% |
| 4046 |
\@if@sw\if@reversemargin\fi{\true@sw}{\false@sw}% |
| 4047 |
}% |
| 4048 |
}% |
| 4049 |
% \end{macrocode} |
| 4050 |
% |
| 4051 |
% The following procedure yields a Boolean value; it determines whether a float in the deferred queue |
| 4052 |
% is appropriate for placing. In the one-column grid, all floats are so. |
| 4053 |
% \begin{macrocode} |
| 4054 |
\def\@floatselect@sw@one#1{\true@sw}% |
| 4055 |
% \end{macrocode} |
| 4056 |
% |
| 4057 |
% \begin{macrocode} |
| 4058 |
\def\onecolumngrid@push{% |
| 4059 |
\do@output@MVL{% |
| 4060 |
\@ifnum{\pagegrid@col=\@ne}{% |
| 4061 |
\global\let\restorecolumngrid\@empty |
| 4062 |
}{% |
| 4063 |
\xdef\restorecolumngrid{% |
| 4064 |
\noexpand\start@column{\thepagegrid}{\the\pagegrid@col}% |
| 4065 |
}% |
| 4066 |
\start@column{one}{\@ne}% |
| 4067 |
}% |
| 4068 |
}% |
| 4069 |
}% |
| 4070 |
\def\onecolumngrid@pop{% |
| 4071 |
\do@output@MVL{\restorecolumngrid}% |
| 4072 |
}% |
| 4073 |
% \end{macrocode} |
| 4074 |
% \end{macro} |
| 4075 |
% \end{macro} |
| 4076 |
% \end{macro} |
| 4077 |
% \end{macro} |
| 4078 |
% \end{macro} |
| 4079 |
% \end{macro} |
| 4080 |
% \end{macro} |
| 4081 |
% |
| 4082 |
% |
| 4083 |
% \subsubsection{Two-column page grid} |
| 4084 |
% |
| 4085 |
% \begin{macro}{\twocolumngrid} |
| 4086 |
% \begin{macro}{\open@column@mlt} |
| 4087 |
% \begin{macro}{\shut@column@mlt} |
| 4088 |
% \begin{macro}{\end@column@mlt} |
| 4089 |
% \begin{macro}{\output@column@mlt} |
| 4090 |
% \begin{macro}{\@addmarginpar@mlt} |
| 4091 |
% \begin{macro}{\set@footnotewidth@mlt} |
| 4092 |
% \begin{macro}{\set@footnotewidth@two} |
| 4093 |
% \begin{macro}{\compose@footnotes@two} |
| 4094 |
% Here are all the procedures necessary for the standard page grid named ``mlt'': |
| 4095 |
% the multi-column page grid. With an argument of "2", it is, |
| 4096 |
% of course, \LaTeX's familiar \cmd\twocolumn\ layout. |
| 4097 |
% |
| 4098 |
% We start with the procedure to switch to the two-column page grid. |
| 4099 |
% \begin{macrocode} |
| 4100 |
\newcommand\twocolumngrid{\do@columngrid{mlt}{\tw@}}% |
| 4101 |
% \end{macrocode} |
| 4102 |
% |
| 4103 |
% The corresponding command of \LaTeX\ is obsolete. |
| 4104 |
% \begin{macrocode} |
| 4105 |
\let\twocolumn\@undefined |
| 4106 |
% \end{macrocode} |
| 4107 |
% |
| 4108 |
% Of course, \cmd\@topnewpage\ is also obsolete. Just do |
| 4109 |
%\begin{quote} |
| 4110 |
% \cmd\clearpage\cmd\onecolumngrid<vertical mode material>\cmd\twocolumngrid. |
| 4111 |
%\end{quote} |
| 4112 |
% \begin{macrocode} |
| 4113 |
\let\@topnewpage\@undefined |
| 4114 |
% \end{macrocode} |
| 4115 |
% |
| 4116 |
% If your document class descends from one of \LaTeX's standard classes.dtx-derived |
| 4117 |
% classes, it will break. You must expunge from it all such commands. |
| 4118 |
% |
| 4119 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 4120 |
% |
| 4121 |
% Bug 571 note: it is not enough to have the \cmd\pagesofar, we must also deal with the \cmd\footsofar. |
| 4122 |
% At this juncture, we should treat the case where the document has an essentially two-column page grid, |
| 4123 |
% with occasional excursions into the one-column grid. |
| 4124 |
% If a footnote is set within the latter grid, its set width should be that of the two-column grid. |
| 4125 |
% |
| 4126 |
% When a page is shipped out, if we are currently in a one-column grid, we will compose the footnotes onto the page |
| 4127 |
% in the form of balanced columns. This is only one way to handle footnotes: \classname{multicol} |
| 4128 |
% appears to set footnotes on the full text width. |
| 4129 |
% \begin{macrocode} |
| 4130 |
\def\open@column@mlt#1{% |
| 4131 |
\ltxgrid@info@sw{\class@info{\string\open@column@mlt\string#1}}{}% |
| 4132 |
% \end{macrocode} |
| 4133 |
% At this point, we must \cmd\insert\ the footnotes back into the Main Vertical List. |
| 4134 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 4135 |
% \begin{macrocode} |
| 4136 |
\@ifvoid{\footsofar}{}{% |
| 4137 |
\insert\footins\bgroup\unvbox\footsofar\egroup |
| 4138 |
}% |
| 4139 |
% \end{macrocode} |
| 4140 |
% Record which page grid we are using. Then calculate the set width (\cmd\hsize) and the goal height (\cmd\vsize). |
| 4141 |
% |
| 4142 |
% Klootch: we set the \cmd\count\cmd\footins\ to a magic number. This value is valid whether footnotes are being |
| 4143 |
% set on the column width or the full text width. |
| 4144 |
% \begin{macrocode} |
| 4145 |
\gdef\thepagegrid{mlt}% |
| 4146 |
\global\pagegrid@col#1% |
| 4147 |
\global\pagegrid@cur\@ne |
| 4148 |
\global\count\footins\@m |
| 4149 |
\set@column@hsize\pagegrid@col |
| 4150 |
\set@colht |
| 4151 |
}% |
| 4152 |
% \end{macrocode} |
| 4153 |
% |
| 4154 |
% The procedure \cmd\shut@column@mlt\ ends the current column, balances the columns, and |
| 4155 |
% salts away all in \cmd\pagesofar. Because it is called in a message handler, |
| 4156 |
% we are assured that marks are handled properly. |
| 4157 |
% Attention: because this procedure balances columns, all footnotes are |
| 4158 |
% held aside in \cmd\footsofar\ for placement at the bottom of the page. |
| 4159 |
% |
| 4160 |
% Bug note: the last macro executed by this procedure is \cmd\set@colht, |
| 4161 |
% but had been erroneously \cmd\set@colroom. |
| 4162 |
% I now believe that the latter should be changed pretty much everywhere to the former. |
| 4163 |
% |
| 4164 |
% This instance of \cmd\@makecolumn\ is building material for \cmd\pagesofar, rather than |
| 4165 |
% for \cmd\shipout. |
| 4166 |
% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument} |
| 4167 |
% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument} |
| 4168 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 4169 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4170 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 4171 |
% \begin{macrocode} |
| 4172 |
\def\shut@column@mlt{% |
| 4173 |
\ltxgrid@info@sw{\class@info{\string\shut@column@mlt}}{}% |
| 4174 |
\@cclv@nontrivial@sw{% |
| 4175 |
\@makecolumn\false@sw |
| 4176 |
\@ifnum{\pagegrid@cur<\pagegrid@col}{% |
| 4177 |
\expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox |
| 4178 |
\global\advance\pagegrid@cur\@ne |
| 4179 |
}{}% |
| 4180 |
}{% |
| 4181 |
\void@cclv |
| 4182 |
}% |
| 4183 |
\@ifnum{\pagegrid@cur>\@ne}{% |
| 4184 |
\csname balance@\the\pagegrid@col\endcsname |
| 4185 |
\grid@column\@outputbox{}% |
| 4186 |
\@combinepage\false@sw |
| 4187 |
\@combinedblfloats |
| 4188 |
\global\setbox\pagesofar\box\@outputbox |
| 4189 |
\show@pagesofar@size |
| 4190 |
}{}% |
| 4191 |
\set@colht |
| 4192 |
}% |
| 4193 |
% \end{macrocode} |
| 4194 |
% |
| 4195 |
% The procedure \cmd\float@column@mlt\ takes care of a float page that has been built by \cmd\@tryfcolumn, |
| 4196 |
% in the multi-column page grid. It is coincidentally identical to what happens in |
| 4197 |
% \cmd\do@startpage\ when a page needs to be shipped out. |
| 4198 |
% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}} |
| 4199 |
% \begin{macrocode} |
| 4200 |
\def\float@column@mlt{% |
| 4201 |
\@output@combined@page |
| 4202 |
}% |
| 4203 |
% \end{macrocode} |
| 4204 |
% |
| 4205 |
% The procedure \cmd\end@column@mlt\ is executed at the end of \cmd\clearpage\ processing, |
| 4206 |
% if we were in a multi-column page grid, once all permissive float pages have been shipped out. |
| 4207 |
% If no floats are committed and if no columns are yet filled, we have nothing to do. |
| 4208 |
% Otherwise, we kick out a column and try again. |
| 4209 |
% |
| 4210 |
% Note that in our code to kick out a column, we must deal properly with the case where the column |
| 4211 |
% is trivial: it will have nothing but \cmd\topskip\ glue plus a protection box. We substitute an ordinary |
| 4212 |
% \cmd\null\ for the protection box. |
| 4213 |
% |
| 4214 |
% \begin{macrocode} |
| 4215 |
\def\end@column@mlt{% |
| 4216 |
\@ifx@empty\@toplist{% |
| 4217 |
\@ifx@empty\@botlist{% |
| 4218 |
\@ifx@empty\@dbltoplist{% |
| 4219 |
\@ifx@empty\@deferlist{% |
| 4220 |
\@ifnum{\pagegrid@cur=\@ne}{% |
| 4221 |
\false@sw |
| 4222 |
}{% |
| 4223 |
\true@sw |
| 4224 |
}% |
| 4225 |
}{% |
| 4226 |
\true@sw |
| 4227 |
}% |
| 4228 |
}{% |
| 4229 |
\true@sw |
| 4230 |
}% |
| 4231 |
}{% |
| 4232 |
\true@sw |
| 4233 |
}% |
| 4234 |
}{% |
| 4235 |
\true@sw |
| 4236 |
}% |
| 4237 |
% true = kick out a column and try again |
| 4238 |
{% |
| 4239 |
\@cclv@nontrivial@sw{% |
| 4240 |
\unvbox\@cclv\remove@lastbox |
| 4241 |
}{% |
| 4242 |
\unvbox\@cclv\remove@lastbox\unskip\null |
| 4243 |
}% |
| 4244 |
\protect@penalty\do@newpage@pen |
| 4245 |
\protect@penalty\do@endpage@pen |
| 4246 |
}{% |
| 4247 |
\unvbox\@cclv\remove@lastbox |
| 4248 |
}% |
| 4249 |
}% |
| 4250 |
% \end{macrocode} |
| 4251 |
% |
| 4252 |
% The procedure \cmd\output@column@mlt (cf. \cmd\output@column@one) |
| 4253 |
% is dispatched from the output routine when |
| 4254 |
% we have completed a column in a multi-column page grid). |
| 4255 |
% (It replaces the \cmd\@outputdblcol\ of standard \LaTeX.) |
| 4256 |
% If a complete set of columns is at hand, it ships out the page and |
| 4257 |
% lays down an interrupt for \cmd\do@startpage@pen, which will commit the |
| 4258 |
% full-page-width floats to the next page. |
| 4259 |
% Like \cmd\output@column@mlt, this is followed by |
| 4260 |
% an output routine message to prepare a new column. |
| 4261 |
% |
| 4262 |
% If a page needs to be shipped out, it uses the same mechanism as \cmd\do@startpage. |
| 4263 |
% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}} |
| 4264 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 4265 |
% \begin{macrocode} |
| 4266 |
\def\output@column@mlt{% |
| 4267 |
\@ifnum{\pagegrid@cur<\pagegrid@col}{% |
| 4268 |
\expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox |
| 4269 |
\global\advance\pagegrid@cur\@ne |
| 4270 |
}{% |
| 4271 |
\set@adj@colht\dimen@ |
| 4272 |
\grid@column\@outputbox{}% |
| 4273 |
\@output@combined@page |
| 4274 |
}% |
| 4275 |
}% |
| 4276 |
% \end{macrocode} |
| 4277 |
% The procedure \cmd\output@column@mlt\ obsoletes \LaTeX's \cmd\@outputdblcol |
| 4278 |
% \begin{macrocode} |
| 4279 |
\let\@outputdblcol\@undefined |
| 4280 |
% \end{macrocode} |
| 4281 |
% |
| 4282 |
% The following procedure yields a Boolean value; it determines whether a float in the deferred queue |
| 4283 |
% is appropriate for placement in the column. In the multi-column grid, only those narrower than \cmd\textwidth\ are so. |
| 4284 |
% \begin{macrocode} |
| 4285 |
\def\@floatselect@sw@mlt#1{\@if@notdblfloat{#1}}% |
| 4286 |
% \end{macrocode} |
| 4287 |
% |
| 4288 |
% The following procedure determines which side of the page a marginpar will appear. |
| 4289 |
% It reproduces the behavior of standard \LaTeX. |
| 4290 |
% \begin{macrocode} |
| 4291 |
\def\@addmarginpar@mlt{% emits a boolean |
| 4292 |
\@ifnum{\pagegrid@cur=\@ne}% |
| 4293 |
}% |
| 4294 |
% \end{macrocode} |
| 4295 |
% |
| 4296 |
% \cmd\set@footnotewidth@one\ sets the width of type within footnotes to span the full text width; |
| 4297 |
% \cmd\set@footnotewidth@two\ to span a single column of the two-column grid, and |
| 4298 |
% more generally \cmd\set@footnotewidth@mlt\ for a multi-column page grid. |
| 4299 |
% \begin{macrocode} |
| 4300 |
\def\set@footnotewidth@one{% |
| 4301 |
\hsize\columnwidth |
| 4302 |
\linewidth\hsize |
| 4303 |
}% |
| 4304 |
\def\set@footnotewidth@two{\set@footnotewidth@mlt\tw@}% |
| 4305 |
\def\set@footnotewidth@mlt#1{% |
| 4306 |
\hsize\textwidth |
| 4307 |
\advance\hsize\columnsep |
| 4308 |
\divide\hsize#1% |
| 4309 |
\advance\hsize-\columnsep |
| 4310 |
\linewidth\hsize |
| 4311 |
}% |
| 4312 |
% \end{macrocode} |
| 4313 |
% |
| 4314 |
% \cmd\compose@footnotes\ is the procedure for arranging the footnotes for |
| 4315 |
% placement at the bottom of the page or column. |
| 4316 |
% In the former case, the material will be shipped out; in the latter, we must allow |
| 4317 |
% the column to possibly be balanced later on. |
| 4318 |
% |
| 4319 |
% \cmd\compose@footnotes@one\ is a no-op, because the footnotes require no rearrangement. |
| 4320 |
% In a scheme where footnotes are set on the full text width, this would be the procedure called. |
| 4321 |
% |
| 4322 |
% \cmd\compose@footnotes@two\ implements the case where a two-column document has been interrupted |
| 4323 |
% with full-page-width text (e.g., the widetext environment or the end of the document), |
| 4324 |
% and a natural page break appears. |
| 4325 |
% |
| 4326 |
% In either case, we assume that argument \verb+#1+ is an \cmd\insert\ register and must be assigned globally, |
| 4327 |
% so that when it is accessed with \cmd\box\ or \cmd\unvbox, it will be voided globally as well. |
| 4328 |
% |
| 4329 |
% To extend this scheme to a three-column page grid \cmd\compose@footnotes@thr@@\ would be created: |
| 4330 |
% it would balance the saved up footnotes into three columns. |
| 4331 |
% |
| 4332 |
% \begin{macrocode} |
| 4333 |
\def\compose@footnotes@one#1{% |
| 4334 |
\ltxgrid@foot@info@sw{\class@info{\string\compose@footnotes@one\string#1}\trace@box#1}{}% |
| 4335 |
}% |
| 4336 |
\let\compose@footnotes\compose@footnotes@one |
| 4337 |
\def\compose@footnotes@two#1{% |
| 4338 |
\ltxgrid@foot@info@sw{\class@info{\string\compose@footnotes@two\string#1}\trace@box#1}{}% |
| 4339 |
\setbox\z@\box\@tempboxa |
| 4340 |
\let\recover@column\recover@column@null |
| 4341 |
\let\marry@baselines\@empty |
| 4342 |
\balance@two#1\@tempboxa |
| 4343 |
\global\setbox#1\hbox to\textwidth{\box#1\hfil\box\@tempboxa}% |
| 4344 |
\ltxgrid@foot@info@sw{\trace@box#1}{}% |
| 4345 |
}% |
| 4346 |
% \end{macrocode} |
| 4347 |
% \end{macro} |
| 4348 |
% \end{macro} |
| 4349 |
% \end{macro} |
| 4350 |
% \end{macro} |
| 4351 |
% \end{macro} |
| 4352 |
% \end{macro} |
| 4353 |
% \end{macro} |
| 4354 |
% \end{macro} |
| 4355 |
% |
| 4356 |
% |
| 4357 |
% \subsubsection{Page grid utility procedures} |
| 4358 |
% |
| 4359 |
% \begin{macro}{\pagegrid@cur} |
| 4360 |
% \begin{macro}{\pagegrid@col} |
| 4361 |
% \begin{macro}{\pagegrid@init} |
| 4362 |
% We take over \LaTeX's \cmd\col@number, and \cmd\@leftcolumn, which are obsolete (\cmd\@holdpg\ could also be taken over). |
| 4363 |
% We create two counters to hold the columns in the page grid and the current column within. |
| 4364 |
% We also create the first of a set of box registers to hold the committted columns. |
| 4365 |
% \begin{macrocode} |
| 4366 |
\let\pagegrid@cur\col@number |
| 4367 |
\let\col@number\@undefined |
| 4368 |
\newcount\pagegrid@col |
| 4369 |
\pagegrid@cur\@ne |
| 4370 |
\expandafter\let\csname col@\the\pagegrid@cur\endcsname\@leftcolumn |
| 4371 |
\let\@leftcolumn\@undefined |
| 4372 |
% \end{macrocode} |
| 4373 |
% |
| 4374 |
% The default is for maximum two columns. |
| 4375 |
% If your class will require more columns, assign that number to \cmd\pagegrid@col\ |
| 4376 |
% before \envb{document} time. |
| 4377 |
% \begin{macrocode} |
| 4378 |
\pagegrid@col\tw@ |
| 4379 |
% \end{macrocode} |
| 4380 |
% |
| 4381 |
% The procedure \cmd\pagegrid@init\ is a loop, exercising \cmd\newbox\ sufficiently to create the |
| 4382 |
% boxes for holding the columns in the page grid; these have names like \expandafter\cmd\csname col@1\endcsname, etc. |
| 4383 |
% \begin{macrocode} |
| 4384 |
\def\pagegrid@init{% |
| 4385 |
\advance\pagegrid@cur\@ne |
| 4386 |
\@ifnum{\pagegrid@cur<\pagegrid@col}{% |
| 4387 |
\csname newbox\expandafter\endcsname\csname col@\the\pagegrid@cur\endcsname |
| 4388 |
\pagegrid@init |
| 4389 |
}{% |
| 4390 |
}% |
| 4391 |
}% |
| 4392 |
\appdef\class@documenthook{% |
| 4393 |
\pagegrid@init |
| 4394 |
}% |
| 4395 |
% \end{macrocode} |
| 4396 |
% \end{macro} |
| 4397 |
% \end{macro} |
| 4398 |
% \end{macro} |
| 4399 |
% |
| 4400 |
% \begin{macro}{\grid@column} |
| 4401 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 4402 |
% The procedure \cmd\grid@column\ knows how to lay up the columns in a multi-column page grid. |
| 4403 |
% It uses utility procedures \cmd\append@column@\ and \cmd\box@column. |
| 4404 |
% |
| 4405 |
% The first argument is the box register to create, usually \cmd\@outputbox, and provides both input and output. |
| 4406 |
% The second argument a dimension, allowing us to strut down the depth of the box we create. |
| 4407 |
% |
| 4408 |
% \begin{macrocode} |
| 4409 |
\def\grid@column#1#2{% |
| 4410 |
\ltxgrid@info@sw{\class@info{\string\grid@column\string#1}}{}% |
| 4411 |
\global\setbox#1\vbox\bgroup |
| 4412 |
\hb@xt@\textwidth\bgroup |
| 4413 |
\vrule\@height\z@\@width\z@\@if@empty{#2}{}{\@depth#2}% |
| 4414 |
\pagegrid@cur\@ne |
| 4415 |
\@ifnum{\pagegrid@cur<\pagegrid@col}{\loopwhile{\append@column@\pagegrid@cur\pagegrid@col}}{}% |
| 4416 |
\box@column#1% |
| 4417 |
\egroup |
| 4418 |
% \end{macrocode} |
| 4419 |
% FIXME: page depth! |
| 4420 |
% \begin{macrocode} |
| 4421 |
\vskip\z@skip |
| 4422 |
\egroup |
| 4423 |
}% |
| 4424 |
% \end{macrocode} |
| 4425 |
% \end{macro} |
| 4426 |
% |
| 4427 |
% \begin{macro}{\append@column@} |
| 4428 |
% \begin{macro}{\box@column} |
| 4429 |
% \begin{macro}{\marry@baselines} |
| 4430 |
% The procedure \cmd\append@column@\ appends columns for \cmd\grid@column, |
| 4431 |
% \cmd\box@column\ builds the columns for \cmd\append@column@, |
| 4432 |
% and \cmd\marry@baselines\ pastes vertical things back together. |
| 4433 |
% \changes{4.0a}{2001/06/18}{Introduce \cs{marry@height} } |
| 4434 |
% |
| 4435 |
% Note that \cmd\box@column\ makes an attempt to prevent excessive \cmd\topskip\ |
| 4436 |
% or \cmd\baselineskip\ glue |
| 4437 |
% from being applied by \TeX\ when \cmd\@outputbox\ is contributed to the MVL. |
| 4438 |
% If this is not done, it is possible to get into an infinite loop in the corner case, |
| 4439 |
% wherein the page grid is changed to one column and the balanced-up columns are |
| 4440 |
% already sufficient to fill the page. |
| 4441 |
% |
| 4442 |
% Note (AO 0920): I have changed the dimension involved with \cmd\box@column\ from |
| 4443 |
% \cmd\vsize\ to \cmd\textheight, because the former is certainly not the correct value |
| 4444 |
% to use: it will change if floats have been placed in the last column of the page. |
| 4445 |
% I believe \cmd\textheight\ is the correct parameter to use here. |
| 4446 |
% |
| 4447 |
% A REVTeX4 user, Sergey Strelkov ([email protected]), wants the option |
| 4448 |
% of ragged-bottom columns. Implementing this feature properly means reboxing the |
| 4449 |
% columns to their natural height only if \cmd\raggedcolumn@sw\ is true. |
| 4450 |
% Otherwise, they get reboxed to their common height (\cmd\@colht?). |
| 4451 |
% |
| 4452 |
% Note that the default has hereby changed from ragged to flush. |
| 4453 |
% It's not clear that anyone but Sergey will notice. |
| 4454 |
% |
| 4455 |
% The macro \cmd\marry@skip\ addresses (in a limited way) |
| 4456 |
% the fact that neither the value of \cmd\baselineskip\ nor that of \cmd\topskip\ |
| 4457 |
% can be relied upon for the purpose of marrying the baselines of two split columns. |
| 4458 |
% (Because there might have been a local change to their values at the point where |
| 4459 |
% the output routine got triggered.) |
| 4460 |
% |
| 4461 |
% For best results, your document class should call for grid changes only when in basal text |
| 4462 |
% settings. The \cmd\marry@baselines\ procedure will use the values appropriate to that point |
| 4463 |
% when attempting to put the columns back together. |
| 4464 |
% |
| 4465 |
% In any case, we are not attempting to solve the more general problem of how to marry baselines |
| 4466 |
% where the leading can change arbitrarily within the galley or where glue could have been trimmed |
| 4467 |
% at a page top. |
| 4468 |
% |
| 4469 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 4470 |
% Procedure \cmd\append@column@\ composes a column onto the horizontal list along with its \cmd\columnseprule. |
| 4471 |
% Its arguments are: \verb+#1+---\cmd\pagegrid@cur, and \verb+#2+---\cmd\pagegrid@col |
| 4472 |
% \begin{macrocode} |
| 4473 |
\def\append@column@#1#2{% |
| 4474 |
\expandafter\box@column\csname col@\the#1\endcsname |
| 4475 |
\hfil\vrule\@width\columnseprule\hfil |
| 4476 |
\advance#1\@ne |
| 4477 |
% \end{macrocode} |
| 4478 |
% This procedure is the argument of \cmd\loopwhile, so it must leave a Boolean (e.g., \cmd\true@sw) in \TeX's scanner. |
| 4479 |
% \begin{macrocode} |
| 4480 |
\@ifnum{#1<#2}% |
| 4481 |
}% |
| 4482 |
% \end{macrocode} |
| 4483 |
% \changes{4.1n}{2010/01/02}{(AO, 571) calling sequence of \cs{combine@foot@inserts} and \cs{grid@column} to expose box registers; that of \cs{append@column@} its column counters}% |
| 4484 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4485 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 4486 |
% Procdure \cmd\box@column, used by \cmd\append@column@, puts down a box containing the specified column. |
| 4487 |
% Its height is adjusted down to \cmd\@colht, if needed; likewise, the width is set to \cmd\columnwidth. |
| 4488 |
% The rag at the bottom is controlled by \cmd\raggedcolumn@skip. |
| 4489 |
% \begin{macrocode} |
| 4490 |
\def\box@column#1{% |
| 4491 |
\ltxgrid@info@sw{\class@info{\string\box@column\string#1}}{}% |
| 4492 |
\raise\topskip |
| 4493 |
\hb@xt@\columnwidth\bgroup |
| 4494 |
\dimen@\ht#1\@ifdim{\dimen@>\@colht}{\dimen@\@colht}{}% |
| 4495 |
\count@\vbadness\vbadness\@M |
| 4496 |
\dimen@ii\vfuzz\vfuzz\maxdimen |
| 4497 |
\ltxgrid@info@sw{\saythe\@colht\saythe\dimen@}{}% |
| 4498 |
\vtop to\dimen@\bgroup |
| 4499 |
\hrule\@height\z@ |
| 4500 |
\unvbox#1% |
| 4501 |
\raggedcolumn@skip |
| 4502 |
\egroup |
| 4503 |
\vfuzz\dimen@ii |
| 4504 |
\vbadness\count@ |
| 4505 |
\hss |
| 4506 |
\egroup |
| 4507 |
}% |
| 4508 |
% \end{macrocode} |
| 4509 |
% The purpose of procedure \cmd\marry@baselines\ is to ensure that the baseline spacing is correct; |
| 4510 |
% it does this by making adjustments to the previous line, compensating for its depth, and by adding in |
| 4511 |
% skip glue in an amount that assumes the added material has \cmd\topskip\ glue above. |
| 4512 |
% \begin{macrocode} |
| 4513 |
\def\marry@baselines{% |
| 4514 |
\begingroup |
| 4515 |
\setbox\z@\lastbox |
| 4516 |
\@ifvoid{\z@}{% |
| 4517 |
\endgroup |
| 4518 |
}{% |
| 4519 |
\aftergroup\kern |
| 4520 |
\aftergroup-% |
| 4521 |
\expandafter\box\expandafter\z@\expandafter\endgroup\the\dp\z@\relax |
| 4522 |
}% |
| 4523 |
\vskip\marry@skip\relax |
| 4524 |
}% |
| 4525 |
\gdef\marry@skip{\z@skip}% |
| 4526 |
\def\set@marry@skip{% |
| 4527 |
\begingroup |
| 4528 |
\skip@\baselineskip\advance\skip@-\topskip |
| 4529 |
\@ifdim{\skip@>\z@}{% |
| 4530 |
\xdef\marry@skip{\the\skip@}% |
| 4531 |
}{}% |
| 4532 |
\endgroup |
| 4533 |
}% |
| 4534 |
% \end{macrocode} |
| 4535 |
% \changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}} |
| 4536 |
% \begin{macrocode} |
| 4537 |
\appdef\document@inithook{% |
| 4538 |
\@ifxundefined\raggedcolumn@sw{\@booleanfalse\raggedcolumn@sw}{}% |
| 4539 |
}% |
| 4540 |
\def\raggedcolumn@skip{% |
| 4541 |
\vskip\z@\raggedcolumn@sw{\@plus.0001fil\@minus.0001fil}{}\relax |
| 4542 |
}% |
| 4543 |
% \end{macrocode} |
| 4544 |
% \end{macro} |
| 4545 |
% \end{macro} |
| 4546 |
% \end{macro} |
| 4547 |
% |
| 4548 |
% \begin{macro}{\@combinepage} |
| 4549 |
% The procedure \cmd\@combinepage\ prepends the stored page (\cmd\pagesofar) to \cmd\@outputbox\ and |
| 4550 |
% employs \cmd\@combineinserts\ to lay down the footnotes. |
| 4551 |
% The next event will usually be shipping out the made-up page, but not always. |
| 4552 |
% Therefore the argument of \cmd\@combinepage, which must be a Boolean, determines |
| 4553 |
% if the footnotes are to be combined into this page. |
| 4554 |
% |
| 4555 |
% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument} |
| 4556 |
% \changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.} |
| 4557 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4558 |
% |
| 4559 |
% QUERY: In the following, if \cmd\box\cmd\footins\ is not void, its contents are lost. Can this ever happen? |
| 4560 |
% \begin{macrocode} |
| 4561 |
\def\@combinepage#1{% |
| 4562 |
\ltxgrid@foot@info@sw{\class@info{\string\@combinepage\string#1}}{}% |
| 4563 |
\@ifvoid\pagesofar{}{% |
| 4564 |
\setbox\@outputbox\vbox{% |
| 4565 |
\unvbox\pagesofar |
| 4566 |
\marry@baselines |
| 4567 |
\unvbox\@outputbox |
| 4568 |
}% |
| 4569 |
}% |
| 4570 |
#1{% |
| 4571 |
\@ifvoid\footsofar{}{% |
| 4572 |
% \end{macrocode} |
| 4573 |
% At this point, \cmd\footins\ is empty; all of the footnotes have been combined into \cmd\footsofar. |
| 4574 |
% \begin{macrocode} |
| 4575 |
\show@box@size{Combining page footnotes}\footsofar |
| 4576 |
\setbox\footins\box\footsofar |
| 4577 |
% \end{macrocode} |
| 4578 |
% Depending on the page grid, we compose the footnotes for placement on the page. |
| 4579 |
% \begin{macrocode} |
| 4580 |
\compose@footnotes |
| 4581 |
\@combineinserts\@outputbox\footins |
| 4582 |
}% |
| 4583 |
}{% |
| 4584 |
% \end{macrocode} |
| 4585 |
%QUERY: The following line was removed, probably to fix a bug. When was this done? |
| 4586 |
% \begin{verbatim} |
| 4587 |
% \global\setbox\footins\box\footsofar |
| 4588 |
% \end{verbatim} |
| 4589 |
% \begin{macrocode} |
| 4590 |
}% |
| 4591 |
}% |
| 4592 |
% \end{macrocode} |
| 4593 |
% \end{macro} |
| 4594 |
% |
| 4595 |
% \begin{macro}{\@cflt} |
| 4596 |
% \begin{macro}{\@cflb} |
| 4597 |
% \changes{4.1b}{2008/08/04}{} |
| 4598 |
% We modify \LaTeX's \cmd\@cflt\ and \cmd\@cflb\ to remove the unwanted glue with \cmd\unskip. |
| 4599 |
% \begin{macrocode} |
| 4600 |
\def \@cflt{% |
| 4601 |
\let \@elt \@comflelt |
| 4602 |
\setbox\@tempboxa \vbox{}% |
| 4603 |
\@toplist |
| 4604 |
\setbox\@outputbox \vbox{% |
| 4605 |
\boxmaxdepth \maxdepth |
| 4606 |
\unvbox\@tempboxa\unskip |
| 4607 |
\topfigrule\vskip \textfloatsep |
| 4608 |
\unvbox\@outputbox |
| 4609 |
}% |
| 4610 |
\let\@elt\relax |
| 4611 |
\xdef\@freelist{\@freelist\@toplist}% |
| 4612 |
\global\let\@toplist\@empty |
| 4613 |
}% |
| 4614 |
\def \@cflb {% |
| 4615 |
\let\@elt\@comflelt |
| 4616 |
\setbox\@tempboxa \vbox{}% |
| 4617 |
\@botlist |
| 4618 |
\setbox\@outputbox \vbox{% |
| 4619 |
\unvbox\@outputbox |
| 4620 |
\vskip \textfloatsep\botfigrule |
| 4621 |
\unvbox\@tempboxa\unskip |
| 4622 |
}% |
| 4623 |
\let\@elt\relax |
| 4624 |
\xdef\@freelist{\@freelist\@botlist}% |
| 4625 |
\global \let \@botlist\@empty |
| 4626 |
}% |
| 4627 |
% \end{macrocode} |
| 4628 |
% \end{macro} |
| 4629 |
% \end{macro} |
| 4630 |
% |
| 4631 |
% \begin{macro}{\@combinedblfloats} |
| 4632 |
% We modify \LaTeX's \cmd\@combinedblfloats\ to be more appropriate for incremental page building: |
| 4633 |
% we \cmd\unvbox\ the \cmd\@outputbox. |
| 4634 |
% \begin{macrocode} |
| 4635 |
\def\@combinedblfloats{% |
| 4636 |
\@ifx@empty\@dbltoplist{}{% |
| 4637 |
\setbox\@tempboxa\vbox{}% |
| 4638 |
\let\@elt\@comdblflelt\@dbltoplist |
| 4639 |
\let\@elt\relax\xdef\@freelist{\@freelist\@dbltoplist}% |
| 4640 |
\global\let\@dbltoplist\@empty |
| 4641 |
\setbox\@outputbox\vbox{% |
| 4642 |
%\boxmaxdepth\maxdepth %% probably not needed, CAR |
| 4643 |
\unvbox\@tempboxa\unskip |
| 4644 |
\@ifnum{\@dbltopnum>\m@ne}{\dblfigrule}{}%FIXME: how is \@dbltopnum maintained? |
| 4645 |
\vskip\dbltextfloatsep |
| 4646 |
\unvbox\@outputbox |
| 4647 |
}% |
| 4648 |
}% |
| 4649 |
}% |
| 4650 |
% \end{macrocode} |
| 4651 |
% \end{macro} |
| 4652 |
% |
| 4653 |
% \begin{macro}{\set@column@hsize}% |
| 4654 |
% The procedure \cmd\set@column@hsize\ takes care of setting up the horizontal dimensions |
| 4655 |
% for the current page grid. The present routine will certainly not be adequate for more |
| 4656 |
% complex page layouts (e.g., with a side column), but works for the common ones. |
| 4657 |
% \changes{4.0a}{2001/06/18}{Introduce \cs{set@marry@height} } |
| 4658 |
% \begin{macrocode} |
| 4659 |
\def\set@column@hsize#1{% |
| 4660 |
\pagegrid@col#1% |
| 4661 |
\global\columnwidth\textwidth |
| 4662 |
\global\advance\columnwidth\columnsep |
| 4663 |
\global\divide\columnwidth\pagegrid@col |
| 4664 |
\global\advance\columnwidth-\columnsep |
| 4665 |
\global\hsize\columnwidth |
| 4666 |
\global\linewidth\columnwidth |
| 4667 |
\skip@\baselineskip\advance\skip@-\topskip |
| 4668 |
\@ifnum{\pagegrid@col>\@ne}{\set@marry@skip}{}% |
| 4669 |
}% |
| 4670 |
% \end{macrocode} |
| 4671 |
% \end{macro} |
| 4672 |
% |
| 4673 |
% \begin{macro}{\set@colht}% |
| 4674 |
% \begin{macro}{\set@colroom}% |
| 4675 |
% \begin{macro}{\set@vsize}% |
| 4676 |
% \begin{macro}{\set@adj@colht}% |
| 4677 |
% The story of \cmd\textheight, \cmd\@colht, \cmd\@colroom, and \cmd\vsize. |
| 4678 |
% |
| 4679 |
% \cmd\textheight---height of the text column. Not a running parameter, however, each time a page is |
| 4680 |
% shipped out, the \cmd\textheight\ could in principle be altered. This must be done before |
| 4681 |
% |
| 4682 |
% \cmd\@colht---\cmd\textheight\ minus the height of any full-page-width floats. The latter are committed |
| 4683 |
% only just after shipping out, and only if we are in a multicolumn page grid. |
| 4684 |
% Therefore, \cmd\@colht\ should be set after a \cmd\shipout\ (by \cmd\@outputpage) and |
| 4685 |
% will be adjusted when full-page-width floats are committed to the fresh page by \cmd\do@startpage. |
| 4686 |
% |
| 4687 |
% \cmd\@colroom---\cmd\@colht\ (adjusted by \cmd\pagesofar) minus the height of any column-width floats. |
| 4688 |
% The latter are committed anywhere on the page, at which point \cmd\@colroom\ must be adjusted. |
| 4689 |
% Therefore, \cmd\@colroom\ should be set (by \cmd\set@colroom) whenever a column is prepared (by ). |
| 4690 |
%FIXME: committed (by \cmd\output@column@) and |
| 4691 |
% will be adjusted (by \cmd\@add@float\ or \cmd\do@startcolumn) whenever a float is committted to the column. |
| 4692 |
% |
| 4693 |
% \cmd\vsize---\cmd\@colroom. |
| 4694 |
% Therefore, \cmd\vsize\ should be set (by \cmd\set@vsize) whenever |
| 4695 |
% the \cmd\@colroom\ is set (by \cmd\set@colroom) or adjusted (by \cmd\@add@float\ or \cmd\do@startcolumn) |
| 4696 |
%FIXME: or when the \cmd\pagesofar\ box is changed (after invoking \cmd\open@column@). |
| 4697 |
% |
| 4698 |
% Question: what if there are committed floats? Footnotes? |
| 4699 |
% Answer: full-page-width floats are only committed at top, and they are already reckoned with in \cmd\@colht. |
| 4700 |
% Column-width committed floats are incorporated by \cmd\@makecolumn. |
| 4701 |
% |
| 4702 |
% As to footnotes, our scheme is to keep the \cmd\footins\ insert register up to date, and to use the insert mechanism |
| 4703 |
% to ensure room for footnotes. |
| 4704 |
% When a change is made to the page grid, the footnotes will need to be propagated back into the MVL. |
| 4705 |
% |
| 4706 |
% Note: FIXME: adjusting for \cmd\pagesofar\ is done at not quite the right time. I need to reexamine \cmd\set@colht, |
| 4707 |
% because \cmd\@dbltoplist\ and \cmd\pagesofar\ really should be on the same footing. |
| 4708 |
% Perhaps \cmd\@colht\ and \cmd\@colroom\ should both deal with their respective ``lists'' in the same way? |
| 4709 |
% |
| 4710 |
% These concerns will be particularly germane if we ever extend this package to deal with full-page-width floats |
| 4711 |
% placed at the bottom of the page, or committed on the same page as called out. |
| 4712 |
% |
| 4713 |
% It occurs to me that we should ditch \cmd\set@colroom\ and only ever execute \cmd\set@colht, |
| 4714 |
% which sets \cmd\@colroom\ as a side effect. |
| 4715 |
% If so, we can make \cmd\@colht\ take \cmd\pagesofar\ into account, as it should. Then \cmd\@colht\ will return to its |
| 4716 |
% original significance as the value that \cmd\@colroom\ is set to after a column is committed. |
| 4717 |
% |
| 4718 |
% On the other hand, why not simply forget all this caching and (re-)calculate \cmd\vsize\ as late as possible? |
| 4719 |
% Particularly, \cmd\@colht\ is an artifact of the old way of doing things, where once it was set, it would never change. |
| 4720 |
% |
| 4721 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4722 |
% \begin{macrocode} |
| 4723 |
\def\set@colht{% |
| 4724 |
\set@adj@textheight\@colht |
| 4725 |
\global\let\enlarge@colroom\@empty |
| 4726 |
\set@colroom |
| 4727 |
}% |
| 4728 |
\def\set@adj@textheight#1{% |
| 4729 |
\ltxgrid@info@sw{\class@info{\string\set@adj@textheight\string#1}\saythe\textheight}{}% |
| 4730 |
#1\textheight |
| 4731 |
\def\@elt{\adj@page#1}% |
| 4732 |
\@booleantrue\firsttime@sw\@dbltoplist |
| 4733 |
\let\@elt\relax |
| 4734 |
\global#1#1\relax |
| 4735 |
\ltxgrid@info@sw{\saythe#1}{}% |
| 4736 |
}% |
| 4737 |
\def\set@colroom{% |
| 4738 |
\ltxgrid@info@sw{\class@info{\string\set@colroom}}{}% |
| 4739 |
\set@adj@colht\@colroom |
| 4740 |
\@if@empty\enlarge@colroom{}{% |
| 4741 |
\global\advance\@colroom\enlarge@colroom\relax |
| 4742 |
\ltxgrid@info@sw{\saythe\@colroom}{}% |
| 4743 |
}% |
| 4744 |
\@ifdim{\@colroom>\topskip}{}{% |
| 4745 |
\ltxgrid@info{Not enough room: \string\@colroom=\the\@colroom; increasing to \the\topskip}% |
| 4746 |
\@colroom\topskip |
| 4747 |
}% |
| 4748 |
\global\@colroom\@colroom |
| 4749 |
%<ignore> \ltxgrid@info@sw{\class@info{\string\set@colroom\string\vsize=\string\colroom}\saythe\vsize}{}% |
| 4750 |
\set@vsize |
| 4751 |
}% |
| 4752 |
% |
| 4753 |
\def\set@vsize{% |
| 4754 |
\global\vsize\@colroom |
| 4755 |
\ltxgrid@info@sw{\class@info{\string\set@vsize\string\vsize=\string\colroom}\saythe\vsize}{}% |
| 4756 |
}% |
| 4757 |
% \end{macrocode} |
| 4758 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4759 |
% \begin{macrocode} |
| 4760 |
\def\set@adj@colht#1{% |
| 4761 |
#1\@colht |
| 4762 |
\ltxgrid@info@sw{\class@info{\string\set@adj@colht\string#1-\string\pagesofar}\saythe#1}{}% |
| 4763 |
\@ifvoid\pagesofar{}{% |
| 4764 |
\advance#1-\ht\pagesofar\advance#1-\dp\pagesofar |
| 4765 |
\ltxgrid@info@sw{\class@info{\string\pagesofar}\saythe#1}{}% |
| 4766 |
}% |
| 4767 |
\def\@elt{\adj@column#1}% |
| 4768 |
\@booleantrue\firsttime@sw\@toplist |
| 4769 |
\@booleantrue\firsttime@sw\@botlist |
| 4770 |
\let\@elt\relax |
| 4771 |
}% |
| 4772 |
\def\adj@column#1#2{% |
| 4773 |
\advance#1-\ht#2% |
| 4774 |
\advance#1-\firsttime@sw{\textfloatsep\@booleanfalse\firsttime@sw}{\floatsep}% |
| 4775 |
\ltxgrid@info@sw{\class@info{\string\adj@column\string#1-\string#2}\saythe#1}{}% |
| 4776 |
}% |
| 4777 |
\def\adj@page#1#2{% |
| 4778 |
\advance#1-\ht#2% |
| 4779 |
\advance#1-\firsttime@sw{\dbltextfloatsep\@booleanfalse\firsttime@sw}{\dblfloatsep}% |
| 4780 |
\ltxgrid@info@sw{\class@info{\string\adj@page\string#1-\string#2}\saythe#1}{}% |
| 4781 |
}% |
| 4782 |
\def\set@adj@box#1#2{% |
| 4783 |
\@ifvoid#2{}{% |
| 4784 |
\advance#1-\ht#2\advance#1-\dp#2% |
| 4785 |
\@booleantrue\temp@sw |
| 4786 |
\ltxgrid@foot@info@sw{\class@info{\string\set@adj@box\string#2}\saythe#1}{}% |
| 4787 |
}% |
| 4788 |
}% |
| 4789 |
% \end{macrocode} |
| 4790 |
% \end{macro} |
| 4791 |
% \end{macro} |
| 4792 |
% \end{macro} |
| 4793 |
% \end{macro} |
| 4794 |
% |
| 4795 |
% \begin{macro}{\@outputpage@tail}% |
| 4796 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}% |
| 4797 |
% In \cmd\@outputpage@tail, we set \cmd\@colht\ and the float placement parameters |
| 4798 |
% (this is the one point where it is appropriate to set \cmd\@colht). |
| 4799 |
% At \cmd\do@startpage\ time, we adjust \cmd\@colht's value to reflect committed |
| 4800 |
% full-page-width floats. |
| 4801 |
% |
| 4802 |
% Note: with a correctly written output routine, a call to \cmd\@outputpage\ will inevitably be |
| 4803 |
% followed by a call to \cmd\do@startpage, so these procedure calls would be unneeded. |
| 4804 |
% \begin{macrocode} |
| 4805 |
\appdef\@outputpage@tail{% |
| 4806 |
\set@colht % FIXME: needed? |
| 4807 |
\@floatplacement % FIXME: needed? |
| 4808 |
\@dblfloatplacement % FIXME: needed? |
| 4809 |
}% |
| 4810 |
% \end{macrocode} |
| 4811 |
% \end{macro} |
| 4812 |
% |
| 4813 |
% \begin{macro}{balance@2} |
| 4814 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{balance@2} defined more transparently}% |
| 4815 |
% We define procedures for balancing columns in a multicolumn layout. |
| 4816 |
% For now, we define only one: a procedure for the two-column grid. |
| 4817 |
% All others will simply \cmd\relax\ out. |
| 4818 |
% |
| 4819 |
% The following code defines \verb+\balance@2+ without all the clunky \cmd\csname\ commands |
| 4820 |
% in the replacement part, |
| 4821 |
% which appears on the right-hand side of the assignment to \cmd\toks@. |
| 4822 |
% |
| 4823 |
% The method is straightforward: balance the two columns of text, and balance the footnotes. |
| 4824 |
% Later on, \cmd\@combineinserts\ will be called to place the footnotes after the now-balanced columns. |
| 4825 |
% |
| 4826 |
% \changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated} |
| 4827 |
% It was necessary to deal with the case where \cmd\box\cmd\footsofar\ was not empty |
| 4828 |
% upon execution of this balancing code. We store it away in \cmd\box\cmd\footins\ and |
| 4829 |
% add it back in afterwards. |
| 4830 |
% |
| 4831 |
% Here is a conundrum: if we switch between single-, two-, and three-column page grids: |
| 4832 |
% On what measure should the footnotes be set? |
| 4833 |
% \begin{macrocode} |
| 4834 |
\begingroup |
| 4835 |
\catcode`\1=\cat@letter |
| 4836 |
\catcode`\2=\cat@letter |
| 4837 |
% \end{macrocode} |
| 4838 |
% \cmd\toks@\ contains the repacement part for an effective \cmd\def\cs{balance@2}. |
| 4839 |
% \begin{macrocode} |
| 4840 |
\toks@{% |
| 4841 |
% \end{macrocode} |
| 4842 |
% \cmd\balance@two, by side effect, strips footnotes into \cmd\box\cmd\footins. |
| 4843 |
% \begin{macrocode} |
| 4844 |
\setbox\footins\box\footsofar |
| 4845 |
\balance@two\col@1\@outputbox |
| 4846 |
% \end{macrocode} |
| 4847 |
% We ensure that the box assignments are global. |
| 4848 |
% \begin{macrocode} |
| 4849 |
\global\setbox\col@1\box\col@1 |
| 4850 |
\global\setbox\@outputbox\box\@outputbox |
| 4851 |
% \end{macrocode} |
| 4852 |
% The following line puts all footnotes into the footnote galley, \cmd\footsofar. |
| 4853 |
% \begin{macrocode} |
| 4854 |
\combine@foot@inserts\footsofar\footins |
| 4855 |
}% |
| 4856 |
\aftergroup\def\aftergroup\balance@2\expandafter |
| 4857 |
\endgroup\expandafter{\the\toks@}% |
| 4858 |
% \end{macrocode} |
| 4859 |
% \end{macro} |
| 4860 |
% |
| 4861 |
% \begin{macro}{\balance@two} |
| 4862 |
% The procedure \cmd\balance@two\ takes two columns and balances them; in the process it removes |
| 4863 |
% any footnotes that may be present to a place of safety \cmd\footsofar, |
| 4864 |
% for later placement at the foot of the shipped-out page. |
| 4865 |
% The box register \cmd\box\cmd\@ne\ is the aggregate of all columns. |
| 4866 |
% The box register \cmd\box\cmd \z@\ is the last column. |
| 4867 |
% The box register \cmd\box\cmd\tw@\ is the first column. |
| 4868 |
% The \cmd\dimen\ register \cmd\dimen@\ is the trial value to \cmd\vsplit\ to, |
| 4869 |
% initially half the height of \cmd\box\cmd\@ne. |
| 4870 |
% The \cmd\dimen\ register \cmd\dimen@i\ is the increment for the next trial; |
| 4871 |
% its initial value is equal to the initial value of \cmd\dimen@. |
| 4872 |
% The \cmd\dimen\ register \cmd\dimen@ii\ is the difference of the heights of the two columns. |
| 4873 |
% |
| 4874 |
% The procedure uses a binary search for that value of \cmd\dimen@\ which is stable to within .5\cmd\p@\ and which |
| 4875 |
% makes the last column be shorter than the others. |
| 4876 |
% |
| 4877 |
% This procedure can be extended to multiple columns simply by changing it to execute \cmd\vsplit\ multiple |
| 4878 |
% times (one less than the total number of columns in the page layout) and to calculating \cmd\dimen@ii\ |
| 4879 |
% to be the difference of the heights of last column and the \cmd\dimen@. |
| 4880 |
% Upon termination of the search, one would excute the \cmd\vsplit s once again, this time |
| 4881 |
% using the actual \cmd\col@\ box registers to store the |
| 4882 |
% balanced columns, thereby clobbering their former contents. |
| 4883 |
% |
| 4884 |
% Bug Note: |
| 4885 |
% as originally written, this macro had a bug, which is well worth avoiding under similar circumstances anywhere. |
| 4886 |
% So, learn from the mistakes of others, as they say. |
| 4887 |
% In trying to remove the depth of the boxes created via \cmd\vsplit\ within the \cmd\loopwhile\ control, |
| 4888 |
% I originally coded |
| 4889 |
% \cmd\unvbox |
| 4890 |
% \cmd\z@\ |
| 4891 |
% \cmd\setbox |
| 4892 |
% \cmd\z@ |
| 4893 |
% \cmd\lastbox\ |
| 4894 |
% \cmd\dimen@ |
| 4895 |
% \cmd\dp |
| 4896 |
% \cmd\z@\ |
| 4897 |
% \cmd\box |
| 4898 |
% \cmd\z@\ |
| 4899 |
% \cmd\vskip-% |
| 4900 |
% \cmd\dimen@. |
| 4901 |
% The error here is that the (horizontal) shift of the last box in the vertical list will be lost in the process. |
| 4902 |
% Simply put, \cmd\setbox\cmd\z@\cmd\lastbox\ fails to retain the shift of the box node in the vertical list, |
| 4903 |
% and when it is put down again via \cmd\box\cmd\z@, it will no longer have the correct shift. |
| 4904 |
% |
| 4905 |
% This bug affected things placed in the MVL with \cmd\moveleft, \cmd\moveright, \cmd\parshape, and |
| 4906 |
% \cmd\hangindent, as well as things shifted by \TeX's primitive mechanisms. |
| 4907 |
% |
| 4908 |
% A superior strategy for removing the depth of the last line of the list is more expensive, but safer: |
| 4909 |
% make a separate copy of the list, measure the depth of the last box as above, but then discard |
| 4910 |
% the list, retaining only the value of the dimension. |
| 4911 |
% |
| 4912 |
% Note that this procedure will not work if the material within is excessively chunky. |
| 4913 |
% A particular failure mode exists where none of the material is allocated to the last (right) column. |
| 4914 |
% We detect this case and revert to unbalanced columns. |
| 4915 |
% |
| 4916 |
% Another failure mode is where a large chunk occurs at the beginning of the composite box. |
| 4917 |
% In this case, the left column may fill up even when \cmd\dimen@\ is very small. |
| 4918 |
% If this configuration leaves the left column longer than the right, then we are done, |
| 4919 |
% but \cmd\dimen@\ by no means represents the height of either finished box. |
| 4920 |
% |
| 4921 |
% Therefore the last step in the process is to rebox the two columns to a common height determined |
| 4922 |
% independently of the balancing process. |
| 4923 |
% |
| 4924 |
% The dimension involved is checked against the current \cmd\@colroom\ to guard against the case where |
| 4925 |
% excessive material happens to fall in either column. |
| 4926 |
% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}} |
| 4927 |
% \changes{4.1n}{2009/12/02}{More diagnostics of column balancing} |
| 4928 |
% \changes{4.1n}{2010/01/02}{(AO, 571) coding convention: use \cs{bgroup}, \cs{egroup} (instead of braces) when a box is being built}% |
| 4929 |
% \changes{4.1n}{2010/01/02}{(AO, 571) Footnotes, when columns are balanced or when they are composed with their column}% |
| 4930 |
% \changes{4.1n}{2010/01/02}{(AO, 571) Change \cs{balance@two}'s balancing algorithm to more successfully balance extremely short columns.} |
| 4931 |
% \begin{macrocode} |
| 4932 |
\def\balance@two#1#2{% |
| 4933 |
\ltxgrid@info@sw{\class@info{\string\balance@two\string#1\string#2}}{}% |
| 4934 |
\outputdebug@sw{\trace@scroll{\showbox#1\showbox#2}}{}% |
| 4935 |
% \end{macrocode} |
| 4936 |
% The first step is to recover the footnotes from the bottoms of the two columns (globally, into \cmd\footsofar) |
| 4937 |
% and to combine the text into \cmd\box\cmd\@ne, but without voiding either of the argument boxes. |
| 4938 |
% \begin{macrocode} |
| 4939 |
\setbox\thr@@\copy\footsofar |
| 4940 |
\setbox\@ne\vbox\bgroup |
| 4941 |
\@ifvoid{#1}{}{% |
| 4942 |
\recover@column#1\footsofar\column@recovered\footins@recovered |
| 4943 |
\@ifvoid{#2}{}{\marry@baselines}% |
| 4944 |
}% |
| 4945 |
\@ifvoid{#2}{}{% |
| 4946 |
\recover@column#2\footsofar\column@recovered\footins@recovered |
| 4947 |
}% |
| 4948 |
\egroup |
| 4949 |
\outputdebug@sw{\trace@scroll{\showbox\@ne}}{}% |
| 4950 |
\ltxgrid@foot@info@sw{\trace@scroll{\showbox\footsofar}}{}% |
| 4951 |
% \end{macrocode} |
| 4952 |
% Hereunder, \cmd\dimen@\ is the split value. We adjust it until the step size is small enough, while the split is acceptable. |
| 4953 |
% Also, \cmd\dimen@i\ is the step size. Once this value is greater than a half point, we must iterate. |
| 4954 |
% \begin{macrocode} |
| 4955 |
\dimen@\ht\@ne\divide\dimen@\tw@ |
| 4956 |
\dimen@i\dimen@ |
| 4957 |
\vbadness\@M |
| 4958 |
\vfuzz\maxdimen |
| 4959 |
\splittopskip\topskip |
| 4960 |
\loopwhile{% |
| 4961 |
\setbox\z@\copy\@ne\setbox\tw@\vsplit\z@ to\dimen@ |
| 4962 |
\remove@depth\z@\remove@depth\tw@ |
| 4963 |
% \end{macrocode} |
| 4964 |
% The following line would provide a diagnostic of the iterations of column balancing, were we to use it. |
| 4965 |
% \begin{verbatim} |
| 4966 |
% \outputdebug@sw{\trace@scroll{\showbox\tw@\showbox\z@}}{}% |
| 4967 |
% \end{verbatim} |
| 4968 |
% Hereunder, \cmd\dimen@ii\ is used to reckon the difference in height between the left box and the right. |
| 4969 |
% \begin{macrocode} |
| 4970 |
\dimen@ii\ht\tw@\advance\dimen@ii-\ht\z@ |
| 4971 |
\dimen@i=.5\dimen@i |
| 4972 |
\ltxgrid@info@sw{\saythe\dimen@\saythe\dimen@i\saythe\dimen@ii}{}% |
| 4973 |
% \end{macrocode} |
| 4974 |
% If the columns are within a half-point of each other, |
| 4975 |
% \begin{macrocode} |
| 4976 |
\@ifdim{\dimen@ii<.5\p@}{% |
| 4977 |
\@ifdim{\dimen@ii>-.5\p@}% |
| 4978 |
}{% |
| 4979 |
\false@sw |
| 4980 |
}% |
| 4981 |
% \end{macrocode} |
| 4982 |
% The above results in a Boolean, which now chooses between the following two brace-delimited clauses. |
| 4983 |
% If the step size is less than a half-point, then terminate the loop. |
| 4984 |
% \begin{macrocode} |
| 4985 |
{% |
| 4986 |
\true@sw |
| 4987 |
}{% |
| 4988 |
\@ifdim{\dimen@i<.5\p@}% |
| 4989 |
}% |
| 4990 |
% \end{macrocode} |
| 4991 |
% The above results in a Boolean, which now chooses between the following two brace-delimited clauses. |
| 4992 |
% The true-part terminates the loop, otherwise iterate. |
| 4993 |
% \begin{macrocode} |
| 4994 |
{% |
| 4995 |
\false@sw |
| 4996 |
}% |
| 4997 |
{% |
| 4998 |
% \end{macrocode} |
| 4999 |
% For the next iteration, the candidate split dimension \cmd\dimen@\ will be one step larger |
| 5000 |
% if the height of the left box is less than that of the right box. |
| 5001 |
% Otherwise it will be one step smaller. |
| 5002 |
% \begin{macrocode} |
| 5003 |
\advance\dimen@\@ifdim{\dimen@ii<\z@}{}{-}\dimen@i |
| 5004 |
\true@sw |
| 5005 |
}% |
| 5006 |
}% |
| 5007 |
% \end{macrocode} |
| 5008 |
% The loop has terminated. |
| 5009 |
% \begin{macrocode} |
| 5010 |
\ltxgrid@info@sw{\saythe\dimen@\saythe\dimen@i\saythe\dimen@ii}{}% |
| 5011 |
% \end{macrocode} |
| 5012 |
% The algorithm has failed to find a satisfactory result if |
| 5013 |
% the left column is of non-zero height and the right column is of zero height. |
| 5014 |
% \begin{macrocode} |
| 5015 |
\@ifdim{\ht\z@=\z@}{% |
| 5016 |
\@ifdim{\ht\tw@=\z@}% |
| 5017 |
}{% |
| 5018 |
\true@sw |
| 5019 |
}% |
| 5020 |
% \end{macrocode} |
| 5021 |
% The \cmd\false@sw\ branch is executed if the algorithm has failed. |
| 5022 |
% We restore the original boxes. |
| 5023 |
% \begin{macrocode} |
| 5024 |
{% |
| 5025 |
}{% |
| 5026 |
\ltxgrid@info{Unsatifactorily balanced columns: giving up}% |
| 5027 |
\setbox\tw@\box#1% |
| 5028 |
\setbox\z@ \box#2% |
| 5029 |
\global\setbox\footsofar\box\thr@@ |
| 5030 |
}% |
| 5031 |
\setbox\tw@\vbox{\unvbox\tw@\vskip\z@skip}% |
| 5032 |
\setbox\z@ \vbox{\unvbox\z@ \vskip\z@skip}% |
| 5033 |
\set@colht |
| 5034 |
\dimen@\ht\z@\@ifdim{\dimen@<\ht\tw@}{\dimen@\ht\tw@}{}% |
| 5035 |
\@ifdim{\dimen@>\@colroom}{\dimen@\@colroom}{}% |
| 5036 |
\ltxgrid@info@sw{\saythe{\ht\z@}\saythe{\ht\tw@}\saythe\@colroom\saythe\dimen@}{}% |
| 5037 |
\setbox#1\vbox to\dimen@{\unvbox\tw@\unskip\raggedcolumn@skip}% |
| 5038 |
\setbox#2\vbox to\dimen@{\unvbox\z@ \unskip\raggedcolumn@skip}% |
| 5039 |
\outputdebug@sw{\trace@scroll{\showbox#1\showbox#2}}{}% |
| 5040 |
}% |
| 5041 |
% \end{macrocode} |
| 5042 |
% Procedure \cmd\remove@depth\ rearranges the given (vertical) box register so that it has zero depth. |
| 5043 |
% \begin{macrocode} |
| 5044 |
\def\remove@depth#1{% |
| 5045 |
\setbox#1\vbox\bgroup |
| 5046 |
\unvcopy#1% |
| 5047 |
\setbox\z@\vbox\bgroup |
| 5048 |
\unvbox#1% |
| 5049 |
\setbox\z@\lastbox |
| 5050 |
\aftergroup\kern\aftergroup-\expandafter |
| 5051 |
\egroup |
| 5052 |
\the\dp\z@\relax |
| 5053 |
\egroup |
| 5054 |
}% |
| 5055 |
% \end{macrocode} |
| 5056 |
% \end{macro} |
| 5057 |
% |
| 5058 |
% \changes{4.1n}{2010/01/02}{(AO, 571) Abandon \cs{recover@footins} in favor of \cs{recover@column}}% |
| 5059 |
% Procedure \cmd\recover@column\ is a utility to separate a column box into text and footnotes; |
| 5060 |
% the former being contributed to the current (vertical) list, the latter appended to the given register, usually \cmd\footsofar. |
| 5061 |
% |
| 5062 |
% Argument \verb+#1+ is the input: it should be a \cmd\vbox, and it remains unaltered. |
| 5063 |
% Argument \verb+#2+ is the box into which to (globally) add the footnotes, usually \cmd\footsofar. |
| 5064 |
% Arguments \verb+#3+ and \verb+#4+ are scratch box registers to use in this calculation. |
| 5065 |
% As a side effect, \verb+#3+ will be unboxed into whatever vertical mode we are in at the moment (should be a \cmd\vbox). |
| 5066 |
% \begin{macrocode} |
| 5067 |
\def\recover@column#1#2#3#4{% |
| 5068 |
\ltxgrid@info@sw{\class@info{\string\recover@column\string#1\string#2\string#3\string#4}}{}% |
| 5069 |
\setbox#4\vbox{\unvcopy#1}% |
| 5070 |
\ltxgrid@foot@info@sw{\trace@scroll{\showbox#4}}{}% |
| 5071 |
\dimen@\ht#4% |
| 5072 |
\ltxgrid@foot@info@sw{\saythe\dimen@}{}% |
| 5073 |
\setbox#4\vbox\bgroup |
| 5074 |
\unvbox#4\unskip |
| 5075 |
% \end{macrocode} |
| 5076 |
% We now strip the footnotes from the bottom of this box, adding them to \cmd\footsofar. |
| 5077 |
% The method relies on a signal, consisting of a complementary pair of kerns, placed at the bottom of the box by \cmd\@combineinserts. |
| 5078 |
% \begin{macrocode} |
| 5079 |
\dimen@i\lastkern\unkern\advance\dimen@i\lastkern |
| 5080 |
\@ifdim{\dimen@i=\z@}{% |
| 5081 |
\dimen@i\lastkern\unkern |
| 5082 |
\ltxgrid@foot@info@sw{\saythe\dimen@i}{}% |
| 5083 |
\aftergroup\dimen@i |
| 5084 |
\expandafter\egroup\the\dimen@i\relax |
| 5085 |
}{% |
| 5086 |
\egroup |
| 5087 |
}% |
| 5088 |
% \end{macrocode} |
| 5089 |
% Split the column into \verb+#3+ and the footnote into \verb+#4+. |
| 5090 |
% Append the footnote to \verb+#2+. |
| 5091 |
% \begin{macrocode} |
| 5092 |
\@ifdim{\dimen@i<\z@}{% |
| 5093 |
\advance\dimen@\dimen@i |
| 5094 |
\ltxgrid@foot@info@sw{\saythe\dimen@i\saythe\dimen@}{}% |
| 5095 |
\splittopskip\z@skip |
| 5096 |
\global\setbox#3\vsplit#4 to\dimen@ |
| 5097 |
\global\setbox#4\vbox{\unvbox#4}% |
| 5098 |
\ltxgrid@foot@info@sw{\trace@scroll{\showbox#1\showbox#2\showbox#3\showbox#4}}{}% |
| 5099 |
\global\setbox#2\vbox\bgroup\unvbox#2\vskip\z@skip\unvbox#4\egroup |
| 5100 |
}{% |
| 5101 |
% \end{macrocode} |
| 5102 |
% What if \cmd\dimen@i\ is zero? |
| 5103 |
% In that case, \cmd\setbox\#3\cmd\box\#4, and do not touch \cmd\box\#2. |
| 5104 |
% \begin{macrocode} |
| 5105 |
\setbox#3\box#4% |
| 5106 |
\ltxgrid@foot@info@sw{\trace@scroll{\showbox#1\showbox#2\showbox#3\showbox#4}}{}% |
| 5107 |
}% |
| 5108 |
\unvbox#3% |
| 5109 |
\loopwhile{\dimen@\lastskip\@ifdim{\dimen@>\z@}{\unskip\true@sw}{\false@sw}}% |
| 5110 |
}% |
| 5111 |
\def\recover@column@null#1#2#3#4{% |
| 5112 |
\unvcopy#1% |
| 5113 |
}% |
| 5114 |
% \end{macrocode} |
| 5115 |
% \end{macro} |
| 5116 |
% |
| 5117 |
% \begin{macro}{\@begindocumenthook} |
| 5118 |
% Initialization: |
| 5119 |
% we initialize to the page grid named ``one''. |
| 5120 |
% If the class decides to initially set type in a different grid, it |
| 5121 |
% should execute these same commands, but changing the first to the appropriate procedure. |
| 5122 |
% |
| 5123 |
% Note that the point where this sequence is executed would be an excellent place to arrange for |
| 5124 |
% floats to be committed to the first page of a document. |
| 5125 |
% That is, we execute \cmd\do@startpage, which triggers \cmd\do@startcolumn. |
| 5126 |
% |
| 5127 |
% FIXME: it should be the job of the page grid to determine the procedure to execute at |
| 5128 |
% the start of the job. Make this a hook. |
| 5129 |
% \begin{macrocode} |
| 5130 |
\rvtx@ifformat@geq{2020/10/01}% |
| 5131 |
{% |
| 5132 |
\AddToHook{begindocument}{% |
| 5133 |
\open@column@one\@ne |
| 5134 |
\set@colht |
| 5135 |
\@floatplacement |
| 5136 |
\@dblfloatplacement |
| 5137 |
}% |
| 5138 |
}{% |
| 5139 |
\prepdef\@begindocumenthook{% |
| 5140 |
\open@column@one\@ne |
| 5141 |
\set@colht |
| 5142 |
\@floatplacement |
| 5143 |
\@dblfloatplacement |
| 5144 |
}% |
| 5145 |
} |
| 5146 |
% \end{macrocode} |
| 5147 |
% \end{macro} |
| 5148 |
% |
| 5149 |
% Comment: our technique of balancing columns is severely limited, because it cannot properly work |
| 5150 |
% with \env{longtable}, which places material at the bottom and top of the column break. |
| 5151 |
% |
| 5152 |
% The proper way to handle a grid change in the middle of the page is to accumulate all the material for |
| 5153 |
% an entire article (or chapter) and then assemble finished pages therefrom. This approach is fundamentally |
| 5154 |
% superior for complex layouts: it corresponds to real-world workflows. |
| 5155 |
% Such a scheme is an excellent subject for another \LaTeX\ package. |
| 5156 |
% |
| 5157 |
% |
| 5158 |
% \subsection{Patches for the longtable package}% |
| 5159 |
% |
| 5160 |
% \LaTeX's ``required'' package \classname{longtable} (written by David P. Carlilsle), |
| 5161 |
% which is part of /latex/required/tools, is incmpatible with both |
| 5162 |
% \LaTeX's ``required'' package \classname{multicol} and with |
| 5163 |
% \LaTeX's native \cmd\twocolumn\ capability. There is no essential reason |
| 5164 |
% for this incompatability, aside from implementation details, and the |
| 5165 |
% \classname{ltxgrid} package gives us the ability to lift them. |
| 5166 |
% |
| 5167 |
% Only four of \classname{longtable}'s procedures require rewriting: |
| 5168 |
% \cmd\longtable, |
| 5169 |
% \cmd\endlongtable, |
| 5170 |
% \cmd\LT@start, and |
| 5171 |
% \cmd\LT@end@hd@ft. |
| 5172 |
% The procedure \cmd\switch@longtable\ checks against their expected meanings |
| 5173 |
% and, if all is as expected, applies the patches. |
| 5174 |
% In the process, we simplify things considerably and also make them more |
| 5175 |
% secure. |
| 5176 |
% |
| 5177 |
% Why does \classname{longtable} need to access the output routine, anyway? |
| 5178 |
% What it comes down to, is what happens when a pagebreak falls within a |
| 5179 |
% long table. If this happens, we would like to append a row at the bottom of |
| 5180 |
% the broken table and add a row at the top of the next page. |
| 5181 |
% |
| 5182 |
% These things can be accomodated easily by the \classname{ltxgrid} output |
| 5183 |
% routine hooks. |
| 5184 |
% |
| 5185 |
% \begin{macro}{\longtable} |
| 5186 |
% \begin{macrocode} |
| 5187 |
\def\longtable@longtable{% |
| 5188 |
\par |
| 5189 |
\ifx\multicols\@undefined\else\ifnum\col@number>\@ne\@twocolumntrue\fi\fi |
| 5190 |
\if@twocolumn\LT@err{longtable not in 1-column mode}\@ehc\fi |
| 5191 |
\begingroup |
| 5192 |
\@ifnextchar[\LT@array{\LT@array[x]}% |
| 5193 |
}% |
| 5194 |
\def\longtable@new{% |
| 5195 |
\par |
| 5196 |
\@ifnextchar[\LT@array{\LT@array[x]}% |
| 5197 |
}% |
| 5198 |
% \end{macrocode} |
| 5199 |
% \end{macro} |
| 5200 |
% |
| 5201 |
% \begin{macro}{\endlongtable} |
| 5202 |
% \begin{macrocode} |
| 5203 |
\def\endlongtable@longtable{% |
| 5204 |
\crcr |
| 5205 |
\noalign{% |
| 5206 |
\let\LT@entry\LT@entry@chop |
| 5207 |
\xdef\LT@save@row{\LT@save@row}}% |
| 5208 |
\LT@echunk |
| 5209 |
\LT@start |
| 5210 |
\unvbox\z@ |
| 5211 |
\LT@get@widths |
| 5212 |
\if@filesw |
| 5213 |
{\let\LT@entry\LT@entry@write\immediate\write\@auxout{% |
| 5214 |
\gdef\expandafter\noexpand |
| 5215 |
\csname LT@\romannumeral\c@LT@tables\endcsname |
| 5216 |
{\LT@save@row}}}% |
| 5217 |
\fi |
| 5218 |
\ifx\LT@save@row\LT@@save@row |
| 5219 |
\else |
| 5220 |
\LT@warn{Column \@width s have changed\MessageBreak |
| 5221 |
in table \thetable}% |
| 5222 |
\LT@final@warn |
| 5223 |
\fi |
| 5224 |
\endgraf\penalty -\LT@end@pen |
| 5225 |
\endgroup |
| 5226 |
\global\@mparbottom\z@ |
| 5227 |
\pagegoal\vsize |
| 5228 |
\endgraf\penalty\z@\addvspace\LTpost |
| 5229 |
\ifvoid\footins\else\insert\footins{}\fi |
| 5230 |
}% |
| 5231 |
% \end{macrocode} |
| 5232 |
% \changes{4.1a}{2008/06/29}{Repair error in \cs{endlongtable@new} involving \cs{@ifx}: argument not delimited.} |
| 5233 |
% \begin{macrocode} |
| 5234 |
\def\endlongtable@new{% |
| 5235 |
\crcr |
| 5236 |
\noalign{% |
| 5237 |
\let\LT@entry\LT@entry@chop |
| 5238 |
\xdef\LT@save@row{\LT@save@row}% |
| 5239 |
}% |
| 5240 |
\LT@echunk |
| 5241 |
\LT@start |
| 5242 |
\unvbox\z@ |
| 5243 |
\LT@get@widths |
| 5244 |
\@if@sw\if@filesw\fi{% |
| 5245 |
{% |
| 5246 |
\let\LT@entry\LT@entry@write |
| 5247 |
\immediate\write\@auxout{% |
| 5248 |
\gdef\expandafter\noexpand\csname LT@\romannumeral\c@LT@tables\endcsname |
| 5249 |
{\LT@save@row}% |
| 5250 |
}% |
| 5251 |
}% |
| 5252 |
}{}% |
| 5253 |
\@ifx{\LT@save@row\LT@@save@row}{}{% |
| 5254 |
\LT@warn{% |
| 5255 |
Column \@width s have changed\MessageBreak in table \thetable |
| 5256 |
}\LT@final@warn |
| 5257 |
}% |
| 5258 |
\endgraf |
| 5259 |
\nobreak |
| 5260 |
\box\@ifvoid\LT@lastfoot{\LT@foot}{\LT@lastfoot}% |
| 5261 |
\global\@mparbottom\z@ |
| 5262 |
\endgraf |
| 5263 |
\LT@post |
| 5264 |
}% |
| 5265 |
% \end{macrocode} |
| 5266 |
% \end{macro} |
| 5267 |
% |
| 5268 |
% \begin{macro}{\LT@start} |
| 5269 |
% \begin{macrocode} |
| 5270 |
\def\LT@start@longtable{% |
| 5271 |
\let\LT@start\endgraf |
| 5272 |
\endgraf\penalty\z@\vskip\LTpre |
| 5273 |
\dimen@\pagetotal |
| 5274 |
\advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
| 5275 |
\advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
| 5276 |
\advance\dimen@ \ht\LT@foot |
| 5277 |
\dimen@ii\vfuzz |
| 5278 |
\vfuzz\maxdimen |
| 5279 |
\setbox\tw@\copy\z@ |
| 5280 |
\setbox\tw@\vsplit\tw@ to \ht\@arstrutbox |
| 5281 |
\setbox\tw@\vbox{\unvbox\tw@}% |
| 5282 |
\vfuzz\dimen@ii |
| 5283 |
\advance\dimen@ \ht |
| 5284 |
\ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi |
| 5285 |
\advance\dimen@\dp |
| 5286 |
\ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi |
| 5287 |
\advance\dimen@ -\pagegoal |
| 5288 |
\ifdim \dimen@>\z@\vfil\break\fi |
| 5289 |
\global\@colroom\@colht |
| 5290 |
\ifvoid\LT@foot\else |
| 5291 |
\advance\vsize-\ht\LT@foot |
| 5292 |
\global\advance\@colroom-\ht\LT@foot |
| 5293 |
\dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@ |
| 5294 |
\maxdepth\z@ |
| 5295 |
\fi |
| 5296 |
\ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi |
| 5297 |
% \end{macrocode} |
| 5298 |
% At some point before version 4.11, the \cmd\nobreak\ was added. |
| 5299 |
% \begin{macrocode} |
| 5300 |
\nobreak |
| 5301 |
% \end{macrocode} |
| 5302 |
% |
| 5303 |
% \begin{macrocode} |
| 5304 |
\output{\LT@output}% |
| 5305 |
}% |
| 5306 |
\def\LT@start@new{% |
| 5307 |
\let\LT@start\endgraf |
| 5308 |
\endgraf |
| 5309 |
\markthr@@{}% |
| 5310 |
\LT@pre |
| 5311 |
\@ifvoid\LT@firsthead{\LT@top}{\box\LT@firsthead\nobreak}% |
| 5312 |
\mark@envir{longtable}% |
| 5313 |
}% |
| 5314 |
% \end{macrocode} |
| 5315 |
% \end{macro} |
| 5316 |
% |
| 5317 |
% \begin{macro}{\LT@end} |
| 5318 |
% \begin{macrocode} |
| 5319 |
\def\LT@end@hd@ft@longtable#1{% |
| 5320 |
\LT@echunk |
| 5321 |
\ifx\LT@start\endgraf |
| 5322 |
\LT@err{Longtable head or foot not at start of table}{Increase LTchunksize}% |
| 5323 |
\fi |
| 5324 |
\setbox#1\box\z@ |
| 5325 |
\LT@get@widths\LT@bchunk |
| 5326 |
}% |
| 5327 |
\def\LT@end@hd@ft@new#1{% |
| 5328 |
\LT@echunk |
| 5329 |
\@ifx{\LT@start\endgraf}{% |
| 5330 |
\LT@err{Longtable head or foot not at start of table}{Increase LTchunksize}% |
| 5331 |
}% |
| 5332 |
\global\setbox#1\box\z@ |
| 5333 |
\LT@get@widths |
| 5334 |
\LT@bchunk |
| 5335 |
}% |
| 5336 |
% \end{macrocode} |
| 5337 |
% \end{macro} |
| 5338 |
% |
| 5339 |
% \begin{macro}{\LT@array} |
| 5340 |
% |
| 5341 |
% |
| 5342 |
% \begin{macrocode} |
| 5343 |
\def\LT@array@longtable[#1]#2{% |
| 5344 |
\refstepcounter{table}\stepcounter{LT@tables}% |
| 5345 |
\if l#1% |
| 5346 |
\LTleft\z@ \LTright\fill |
| 5347 |
\else\if r#1% |
| 5348 |
\LTleft\fill \LTright\z@ |
| 5349 |
\else\if c#1% |
| 5350 |
\LTleft\fill \LTright\fill |
| 5351 |
\fi\fi\fi |
| 5352 |
\let\LT@mcol\multicolumn |
| 5353 |
\let\LT@@tabarray\@tabarray |
| 5354 |
\let\LT@@hl\hline |
| 5355 |
\def\@tabarray{% |
| 5356 |
\let\hline\LT@@hl |
| 5357 |
\LT@@tabarray}% |
| 5358 |
\let\\\LT@tabularcr\let\tabularnewline\\% |
| 5359 |
\def\newpage{\noalign{\break}}% |
| 5360 |
\def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% |
| 5361 |
\def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% |
| 5362 |
\let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption |
| 5363 |
\@tempdima\ht\strutbox |
| 5364 |
\let\@endpbox\LT@endpbox |
| 5365 |
\ifx\extrarowheight\@undefined |
| 5366 |
\let\@acol\@tabacol |
| 5367 |
\let\@classz\@tabclassz \let\@classiv\@tabclassiv |
| 5368 |
\def\@startpbox{\vtop\LT@startpbox}% |
| 5369 |
\let\@@startpbox\@startpbox |
| 5370 |
\let\@@endpbox\@endpbox |
| 5371 |
\let\LT@LL@FM@cr\@tabularcr |
| 5372 |
\else |
| 5373 |
\advance\@tempdima\extrarowheight |
| 5374 |
\col@sep\tabcolsep |
| 5375 |
\let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr |
| 5376 |
\fi |
| 5377 |
\setbox\@arstrutbox\hbox{\vrule |
| 5378 |
\@height \arraystretch \@tempdima |
| 5379 |
\@depth \arraystretch \dp \strutbox |
| 5380 |
\@width \z@}% |
| 5381 |
\let\@sharp##\let\protect\relax |
| 5382 |
\begingroup |
| 5383 |
\@mkpream{#2}% |
| 5384 |
\xdef\LT@bchunk{% |
| 5385 |
\global\advance\c@LT@chunks\@ne |
| 5386 |
\global\LT@rows\z@\setbox\z@\vbox\bgroup |
| 5387 |
\LT@setprevdepth |
| 5388 |
% \end{macrocode} |
| 5389 |
% At some point before version 4.11, the \cmd\noexpand\ was added. |
| 5390 |
% We need not change our own version, because we did it right, back in 1998 (using \cmd\appdef). |
| 5391 |
% \begin{macrocode} |
| 5392 |
\tabskip\LTleft \noexpand\halign to\hsize\bgroup |
| 5393 |
\tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}% |
| 5394 |
\endgroup |
| 5395 |
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols |
| 5396 |
\LT@make@row |
| 5397 |
\m@th\let\par\@empty |
| 5398 |
\everycr{}\lineskip\z@\baselineskip\z@ |
| 5399 |
\LT@bchunk}% |
| 5400 |
\def\LT@LR@l{\LTleft\z@ \LTright\fill}% |
| 5401 |
\def\LT@LR@r{\LTleft\fill \LTright\z@ }% |
| 5402 |
\def\LT@LR@c{\LTleft\fill \LTright\fill}% |
| 5403 |
\def\LT@array@new[#1]#2{% |
| 5404 |
\refstepcounter{table}\stepcounter{LT@tables}% |
| 5405 |
\table@hook |
| 5406 |
\LTleft\fill \LTright\fill |
| 5407 |
\csname LT@LR@#1\endcsname |
| 5408 |
\let\LT@mcol\multicolumn |
| 5409 |
\let\LT@@hl\hline |
| 5410 |
\prepdef\@tabarray{\let\hline\LT@@hl}% |
| 5411 |
\let\\\LT@tabularcr |
| 5412 |
\let\tabularnewline\\% |
| 5413 |
\def\newpage{\noalign{\break}}% |
| 5414 |
\def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% |
| 5415 |
\def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% |
| 5416 |
\let\hline\LT@hline |
| 5417 |
\let\kill\LT@kill |
| 5418 |
\let\caption\LT@caption |
| 5419 |
\@tempdima\ht\strutbox |
| 5420 |
\let\@endpbox\LT@endpbox |
| 5421 |
\@ifxundefined\extrarowheight{% |
| 5422 |
\let\@acol\@tabacol |
| 5423 |
\let\@classz\@tabclassz |
| 5424 |
\let\@classiv\@tabclassiv |
| 5425 |
\def\@startpbox{\vtop\LT@startpbox}% |
| 5426 |
\let\@@startpbox\@startpbox |
| 5427 |
\let\@@endpbox\@endpbox |
| 5428 |
% \end{macrocode} |
| 5429 |
% Because \classname{ltxutil} patches \LaTeX's \cmd\@tabularcr and \cmd\@xtabularcr, |
| 5430 |
% we must restore these procedures in the scope of \env{longtable}. |
| 5431 |
% Ironically, the patches in \classname{ltxutil} were for the purpose of extending |
| 5432 |
% the \env{tabular} environment to prevent pagebreaks with the *-form of \cmd\\, |
| 5433 |
% just the same as is being done here. But the two mechanisms conflict. |
| 5434 |
% \changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: restore \cs{@tabularcr} and \cs{@xtabularcr}} |
| 5435 |
% \begin{macrocode} |
| 5436 |
\let\LT@LL@FM@cr\@tabularcr@LaTeX |
| 5437 |
\let\@xtabularcr\@xtabularcr@LaTeX |
| 5438 |
}{% |
| 5439 |
\advance\@tempdima\extrarowheight |
| 5440 |
\col@sep\tabcolsep |
| 5441 |
\let\@startpbox\LT@startpbox |
| 5442 |
% \end{macrocode} |
| 5443 |
% \changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: set \cs{LT@LL@FM@cr} to \cs{@arraycr@array} instead of \cs{@arraycr}} |
| 5444 |
% \begin{macrocode} |
| 5445 |
\let\LT@LL@FM@cr\@arraycr@array |
| 5446 |
}% |
| 5447 |
% |
| 5448 |
\let\@acoll\@tabacoll |
| 5449 |
\let\@acolr\@tabacolr |
| 5450 |
\let\@acol\@tabacol |
| 5451 |
% |
| 5452 |
\setbox\@arstrutbox\hbox{% |
| 5453 |
\vrule |
| 5454 |
\@height \arraystretch \@tempdima |
| 5455 |
\@depth \arraystretch \dp \strutbox |
| 5456 |
\@width \z@ |
| 5457 |
}% |
| 5458 |
\let\@sharp##% |
| 5459 |
\let\protect\relax |
| 5460 |
\begingroup |
| 5461 |
\@mkpream{#2}% |
| 5462 |
\@mkpream@relax |
| 5463 |
\edef\@preamble{\@preamble}% |
| 5464 |
\prepdef\@preamble{% |
| 5465 |
\global\advance\c@LT@chunks\@ne |
| 5466 |
\global\LT@rows\z@ |
| 5467 |
\setbox\z@\vbox\bgroup |
| 5468 |
\LT@setprevdepth |
| 5469 |
\tabskip\LTleft |
| 5470 |
\halign to\hsize\bgroup |
| 5471 |
\tabskip\z@ |
| 5472 |
\@arstrut |
| 5473 |
}% |
| 5474 |
\appdef\@preamble{% |
| 5475 |
\tabskip\LTright |
| 5476 |
\cr |
| 5477 |
}% |
| 5478 |
\global\let\LT@bchunk\@preamble |
| 5479 |
\endgroup |
| 5480 |
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols |
| 5481 |
\LT@make@row |
| 5482 |
\m@th |
| 5483 |
\let\par\@empty |
| 5484 |
\everycr{}% |
| 5485 |
\lineskip\z@ |
| 5486 |
\baselineskip\z@ |
| 5487 |
\LT@bchunk |
| 5488 |
}% |
| 5489 |
\appdef\table@hook{}% |
| 5490 |
% \end{macrocode} |
| 5491 |
% \end{macro} |
| 5492 |
% |
| 5493 |
% \begin{macro}{\switch@longtable} |
| 5494 |
% |
| 5495 |
% Here is the switch from standard \classname{longtable} to the new, \classname{ltxgrid}-compatible values. |
| 5496 |
% |
| 5497 |
% At this point, we extend \env{longtable} with a \env{longtable*} form, which signifies that we want to |
| 5498 |
% use the full page width for setting the table. |
| 5499 |
% You can think this way: \env{longtable*} is to \env{longtable} as \env{table*} is to \env{table}. |
| 5500 |
% |
| 5501 |
% \begin{macrocode} |
| 5502 |
\def\switch@longtable{% |
| 5503 |
\@ifpackageloaded{longtable}{% |
| 5504 |
\@ifx{\longtable\longtable@longtable}{% |
| 5505 |
\@ifx{\endlongtable\endlongtable@longtable}{% |
| 5506 |
\@ifx{\LT@start\LT@start@longtable}{% |
| 5507 |
\@ifx{\LT@end@hd@ft\LT@end@hd@ft@longtable}{% |
| 5508 |
\@ifx{\LT@array\LT@array@longtable}{% |
| 5509 |
\true@sw |
| 5510 |
}{\false@sw}% |
| 5511 |
}{\false@sw}% |
| 5512 |
}{\false@sw}% |
| 5513 |
}{\false@sw}% |
| 5514 |
}{\false@sw}% |
| 5515 |
{% |
| 5516 |
\class@info{Patching longtable package}% |
| 5517 |
}{% |
| 5518 |
\class@info{Patching unrecognized longtable package. (Proceeding with fingers crossed)}% |
| 5519 |
}% |
| 5520 |
\let\longtable\longtable@new |
| 5521 |
\let\endlongtable\endlongtable@new |
| 5522 |
\let\LT@start\LT@start@new |
| 5523 |
\let\LT@end@hd@ft\LT@end@hd@ft@new |
| 5524 |
\let\LT@array\LT@array@new |
| 5525 |
\newenvironment{longtable*}{% |
| 5526 |
\onecolumngrid@push |
| 5527 |
\longtable |
| 5528 |
}{% |
| 5529 |
\endlongtable |
| 5530 |
\onecolumngrid@pop |
| 5531 |
}% |
| 5532 |
% \end{macrocode} |
| 5533 |
% Removed obsolete code. |
| 5534 |
% \begin{macrocode} |
| 5535 |
}{}% |
| 5536 |
}% |
| 5537 |
% \end{macrocode} |
| 5538 |
% \end{macro} |
| 5539 |
% |
| 5540 |
% \begin{macro}{\LT@pre} |
| 5541 |
% \begin{macro}{\LT@bot} |
| 5542 |
% \begin{macro}{\LT@top} |
| 5543 |
% \begin{macro}{\LT@post} |
| 5544 |
% \begin{macro}{\LT@adj} |
| 5545 |
% Note that at the end of the longtable environment, we reestablish the \cmd\mark@envir\ of the |
| 5546 |
% containing environment. We have left \cmd\curr@envir\ alone, so this will work. |
| 5547 |
% \begin{macrocode} |
| 5548 |
\def\LT@pre{\penalty\z@\vskip\LTpre}% |
| 5549 |
\def\LT@bot{\nobreak\copy\LT@foot\vfil}% |
| 5550 |
\def\LT@top{\copy\LT@head\nobreak}% |
| 5551 |
\def\LT@post{\penalty\z@\addvspace\LTpost\mark@envir{\curr@envir}}% |
| 5552 |
\def\LT@adj{% |
| 5553 |
\setbox\z@\vbox{\null}\dimen@-\ht\z@ |
| 5554 |
\setbox\z@\vbox{\unvbox\z@\LT@bot}\advance\dimen@\ht\z@ |
| 5555 |
\global\advance\vsize-\dimen@ |
| 5556 |
}% |
| 5557 |
% \end{macrocode} |
| 5558 |
% \end{macro} |
| 5559 |
% \end{macro} |
| 5560 |
% \end{macro} |
| 5561 |
% \end{macro} |
| 5562 |
% \end{macro} |
| 5563 |
% |
| 5564 |
% \begin{macro}{output@init} |
| 5565 |
% \begin{macro}{output@prep} |
| 5566 |
% \begin{macro}{output@post} |
| 5567 |
% \begin{macrocode} |
| 5568 |
\def\output@init@longtable{\LT@adj}% |
| 5569 |
\def\output@prep@longtable{\setbox\@cclv\vbox{\unvbox\@cclv\LT@bot}}% |
| 5570 |
\def\output@post@longtable{\LT@top}% |
| 5571 |
% \end{macrocode} |
| 5572 |
% \end{macro} |
| 5573 |
% \end{macro} |
| 5574 |
% \end{macro} |
| 5575 |
% |
| 5576 |
% |
| 5577 |
% \subsection{Patches for index processing}% |
| 5578 |
% |
| 5579 |
% Another feature that uses the output routine hooks occurs within |
| 5580 |
% an index, where one wishes to apply a ``continue head'' when a |
| 5581 |
% column breaks within a primary index entry. |
| 5582 |
% Some book designs call for the continue head to only be applied |
| 5583 |
% at a turnpage break. |
| 5584 |
% |
| 5585 |
% In any case, it is easy enough for \cmd\output@post@theindex\ |
| 5586 |
% to do this in conjunction with component marks. |
| 5587 |
% Only the bare outlines are shown here. |
| 5588 |
% |
| 5589 |
% \begin{macro}{\output@init} |
| 5590 |
% \begin{macro}{\output@prep} |
| 5591 |
% \begin{macro}{\output@post} |
| 5592 |
% \begin{macrocode} |
| 5593 |
\let\output@init@theindex\@empty |
| 5594 |
\let\output@prep@theindex\@empty |
| 5595 |
\def\output@post@theindex{% |
| 5596 |
\@ifodd\c@page{}{% |
| 5597 |
\@ifnum{\pagegrid@cur=\@ne}{% |
| 5598 |
% \end{macrocode} |
| 5599 |
% We have the leftmost column of a verso page: |
| 5600 |
% Insert the current top-level continued head. |
| 5601 |
% \begin{macrocode} |
| 5602 |
}% |
| 5603 |
}% |
| 5604 |
}% |
| 5605 |
% \end{macrocode} |
| 5606 |
% \end{macro} |
| 5607 |
% \end{macro} |
| 5608 |
% \end{macro} |
| 5609 |
% |
| 5610 |
% |
| 5611 |
% \subsection{Checking the auxiliary file}% |
| 5612 |
% |
| 5613 |
% We relegate the checking of the auxiliary file to the output routine. |
| 5614 |
% This task must wait until the last page is shipped out, because otherwise |
| 5615 |
% the stream might get closed before the last page is shipped out. |
| 5616 |
% Obviously, we must use \cmd\do@output@MVL\ for the job. |
| 5617 |
% |
| 5618 |
% \begin{macro}{\check@aux} |
| 5619 |
% \begin{macrocode} |
| 5620 |
\def\check@aux{\do@output@MVL{\do@check@aux}}% |
| 5621 |
% \end{macrocode} |
| 5622 |
% \end{macro} |
| 5623 |
% |
| 5624 |
% |
| 5625 |
% |
| 5626 |
% \subsection{Dealing with stuck floats and stalled float dequeueing}% |
| 5627 |
% |
| 5628 |
% \LaTeX's float placement mechanism is fundamentally flawed, as evidenced by |
| 5629 |
% its warning message ``too many unprocessed floats'', which users understandably find frustrating. |
| 5630 |
% The \classname{ltxgrid} package provides tools for ameliorating the situation somewhat. |
| 5631 |
% |
| 5632 |
% Two cases require detection and rectification: |
| 5633 |
% \begin{enumerate} |
| 5634 |
% \item |
| 5635 |
% A float is ``stuck'' in the \cmd\@deferlist: for whatever reason, the float fails to be committed, |
| 5636 |
% even at the start of a fresh page. |
| 5637 |
% Once this condition prevails, following floats can never be committed, subsequently all of \LaTeX's |
| 5638 |
% float registers are used up. |
| 5639 |
% |
| 5640 |
% If this condition is detected, we reconsider float dequeueing under permissive (\cmd\clearpage-style) processing. |
| 5641 |
% |
| 5642 |
% \item |
| 5643 |
% The \cmd\@freelist\ is exhausted: |
| 5644 |
% a large concentration of floats, say, uses up all of \LaTeX's float registers all at once. |
| 5645 |
% This condition commonly occurs when the user collects floats at the end of the document, for some reason. |
| 5646 |
% |
| 5647 |
% 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. |
| 5648 |
% However, no further action is taken until the pagebuilder is visited, so floats can accumulate. |
| 5649 |
% Also, even after the pagebuilder is visited, deferred floats can accumulate, and these are not committed |
| 5650 |
% until a column (or page) of text is completed. |
| 5651 |
% |
| 5652 |
% Once the last free float register is used, action should be taken that will commit some of the deferred floats, |
| 5653 |
% even if this might require ending the page right where we are (resulting in a short page). |
| 5654 |
% |
| 5655 |
% Perhaps, committed floats should be stored using some mechanism other than a list, as is currently done. |
| 5656 |
% A feasible alternative storage method would be to use a \cmd\box\ register in place of |
| 5657 |
% \cmd\@toplist, |
| 5658 |
% \cmd\@botlist, and |
| 5659 |
% \cmd\@dbltoplist. |
| 5660 |
% This is probably just fine, since such committed floats are not reconsidered (I think). |
| 5661 |
% |
| 5662 |
% \end{enumerate} |
| 5663 |
% |
| 5664 |
% The emergency processing implemented here immediately ends the current page and begins to output float pages under (\cmd\clearpage-style) rules. |
| 5665 |
% It proceeds until all deferred floats have been flushed. |
| 5666 |
% |
| 5667 |
% Users should expect non-optimal page makeup under these circumstances. |
| 5668 |
% |
| 5669 |
% Note that there is a weakness in our approach that we have not attempted to repair: if floats are being |
| 5670 |
% added as part of a paragraph, we will not be able to take these remedial steps until the paragraph ends. |
| 5671 |
% This means that the approach implemented here cannot fix all \LaTeX\ documents. Users can still construct |
| 5672 |
% documents that exhaust \LaTeX's pool of float registers! |
| 5673 |
% |
| 5674 |
% \begin{macro}{\check@deferlist@stuck} |
| 5675 |
% \begin{macro}{\@outputpage@tail} |
| 5676 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}% |
| 5677 |
% We detect the case where, at the start of a fresh page, there are deferred floats, but none are |
| 5678 |
% committed. We memorize the \cmd\@deferlist\ at \cmd\shipout\ time, then examine it at the point where |
| 5679 |
% our efforts to commit floats to the new page are complete. |
| 5680 |
% If it has not changed, the first float must be stuck, and we |
| 5681 |
% attempt to fix things via \cmd\force@deferlist@stuck. |
| 5682 |
% |
| 5683 |
% This simple approach is comp[letely effective in for typical documents. |
| 5684 |
% |
| 5685 |
% Note that we try to avoid an infinite loop by examining the value of \cmd\clearpage@sw: |
| 5686 |
% if we come here with that boolean true, we are in a loop. |
| 5687 |
% \begin{macrocode} |
| 5688 |
\def\check@deferlist@stuck#1{% |
| 5689 |
\@ifx{\@deferlist@postshipout\@empty}{}{% |
| 5690 |
\@ifx{\@deferlist@postshipout\@deferlist}{% |
| 5691 |
\@fltstk |
| 5692 |
\clearpage@sw{% |
| 5693 |
\ltxgrid@warn{Deferred float stuck during \string\clearpage\space processing}% |
| 5694 |
}{% |
| 5695 |
\force@deferlist@stuck#1% |
| 5696 |
}% |
| 5697 |
}{% |
| 5698 |
% \end{macrocode} |
| 5699 |
% We have successfully committed float(s) |
| 5700 |
% \begin{macrocode} |
| 5701 |
}% |
| 5702 |
\global\let\@deferlist@postshipout\@empty |
| 5703 |
}% |
| 5704 |
}% |
| 5705 |
\def\@fltstk{% |
| 5706 |
\@latex@warning{A float is stuck (cannot be placed without \string\clearpage)}% |
| 5707 |
}% |
| 5708 |
\appdef\@outputpage@tail{% |
| 5709 |
\global\let\@deferlist@postshipout\@deferlist |
| 5710 |
}% |
| 5711 |
% \end{macrocode} |
| 5712 |
% \end{macro} |
| 5713 |
% \end{macro} |
| 5714 |
% |
| 5715 |
% \begin{macro}{\@next} |
| 5716 |
% \begin{macro}{\@xnext} |
| 5717 |
% We rewrite the \LaTeX\ kernel macros that dequeue float registers from, e.g., \cmd\@deferlist, |
| 5718 |
% providing a test for the condition where the pool of free registers is about to underflow. |
| 5719 |
% |
| 5720 |
% In this case, we attempt to fix things via \cmd\force@deferlist@empty. |
| 5721 |
% \begin{macrocode} |
| 5722 |
\def\@next#1#2{% |
| 5723 |
\@ifx{#2\@empty}{\false@sw}{% |
| 5724 |
\expandafter\@xnext#2\@@#1#2% |
| 5725 |
\true@sw |
| 5726 |
}% |
| 5727 |
}% |
| 5728 |
\def\@xnext\@elt#1#2\@@#3#4{% |
| 5729 |
\def#3{#1}% |
| 5730 |
\gdef#4{#2}% |
| 5731 |
\def\@tempa{#4}\def\@tempb{\@freelist}% |
| 5732 |
\@ifx{\@tempa\@tempb}{% |
| 5733 |
\@ifx{#4\@empty}{% |
| 5734 |
\force@deferlist@empty%{Float register pool exhausted}% |
| 5735 |
}{}% |
| 5736 |
}{}% |
| 5737 |
}% |
| 5738 |
% \end{macrocode} |
| 5739 |
% \end{macro} |
| 5740 |
% \end{macro} |
| 5741 |
% |
| 5742 |
% \begin{macro}{\force@deferlist@stuck} |
| 5743 |
% \begin{macro}{\force@deferlist@empty} |
| 5744 |
% \begin{macro}{\force@deferlist@sw} |
| 5745 |
% \begin{macro}{\do@forcecolumn@pen} |
| 5746 |
% \begin{macro}{\do@forcecolumn} |
| 5747 |
% The procedure \cmd\force@deferlist@empty\ is an attempt to rectify a situation where \LaTeX's float placement mechanism |
| 5748 |
% may fail (``too many unprocessed floats''). |
| 5749 |
% |
| 5750 |
% We put down interrupts that call for the float placement to be redone, but under permissive conditions, |
| 5751 |
% just the same as if \cmd\clearpage\ had been invoked. |
| 5752 |
% |
| 5753 |
% Note that the attempt to rectify the error is contingent on the setting of \cmd\force@deferlist@sw, |
| 5754 |
% default false. A document class using this package that wishes to enable this error recovery mechanism should |
| 5755 |
% set this boolean to true. |
| 5756 |
% |
| 5757 |
% The interrupt \cmd\do@forcecolumn@pen, which invokes the procedure \cmd\do@forcecolumn, |
| 5758 |
% does the same as \cmd\do@startcolumn, except under permissive conditions: |
| 5759 |
% we are trying to empty out the float registers completely. |
| 5760 |
% |
| 5761 |
% In order to properly with the case where there is material in \cmd\box\cmd\@cclv, |
| 5762 |
% \cmd\@toplist, \cmd\@botlist, \cmd\@dbltoplist, etc, |
| 5763 |
% we do what amounts to \cmd\newpage\ to get things rolling. |
| 5764 |
% |
| 5765 |
% In \cmd\force@deferlist@stuck, we take advantage of already being in the output routine: |
| 5766 |
% simply reinvoke \cmd\do@startcolumn\ under permissive conditions. |
| 5767 |
% |
| 5768 |
% \begin{macrocode} |
| 5769 |
\def\force@deferlist@stuck#1{% |
| 5770 |
\force@deferlist@sw{% |
| 5771 |
\@booleantrue\clearpage@sw |
| 5772 |
\@booleantrue\forcefloats@sw |
| 5773 |
#1% |
| 5774 |
}{% |
| 5775 |
}% |
| 5776 |
}% |
| 5777 |
\def\force@deferlist@empty{% |
| 5778 |
\force@deferlist@sw{% |
| 5779 |
\penalty-\pagebreak@pen |
| 5780 |
\protect@penalty\do@forcecolumn@pen |
| 5781 |
}{% |
| 5782 |
}% |
| 5783 |
}% |
| 5784 |
\@booleanfalse\force@deferlist@sw |
| 5785 |
\mathchardef\do@forcecolumn@pen=10009 |
| 5786 |
\@namedef{output@-\the\do@forcecolumn@pen}{\do@forcecolumn}% |
| 5787 |
\def\do@forcecolumn{% |
| 5788 |
\@booleantrue\clearpage@sw |
| 5789 |
\@booleantrue\forcefloats@sw |
| 5790 |
% \end{macrocode} |
| 5791 |
% \begin{verbatim} |
| 5792 |
%\unvbox\@cclv |
| 5793 |
%\vfil |
| 5794 |
%\penalty-\pagebreak@pen |
| 5795 |
% \end{verbatim} |
| 5796 |
% \begin{macrocode} |
| 5797 |
\do@startcolumn |
| 5798 |
}% |
| 5799 |
% \end{macrocode} |
| 5800 |
% \end{macro} |
| 5801 |
% \end{macro} |
| 5802 |
% \end{macro} |
| 5803 |
% \end{macro} |
| 5804 |
% \end{macro} |
| 5805 |
% |
| 5806 |
% A more thorough revision of \LaTeX's float placement mechanism would involve substituting a single \cmd\box\ |
| 5807 |
% register for the \cmd\@deferlist. This way, \LaTeX's ability to have latent floats would be limited by |
| 5808 |
% box memory alone. |
| 5809 |
% |
| 5810 |
% Because only the \cmd\box\ and \cmd\count\ components of the float box register are actually used by \LaTeX, |
| 5811 |
% our scheme can be accomplished if we can find a way to encode the information held in the \cmd\count\ component. |
| 5812 |
% |
| 5813 |
% A first-in, first-out mechanism exists, wherein a box-penalty pair is dequeued by \cmd\lastbox\cmd\lastpenalty\cmd\unpenalty\ and enqueued |
| 5814 |
% by \cmd\setbox\cmd\foo=\cmd\hbox\cmd\bgroup\cmd\penalty\cmd\floatpenalty\cmd\box\cmd\floatbox\cmd\unhbox\cmd\foo\cmd\egroup. |
| 5815 |
% |
| 5816 |
% Note that this scheme is made possible by our change to \LaTeX's float placement mechanism, |
| 5817 |
% wherein we consolidated the two \cmd\@deferlist s into one. |
| 5818 |
% |
| 5819 |
% \section{Support for legacy \LaTeX\ commands} |
| 5820 |
% |
| 5821 |
% We provide support for the \cmd\enlargethispage\ command. |
| 5822 |
% |
| 5823 |
% Note: using a command of this sort does not automatically enlarge both pages of a spread, which would be the convention in page composition. |
| 5824 |
% |
| 5825 |
% Timing Note: In a multicolumn page grid, the user should issue the \cmd\enlargethispage\ command |
| 5826 |
% while the first column of the page is being typeset. |
| 5827 |
% We provide a helpful message if the timing is wrong. |
| 5828 |
% |
| 5829 |
% This code can serve as a model for introducing commands that need to execute within the safety of the output routine. |
| 5830 |
% We ensure that the arguments are fully expanded, then execute \cmd\do@output@MVL\ to cause an output procedure, |
| 5831 |
% \cmd\@@enlargethispage, to execute. When it does execute, the MVL will be exposed. |
| 5832 |
% |
| 5833 |
% The \cmd\@@enlargethispage\ procedure simply adjusts the vertical dimensions of the page. |
| 5834 |
% The adjustment will persist until the column is committed, at which point the page dimension |
| 5835 |
% will revert to its standard value. |
| 5836 |
% \begin{macrocode} |
| 5837 |
\def\enlargethispage{% |
| 5838 |
\@ifstar{% |
| 5839 |
\@enlargethispage{}% |
| 5840 |
}{% |
| 5841 |
\@enlargethispage{}% |
| 5842 |
}% |
| 5843 |
}% |
| 5844 |
\def\@enlargethispage#1#2{% |
| 5845 |
\begingroup |
| 5846 |
\dimen@#2\relax |
| 5847 |
\edef\@tempa{#1}% |
| 5848 |
\edef\@tempa{\noexpand\@@enlargethispage{\@tempa}{\the\dimen@}}% |
| 5849 |
\expandafter\do@output@MVL\expandafter{\@tempa}% |
| 5850 |
\endgroup |
| 5851 |
}% |
| 5852 |
\def\@@enlargethispage#1#2{% |
| 5853 |
\def\@tempa{one}% |
| 5854 |
\@ifx{\thepagegrid\@tempa}{% |
| 5855 |
\true@sw |
| 5856 |
}{% |
| 5857 |
\def\@tempa{mlt}% |
| 5858 |
\@ifx{\thepagegrid\@tempa}{% |
| 5859 |
\@ifnum{\pagegrid@cur=\@ne}{% |
| 5860 |
% \end{macrocode} |
| 5861 |
% OK to adjust this page |
| 5862 |
% \begin{macrocode} |
| 5863 |
\gdef\enlarge@colroom{#2}% |
| 5864 |
\true@sw |
| 5865 |
}{% |
| 5866 |
% \end{macrocode} |
| 5867 |
% Can only adjust this column; give up |
| 5868 |
% \begin{macrocode} |
| 5869 |
\ltxgrid@warn{Too late to enlarge this page; move the command to the first column.}% |
| 5870 |
\false@sw |
| 5871 |
}% |
| 5872 |
}{% |
| 5873 |
% \end{macrocode} |
| 5874 |
% Unknown page grid |
| 5875 |
% \begin{macrocode} |
| 5876 |
\ltxgrid@warn{Unable to enlarge a page of this kind.}% |
| 5877 |
\false@sw |
| 5878 |
}% |
| 5879 |
}% |
| 5880 |
{% |
| 5881 |
\class@info{Enlarging page \thepage\space by #2}% |
| 5882 |
\global\advance\@colroom#2\relax |
| 5883 |
\set@vsize |
| 5884 |
}{% |
| 5885 |
% \end{macrocode} |
| 5886 |
% Could not adjust this page |
| 5887 |
% \begin{macrocode} |
| 5888 |
}% |
| 5889 |
}% |
| 5890 |
\let\enlarge@colroom\@empty |
| 5891 |
% \end{macrocode} |
| 5892 |
% The \cmd\@kludgeins\ insert register is now unneeded. |
| 5893 |
% Ensure that packages using this mechanism break (preferrable to subtle bugs). |
| 5894 |
% \begin{macrocode} |
| 5895 |
\let\@kludgeins\@undefined |
| 5896 |
% \end{macrocode} |
| 5897 |
% |
| 5898 |
% \subsubsection{Building the page for shipout} |
| 5899 |
% |
| 5900 |
% \begin{macro}{\@outputpage@head} |
| 5901 |
% We set \cmd\@outputpage@head\ to make the \cmd\@outputbox\ be of fixed height. |
| 5902 |
% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}% |
| 5903 |
% \begin{macrocode} |
| 5904 |
\@booleantrue\textheight@sw |
| 5905 |
\prepdef\@outputpage@head{% |
| 5906 |
\textheight@sw{% |
| 5907 |
\count@\vbadness\vbadness\@M |
| 5908 |
\dimen@\vfuzz\vfuzz\maxdimen |
| 5909 |
\setbox\@outputbox\vbox to\textheight{\unvbox\@outputbox}% |
| 5910 |
\vfuzz\dimen@ |
| 5911 |
\vbadness\count@ |
| 5912 |
}{}% |
| 5913 |
}% |
| 5914 |
% \end{macrocode} |
| 5915 |
% \end{macro} |
| 5916 |
% |
| 5917 |
% \begin{macro}{\@outputpage@head} |
| 5918 |
% For compatibility with David Carlisle's \classname{lscape} package, we need to allow the |
| 5919 |
% \cmd\LS@rot\ procedure to mung \cmd\@outputbox. |
| 5920 |
% |
| 5921 |
% Implementation note: the \classname{lscape} package effectively tailpatches two \LaTeX\ internals to accomplish its purpose, |
| 5922 |
% an approach that is not robust. It is more robust to headpatch \cmd\@outputpage, which is what we do here. |
| 5923 |
% \changes{4.1o}{2010/02/02}{(AO, 576) Allow \classname{lscape} to act on \cs{@outputbox} at the right time}% |
| 5924 |
% \begin{macrocode} |
| 5925 |
\appdef\@outputpage@head{% |
| 5926 |
\@ifx{\LS@rot\@undefined}{}{\LS@rot}% |
| 5927 |
}% |
| 5928 |
% \end{macrocode} |
| 5929 |
% \end{macro} |
| 5930 |
% |
| 5931 |
% \subsubsection{Warning message} |
| 5932 |
% |
| 5933 |
% \begin{macro}{\ltxgrid@info} |
| 5934 |
% \begin{macro}{\ltxgrid@warn} |
| 5935 |
% Something has happened that the user might be interested in. |
| 5936 |
% Print a message to the log, but only if the user selected the verbose option. |
| 5937 |
% \begin{macrocode} |
| 5938 |
\def\ltxgrid@info{% |
| 5939 |
\ltxgrid@info@sw{\class@info}{\@gobble}% |
| 5940 |
}% |
| 5941 |
\@booleanfalse\ltxgrid@info@sw |
| 5942 |
\def\ltxgrid@warn{% |
| 5943 |
\ltxgrid@warn@sw{\class@warn}{\@gobble}% |
| 5944 |
}% |
| 5945 |
\@booleantrue\ltxgrid@warn@sw |
| 5946 |
\@booleanfalse\ltxgrid@foot@info@sw |
| 5947 |
% \end{macrocode} |
| 5948 |
% \end{macro} |
| 5949 |
% \end{macro} |
| 5950 |
% |
| 5951 |
% \section{Line-wise processing}% |
| 5952 |
% Sometimes we wish to process each line of type that will be placed into the galley, |
| 5953 |
% for example, applying line numbering to a document. |
| 5954 |
% To accomplish the task, we have to force a visit to the output routine after each such line, whereupon |
| 5955 |
% we can process it accordingly (in the case of line numbering, we could do as \filename{lineno.sty} and |
| 5956 |
% append an appropriately formed box to the MVL). |
| 5957 |
% |
| 5958 |
% In implementing such a scheme, we will have to instantiate interrupts for the following cases: |
| 5959 |
% \begin{description} |
| 5960 |
% |
| 5961 |
% \item[\cmd\interlinepenalty\ and friends] These include \cmd\clubpenalty, \cmd\widowpenalty, \cmd\displaywidowpenalty, and \cmd\brokenpenalty. |
| 5962 |
% |
| 5963 |
% |
| 5964 |
% \item[Display math penalties] Includes \cmd\predisplaypenalty, \cmd\postdisplaypenalty, and \cmd\interdisplaylinepenalty. |
| 5965 |
% |
| 5966 |
% |
| 5967 |
% \item[\cs{par}] The penalty following the last line of the paragraph. |
| 5968 |
% |
| 5969 |
% |
| 5970 |
% \item[\cmd\vadjust] A trap for any \cmd\vadjust\ command that falls in the paragraph. |
| 5971 |
% |
| 5972 |
% \end{description} |
| 5973 |
% |
| 5974 |
% \begin{macro}{\def@next@handler} |
| 5975 |
% \begin{macro}{\def@line@handler} |
| 5976 |
% Utility procedures \cmd\def@next@handler\ and \cmd\def@line@handler\ help in the creation of |
| 5977 |
% interrupt handlers. |
| 5978 |
% |
| 5979 |
% \cmd\def@next@handler\ increments the scratch count register (argument 1), |
| 5980 |
% using this value to \cmd\mathchardef\ its second argument |
| 5981 |
% as the negative of the flag value to be used as a penalty for exciting the interrupt (argument 3). |
| 5982 |
% As a byproduct, it leaves the given scratch counter incremented. |
| 5983 |
% \begin{macrocode} |
| 5984 |
\def\def@next@handler#1#2#3{% |
| 5985 |
\advance#1\@ne\mathchardef#2\the#1% |
| 5986 |
\expandafter\def\csname output@-\the#1\endcsname{#3}% |
| 5987 |
% \end{macrocode} |
| 5988 |
% The following line is for diagnostic purposes. |
| 5989 |
% \begin{verbatim} |
| 5990 |
% \typeout{\string#2(\expandafter\string\csname output@\the#1\endcsname:\expandafter\meaning\csname output@\the#1\endcsname)}% |
| 5991 |
% \end{verbatim} |
| 5992 |
% \begin{macrocode} |
| 5993 |
}% |
| 5994 |
% \end{macrocode} |
| 5995 |
% \cmd\def@line@handler\ uses \cmd\int@parpenalty\ as a base. |
| 5996 |
% The interrupt is the sum of that base with the first argument, |
| 5997 |
% and the handler is the second argument. |
| 5998 |
% \begin{macrocode} |
| 5999 |
\def\def@line@handler#1#2{% |
| 6000 |
\begingroup |
| 6001 |
\@tempcnta\int@parpenalty |
| 6002 |
\advance\@tempcnta-#1% |
| 6003 |
% \end{macrocode} |
| 6004 |
% The following line is for diagnostic purposes. |
| 6005 |
% \begin{verbatim} |
| 6006 |
% \typeout{Defining: \expandafter\string\csname output@\the\linenopenalty\endcsname}% |
| 6007 |
% \end{verbatim} |
| 6008 |
% \begin{macrocode} |
| 6009 |
\aftergroup\def |
| 6010 |
\expandafter\aftergroup\csname output@-\the\@tempcnta\endcsname |
| 6011 |
\endgroup{#2}% |
| 6012 |
}% |
| 6013 |
% \end{macrocode} |
| 6014 |
% \end{macro} |
| 6015 |
% \end{macro} |
| 6016 |
% |
| 6017 |
% \begin{macro}{\int@parpenalty} |
| 6018 |
% \begin{macro}{\@handle@line@ltx} |
| 6019 |
% \begin{macro}{\@@handle@line@ltx} |
| 6020 |
% We first set \cmd\int@parpenalty\ to our chosen base value${}\le -11012$. |
| 6021 |
% We then define all the handlers for lines within a paragraph, of which there are 12 different cases. |
| 6022 |
% \begin{macrocode} |
| 6023 |
\mathchardef\int@parpenalty11012 |
| 6024 |
\def@line@handler\z@{\@handle@line@ltx{}{}{}}% |
| 6025 |
\def@line@handler\@ne{\@handle@line@ltx{}{}{\brokenpenalty@ltx}}% |
| 6026 |
\def@line@handler\tw@{\@handle@line@ltx{}{\clubpenalty@ltx}{}}% |
| 6027 |
\def@line@handler\thr@@{\@handle@line@ltx{\clubpenalty@ltx}{}{\brokenpenalty@ltx}}% |
| 6028 |
\def@line@handler\f@ur{\@handle@line@ltx{\widowpenalty@ltx}{}{}}% |
| 6029 |
\def@line@handler{5}{\@handle@line@ltx{\widowpenalty@ltx}{}{\brokenpenalty@ltx}}% |
| 6030 |
\def@line@handler{6}{\@handle@line@ltx{\widowpenalty@ltx}{\clubpenalty@ltx}{}}% |
| 6031 |
\def@line@handler{7}{\@handle@line@ltx{\widowpenalty@ltx}{\clubpenalty@ltx}{\brokenpenalty@ltx}}% |
| 6032 |
\def@line@handler{8}{\@handle@line@ltx{\displaywidowpenalty@ltx}{}{}}% |
| 6033 |
\def@line@handler{9}{\@handle@line@ltx{\displaywidowpenalty@ltx}{}{\brokenpenalty@ltx}}% |
| 6034 |
\def@line@handler{10}{\@handle@line@ltx{\displaywidowpenalty@ltx}{\clubpenalty@ltx}{}}% |
| 6035 |
\def@line@handler{11}{\@handle@line@ltx{\displaywidowpenalty@ltx}{\clubpenalty@ltx}{\brokenpenalty@ltx}}% |
| 6036 |
% \end{macrocode} |
| 6037 |
% |
| 6038 |
% The default handler for lines within a paragraph simply |
| 6039 |
% restores the value of the \cmd\penalty\ to the normal value. |
| 6040 |
% If something more useful needs to be done, we can change the definition of \cmd\@@handle@line@ltx. |
| 6041 |
% \begin{macrocode} |
| 6042 |
\def\@handle@line@ltx#1#2#3{% |
| 6043 |
\@@handle@line@ltx |
| 6044 |
\@tempcnta\lastpenalty |
| 6045 |
\@tempcntb\interlinepenalty@ltx\relax |
| 6046 |
\@if@empty{#1}{}{\advance\@tempcntb#1\relax}% |
| 6047 |
\@if@empty{#2}{}{\advance\@tempcntb#2\relax}% |
| 6048 |
\@if@empty{#3}{}{\advance\@tempcntb#3\relax}% |
| 6049 |
\penalty\@ifnum{\@tempcnta<\@tempcntb}{\@tempcntb}{\@tempcnta}% |
| 6050 |
}% |
| 6051 |
\let\@@handle@line@ltx\@empty |
| 6052 |
% \end{macrocode} |
| 6053 |
% \end{macro} |
| 6054 |
% \end{macro} |
| 6055 |
% \end{macro} |
| 6056 |
% |
| 6057 |
% \begin{macro}{\int@postparpenalty} |
| 6058 |
% \begin{macro}{\int@vadjustpenalty} |
| 6059 |
% \begin{macro}{\int@whatsitpenalty} |
| 6060 |
% \begin{macro}{\int@predisplaypenalty} |
| 6061 |
% \begin{macro}{\int@interdisplaylinepenalty} |
| 6062 |
% \begin{macro}{\int@postdisplaypenalty} |
| 6063 |
% \begin{macro}{\@handle@display@ltx} |
| 6064 |
% \begin{macro}{\@@handle@display@ltx} |
| 6065 |
% \begin{macro}{\handle@par@ltx} |
| 6066 |
% We herewith define all the handlers for cases relating to display math: |
| 6067 |
% last line before a display math, |
| 6068 |
% last line of a display math, and a line within a display math. |
| 6069 |
% We also handle the last line of a paragraph, a whatsit node, and a \cmd\vadjust. |
| 6070 |
% \begin{macrocode} |
| 6071 |
\@tempcnta\int@parpenalty |
| 6072 |
\def@next@handler\@tempcnta\int@postparpenalty{\reset@queues@ltx\handle@par@ltx}% |
| 6073 |
\def@next@handler\@tempcnta\int@vadjustpenalty{\handle@vadjust@ltx}% |
| 6074 |
\def@next@handler\@tempcnta\int@whatsitpenalty{\handle@whatsit@ltx}% |
| 6075 |
\def@next@handler\@tempcnta\int@predisplaypenalty{\reset@queues@ltx\@handle@display@ltx{\predisplaypenalty@ltx}}% |
| 6076 |
\def@next@handler\@tempcnta\int@interdisplaylinepenalty{\@handle@display@ltx{\interdisplaylinepenalty@ltx}}% |
| 6077 |
\def@next@handler\@tempcnta\int@postdisplaypenalty{\@handle@display@ltx{\postdisplaypenalty@ltx}}% |
| 6078 |
% \end{macrocode} |
| 6079 |
% The default handler for display math lines simply |
| 6080 |
% restores the value of the \cmd\penalty\ to the normal value. |
| 6081 |
% If something more useful needs to be done, we can change the definition of \cmd\@@handle@display@ltx. |
| 6082 |
% \begin{macrocode} |
| 6083 |
\def\@handle@display@ltx#1{% |
| 6084 |
\@@handle@display@ltx |
| 6085 |
\@tempcnta\lastpenalty |
| 6086 |
\@tempcntb#1% |
| 6087 |
\penalty\@ifnum{\@tempcnta<\@tempcntb}{\@tempcntb}{\@tempcnta}% |
| 6088 |
}% |
| 6089 |
\let\@@handle@display@ltx\@empty |
| 6090 |
% \end{macrocode} |
| 6091 |
% |
| 6092 |
% We provide stub definitions for the handlers for the last line of a paragraph, a \cmd\vadjust, and a whatsit node (e.g., \cmd\write, \cmd\special). |
| 6093 |
% There is no canonical penalty for such cases. |
| 6094 |
% \begin{macrocode} |
| 6095 |
\def\handle@par@ltx{}% |
| 6096 |
% \end{macrocode} |
| 6097 |
% \end{macro} |
| 6098 |
% \end{macro} |
| 6099 |
% \end{macro} |
| 6100 |
% \end{macro} |
| 6101 |
% \end{macro} |
| 6102 |
% \end{macro} |
| 6103 |
% \end{macro} |
| 6104 |
% \end{macro} |
| 6105 |
% \end{macro} |
| 6106 |
% |
| 6107 |
% Note that a whatsit needs to be handled differently from a \cmd\vadjust: |
| 6108 |
% a whatsit node does not affect the (crucial) depth of \cmd\box\cmd\@cclv, while the more |
| 6109 |
% general \cmd\vadjust\ may cause any kind of vertical mode material to be interposed just below the line |
| 6110 |
% we are trying to trap, in particular \cmd\vskip s and \cmd\penalty s. |
| 6111 |
% |
| 6112 |
% \begin{macro}{\set@linepenalties} |
| 6113 |
% \begin{macro}{\restore@linepenalties} |
| 6114 |
% \begin{macro}{\set@displaypenalties} |
| 6115 |
% Now we define utility procedures that set up for a paragraph to be broken into lines, |
| 6116 |
% restoring the penalties afterwards. |
| 6117 |
% |
| 6118 |
% Utility procedure \cmd\set@linepenalties\ systematically sets the penalties of paragraph breaking |
| 6119 |
% to flag values, meanwhile storing away the normal values for access by the output routine. |
| 6120 |
% \begin{macrocode} |
| 6121 |
\def\set@linepenalties{% |
| 6122 |
\expandafter\def\expandafter\interlinepenalty@ltx\expandafter{\the\interlinepenalty}% |
| 6123 |
\interlinepenalty-\int@parpenalty |
| 6124 |
\expandafter\def\expandafter\brokenpenalty@ltx\expandafter{\the\brokenpenalty}% |
| 6125 |
\brokenpenalty\@ne |
| 6126 |
\expandafter\def\expandafter\clubpenalty@ltx\expandafter{\the\clubpenalty}% |
| 6127 |
\clubpenalty\tw@ |
| 6128 |
\expandafter\def\expandafter\widowpenalty@ltx\expandafter{\the\widowpenalty}% |
| 6129 |
\widowpenalty\f@ur |
| 6130 |
\expandafter\def\expandafter\displaywidowpenalty@ltx\expandafter{\the\displaywidowpenalty}% |
| 6131 |
\displaywidowpenalty8\relax |
| 6132 |
}% |
| 6133 |
% \end{macrocode} |
| 6134 |
% |
| 6135 |
% Utility procedure \cmd\restore@linepenalties\ restores the values of the penalty parameters that were |
| 6136 |
% modified by \cmd\set@linepenalties. |
| 6137 |
% \begin{macrocode} |
| 6138 |
\def\restore@linepenalties{% |
| 6139 |
\interlinepenalty\interlinepenalty@ltx |
| 6140 |
\brokenpenalty\brokenpenalty@ltx |
| 6141 |
\clubpenalty\clubpenalty@ltx |
| 6142 |
\widowpenalty\widowpenalty@ltx |
| 6143 |
\displaywidowpenalty\displaywidowpenalty@ltx |
| 6144 |
\relax |
| 6145 |
}% |
| 6146 |
% \end{macrocode} |
| 6147 |
% |
| 6148 |
% In the following, the first argument should be a boolean (either \cmd\true@sw\ or \cmd\false@sw). |
| 6149 |
% \begin{macrocode} |
| 6150 |
\def\set@displaypenalties#1{% |
| 6151 |
\expandafter\def\expandafter\predisplaypenalty@ltx\expandafter{\the\predisplaypenalty}% |
| 6152 |
\expandafter\def\expandafter\interdisplaylinepenalty@ltx\expandafter{\the\interdisplaylinepenalty}% |
| 6153 |
\expandafter\def\expandafter\postdisplaypenalty@ltx\expandafter{\the\postdisplaypenalty}% |
| 6154 |
\@ifhmode{\predisplaypenalty-\int@predisplaypenalty\relax}{}% |
| 6155 |
#1{\interdisplaylinepenalty-\int@interdisplaylinepenalty\relax}{}% |
| 6156 |
#1{\postdisplaypenalty-\int@postdisplaypenalty\relax}{}% |
| 6157 |
}% |
| 6158 |
% \end{macrocode} |
| 6159 |
% We provide no procedure to restore the respective penalties, because they are altered within a group: |
| 6160 |
% \TeX 's context stack will automatically restore things. |
| 6161 |
% \end{macro} |
| 6162 |
% \end{macro} |
| 6163 |
% \end{macro} |
| 6164 |
% |
| 6165 |
% \begin{macro}{\enqueue@whatsit@ltx}% |
| 6166 |
% \begin{macro}{\handle@whatsit@ltx}% |
| 6167 |
% \begin{macro}{\do@whatsit}% |
| 6168 |
% \begin{macro}{\@g@pop@ltx}% |
| 6169 |
% Here is a facility for dealing with whatsit nodes while we are trapping paragraph lines. |
| 6170 |
% We simply enqueue a macro that will create the desired whatsit node, dequeueing it in the output routine. |
| 6171 |
% \begin{macrocode} |
| 6172 |
\def\enqueue@whatsit@ltx#1{% |
| 6173 |
\gappdef\g@whatsit@queue{{#1}}% |
| 6174 |
\vadjust{\penalty-\int@whatsitpenalty}% |
| 6175 |
}% |
| 6176 |
\def\handle@whatsit@ltx{% |
| 6177 |
\unvbox\@cclv |
| 6178 |
\g@pop@ltx\g@whatsit@queue\@tempa |
| 6179 |
\expandafter\do@whatsit\expandafter{\@tempa}% |
| 6180 |
}% |
| 6181 |
\def\do@whatsit#1{}% |
| 6182 |
\def\g@pop@ltx#1#2{% |
| 6183 |
\expandafter\@g@pop@ltx#1{}{}\@@#1#2% |
| 6184 |
}% |
| 6185 |
\def\@g@pop@ltx#1#2\@@#3#4{% |
| 6186 |
\gdef#3{#2}% |
| 6187 |
\def#4{#1}% |
| 6188 |
}% |
| 6189 |
% \end{macrocode} |
| 6190 |
% \end{macro} |
| 6191 |
% \end{macro} |
| 6192 |
% \end{macro} |
| 6193 |
% \end{macro} |
| 6194 |
% |
| 6195 |
% \begin{macro}{\vspace}% |
| 6196 |
% \begin{macro}{\pagebreak}% |
| 6197 |
% \begin{macro}{\nopagebreak}% |
| 6198 |
% \begin{macro}{\\}% |
| 6199 |
% \begin{macro}{\@arrayparboxrestore}% |
| 6200 |
% We wish to prevent \filename{lineno.sty} from patching \cmd\vspace\ and \cmd\pagebreak, |
| 6201 |
% because that package does it through global assignments, which is prone to failure. |
| 6202 |
% |
| 6203 |
% We also wish to prevent that package from patching \cmd\@arrayparboxrestore, because |
| 6204 |
% it prevents us from \cmd\unvbox ing vertical mode material into the MVL and numbering those |
| 6205 |
% lines. |
| 6206 |
% |
| 6207 |
% We start by retaining the original definitions of these commands, so we can restore them |
| 6208 |
% if \filename{lineno.sty} does get loaded. |
| 6209 |
% \begin{macrocode} |
| 6210 |
\let\vspace@ltx\vspace |
| 6211 |
\let\pagebreak@ltx\pagebreak |
| 6212 |
\let\nopagebreak@ltx\nopagebreak |
| 6213 |
\let\endline@ltx\\ |
| 6214 |
\let\@arrayparboxrestore@ltx\@arrayparboxrestore |
| 6215 |
% \end{macrocode} |
| 6216 |
% |
| 6217 |
% Next, we provide for line-wise processing by patching the procedures associated with these same three commands. |
| 6218 |
% |
| 6219 |
% Depending on the running version of \LaTeX, these commands use \cs{vskip} (before 2020-10-01), or |
| 6220 |
% \cs{@vspace@calcify} to add \textsf{calc}-like support in the kernel. To avoid duplicating the tests, |
| 6221 |
% define a macro \cs{@tempa} that takes the right form of the primitive spacing command and defines \LaTeX's |
| 6222 |
% spacing macros accordingly. |
| 6223 |
% \begin{macrocode} |
| 6224 |
\def\@tempa#1{% |
| 6225 |
% \end{macrocode} |
| 6226 |
% |
| 6227 |
% There are exactly four core \LaTeX\ procedures that use \cmd\vadjust\ to insert vertical mode material |
| 6228 |
% into the main vertical list: \cmd\vspace, \cmd\pagebreak, \cmd\nopagebreak, and \cmd\\. |
| 6229 |
% Other commands may use \cmd\vadjust, but they are inserting an interrupt (via a penalty${}<10000$), |
| 6230 |
% and such a thing does not mask the depth of \cmd\box\cmd\@cclv, hence is permissible. |
| 6231 |
% |
| 6232 |
% In each case, we replace the core \LaTeX\ procedure with one that itself replaces \cmd\vadjust\ with |
| 6233 |
% \cmd\ex@vadjust@ltx. The meaning of this procedure can be left as \cmd\vadjust, or it can be changed to |
| 6234 |
% one that accomplishes the equivalent without masking the depth of \cmd\box\cmd\@cclv. |
| 6235 |
% |
| 6236 |
% The first procedure is \cmd\@vspace, here shown in original form and in the patched alternative form. |
| 6237 |
% This procedure and \cmd\@vspacer\ implement the \cmd\vspace\ command. |
| 6238 |
% |
| 6239 |
% \begin{macrocode} |
| 6240 |
\def\@vspace@org ##1{% |
| 6241 |
\ifvmode |
| 6242 |
#1% \vskip #1 |
| 6243 |
\vskip\z@skip |
| 6244 |
\else |
| 6245 |
\@bsphack |
| 6246 |
\vadjust{\@restorepar |
| 6247 |
#1% \vskip #1 |
| 6248 |
\vskip\z@skip |
| 6249 |
}% |
| 6250 |
\@esphack |
| 6251 |
\fi |
| 6252 |
}% |
| 6253 |
\def\@vspace@ltx##1{% |
| 6254 |
\@ifvmode{% |
| 6255 |
#1% \vskip #1 |
| 6256 |
\vskip\z@skip |
| 6257 |
}{% |
| 6258 |
\@bsphack |
| 6259 |
\ex@vadjust@ltx{% |
| 6260 |
\@restorepar |
| 6261 |
\nobreak |
| 6262 |
#1% \vskip #1 |
| 6263 |
\vskip\z@skip |
| 6264 |
}% |
| 6265 |
\@esphack |
| 6266 |
}% |
| 6267 |
}% |
| 6268 |
% \end{macrocode} |
| 6269 |
% |
| 6270 |
% The second procedure is \cmd\@vspacer. |
| 6271 |
% \begin{macrocode} |
| 6272 |
\def\@vspacer@org##1{% |
| 6273 |
\ifvmode |
| 6274 |
\dimen@\prevdepth |
| 6275 |
\hrule \@height\z@ |
| 6276 |
\nobreak |
| 6277 |
#1%\vskip #1 |
| 6278 |
\vskip\z@skip |
| 6279 |
\prevdepth\dimen@ |
| 6280 |
\else |
| 6281 |
\@bsphack |
| 6282 |
\vadjust{\@restorepar |
| 6283 |
\hrule \@height\z@ |
| 6284 |
\nobreak |
| 6285 |
#1%\vskip #1 |
| 6286 |
\vskip\z@skip}% |
| 6287 |
\@esphack |
| 6288 |
\fi |
| 6289 |
}% |
| 6290 |
\def\@vspacer@ltx##1{% |
| 6291 |
\@ifvmode{% |
| 6292 |
\dimen@\prevdepth |
| 6293 |
\hrule\@height\z@ |
| 6294 |
\nobreak |
| 6295 |
#1%\vskip#1 |
| 6296 |
\vskip\z@skip |
| 6297 |
\prevdepth\dimen@ |
| 6298 |
}{% |
| 6299 |
\@bsphack |
| 6300 |
\ex@vadjust@ltx{% |
| 6301 |
\@restorepar |
| 6302 |
\hrule\@height\z@ |
| 6303 |
\nobreak |
| 6304 |
#1%\vskip#1 |
| 6305 |
\vskip\z@skip |
| 6306 |
}% |
| 6307 |
\@esphack |
| 6308 |
}% |
| 6309 |
}% |
| 6310 |
% \end{macrocode} |
| 6311 |
% |
| 6312 |
% Now define the macros above conditionally depending on the \LaTeX version. |
| 6313 |
% \begin{macrocode} |
| 6314 |
} |
| 6315 |
\rvtx@ifformat@geq{2020/10/01}% |
| 6316 |
{\@tempa{\@vspace@calcify{#1}}}% |
| 6317 |
{\@tempa{\vskip #1 }}% |
| 6318 |
% \end{macrocode} |
| 6319 |
% |
| 6320 |
% The procedure \cmd\@no@pgbk\ implements both \cmd\pagebreak\ and \cmd\nopagebreak. |
| 6321 |
% \begin{macrocode} |
| 6322 |
\def\@no@pgbk@org #1[#2]{% |
| 6323 |
\ifvmode |
| 6324 |
\penalty #1\@getpen{#2}% |
| 6325 |
\else |
| 6326 |
\@bsphack |
| 6327 |
\vadjust{\penalty #1\@getpen{#2}}% |
| 6328 |
\@esphack |
| 6329 |
\fi |
| 6330 |
}% |
| 6331 |
\def\@no@pgbk@ltx#1[#2]{% |
| 6332 |
\@ifvmode{% |
| 6333 |
\penalty#1\@getpen{#2}% |
| 6334 |
}{% |
| 6335 |
\@bsphack |
| 6336 |
\ex@vadjust@ltx{% |
| 6337 |
\penalty#1\@getpen{#2}% |
| 6338 |
}% |
| 6339 |
\@esphack |
| 6340 |
}% |
| 6341 |
}% |
| 6342 |
% \end{macrocode} |
| 6343 |
% |
| 6344 |
% The command to end a line of type, \cmd\\, is defined via \cmd\DeclareRobustCommand, |
| 6345 |
% so we must proceed carefully: |
| 6346 |
% A procedure is defined whose \cmd\long\cmd\csname\ is contructed via the incantation: |
| 6347 |
% \cmd\csname\cmd\expandafter\cmd\@gobble\cmd\string\cmd\\ \cmd\endcsname. |
| 6348 |
% Note the non-trivial space character after the \cmd\\: it is incorporated into |
| 6349 |
% the \cmd\csname. |
| 6350 |
% |
| 6351 |
% Here is the original core \LaTeX\ definition for |
| 6352 |
% the procedure involved, along with our revised version. |
| 6353 |
% \changes{2020/09/30}{4.2d}{Conditionally use \cs{protected} or \cs{long} to track \LaTeX{} changes.} |
| 6354 |
% \begin{macrocode} |
| 6355 |
\rvtx@ifformat@geq{2020/02/02}% |
| 6356 |
{\protected}{\long}\def\end@line@org{% |
| 6357 |
\let\reserved@e\relax |
| 6358 |
\let\reserved@f\relax |
| 6359 |
\@ifstar{% |
| 6360 |
\let\reserved@e\vadjust |
| 6361 |
\let\reserved@f\nobreak |
| 6362 |
\@xnewline |
| 6363 |
}% |
| 6364 |
\@xnewline |
| 6365 |
}% |
| 6366 |
\rvtx@ifformat@geq{2020/02/02}% |
| 6367 |
{\protected}{\long}\def\end@line@ltx{% |
| 6368 |
\let\reserved@e\relax |
| 6369 |
\let\reserved@f\relax |
| 6370 |
\@ifstar{% |
| 6371 |
\let\reserved@e\ex@vadjust@ltx |
| 6372 |
\let\reserved@f\nobreak |
| 6373 |
\@xnewline |
| 6374 |
}{% |
| 6375 |
\@xnewline |
| 6376 |
}% |
| 6377 |
}% |
| 6378 |
% \end{macrocode} |
| 6379 |
% An additional procedure requiring patching has the following original core \LaTeX\ |
| 6380 |
% definition; we modify it correspondingly. |
| 6381 |
% \begin{macrocode} |
| 6382 |
\def\@tempa#1{% |
| 6383 |
\def\@newline@org[##1]{% |
| 6384 |
\let\reserved@e\vadjust |
| 6385 |
\@gnewline{#1}% \vskip#1 |
| 6386 |
}% |
| 6387 |
\def\@newline@ltx[##1]{% |
| 6388 |
\let\reserved@e\ex@vadjust@ltx |
| 6389 |
\@gnewline{#1}% \vskip#1 |
| 6390 |
}% |
| 6391 |
} |
| 6392 |
\rvtx@ifformat@geq{2020/10/01}% |
| 6393 |
{\@tempa{\@vspace@calcify{#1}}}% |
| 6394 |
{\@tempa{\vskip #1}}% |
| 6395 |
% \end{macrocode} |
| 6396 |
% We now install our patches. |
| 6397 |
% If some package overrides these macros, we will detect and complain. |
| 6398 |
% |
| 6399 |
% \begin{macrocode} |
| 6400 |
\@ifx{\@vspace\@vspace@org}{% |
| 6401 |
\@ifx{\@vspacer\@vspacer@org}{% |
| 6402 |
\@ifx{\@no@pgbk\@no@pgbk@org}{% |
| 6403 |
\@ifx{\@newline\@newline@org}{% |
| 6404 |
\expandafter\@ifx\expandafter{% |
| 6405 |
\csname\rvtx@ifformat@geq{2020/02/02}% |
| 6406 |
{\expandafter\@gobble\string\\}% |
| 6407 |
{\expandafter\@gobble\string\\ }\endcsname |
| 6408 |
\end@line@org |
| 6409 |
}{% |
| 6410 |
\true@sw |
| 6411 |
}{\false@sw}% |
| 6412 |
}{\false@sw}% |
| 6413 |
}{\false@sw}% |
| 6414 |
}{\false@sw}% |
| 6415 |
}{\false@sw}% |
| 6416 |
{% |
| 6417 |
\class@info{Overriding \string\@vspace, \string\@vspacer, \string\@no@pgbk, \string\@newline, and \string\\ }% |
| 6418 |
\let\@normalcr\end@line@ltx |
| 6419 |
\expandafter\let |
| 6420 |
\csname\rvtx@ifformat@geq{2020/02/02}% |
| 6421 |
{\expandafter\@gobble\string\\}% |
| 6422 |
{\expandafter\@gobble\string\\ }\endcsname\@normalcr |
| 6423 |
\let\@newline\@newline@ltx |
| 6424 |
\let\@vspace\@vspace@ltx |
| 6425 |
\let\@vspacer\@vspacer@ltx |
| 6426 |
\let\@no@pgbk\@no@pgbk@ltx |
| 6427 |
}{% |
| 6428 |
\class@warn{% |
| 6429 |
Failed to recognize \string\@vspace, \string\@vspacer, \string\@no@pgbk, \string\@newline, and \string\\; |
| 6430 |
no patches applied. Please get a more up-to-date class, |
| 6431 |
}% |
| 6432 |
}% |
| 6433 |
% \end{macrocode} |
| 6434 |
% Note that we have assigned the same meaning to \cmd\@normalcr, which is necessary to \LaTeX. |
| 6435 |
% \end{macro} |
| 6436 |
% \end{macro} |
| 6437 |
% \end{macro} |
| 6438 |
% \end{macro} |
| 6439 |
% \end{macro} |
| 6440 |
% |
| 6441 |
% \begin{macro}{\ex@vadjust@ltx} |
| 6442 |
% \begin{macro}{\enqueue@vadjust@ltx} |
| 6443 |
% \begin{macro}{\handle@vadjust@ltx} |
| 6444 |
% \begin{macro}{\g@vadjust@line} |
| 6445 |
% \begin{macro}{\reset@queues@ltx} |
| 6446 |
% Here we give the default definition for \cmd\ex@vadjust@ltx\ along with |
| 6447 |
% the definitions for the alternative version and its the associated handler. |
| 6448 |
% \begin{macrocode} |
| 6449 |
\let\ex@vadjust@ltx\vadjust |
| 6450 |
\def\enqueue@vadjust@ltx#1{% |
| 6451 |
\gappdef\g@vadjust@queue{{#1}}% |
| 6452 |
\vadjust{\penalty-\int@vadjustpenalty}% |
| 6453 |
}% |
| 6454 |
\def\handle@vadjust@ltx{% |
| 6455 |
\unvbox\@cclv |
| 6456 |
\g@pop@ltx\g@vadjust@queue\@tempa |
| 6457 |
\expandafter\gappdef\expandafter\g@vadjust@line\expandafter{\@tempa}% |
| 6458 |
}% |
| 6459 |
\let\g@vadjust@line\@empty |
| 6460 |
% \end{macrocode} |
| 6461 |
% Procedure \cmd\reset@queues@ltx\ resets the whatsit queue and the \cmd\vadjust\ queues |
| 6462 |
% to their empty state. This should be done whenever we leave horizontal mode and |
| 6463 |
% complete the processing of these queues: upon executing, effectively, primitive \cmd\par\ |
| 6464 |
% or interrupting a paragraph with display math. |
| 6465 |
% \begin{macrocode} |
| 6466 |
\def\reset@queues@ltx{% |
| 6467 |
\global\let\g@whatsit@queue\@empty |
| 6468 |
\global\let\g@vadjust@queue\@empty |
| 6469 |
}% |
| 6470 |
% \end{macrocode} |
| 6471 |
% \end{macro} |
| 6472 |
% \end{macro} |
| 6473 |
% \end{macro} |
| 6474 |
% \end{macro} |
| 6475 |
% \end{macro} |
| 6476 |
% |
| 6477 |
% \section{Patching the lineno.sty package} |
| 6478 |
% |
| 6479 |
% \filename{lineno.sty} is a \LaTeX\ package that applies line numbering to a document. |
| 6480 |
% The basic method is to give \cmd\interlinepenalty\ and like penalties such a value as |
| 6481 |
% to force a visit to the output routine, where the line of type is given its number. |
| 6482 |
% In order to properly measure the depth of \cmd\box\cmd\@cclv, it defers \cmd\vadjust\ |
| 6483 |
% commands that may insert \cmd\vskip\ or \cmd\penalty\ nodes. |
| 6484 |
% |
| 6485 |
% The implementation of that package, however, manipulates \cmd\holdinginserts\ in a dangerous |
| 6486 |
% way: outside the safety of the output routine. It also alters the meaning of \cmd\vadjust\ |
| 6487 |
% using global assignments. We patch its code to avoid these problems. The \filename{ltxgrid} |
| 6488 |
% package already has the needed mechanisms in place to do these jobs correctly. |
| 6489 |
% |
| 6490 |
% The methods we use can accomodate any values of penalties like \cmd\clubpenalty, etc: |
| 6491 |
% we do not make assumptions about the range of values these penalty parameters could take. |
| 6492 |
% |
| 6493 |
% |
| 6494 |
% \begin{macro}{\linenomathWithnumbers} |
| 6495 |
% \begin{macro}{\linenomathNonumbers} |
| 6496 |
% \begin{macro}{\endlinenomath} |
| 6497 |
% \begin{macro}{\linenumberpar} |
| 6498 |
% Here are the definitions of procedures in \filename{lineno.sty} |
| 6499 |
% that alter \cmd\holdinginserts. They are current as of version v4.41, 2005/11/02. |
| 6500 |
% We patch them to avoid doing this: in ltxgrid-based classes like REVTeX, the output routine properly manages \cmd\holdinginserts, so packages should not attempt to do so. |
| 6501 |
% Also, we will want \cmd\linenumberpar\ to set \cmd\interlinepenaly\ to dispatch to \cmd\MakeLineNo. |
| 6502 |
% |
| 6503 |
% \begin{macrocode} |
| 6504 |
\newcommand\linenomathWithnumbers@LN{% |
| 6505 |
\ifLineNumbers |
| 6506 |
\ifnum\interlinepenalty>-\linenopenaltypar |
| 6507 |
\global\holdinginserts\thr@@ |
| 6508 |
\advance\interlinepenalty \linenopenalty |
| 6509 |
\ifhmode |
| 6510 |
\advance\predisplaypenalty \linenopenalty |
| 6511 |
\fi |
| 6512 |
\advance\postdisplaypenalty \linenopenalty |
| 6513 |
\advance\interdisplaylinepenalty \linenopenalty |
| 6514 |
\fi |
| 6515 |
\fi |
| 6516 |
\ignorespaces |
| 6517 |
}% |
| 6518 |
\newcommand\linenomathNonumbers@LN{% |
| 6519 |
\ifLineNumbers |
| 6520 |
\ifnum\interlinepenalty>-\linenopenaltypar |
| 6521 |
\global\holdinginserts\thr@@ |
| 6522 |
\advance\interlinepenalty \linenopenalty |
| 6523 |
\ifhmode |
| 6524 |
\advance\predisplaypenalty \linenopenalty |
| 6525 |
\fi |
| 6526 |
\fi |
| 6527 |
\fi |
| 6528 |
\ignorespaces |
| 6529 |
}% |
| 6530 |
\def\endlinenomath@LN{% |
| 6531 |
\ifLineNumbers |
| 6532 |
\global\holdinginserts\@LN@outer@holdins |
| 6533 |
\fi |
| 6534 |
\global\@ignoretrue |
| 6535 |
} |
| 6536 |
\def\linenumberpar@LN{% |
| 6537 |
\ifvmode \@@@par \else |
| 6538 |
\ifinner \@@@par \else |
| 6539 |
\xdef\@LN@outer@holdins{\the\holdinginserts}% |
| 6540 |
\advance \interlinepenalty \linenopenalty |
| 6541 |
\linenoprevgraf \prevgraf |
| 6542 |
\global \holdinginserts \thr@@ |
| 6543 |
\@@@par |
| 6544 |
\ifnum\prevgraf>\linenoprevgraf |
| 6545 |
\penalty-\linenopenaltypar |
| 6546 |
\fi |
| 6547 |
\@LN@parpgbrk |
| 6548 |
\global\holdinginserts\@LN@outer@holdins |
| 6549 |
\advance\interlinepenalty -\linenopenalty |
| 6550 |
\fi |
| 6551 |
\fi |
| 6552 |
}% |
| 6553 |
% \end{macrocode} |
| 6554 |
% \end{macro} |
| 6555 |
% \end{macro} |
| 6556 |
% \end{macro} |
| 6557 |
% \end{macro} |
| 6558 |
% |
| 6559 |
% \begin{macro}{\class@documenthook} |
| 6560 |
% We patch only if we recognize the definitions of all the procedures we are to patch. |
| 6561 |
% \begin{macrocode} |
| 6562 |
\appdef\class@documenthook{% |
| 6563 |
\@ifpackageloaded{lineno}{% |
| 6564 |
\@ifx{\linenomathWithnumbers\linenomathWithnumbers@LN}{% |
| 6565 |
\@ifx{\linenomathNonumbers\linenomathNonumbers@LN}{% |
| 6566 |
\@ifx{\endlinenomath\endlinenomath@LN}{% |
| 6567 |
\@ifx{\linenumberpar\linenumberpar@LN}{% |
| 6568 |
\true@sw |
| 6569 |
}{\false@sw}% |
| 6570 |
}{\false@sw}% |
| 6571 |
}{\false@sw}% |
| 6572 |
}{\false@sw}% |
| 6573 |
{% |
| 6574 |
\class@info{Overriding lineo.sty, restoring output routine,}% |
| 6575 |
% \end{macrocode} |
| 6576 |
% We commence overriding the procedures of \filename{lineno.sty}. |
| 6577 |
% \begin{macrocode} |
| 6578 |
\let\linenumberpar\linenumberpar@ltx |
| 6579 |
\let\endlinenomath\endlinenomath@ltx |
| 6580 |
\expandafter\let\csname endlinenomath*\endcsname\endlinenomath@ltx |
| 6581 |
\let\linenomathWithnumbers\linenomathWithnumbers@ltx |
| 6582 |
\let\linenomathNonumbers\linenomathNonumbers@ltx |
| 6583 |
% \end{macrocode} |
| 6584 |
% Override \filename{lineno.sty}'s equipment for \cmd\vadjust\ and \cmd\linelabel: |
| 6585 |
% we have existing interrupts and handlers for these purposes. |
| 6586 |
% \begin{macrocode} |
| 6587 |
\let\ex@vadjust@ltx\ex@vadjust@line |
| 6588 |
\let\@LN@postlabel\enqueue@whatsit@ltx |
| 6589 |
\let\do@whatsit\write@linelabel |
| 6590 |
% \end{macrocode} |
| 6591 |
% Redirect handlers to those provided by \filename{lineno.sty}, and |
| 6592 |
% give an appropriate meaning to the respective headpatch within the handlers. |
| 6593 |
% \begin{macrocode} |
| 6594 |
\let\handle@par@ltx\handle@par@LN |
| 6595 |
\let\@@handle@line@ltx\Make@LineNo@ltx |
| 6596 |
\let\@@handle@display@ltx\Make@LineNo@ltx |
| 6597 |
% \end{macrocode} |
| 6598 |
% Next, we undo the action taken by \filename{lineno.sty} wherein it |
| 6599 |
% took over the output routine. Instead, we service \filename{lineno.sty} |
| 6600 |
% existing equipment of \filename{ltxgrid}. |
| 6601 |
% We also revert the core \LaTeX\ definitions of |
| 6602 |
% \cmd\vspace, \cmd\pagebreak, \cmd\nopagebreak, and \cmd\\, |
| 6603 |
% which that package takes over (we have our own ways of doing these things). |
| 6604 |
% \begin{macrocode} |
| 6605 |
\output@latex{\natural@output}% |
| 6606 |
\let\vspace\vspace@ltx |
| 6607 |
\let\pagebreak\pagebreak@ltx |
| 6608 |
\let\nopagebreak\nopagebreak@ltx |
| 6609 |
\let\@arrayparboxrestore\@arrayparboxrestore@ltx |
| 6610 |
\let\\\endline@ltx |
| 6611 |
% \end{macrocode} |
| 6612 |
% \changes{4.1f}{2009/07/07}{(AO, 515) Prevent line numbering within a footnote} |
| 6613 |
% When line numbering is in effect, we must avoid any attempt to number the lines of a footnote. |
| 6614 |
% \begin{macrocode} |
| 6615 |
\appdef\set@footnotefont{% |
| 6616 |
\let\par\@@@par |
| 6617 |
\let\@@par\@@@par |
| 6618 |
}% |
| 6619 |
% \end{macrocode} |
| 6620 |
% At last, we detect if the \cmd\linenumbers\ command has already been given; |
| 6621 |
% if so, we do its assignments again, because we have changed the meaning of \cmd\linenumberpar. |
| 6622 |
% \begin{macrocode} |
| 6623 |
\@if@sw\ifLineNumbers\fi{% |
| 6624 |
\class@info{Reinvoke \string\linenumbers}% |
| 6625 |
\let\@@par\linenumberpar |
| 6626 |
\@ifx{\@par\linenumberpar@LN}{\let\@par\linenumberpar}{}% |
| 6627 |
\@ifx{\par\linenumberpar@LN}{\let\par\linenumberpar}{}% |
| 6628 |
}{% |
| 6629 |
\class@info{Line numbering not turned on yet}% |
| 6630 |
}% |
| 6631 |
% \end{macrocode} |
| 6632 |
% Here ends the ``true branch'' of the patch code. |
| 6633 |
% \begin{macrocode} |
| 6634 |
}{% |
| 6635 |
% \end{macrocode} |
| 6636 |
% If the \filename{lineno.sty} package is loaded, but we fail to patch it, notify the user. |
| 6637 |
% \begin{macrocode} |
| 6638 |
\class@warn{Failed to recognize lineno.sty procedures; no patches applied. Please get a more up-to-date class.}% |
| 6639 |
}% |
| 6640 |
}{% |
| 6641 |
% \end{macrocode} |
| 6642 |
% \filename{lineno.sty} is not loaded, so no patches are needed. |
| 6643 |
% \begin{macrocode} |
| 6644 |
}% |
| 6645 |
}% |
| 6646 |
% \end{macrocode} |
| 6647 |
% \end{macro} |
| 6648 |
% |
| 6649 |
% \begin{macro}{\linenumberpar} |
| 6650 |
% \begin{macro}{\@linenumberpar} |
| 6651 |
% Procedure \cmd\linenumberpar\ takes the place of \cmd\par\ when line numbering is in effect; |
| 6652 |
% It executes the \cmd\par\ primitive if we are in vertical mode. |
| 6653 |
% Otherwise we are in horizontal mode in the MVL and wish to end the current paragraph, |
| 6654 |
% or we have \cmd\unvbox ed material onto the MVL. |
| 6655 |
% |
| 6656 |
% \begin{macrocode} |
| 6657 |
\def\linenumberpar@ltx{\@ifvmode{\@@@par}{\@linenumberpar}}% |
| 6658 |
% \end{macrocode} |
| 6659 |
% |
| 6660 |
% Procedure \cmd\@linenumberpar |
| 6661 |
% \begin{macrocode} |
| 6662 |
\def\@linenumberpar{% |
| 6663 |
% \end{macrocode} |
| 6664 |
% Prepare for our trip into the output routine by |
| 6665 |
% saving away the current value of \cmd\prevgraf. |
| 6666 |
% \begin{macrocode} |
| 6667 |
\linenoprevgraf\prevgraf |
| 6668 |
% \end{macrocode} |
| 6669 |
% The following will be used in the output routine dispatcher |
| 6670 |
% to sense that we came from here. |
| 6671 |
% \begin{macrocode} |
| 6672 |
\set@linepenalties |
| 6673 |
% \end{macrocode} |
| 6674 |
% Finally, call primitive \cmd\par\ with the signal value of \cmd\interlinepenalty\ and friends. |
| 6675 |
% \begin{macrocode} |
| 6676 |
\@@@par |
| 6677 |
% \end{macrocode} |
| 6678 |
% We are now in vertical mode. |
| 6679 |
% If lines of type were contributed to the MVL (non-trivial paragraph), |
| 6680 |
% we must force another trip into the output routine to apply |
| 6681 |
% line numbering to the last line of the paragraph. |
| 6682 |
% \begin{macrocode} |
| 6683 |
\@ifnum{\prevgraf>\linenoprevgraf}{ |
| 6684 |
\penalty-\int@postparpenalty |
| 6685 |
}{}% |
| 6686 |
% \end{macrocode} |
| 6687 |
% Execute procedure \cmd\@LN@parpgbrk, which has been set up in the |
| 6688 |
% output routine for us to invoke here. |
| 6689 |
% |
| 6690 |
% \begin{macrocode} |
| 6691 |
\@LN@parpgbrk |
| 6692 |
% \end{macrocode} |
| 6693 |
% To wrap things up, we restore the original value of \cmd\interlinepenalty\ and friends. |
| 6694 |
% |
| 6695 |
% Query: why not employ \TeX's context stack to do the restore? |
| 6696 |
% Would there be something wrong with executing primitive \cmd\par\ within a group? |
| 6697 |
% \begin{macrocode} |
| 6698 |
\restore@linepenalties |
| 6699 |
}% |
| 6700 |
% \end{macrocode} |
| 6701 |
% \end{macro} |
| 6702 |
% \end{macro} |
| 6703 |
% |
| 6704 |
% \begin{macro}{\linenomathWithnumbers} |
| 6705 |
% \begin{macro}{\linenomathNonumbers} |
| 6706 |
% Here are the patched definitions for the commands enabling |
| 6707 |
% line numbering in display math. |
| 6708 |
% \begin{macrocode} |
| 6709 |
\newcommand\linenomathWithnumbers@ltx{\@linenomathnumbers@ltx\true@sw}% |
| 6710 |
\newcommand\linenomathNonumbers@ltx{\@linenomathnumbers@ltx\false@sw}% |
| 6711 |
% \end{macrocode} |
| 6712 |
% \end{macro} |
| 6713 |
% \end{macro} |
| 6714 |
% |
| 6715 |
% \begin{macro}{\@linenomathnumbers} |
| 6716 |
% \begin{macro}{\endlinenomath} |
| 6717 |
% We have just begun a display math, and any paragraph we are setting will now end. |
| 6718 |
% We set all relevant penalties to interrupt values; in the visit to the output routine, |
| 6719 |
% we will replace the penalty with its normal value. |
| 6720 |
% \begin{macrocode} |
| 6721 |
\def\@linenomathnumbers@ltx#1{% |
| 6722 |
\@if@sw\ifLineNumbers\fi{% |
| 6723 |
\set@linepenalties |
| 6724 |
\set@displaypenalties#1% |
| 6725 |
}{}% |
| 6726 |
\ignorespaces |
| 6727 |
}% |
| 6728 |
\def\endlinenomath@ltx{% |
| 6729 |
\global\@ignoretrue |
| 6730 |
}% |
| 6731 |
% \end{macrocode} |
| 6732 |
% \end{macro} |
| 6733 |
% \end{macro} |
| 6734 |
% |
| 6735 |
% We provide a handler for the last line of a paragraph. |
| 6736 |
% \begin{macrocode} |
| 6737 |
\def\handle@par@LN{% |
| 6738 |
\Make@LineNo@ltx |
| 6739 |
% \end{macrocode} |
| 6740 |
% After setting the line number, we arrange for an appropriate penalty to |
| 6741 |
% be laid down after this visit to the output routine ends. |
| 6742 |
% |
| 6743 |
% Query: why not contribute the penalty right here in the visit to the output routine? |
| 6744 |
% \begin{macrocode} |
| 6745 |
\@tempcnta\lastpenalty |
| 6746 |
\@ifnum{\@tempcnta=\z@}{}{% |
| 6747 |
\expandafter\gdef |
| 6748 |
\expandafter\@LN@parpgbrk |
| 6749 |
\expandafter{% |
| 6750 |
\expandafter\penalty |
| 6751 |
\the\@tempcnta |
| 6752 |
% \end{macrocode} |
| 6753 |
% When \cmd\@LN@parpgbrk\ is executed, it resets itself to the default value, |
| 6754 |
% \cmd\@LN@screenoff@pen. |
| 6755 |
% |
| 6756 |
% Query: \cmd\@LN@screenoff@pen\ appears to try to restore the depth of the last box: |
| 6757 |
% why is this being done outside the safety of the output routine? |
| 6758 |
% \begin{macrocode} |
| 6759 |
\global\let\@LN@parpgbrk\@LN@screenoff@pen |
| 6760 |
}% |
| 6761 |
}% |
| 6762 |
}% |
| 6763 |
% \end{macrocode} |
| 6764 |
% |
| 6765 |
% \begin{macro}{\Make@LineNo} |
| 6766 |
% The procedure \cmd\Make@LineNo\ sets the box containing the line number itself. |
| 6767 |
% \begin{macrocode} |
| 6768 |
\def\Make@LineNo@ltx{% |
| 6769 |
\@LN@maybe@normalLineNumber |
| 6770 |
% \end{macrocode} |
| 6771 |
% We measure the depth of \cmd\box\cmd\@cclv\ and unbox it. |
| 6772 |
% At this point, it is crucial that that box have the same depth as that of the last |
| 6773 |
% box within it. |
| 6774 |
% |
| 6775 |
% In the simple case, \cmd\box\cmd\@cclv\ is |
| 6776 |
% a \cmd\vbox\ containing as its last box the \cmd\hbox\ of the paragraph we are processing. |
| 6777 |
% |
| 6778 |
% Query: under what circumstances will this \emph{not} be the case? |
| 6779 |
% \begin{macrocode} |
| 6780 |
\boxmaxdepth\maxdimen\setbox\z@\vbox{\unvbox\@cclv}% |
| 6781 |
\@tempdima\dp\z@ |
| 6782 |
\unvbox\z@ |
| 6783 |
% \end{macrocode} |
| 6784 |
% Then we create the box with the line number, setting its height to zero. |
| 6785 |
% \begin{macrocode} |
| 6786 |
\sbox\@tempboxa{\hb@xt@\z@{\makeLineNumber}}% |
| 6787 |
\ht\@tempboxa\z@ |
| 6788 |
% \end{macrocode} |
| 6789 |
% With these preparations, we invoke \cmd\@LN@depthbox, which |
| 6790 |
% lays that box down (with its depth appropriately set): |
| 6791 |
% this procedure depends on our having set \cmd\@tempdima\ and \cmd\@tempboxa |
| 6792 |
% (kinda kludgy way of passing arguments, really). |
| 6793 |
% \begin{macrocode} |
| 6794 |
\@LN@depthbox |
| 6795 |
% \end{macrocode} |
| 6796 |
% Now increment the line number. I have relocated this token past \cmd\@LN@depthbox: |
| 6797 |
% this may induce a bug, but I am going to hereby force the issue: |
| 6798 |
% why split up the procedure that lays down boxes with a procedure that sets a register value? |
| 6799 |
% \begin{macrocode} |
| 6800 |
\stepLineNumber |
| 6801 |
% \end{macrocode} |
| 6802 |
% Finally, execute the \cmd\vadjust s that fell within the line that we just handled. |
| 6803 |
% |
| 6804 |
% Note that \cmd\enqueue@vadjust@ltx\ had queued up all the \cmd\vadjust\ commands for the paragraph |
| 6805 |
% into \cmd\g@vadjust@queue, laying down an (\cmd\int@vadjustpenalty) interrupt in each ones' place. |
| 6806 |
% The interrupts associated with this line of the paragraph have now moved the tokens to \cmd\g@vadjust@line, |
| 6807 |
% which we now expand and execute. |
| 6808 |
% \begin{macrocode} |
| 6809 |
\g@vadjust@line |
| 6810 |
\global\let\g@vadjust@line\@empty |
| 6811 |
}% |
| 6812 |
% \end{macrocode} |
| 6813 |
% |
| 6814 |
% \begin{macrocode} |
| 6815 |
\def\write@linelabel#1{% |
| 6816 |
\protected@write\@auxout{}{% |
| 6817 |
\string\newlabel{#1}{{\theLineNumber}{\thepage}{}{}{}}% |
| 6818 |
}% |
| 6819 |
}% |
| 6820 |
% \end{macrocode} |
| 6821 |
% |
| 6822 |
% \begin{macrocode} |
| 6823 |
\def\ex@vadjust@line{% |
| 6824 |
\@if@sw\ifLineNumbers\fi{\enqueue@vadjust@ltx}{\vadjust}% |
| 6825 |
}% |
| 6826 |
% \end{macrocode} |
| 6827 |
% \end{macro} |
| 6828 |
% |
| 6829 |
% Note that the \cmd\linelabel\ commands use a mechanism different from \cmd\vadjust, |
| 6830 |
% embodied in the procedure \cmd\enqueue@vadjust@ltx, wherein the |
| 6831 |
% \cmd\write\ primitives are enqueued while the paragraph is being processed, each replaced with |
| 6832 |
% an interrupt, then dequeued and executed by the interrupt handler, leaving a \cmd\write\ node |
| 6833 |
% in place of the interrupt (just where the \cmd\vadjust 's vertical mode material would had been) |
| 6834 |
% just below the box containing the line of type. This \cmd\write, like all whatsits, |
| 6835 |
% does not affect the depth of \cmd\box\cmd\@cclv, unlike the case of general vertical mode material, |
| 6836 |
% which could have interfered. |
| 6837 |
% |
| 6838 |
% \section{End of the \file{ltxgrid} {\sc docstrip} module} |
| 6839 |
% Here ends the module. |
| 6840 |
% \begin{macrocode} |
| 6841 |
%</kernel> |
| 6842 |
% \end{macrocode} |
| 6843 |
% |
| 6844 |
% \Finale |
| 6845 |
% %Here ends the programmer's documentation. |
| 6846 |
% \endinput |
| 6847 |
% |
| 6848 |
\endinput |
| 6849 |
%%EOF |