summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/revtex/ltxgrid.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/revtex/ltxgrid.dtx')
-rw-r--r--Master/texmf-dist/source/latex/revtex/ltxgrid.dtx2814
1 files changed, 2165 insertions, 649 deletions
diff --git a/Master/texmf-dist/source/latex/revtex/ltxgrid.dtx b/Master/texmf-dist/source/latex/revtex/ltxgrid.dtx
index ab0209ed098..fdd4a9fbfc5 100644
--- a/Master/texmf-dist/source/latex/revtex/ltxgrid.dtx
+++ b/Master/texmf-dist/source/latex/revtex/ltxgrid.dtx
@@ -1,29 +1,127 @@
-% \iffalse ltxdoc klootch
+% \iffalse meta-comment balanced on line 109
% ltxgrid.dtx: package to change page grid, MVL.
-% Copyright (c) 1999 Arthur Ogawa
+% Copyright (c) 2009 Arthur Ogawa
%
% Disclaimer
% This file is distributed WITHOUT ANY WARRANTY;
% without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% License
+% You may distribute this file under the conditions of the
+% LaTeX Project Public License 1.3 or later
+% (http://www.latex-project.org/lppl.txt).
% ReadMe
% For the documentation and more detailed instructions for
% installation, typeset this document with \LaTeX.
+% Maintenance Status
+% This work has the LPPL maintenance status "maintained";
+% Current Maintainer of this work is Arthur Ogawa.
+%
+% This work consists of the main source file ltxgrid.dtx
+% and the derived files
+% ltxgrid.sty, ltxgrid.pdf
+% Distribution:
+% CTAN:macros/latex/contrib/revtex/
+%
+% Unpacking:
+% tex ltxgrid.dtx
+%
+% Documentation:
+% latex ltxgrid.dtx; ...
+%
+% Programm calls to get the documentation (example):
+% pdflatex ltxgrid.dtx
+% makeindex -s gind.ist ltxgrid
+% makeindex -s gglo.ist -o ltxgrid.gls ltxgrid.glo
+% pdflatex ltxgrid.dtx
+% makeindex -s gind.ist ltxgrid.idx
+% pdflatex ltxgrid.dtx
+%
+% Installation:
+% TDS:doc/latex/revtex/
+% TDS:tex/latex/revtex/
+% TDS:source/latex/revtex/
+%
+% Thanks, Heiko!
+% This method of letting a single .dtx file serve as both
+% documentation (via latex) and installer (via tex) follows
+% the example of Heiko Oberdiek. Thanks!
+%<*ignore>
+\begingroup
+ \def\x{LaTeX2e}%
+\expandafter\endgroup
+\ifcase
+ 0\expandafter\ifx\csname processbatchFile\endcsname\relax\else1\fi\ifx\fmtname\x\else 1\fi
+ \relax
+\else
+ \csname fi\endcsname
+%</ignore>
+%<*install>
+%% This file will generate documentation and runtime files
+%% from ltxgrid.dtx when run through LaTeX or TeX.
+\input docstrip
+\preamble
+
+This is a generated file;
+altering it directly is inadvisable;
+instead, modify the original source file.
+See the URL in the file 00readme.tex.
+
+License
+ You may distribute this file under the conditions of the
+ LaTeX Project Public License 1.3 or later
+ (http://www.latex-project.org/lppl.txt).
+
+ This file is distributed WITHOUT ANY WARRANTY;
+ without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE.
+
+\endpreamble
+\askforoverwritefalse
+\keepsilent
+ \generate{%
+ %{ignore}
+% \usedir{tex/latex/revtex}%
+ \file{ltxgrid.sty}{%
+ \from{ltxgrid.dtx}{package,kernel}%
+ }%
+ }%
+\ifToplevel{
+\Msg{***********************************************************}
+\Msg{*}
+\Msg{* To finish the installation, please move}
+\Msg{* ltxgrid.sty}
+\Msg{* into a directory searched by TeX;}
+\Msg{* in a TDS-compliant installation:}
+\Msg{* texmf/tex/macros/latex/revtex/.}
+\Msg{*}
+\Msg{* To produce the documentation,
+ run ltxgrid.dtx through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{***********************************************************}
+}
+\endbatchfile
+%</install>
+%<*ignore>
+\fi
+%</ignore>
% \fi
-% \GetFileInfo{ltxgrid.dtx}\CheckSum{4234}
+%
+% \GetFileInfo{ltxgrid.dtx}\CheckSum{5462}
%
% \iffalse ltxdoc klootch
-%<*ltxgrid>
+%<*package>
%%% @LaTeX-file{
%%% filename = "ltxgrid.dtx",
-%%% version = "1.0rc5",
-%%% date = "2001/07/26",
-%%% time = "12:23:00 GMT+8",
-%%% checksum = "4234",
-%%% author = "Arthur Ogawa (mailto:ogawa@teleport.com),
+%%% version = "4.1h",
+%%% date = "2009/10/09",
+%%% time = "11:23:00 GMT+8",
+%%% checksum = "5462",
+%%% author = "Arthur Ogawa (mailto:arthur_ogawa at sbcglobal.net),
%%% commissioned by the American Physical Society.
%%% ",
-%%% copyright = "Copyright (C) 1999, 2000 Arthur Ogawa,
+%%% copyright = "Copyright (C) 1999, 2009 Arthur Ogawa,
%%% distributed under the terms of the
%%% LaTeX Project Public License, see
%%% ftp://ctan.tug.org/macros/latex/base/lppl.txt
@@ -32,23 +130,23 @@
%%% USA",
%%% telephone = "",
%%% FAX = "",
-%%% email = "ogawa@teleport.com",
+%%% email = "mailto colon arthur_ogawa at sbcglobal.net",
%%% codetable = "ISO/ASCII",
%%% keywords = "latex, page grid, main vertical list",
%%% supported = "yes",
%%% abstract = "package to change page grid, MVL",
%%% docstring = "The checksum field above generated by ltxdoc",
%%% }
-%</ltxgrid>
+%</package>
% \fi
%
% \iffalse ltxdoc klootch
-% The following references the \file{00readme.txt} file,
+% The following references the \file{00readme} file,
% which contains basic information about this package.
% The contents of this file are generated when
% you typeset the programmer's documentation.
-% Search on "{filecontents*}{00readme.txt}" to locate it.
-% \fi\input{00readme.txt}%
+% Search on "{filecontents*}{00readme}" to locate it.
+% \fi\input{00readme}%
%
% \subsection{Bill of Materials}
%
@@ -65,7 +163,7 @@
% Typesetting the source file under \LaTeX\
% generates the readme and the installer.
%\begin{verbatim}
-%00readme.txt ltxgrid.ins
+%00readme ltxgrid.ins
%\end{verbatim}
%
% \subsubsection{Generated by \texttt{tex ltxgrid.ins}}%
@@ -101,17 +199,17 @@
% An appropriate message is displayed if
% a different \TeX{} format is used.
% \begin{macrocode}
-%<*doc|ltxgrid>
+%<*driver|package>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
-%</doc|ltxgrid>
+%</driver|package>
% \end{macrocode}
% As desired, the following modules all
% take common version information:
% \begin{macrocode}
-%<ltxgrid>\ProvidesFile{ltxgrid.sty}%
-%<*doc>
+%<package>\ProvidesFile{ltxgrid.sty}%
+%<*driver>
\expandafter\ProvidesFile\expandafter{\jobname.dtx}%
-%</doc>
+%</driver>
% \end{macrocode}
%
% The following line contains, for once and for all,
@@ -120,9 +218,9 @@
% consistently in all generated files and in the
% typeset documentation.
% \begin{macrocode}
-%<*doc|ltxgrid>
- [2001/07/26 1.0rc5 page grid package]% \fileversion
-%</doc|ltxgrid>
+%<*driver|package>
+ [2009/10/09 4.1h page grid package]% \fileversion
+%</driver|package>
% \end{macrocode}
%
%
@@ -130,7 +228,7 @@
%
% This module, consisting of the present section,
% typesets the programmer's documentation,
-% generating the \file{.ins} installer and \file{00readme.txt} as required.
+% generating the \file{.ins} installer and \file{00readme} as required.
%
% Because the only uncommented-out lines of code at the beginning of
% this file constitute the \file{doc} module itself,
@@ -143,7 +241,7 @@
% The \enve{document} command concludes the typesetting run.
%
% \begin{macrocode}
-%<*doc>
+%<*driver>
% \end{macrocode}
%
% \subsection{The Preamble}
@@ -162,7 +260,8 @@
\csname package@font\endcsname
}%
\fi
-\CodelineIndex\EnableCrossrefs
+\CodelineIndex\EnableCrossrefs % makeindex -s gind.ist ltxgrid
+\RecordChanges % makeindex -s gglo.ist -o ltxgrid.gls ltxgrid.glo
% \end{macrocode}
%
% \subsubsection{Docstrip and info directives}
@@ -177,78 +276,6 @@
\expandafter\GetFileInfo\expandafter{\jobname.dtx}%
% \end{macrocode}
%
-%
-% \subsection{The installer file}
-%
-% The installer \file{ltxgrid.ins} appears here.
-% If you have retrieved the standard distribution of this package,
-% the installer file is already on your filesystem.
-% If you are bootstrapping,
-% the first typesetting of the \file{.dtx} file
-% will cause the installer to be generated.
-%
-% The following modules are used to direct
-% {\sc docstrip} in generating the external files:
-% \begin{center}
-% \begin{tabular}{lll}
-% \textbf{Module}&\textbf{File}&\textbf{Description}\\
-% doc &\file{ltxgrid.drv}&driver for programmer's documentation\\
-% ltxgrid,ltxgrid-krn &\file{ltxgrid.sty}&this package\\
-% ltxgrid-krn& &the portion of this package suitable for inclusion within another package
-% \end{tabular}
-% \end{center}
-%
-% \begin{macrocode}
-\begin{filecontents}{ltxgrid.ins}
-%% This file will generate documentation and runtime files
-%% from ltxgrid.dtx when run through LaTeX or TeX.
-\input docstrip
-\preamble
-
-This is a generated file;
-altering it directly is inadvisable;
-instead, modify the original source file.
-See the URL in the file 00readme.txt.
-
-Copyright notice.
-
- These files are distributed
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-\endpreamble
-\keepsilent
- \generate{%
- \file{ltxgrid.drv}{\from{ltxgrid.dtx}{doc}}%
- \file{ltxgrid.sty}{%
- \from{ltxgrid.dtx}{ltxgrid,ltxgrid-krn}%
- }%
- }%
-\ifToplevel{
-\Msg{***********************************************************}
-\Msg{*}
-\Msg{* To finish the installation, please move}
-\Msg{* ltxgrid.sty}
-\Msg{* into a directory searched by TeX;}
-\Msg{* in a TDS-compliant installation:}
-\Msg{* texmf/tex/macros/latex/ao/.}
-\Msg{*}
-\Msg{* To produce the documentation,
- run ltxgrid.dtx through LaTeX.}
-\Msg{*}
-\Msg{* Happy TeXing}
-\Msg{***********************************************************}
-}
-\endbatchfile
-\end{filecontents}
-% \end{macrocode}
-% Note that, because all of the files generated by the installer
-% are part of the standard distribution, it will
-% be necessary to run the installer only when bootstrapping
-% (or, of course, during development).
-% Note, too, that it is rare to generate the \file{doc}
-% module because it suffices to simply typeset the \file{.dtx} file itself.
-%
% \subsection{The ``Read Me'' File}
% As promised above, here is the contents of the
% ``Read Me'' file. That file serves a double purpose,
@@ -273,30 +300,34 @@ Copyright notice.
% begin the programmer's manual.
%
% \begin{macrocode}
-\begin{filecontents*}{00readme.txt}
+\begin{filecontents*}{00readme}
\title{%
A \LaTeX\ Package for changing the page grid and MVL%
\thanks{%
This file has version number \fileversion,
last revised \filedate.%
- % For version number and date,
- % search on "\fileversion" in the .dtx file,
- % or see the end of the 00readme.txt file.
+ }%
+ \thanks{%
+ Version \fileversion\ \copyright\ 2009 The American Physical Society
}%
}%
-
\author{%
-Arthur Ogawa (\texttt{mailto:ogawa@teleport.com}),
-\fileversion\\Copyright (C) 1999, 2000 Arthur Ogawa
-}%
+ Arthur Ogawa%
+ \thanks{\texttt{mailto:arthur\_ogawa at sbcglobal.net}}%
+}%
+%\iffalse
+% For version number and date,
+% search on "\fileversion" in the .dtx file,
+% or see the end of the 00readme file.
+%\fi
\maketitle
This file embodies the \classname{ltxgrid} package,
the implementation and its user documentation.
The distribution point for this work is
-\url{ftp://ftp.teleport.com/users/ogawa/macros/latex/contrib/supported/ltxgrid...},
-which contains fully unpacked, prebuilt runtime files and documentation.
+\url{publish.aps.org/revtex},
+which contains the REV\TeX\ package, and includes source and documentation for this package.
The \classname{ltxgrid} package was commissioned by the American Physical Society
and is distributed under the terms of the \LaTeX\ Project Public License,
@@ -311,9 +342,9 @@ To install, retrieve the distribution,
unpack it into a directory on the target computer,
into a location in your filesystem where it will be found by \LaTeX;
in a TDS-compliant installation this would be:
-\file{texmf/tex/macros/latex/ao/.}
+\file{texmf/tex/macros/latex/revtex/.}
-To use, read the user documentation \file{ltxgrid.pdf}.
+To use, read the user documentation \file{src/ltxgrid.pdf}.
\tableofcontents
@@ -322,9 +353,9 @@ To use, read the user documentation \file{ltxgrid.pdf}.
The package file \file{ltxgrid.sty}
is generated from this file, \file{ltxgrid.dtx},
using the {\sc docstrip} facility of \LaTeX
-via |tex ltxgrid.ins|.
+via |tex ltxgrid.dtx|.
The typeset documentation that you are now reading is generated from
-the same file by typesetting it with \LaTeX\ or pdftex
+this same file by typesetting it with \LaTeX\ or pdftex
via |latex ltxgrid.dtx| or |pdflatex ltxgrid.dtx|.
\subsection{Build Instructions}
@@ -335,22 +366,70 @@ then carry out the following steps:
\begin{enumerate}
\item
Within an otherwise empty directory,
-typeset \file{ltxgrid.dtx} with \LaTeX\ or pdflatex;
+typeset \file{ltxgrid.dtx} with \TeX\ or pdftex;
+thereby generating the package file \file{ltxgrid.sty}.
+
+\item
+Now typeset \file{ltxgrid.dtx} with \LaTeX\ or pdflatex;
you will obtain the typeset documentation you are now reading,
-along with
-the installer \file{ltxgrid.ins},
-and the file \file{00readme.txt}.
+along with the file \file{00readme}.
Note: you will have to run \LaTeX\ twice, then \file{makeindex}, then
\LaTeX\ again in order to obtain a valid index and table of contents.
+
\item
-Now typeset \file{ltxgrid.ins},
-thereby generating the package file \file{ltxgrid.sty}.
+Install the following files into indicated locations within your
+TDS-compliant \texttt{texmf} tree (you may need root access):
+\begin{itemize}
+\item
+\file{$TEXMF/}\file{tex/}\file{latex/}\file{revtex/}\classname{ltxgrid.sty}
+\item
+\file{$TEXMF/}\file{source/}\file{latex/}\file{revtex/}\classname{ltxgrid.dtx}
\item
-Install \classname{ltxgrid.sty}
-by moving it to a location
-in your filesystem where they will be found by \LaTeX.
+\file{$TEXMF/}\file{doc/}\file{latex/}\file{revtex/}\classname{ltxgrid.pdf}
+\end{itemize}
+where \file{TEXMF/} stands for \file{texmf-local/}, or some other \texttt{texmf} tree in your installation.
+\item
+Run \texttt{mktexlsr} on directory \file{$TEXMF/} (you may need root access).
+\item
+Build and installation are now complete;
+now put a \cmd\usepackage\texttt{\{ltxgrid\}} in your document preamble!
+(Note: \texttt{ltxgrid} requires package \texttt{ltxutil}.)
\end{enumerate}
+
+\subsection{Change Log}
+\changes{4.0a}{2001/06/18}{Introduce \cs{marry@height} }
+\changes{4.0a}{2001/06/18}{Introduce \cs{set@marry@height} }
+\changes{4.0a}{2008/06/26 }{\cs{@yfloat}: de-fang \cs{set@footnotewidth} (see ltxutil.dtx): we have already done its job. }
+\changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: restore \cs{@tabularcr} and \cs{@xtabularcr}}
+\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}}
+\changes{4.1a}{2008/06/29}{Repair error in \cs{endlongtable@new} involving \cs{@ifx}: argument not delimited.}
+\changes{4.1b}{2008/08/04}{Get rid of the \cs{reserved@a} idiom}
+\changes{4.1b}{2008/08/04}{Turn off the \cs{set@footnotewidth} mechanism; a float `knows' its proper typesetting context}
+\changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.}
+\changes{4.1b}{2008/08/04}{(AO, 456) Compatibility with other packages that override the output routine, following suggestion by David Kastrup.}
+\changes{4.1b}{2008/08/04}{}
+\changes{4.1b}{2008/08/04}{Box \cs{footbox} changed to box \cs{footsofar}}
+\changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument}
+\changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
+\changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
+\changes{4.1b}{2008/08/04}{New procedure \cs{@iffpsbit} replaces \cs{@getfpsbit}}
+\changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}}
+\changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}}
+\changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}%
+\changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}%
+\changes{4.1b}{2008/08/04}{Procedure \cs{balance@2} defined more transparently}%
+\changes{4.1b}{2008/08/04}{Procedure \cs{set@adj@footins} to adjust for footnotes and other inserts}
+\changes{4.1b}{2008/08/04}{Tally the height of the float}
+\changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}}
+\changes{4.1b}{2008/08/04}{Use \cs{trace@box} instead of \cs{showbox}}
+\changes{4.1f}{2009/07/07}{(AO, 515) Prevent line numbering within a footnote}
+\changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
+\changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated}
+\changes{4.1f}{2009/07/14}{(AO, 519) Do not use \cs{dimen@} register as a scratch register in \cs{set@adj@footins}}
+\changes{4.1f}{2009/07/15}{(AO, 519) Preserve footnotes that are in \cs{footsofar} across a page grid change}
+\changes{4.1g}{2009/10/06}{(AO, 531) Fix package \classname{float} }
+
\end{filecontents*}
% \end{macrocode}
%
@@ -361,13 +440,10 @@ in your filesystem where they will be found by \LaTeX.
% This very cute self-reference is a common \classname{ltxdoc} idiom.
% \begin{macrocode}
\begin{document}%
+\def\revtex{REV\TeX}%
\expandafter\DocInput\expandafter{\jobname.dtx}%
-% ^^A\PrintChanges
\end{document}
-% \end{macrocode}
-%
-% \begin{macrocode}
-%</doc>
+%</driver>
% \end{macrocode}
%
% \section{Using this package}
@@ -396,7 +472,7 @@ in your filesystem where they will be found by \LaTeX.
%
% Note that this package requires the features of the \classname{ltxutil} package,
% available at
-% \url{ftp://ftp.teleport.com/users/ogawa/macros/latex/contrib/supported/ltxutil/}.
+% \url{publish.aps.org/revtex}.
%
% Once loaded, the package gives you acccess to certain procedures,
% usually to be invoked by a \LaTeX\ command or environment, but not at the document level.
@@ -553,7 +629,7 @@ in your filesystem where they will be found by \LaTeX.
% \cmd\twocolumn\ mode such that footnotes are set at the bottom of the right-hand
% column instead of at the foot of each of the two columns.
%
-% Note that it overwrites three \LaTeX\ kernel macros: \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol.
+% Note that it overwrites three \LaTeX\ kernel macros: \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecolumn.
% Fortunately none of the three are patched by \classname{ltxgrid}, so that compatability
% is not excluded on this basis.
%
@@ -604,7 +680,7 @@ in your filesystem where they will be found by \LaTeX.
% Frank Mittelbach's \classname{multicol} package provides a page grid with many columns,
% albeit denies the placement of floats in individual columns.
%
-% It esablishes its own \cmd\output\ routine, which is the reason it runs afoul of
+% It establishes its own \cmd\output\ routine, which is the reason it runs afoul of
% the \classname{longtable} package. On the other hand, \classname{ltxgrid} specifically
% allows for the case where a package installs its own \cmd\output\ routine, so
% there is no incompatability on that basis.
@@ -658,7 +734,7 @@ in your filesystem where they will be found by \LaTeX.
% calculated.
%
% This scheme typically works fine, but it has a significant vulnerability:
-% any discardable items trimmed at the original column break is lost, never to be retrieved.
+% any discardable items trimmed at the original column break are lost, never to be retrieved.
% Consequently, after re-balancing, an element like, say, a section head can fail to have the correct amount of whitespace above.
%
% This problem is due to an unfortunate optimization in \TeX, wherein a certain class of nodes is trimmed from the
@@ -671,8 +747,8 @@ in your filesystem where they will be found by \LaTeX.
% they are quietly passed over during trimming.
%
% An alternative approach for \TeX\ to take would have been,
-% rather than discarding the node entirely, to simply mark it as discarded.
-% (Implementors of NTS, please note!)
+% rather than discarding the node entirely, to simply \emph{mark} it as discarded.
+% (Implementors of extended \TeX, please note!)
% Then, upon shipping out, such nodes would not make it into the DVI.
% \TeX's optimization, driven by the small computer architectures current when it was developed,
% does save mem, but at the cost of revisiting page breaks in a reliable way.
@@ -684,7 +760,7 @@ in your filesystem where they will be found by \LaTeX.
% \section{Implementation of package}
%
% Special acknowledgment: this package uses concepts pioneered
-% and first realized by William Baxter (mailto:web@superscript.com)
+% and first realized by William Baxter (mailto:web at superscript.com)
% in his SuperScript line of commercial typesetting tools, and
% which are used here with his permission. His thorough understanding
% of \TeX's output routine underpins the entire \classname{ltxgrid}
@@ -693,22 +769,22 @@ in your filesystem where they will be found by \LaTeX.
% \subsection{Beginning of the \file{ltxgrid} {\sc docstrip} module}
% Requires the underpinnings of the \classname{ltxkrnext} package.
% \begin{macrocode}
-%<*ltxgrid>
+%<*package>
\def\package@name{ltxgrid}%
\expandafter\PackageInfo\expandafter{\package@name}{%
Page grid for \protect\LaTeXe,
- by A. Ogawa (ogawa@teleport.com)%
+ by A. Ogawa (arthur_ogawa at sbcglobal.net)%
}%
\RequirePackage{ltxutil}%
-%</ltxgrid>
+%</package>
% \end{macrocode}
%
% \subsection{Banner}%
% Credit where due.
% \begin{macrocode}
-%<*ltxgrid-krn>
+%<*kernel>
\typeout{%
- ltxgrid: portions licensed from W. E. Baxter (web@superscript.com)%
+ ltxgrid [2009/07/07 4.1f]: portions licensed from W. E. Baxter (web at superscript.com)%
}%
% \end{macrocode}
%
@@ -718,20 +794,23 @@ in your filesystem where they will be found by \LaTeX.
% The document-level command \cmd\lineloop\ sets numbered lines until the
% specified count is reached.
% This command is mainly used to construct test documents.
+%
+% Because the counter is globally advanced and never reset, successive
+% calls to \cmd\lineloop\ should have an argument ever larger.
+% The formatted output will have each line labeled with its ordinal number.
% \begin{macrocode}
\newcounter{linecount}
+\def\loop@line#1#2{%
+ \par
+ \hb@xt@\hsize{%
+ \global\advance#1\@ne
+ \edef\@tempa{\@ifnum{100>#1}{0}{}\@ifnum{10>#1}{0}{}\number#1}%
+ \@tempa\edef\@tempa{\special{trace:\@tempa}}\@tempa
+ \vrule depth2.5\p@#2\leaders\hrule\hfil
+ }%
+}%
\def\lineloop#1{%
- \loop
- \ifnum\c@linecount<#1\relax
- \global\advance\c@linecount\@ne
- \par
- \hb@xt@\hsize{%
- \ifnum\c@linecount<100 0\fi\ifnum\c@linecount<10 0\fi\number\c@linecount
- \vrule depth2.5\p@
- \leaders\hrule\hfil
- }%
- \penalty\interlinepenalty
- \repeat
+ \loopwhile{\loop@line\c@linecount{}\@ifnum{#1>\c@linecount}}%
}%
% \end{macrocode}
% \end{macro}
@@ -966,7 +1045,7 @@ in your filesystem where they will be found by \LaTeX.
% and \classname{longtable} (authored by David P. Carlisle), which
% swap in their own output routines when the respective package is active.
%
-% The better mechanism, used here, is due to William Baxter (web@superscript.com),
+% The better mechanism, used here, is due to William Baxter (web at superscript.com),
% who has allowed his several ideas to be used in this package.
%
% In what follows, we effectively wrap up the old \LaTeX\ output routine inside
@@ -1021,7 +1100,7 @@ in your filesystem where they will be found by \LaTeX.
% We do introduce flexibility in the form of a mechanism for patching into the
% natural output routine. Three hooks are offered, allowing a procedure
% to prepare for the upcoming visit to the output routine,
-% access to \cmd\box\cmd\@cclv, and after shipping out (or otherwise
+% access to \cmd\box\cmd\@cclv, and after doing \cmd\shipout\ (or otherwise
% committing the material to the page).
%
% Environments, commands, and even packages can install their
@@ -1040,81 +1119,263 @@ in your filesystem where they will be found by \LaTeX.
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\output@latex}
% \begin{macro}{\output}
% Grab the tokens in \cmd\the\cmd\output\ (but without the extra set of braces).
% The value of \cmd\toks@\ must remain untouched until loaded into the appropriate token
% register; this is done a few lines below.
% \begin{macrocode}
\long\def\@tempa#1\@@nil{#1}%
-\toks@
+ \toks@
\expandafter\expandafter
\expandafter{%
\expandafter \@tempa
- \the\output
+ \the\primitive@output
\@@nil
}%
-\newtoks\output
-\output\expandafter{\the\toks@}%
+\newtoks\output@latex
+\output@latex\expandafter{\the\toks@}%
+\let\output\output@latex
% \end{macrocode}
+%
+% A comment on compatibility with other packages that co-opt the output routine.
+%
+% Somewhere on the LaTeX-L list, David Kastrup has urged macro writers to take over
+% the output routine in such a way that others can do likewise. How is this to be
+% accomplished?
+%
+% Consider what the \classname{lineno} package does when it loads.
+% \begin{enumerate}
+% \item
+% It does \cmd\let\ cmd\@tempa\ \cmd\output.
+% This has the effect of identifying \cmd\@tempa\ with the
+% \cmd\toks\ register we created above to hold the old output routine of \LaTeX.
+% Let us say that was \cmd\toks14.
+% \item
+% \classname{lineno} itself effectively does \cmd\newtoks\ \cmd\@LN@output,
+% which assigns that \cmd\csname\ to \cmd\toks 15.
+% \item
+% It loads \cmd\@LN@output\ with the contents of \cmd\@tempa
+% (that is, \cmd\toks14, our copy of \LaTeX's output routine).
+% \item
+% Then it loads \cmd\@tempa\ with its own desired procedure,
+% to be executed at \cmd\output\ time, thereby taking over what it thinks is the output routine,
+% but which is in reality the procedure \revtex\ executes when it wants to pass control
+% to \LaTeX's original output routine.
+% \item
+% It then does \cmd\let\ \cmd\output\ \cmd\@LN@output,
+% which now identifies \cmd\output\ with \cmd\toks15, the output routine of \classname{lineno}.
+% \item
+% When the \cmd\output\ routine is triggered,
+% the primitive output routine \cmd\primitive@output\ is executed, and if
+% appropriate, control is passed to \cmd\output@latex, which \revtex\ had loaded with the old
+% \LaTeX\ output routine, but which is presently loaded with that of \classname{lineno}.
+% \item
+% The output routine of \classname{lineno} is executed, and if appropriate control is passed
+% to \cmd\@LN@output, the old output routine of \LaTeX.
+% \item
+% Furthermore, the \cmd\csname\ \cmd\output\ now points to \cmd\@LN@output\ (\cmd\toks15).
+% This means that someone coming in after \classname{lineno} to take over the output routine
+% will actually get executed after that of \classname{lineno}, but before \LaTeX.
+% \end{enumerate}
+% As you can see, the process of taking over the output routine may continue until all of the
+% \cmd\toks\ registers have been allocated.
+% If, say, \classname{newpackage} would itself like to take over the output routine,
+% and if it uses the above set of steps, then when the output routine is triggered, the order
+% of execution is \revtex, then \classname{lineno}, then \classname{newpackage}, then \LaTeX.
+% Each new package inserts itself on front of \LaTeX.
+% \end{macro}
% \end{macro}
%
% \begin{macro}{\dispatch@output}
-% We now install our own output routine in place of the
-% old one, which is still available as \cmd\the\cmd\output.
+% \changes{4.1b}{2008/08/04}{(AO, 456) Compatibility with other packages that override the output routine, following suggestion by David Kastrup.}
+% We now install our own output routine in place of the original
+% output routine of \LaTeX, which is still available as \cmd\the\ \cmd\output.
%
% The output routine is simply the procedure \cmd\dispatch@output.
% It either dispatches to a procedure based on a particular value of
-% \cmd\outputpenalty\ or it executes \cmd\the\cmd\output\ tokens.
+% \cmd\outputpenalty\ or it executes \cmd\the\cmd\output@latex\ tokens.
% \begin{macrocode}
\primitive@output{\dispatch@output}%
\def\dispatch@output{%
\let\par\@@par
- \expandafter\let\expandafter\@tempa\csname output@\the\outputpenalty\endcsname
- \outputdebug@sw{%
- \saythe\badness
- \saythe\outputpenalty
- \saythe\holdinginserts
- \say\thepagegrid
- \saythe\pagegrid@col
- \saythe\pagegrid@cur
- %\say\bot@envir
- \saythe\insertpenalties
- %\say\@@topmark
- %\say\saved@@topmark
- %\say\@@firstmark
- %\say\saved@@firstmark
- \say\@@botmark
- %\say\saved@@botmark
- \saythe\pagegoal
- \saythe\pagetotal
- \saythe{\badness\@cclv}%
- \expandafter\@ifx\expandafter{\csname output@-\the\execute@message@pen\endcsname\@tempa}{%
- \say\@message@saved
- }{%
- \expandafter\say\csname output@\the\outputpenalty\endcsname
- }%
- \say\@toplist
- \say\@botlist
- \say\@dbltoplist
- \say\@deferlist
- {\tracingall\scrollmode
- \showbox\@cclv
- \showbox\@cclv@saved
- \showbox\pagesofar
- \showbox\footbox
- \showbox\footins@saved
- \showbox\footins
- \showlists
- }%
+% \end{macrocode}
+% Try to interpret \cmd\outputpenalty\ as a dispatcher to a message handler,
+% its value is, e.g., \cmd\do@startpage@pen.
+% \begin{macrocode}
+ \expandafter\let\expandafter\output@procedure\csname output@\the\outputpenalty\endcsname
+% \end{macrocode}
+% If we have failed to find a dispatcher, then settle for \cmd\output@latex.
+% \begin{macrocode}
+ \@ifnotrelax\output@procedure{}{%
+ \expandafter\def\expandafter\output@procedure\expandafter{\the\output@latex}%
+ }%
+% \end{macrocode}
+% Now test if the dispatcher is the special case of \cmd\execute@message@pen, in which case execute the \cmd\@message@saved.
+% \begin{macrocode}
+ \expandafter\@ifx\expandafter{\csname output@-\the\execute@message@pen\endcsname\output@procedure}{%
+ \let\output@procedure\@message@saved
}{}%
- \@ifnotrelax\@tempa{\@tempa}{\the\output}%
+ \outputdebug@sw{\output@debug}{}%
+ \output@procedure
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\set@output@procedure#1#2{%
+ \count@\outputpenalty\advance\count@-#2%
+ \expandafter\let\expandafter#1\csname output@\the\count@\endcsname
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\output@debug{%
+ \saythe\inputlineno
+ \saythe\holdinginserts
+ \saythe\outputpenalty
+ \saythe\interlinepenalty
+ \saythe\brokenpenalty
+ \saythe\clubpenalty
+ \saythe\widowpenalty
+ \saythe\displaywidowpenalty
+ \saythe\predisplaypenalty
+ \saythe\interdisplaylinepenalty
+ \saythe\postdisplaypenalty
+ \say\output@procedure
+ \saythe\badness
+ \say\thepagegrid
+ \saythe\pagegrid@col
+ \saythe\pagegrid@cur
+%\say\bot@envir
+ \saythe\insertpenalties
+%\say\@@topmark
+%\say\saved@@topmark
+%\say\@@firstmark
+%\say\saved@@firstmark
+ \say\@@botmark
+%\say\saved@@botmark
+ \saythe\pagegoal
+ \saythe\pagetotal
+ \saythe{\badness\@cclv}%
+ \say\@toplist
+ \say\@botlist
+ \say\@dbltoplist
+ \say\@deferlist
+ \trace@scroll{%
+ \showbox\@cclv
+ \showbox\@cclv@saved
+ \showbox\pagesofar
+ \showbox\footsofar
+ \showbox\footins@saved
+ \showbox\footins
+ \showlists
+ }%
}%
\@ifxundefined{\outputdebug@sw}{%
\@booleanfalse\outputdebug@sw
}{}%
+\def\trace@scroll#1{\begingroup\showboxbreadth\maxdimen\showboxdepth\maxdimen\scrollmode#1\endgroup}%
+\def\trace@box#1{\trace@scroll{\showbox#1}}%
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@outputpage}
+% \begin{macro}{\@outputpage@head}
+% \begin{macro}{\@outputpage@tail}
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}%
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}%
+% The procedure \cmd\@outputpage\ of standard \LaTeX\ is the sole place where a \cmd\shipout\ is carried out.
+% The procedures that build \cmd\@outputbox\ just before a page is shipped out by \cmd\@outputpage\ are:
+% \cmd\@makecolumn,
+% \cmd\@combinepage, and
+% \cmd\@combinedblfloats.
+%
+% We need to head- and tailpatch this procedure, so we perform here
+% the only modifications to that procedure that are essential.
+% Elsewhere, we will build up the meanings of \cmd\@outputpage@head\ and \cmd\@outputpage@tail.
+% \begin{macrocode}
+\prepdef\@outputpage{\@outputpage@head}%
+\let\@outputpage@head\@empty
+\appdef\@outputpage{\@outputpage@tail}%
+\let\@outputpage@tail\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\show@box@size}
+% \begin{macro}{\show@text@box@size}
+% \begin{macro}{\show@pagesofar@size}
+% \begin{macro}{\show@box@size@sw}
+% \begin{macro}{\total@text}
+% \changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.}
+% Procedure \cmd\show@box@size\ is a diagnostic for the sizes of boxes;
+% the boolean \cmd\show@box@size@sw\ turns it on and off.
+% \begin{macrocode}
+\def\show@box@size#1#2{%
+ \show@box@size@sw{%
+ \begingroup
+ \setbox\z@\vbox{\unvcopy#2\hrule}%
+ \class@info{Show box size: #1^^J%
+ (\the\ht\z@\space X \the\wd\z@)
+ \the\c@page\space\space\the\pagegrid@cur\space\the\pagegrid@col
+ }%
+ \endgroup
+ }{}%
+}%
+% \end{macrocode}
+% Procedure \cmd\show@text@box@size\ tallies the size of the indicated column.
+% If \cmd\box\ \cmd\pagesofar\ is a factor, then its height has been memorized
+% in the depth of the tally box.
+%
+% \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
+% \begin{macrocode}
+\def\show@text@box@size{%
+ \show@box@size{Text column}\@outputbox
+ \tally@box@size@sw{%
+ \@ifdim{\wd\@outputbox>\z@}{%
+ \dimen@\ht\@outputbox\divide\dimen@\@twopowerfourteen
+ \advance\dimen@-\dp\csname box@size@\the\pagegrid@col\endcsname
+ \@ifdim{\dimen@>\z@}{%
+ \advance\dimen@ \ht\csname box@size@\the\pagegrid@col\endcsname
+ \global\ht\csname box@size@\the\pagegrid@col\endcsname\dimen@
+ \show@box@size@sw{%
+ \class@info{Column: \the\dimen@}%
+ }{}%
+ }{}%
+ }{}%
+ \global\dp\csname box@size@\the\pagegrid@col\endcsname\z@
+ }{}%
+}%
+% \end{macrocode}
+% Take the height of \cmd\box\ \cmd\pagesofar\ into account.
+% \begin{macrocode}
+\def\show@pagesofar@size{%
+ \show@box@size{Page so far}\pagesofar
+ \dimen@\ht\pagesofar\divide\dimen@\@twopowerfourteen
+ \global\dp\csname box@size@1\endcsname\dimen@
+ \show@box@size@sw{%
+ \class@info{Pagesofar: \the\dimen@}%
+ }{}%
+}%
+\@booleanfalse\tally@box@size@sw
+\@booleanfalse\show@box@size@sw
+\expandafter\newbox\csname box@size@1\endcsname
+\expandafter\setbox\csname box@size@1\endcsname\hbox{}%
+\expandafter\newbox\csname box@size@2\endcsname
+\expandafter\setbox\csname box@size@2\endcsname\hbox{}%
+\def\total@text{%
+ \@tempdima\the\ht\csname box@size@2\endcsname\divide\@tempdima\@twopowertwo\@tempcnta\@tempdima
+ \@tempdimb\the\ht\csname box@size@1\endcsname\divide\@tempdimb\@twopowertwo\@tempcntb\@tempdimb
+ \class@info{Total text: Column(\the\@tempcnta pt), Page(\the\@tempcntb pt)}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
%
% \subsection{Further thoughts about inserts}
%
@@ -1158,7 +1419,20 @@ in your filesystem where they will be found by \LaTeX.
% In the above, the first of the two visits to the output routine is a dead cycle and requires
% propagation of marks, but nothing else.
%
-% The natural output routine
+% \subsection{The difference between inserts and floats}
+%
+% While revisiting this package in 2008, I needed to clarify under what circumstances inserts
+% would be added to the \cmd\pagesofar. My conclusion is that I had been treating them
+% exactly the same as floats, but that was a mistake.
+%
+% Floats can be committed at the top of a column, in the middel, or at the bottom.
+% Footnotes (the only \cmd\insert\ that is used in \LaTeX) may only be committed at the bottom
+% of a column. So, it was necessary to provide two versions of \cmd\@combinepage, one
+% that committed \cmd\insert s, and the other that did not, the former used only when
+% a \cmd\shipout\ was certain to be performed.
+%
+%
+% \subsection{The natural output routine}
%
% Here is the portion of the output routine that fields cases not handled by
% the dispatcher.
@@ -1176,39 +1450,57 @@ in your filesystem where they will be found by \LaTeX.
% ensured by an initial mark of that value; the associated procedures
% are all nil. Any unknown envir value will "\cmd\relax\ out".
%
-% The code \cmd\move@insert@sw\ tells whether we are on our first visit to
-% the output routine (with \cmd\holdinginserts\ still set), or our second
-% (with \cmd\holdinginserts\ cleared). The output routine will toggle the
-% setting.
+% The test made by \cmd\toggle@insert\ tells whether we are on our first visit to
+% the output routine (with \cmd\holdinginserts\ still positive), or our second
+% (with \cmd\holdinginserts\ zeroed). The output routine will toggle the setting.
%
% The commands \cmd\hold@insertions\ and \cmd\move@insertions\ respectively
-% clear and set the state of \cmd\move@insert@sw, so this procedure effectively
+% clear and set \cmd\holdinginserts, so this procedure effectively
% clears \cmd\holdinginserts\ just long enough to pick up the insertions.
% Important: any output routine that clears \cmd\holdinginserts\
% must guarentee that it is restored on the subsequent visit to the output routine.
% Or, to put it another way, if an output routine detects that \cmd\holdinginserts\
-% is cleared, it should take it upon itself to restore it before exiting.
+% is cleared, it should take it upon itself to restore it to a positive value before exiting.
%
% The branch with \cmd\holdinginserts\ set is executed first; the other
% branch follows on practically immediately thereafter. In the first branch,
% we simply execute the appropriate hook and then execute a dead cycle.
%
% In the branch with \cmd\holdinginserts\ cleared, the procedure
-% builds up the current column, which is now complete, with \cmd\@makecol, then
+% builds up the current column, which is now complete, with \cmd\@makecolumn, then
% dispatches to the shipout routine associated with the current page grid, \cmd\output@column@.
% At the end, it triggers the execution of an output routine to prepare the next column (or page).
%
% \subsection{Natural output routine}%
%
+% \begin{macro}{\natural@output}
% \begin{macro}{\output}
-% Here is what has become of the output routine of \LaTeX.
-% It is of necessity divided into phases, \cmd\output@holding\ is executed upon first encountering the natural page-breaking point, while inserts are being held.
-% 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.
-%
+% Here is the output routine that handles natural pagebreaks:
+% 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.
+% 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.
+% 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,
+% and the insertions (e.g., footnotes) are split off into their assigned box registers.
% \begin{macrocode}
-\output={\toggle@insert\output@holding\output@moving}%
+\def\natural@output{\toggle@insert{\output@holding}{\output@moving}}%
+\output@latex{\natural@output}%
% \end{macrocode}
%
+% In accordance with the scheme suggested by David Kastrup for allowing another output routine
+% to slip itself into ours, we use a token register called \cmd\output.
+% However, we reserve the ability to restore things if we so desire.
+% This we must do in the case of the \filename{lineno.sty} package, because its functionality
+% is best served by being integrated into our own dispatcher-based output routine.
+%
+% To restore our own output routine, we can repeat the above assignment,
+% \begin{verbatim}
+%\output@latex{\natural@output}%
+% \end{verbatim}
+% some time before the document begins.
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\output@holding}
+% \begin{macro}{\@if@exceed@pagegoal}
% The procedure \cmd\output@holding\
% is our first cycle through the output routine; \cmd\holdinginserts\ is still set.
% We give the current environment a heads up
@@ -1224,47 +1516,50 @@ in your filesystem where they will be found by \LaTeX.
% The corner case is at hand if the natural size of \cmd\box\cmd\@cclv\ exceeds \cmd\pagegoal\ and
% the contents cannot be shrunk to fit.
%
+% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}}
% \begin{macrocode}
\def\output@holding{%
- \csname output@init@\bot@envir\endcsname
-%\vbadness\@M
-%\vfuzz\maxdimen
- \@if@exceed@pagegoal{\unvcopy\@cclv}{%
- \setbox\z@\vbox{\unvcopy\@cclv}%
- \outputdebug@sw{{\tracingall\scrollmode\showbox\z@}}{}%
- \dimen@\ht\@cclv\advance\dimen@-\ht\z@
- \dead@cycle@repair\dimen@
- }{%
- \dead@cycle
- }%
+ \csname output@init@\bot@envir\endcsname
+ \@if@exceed@pagegoal{\unvcopy\@cclv}{%
+ \setbox\z@\vbox{\unvcopy\@cclv}%
+ \outputdebug@sw{\trace@box\z@}{}%
+ \dimen@\ht\@cclv\advance\dimen@-\ht\z@
+ \dead@cycle@repair\dimen@
+ }{%
+ \dead@cycle
+ }%
}%
\def\@if@exceed@pagegoal#1{%
\begingroup
- \setbox\z@\vbox{#1}%
- \dimen@\ht\z@\advance\dimen@\dp\z@
- \outputdebug@sw{\saythe\dimen@}{}%
- \@ifdim{\dimen@>\pagegoal}{%
- \setbox\z@\vbox{\@@mark{}\unvbox\z@}%
- \splittopskip\topskip
- \splitmaxdepth\maxdepth
- \vbadness\@M
- \vfuzz\maxdimen
+ \setbox\z@\vbox{#1}%
+ \dimen@\ht\z@\advance\dimen@\dp\z@
+ \outputdebug@sw{\saythe\dimen@}{}%
+ \@ifdim{\dimen@>\pagegoal}{%
+ \setbox\z@\vbox{\@@mark{}\unvbox\z@}%
+ \splittopskip\topskip
+ \splitmaxdepth\maxdepth
+ \vbadness\@M
+ \vfuzz\maxdimen
\setbox\tw@\vsplit\z@ to\pagegoal
- \outputdebug@sw{{\tracingall\scrollmode\showbox\tw@\showbox\z@}}{}%
- \setbox\tw@\vbox{\unvbox\tw@}%
- \@ifdim{\ht\tw@=\z@}{%
- \ltxgrid@info{Found overly large chunk while preparing to move insertions. Attempting repairs}%
- \aftergroup\true@sw
- }{%
- \aftergroup\false@sw
- }%
+ \outputdebug@sw{\trace@scroll{\showbox\tw@\showbox\z@}}{}%
+ \setbox\tw@\vbox{\unvbox\tw@}%
+ \@ifdim{\ht\tw@=\z@}{%
+ \ltxgrid@info{Found overly large chunk while preparing to move insertions. Attempting repairs}%
+ \aftergroup\true@sw
+ }{%
+ \aftergroup\false@sw
+ }%
}{%
- \aftergroup\false@sw
+ \aftergroup\false@sw
}%
- \endgroup
+ \endgroup
}%
% \end{macrocode}
+% \end{macro}
+% \end{macro}
%
+% \begin{macro}{\output@moving}
+% \begin{macro}{\@cclv@nontrivial@sw}
% The procedure \cmd\output@moving\
% is our second cycle through the output routine; \cmd\holdinginserts\ is now cleared,
% and \cmd\insert s will have been split off into their respective box registers, like \cmd\footins.
@@ -1275,7 +1570,7 @@ in your filesystem where they will be found by \LaTeX.
% \item
% If we got here because of a \cmd\clearpage\ command, remove the protection box that this mechanism has left on the MVL.
% \item
-% If the contents of \cmd\box\cmd\@cclv\ are non-trivial, commit it to the current page or ship it out as the case may call for.
+% 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.
% \item
% If not, discard it (we are at the end of \cmd\clearpage\ processing).
% \item
@@ -1302,35 +1597,55 @@ in your filesystem where they will be found by \LaTeX.
% \begin{enumerate}
% \item
% Void out \cmd\box\cmd\@cclv\ and give appropriate warning messages and diagnostics.
-%% \item
-%% Put down the same interrupts as for the non-trivial case above.
+% \item
+% Put down the same interrupts as for the non-trivial case above.
% \end{enumerate}
%
+% This instance of \cmd\@makecolumn\ is followed by \cmd\output@column@,
+% that is, it builds a column for \cmd\shipout\ rather than for adding to \cmd\pagesofar.
+%
+% We need to handle cases where the \cmd\output@pre@, \cmd\output@column@, or \cmd\output@post@\
+% dispatchers come up \cmd\relax ed out: the default is to execute the corresponding
+% procedures from the \env{docuemnt} environment and the one-column grid respectively.
+%
+% One such case comes up with frequency: at the end of the document, where the \cmd\botmark\ is
+% now empty.
+% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\def\output@moving{%
\set@top@firstmark
\@ifnum{\outputpenalty=\do@newpage@pen}{%
\setbox\@cclv\vbox{%
\unvbox\@cclv
- \setbox\z@\lastbox
+ \remove@lastbox
\@ifdim{\ht\z@=\ht\@protection@box}{\box\lastbox}{\unskip}%
}%
}{}%
\@cclv@nontrivial@sw{%
- \csname output@prep@\bot@envir \endcsname
- \@makecol\csname output@column@\thepagegrid\endcsname
+ \expandafter\let\expandafter\output@prep@\csname output@prep@\bot@envir \endcsname
+ \outputdebug@sw{\say\output@prep@}{}%
+ \@ifx{\output@prep@\relax}{\output@prep@document}{\output@prep@}%
+ \@makecolumn\true@sw
+ \expandafter\let\expandafter\output@column@\csname output@column@\thepagegrid\endcsname
+ \outputdebug@sw{\say\output@column@}{}%
+ \@ifx{\output@column@\relax}{\output@column@one}{\output@column@}%
\protect@penalty\do@startcolumn@pen
\clearpage@sw{%
\protect@penalty\do@endpage@pen
}{}%
- \csname output@post@\bot@envir \endcsname
+ \expandafter\let\expandafter\output@post@\csname output@post@\bot@envir \endcsname
+ \outputdebug@sw{\say\output@post@}{}%
+ \@ifx{\output@post@\relax}{\output@post@document}{\output@post@}%
}{%
- {\setbox\z@\box\@cclv}%
+ \void@cclv
}%
- \set@colroom
+ \set@colht
\global\@mparbottom\z@
- \global\@textfloatsheight\z@ %FIXME: this legacy LaTeX variable is set, but never queried!
+ \global\@textfloatsheight\z@
}%
+\def\void@cclv{\begingroup\setbox\z@\box\@cclv\endgroup}%
+\def\remove@lastbox{\setbox\z@\lastbox}%
% \end{macrocode}
%
% The procedure \cmd\@cclv@nontrivial@sw\ determines if this visit to \cmd\output@moving\
@@ -1341,61 +1656,70 @@ in your filesystem where they will be found by \LaTeX.
% typesetting a (full-page-width) title block in a two-column layout.
%
% Note: the code that removes the last box and skip from the output is intended to detect the case
-% where the output has whatit nodes followed by topskip and a protection box.
+% where the output has whatsit nodes followed by topskip and a protection box.
% This is what happens under normal circumstances at the end of \cmd\clearpage\ processing.
+% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}}
% \begin{macrocode}
\def\@cclv@nontrivial@sw{%
- \@ifx@empty\@toplist{%
- \@ifx@empty\@botlist{%
- \@ifvoid\footins{%
- \@ifvoid\@cclv{%
- \false@sw
- }{%
- \setbox\z@\vbox{\unvcopy\@cclv}%
- \@ifdim{\ht\z@=\topskip}{%
- \setbox\z@\vbox{%
- \unvbox\z@
- \setbox\z@\lastbox\dimen@\lastskip\unskip
- \@ifdim{\ht\z@=\ht\@protection@box}{%
- \advance\dimen@\ht\z@
- \@ifdim{\dimen@=\topskip}{%
- \aftergroup\true@sw
- }{%
- \aftergroup\false@sw
- }%
- }{%
- \aftergroup\false@sw
- }%
- }%
- {%
- \false@sw % Normal for \clearpage
- }{%
- \true@sw
- }%
- }{%
- \@ifdim{\ht\z@=\z@}{%
- \ltxgrid@info{Found trivial column. Discarding it}%
- \outputdebug@sw{{\tracingall\scrollmode\showbox\@cclv}}{}%
- \false@sw
- }{%
- \true@sw
- }%
- }%
- }%
- }{%
- \true@sw
- }%
- }{%
- \true@sw
- }%
- }{%
- \true@sw
- }%
+ \@ifx@empty\@toplist{%
+ \@ifx@empty\@botlist{%
+ \@ifvoid\footins{%
+ \@ifvoid\@cclv{%
+ \false@sw
+ }{%
+ \setbox\z@\vbox{\unvcopy\@cclv}%
+ \@ifdim{\ht\z@=\topskip}{%
+ \setbox\z@\vbox\bgroup
+ \unvbox\z@
+ \remove@lastbox
+ \dimen@\lastskip\unskip
+ \@ifdim{\ht\z@=\ht\@protection@box}{%
+ \advance\dimen@\ht\z@
+ \@ifdim{\dimen@=\topskip}{%
+ \aftergroup\true@sw
+ }{%
+ \aftergroup\false@sw
+ }%
+ }{%
+ \aftergroup\false@sw
+ }%
+% \end{macrocode}
+% End of \cmd\box\cmd\z@.
+% \begin{macrocode}
+ \egroup
+ {%
+% \end{macrocode}
+% Normal for \clearpage
+% \begin{macrocode}
+ \false@sw
+ }{%
+ \true@sw
+ }%
+ }{%
+ \@ifdim{\ht\z@=\z@}{%
+ \ltxgrid@info{Found trivial column. Discarding it}%
+ \outputdebug@sw{\trace@box\@cclv}{}%
+ \false@sw
+ }{%
+ \true@sw
+ }%
+ }%
+ }%
+ }{%
+ \true@sw
+ }%
+ }{%
+ \true@sw
+ }%
+ }{%
+ \true@sw
+ }%
}%
% \end{macrocode}
%
%
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\protect@penalty}
% The procedure \cmd\protect@penalty\ is the utility procedure for invoking a
@@ -1465,29 +1789,32 @@ in your filesystem where they will be found by \LaTeX.
%
% \begin{macrocode}
\def\dead@cycle@repair#1{%
- \expandafter\do@@mark
- \expandafter{%
- \@@botmark
- }%
- \unvbox\@cclv
- \nointerlineskip
- \vbox to#1{\vss}%
- \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}%
+ \expandafter\do@@mark
+ \expandafter{%
+ \@@botmark
+ }%
+ \unvbox\@cclv
+ \nointerlineskip
+ \vbox to#1{\vss}%
+ \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}%
}%
\def\dead@cycle@repair@protected#1{%
- \expandafter\do@@mark
- \expandafter{%
- \@@botmark
- }%
- \begingroup
- \unvbox\@cclv
- \setbox\z@\lastbox % Remove protection box
- \nointerlineskip
+ \expandafter\do@@mark
+ \expandafter{%
+ \@@botmark
+ }%
+ \begingroup
+ \unvbox\@cclv
+% \end{macrocode}
+% Remove the protection box
+% \begin{macrocode}
+ \remove@lastbox
+ \nointerlineskip
\advance#1-\ht\@protection@box
- \vbox to#1{\vss}%
- \protection@box % Reinsert protection box
- \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}%
- \endgroup
+ \vbox to#1{\vss}%
+ \protection@box % Reinsert protection box
+ \@ifnum{\outputpenalty<\@M}{\penalty\outputpenalty}{}%
+ \endgroup
}%
\def\dead@cycle{%
\expandafter\do@@mark
@@ -1511,17 +1838,24 @@ in your filesystem where they will be found by \LaTeX.
% Upon our return, at \cmd\output@prep@\ time, the page break will accomodate the material;
% it is now actually inserted by concatenating it with the contents of \cmd\footins.
% The default processing for \cmd\output@post@\ is nil.
+% \changes{4.1b}{2008/08/04}{Procedure \cs{set@adj@footins} to adjust for footnotes and other inserts}
+% \changes{4.1b}{2008/08/04}{Box \cs{footbox} changed to box \cs{footsofar}}
% \begin{macrocode}
\def\output@init@document{%
- \@ifvoid\footbox{}{%
- \global\advance\vsize-\ht\footbox
- \global\advance\vsize-\dp\footbox
- }%
+ \set@adj@footins\vsize\global\vsize\vsize
}%
+% \end{macrocode}
+% QUERY: the following procedure is very like \cmd\combine@foot@inserts. Should it be the same?
+% \begin{macrocode}
\def\output@prep@document{%
- \@ifvoid\footbox{}{%
-% {\tracingall\scrollmode\showbox\footbox\showbox\footins}%
- \setbox\footins\vbox{\unvbox\footbox\unvbox\footins}%
+ \@ifvoid\footsofar{}{%
+ \setbox\footins\vbox\bgroup
+ \unvbox\footsofar
+ \@ifvoid\footins{}{%
+ \marry@baselines
+ \unvbox\footins
+ }%
+ \egroup
}%
}%
\def\output@post@document{}%
@@ -1537,8 +1871,9 @@ in your filesystem where they will be found by \LaTeX.
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@makecol}
-% The procedure \cmd\@makecol\ packages up a page along with all its insertions and floats.
+% \begin{macro}{\@makecolumn}
+% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
+% The procedure \cmd\@makecolumn\ packages up a page along with all its insertions and floats.
% Therefore it is essential that it be executed with \cmd\holdininserts\ cleared.
%
% Note that there is a corner case when in a multi-column grid, where the change back to
@@ -1548,8 +1883,16 @@ in your filesystem where they will be found by \LaTeX.
% Note on \cmd\@kludgeins: we have removed this mechanism from \LaTeX, because the implementation
% of \cmd\enlargethispage\ no longer requires it.
% Here, for consistency sake, we remove \cmd\@makespecialcolbox.
+%
+% The argument of \cmd\@makecolumn\ is a Boolean and determines if we combine the footnote material
+% into the present column. If the procedure is building a column for shipping out, then we will
+% combine the footnote material, if not, we return with the \cmd\footins\ box unchanged.
+%
+% \changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated}
+% I changed the behavior of this procedure in the case where the argument is \cmd\false@sw:
+% send the unused footnote material to \cmd\footsofar.
% \begin{macrocode}
-\def\@makecol{%
+\def\@makecolumn#1{%
\setbox\@outputbox\vbox{%
\boxmaxdepth\@maxdepth
\@tempdima\dp\@cclv
@@ -1557,23 +1900,24 @@ in your filesystem where they will be found by \LaTeX.
\vskip-\@tempdima
}%
\xdef\@freelist{\@freelist\@midlist}\global\let\@midlist\@empty
+ \show@text@box@size
\@combinefloats
- \@combineinserts\@outputbox\footins
-%\@ifvbox\@kludgeins{%
-% \@makespecialcolbox
-%}{%
- \set@adj@colht\dimen@
- \count@\vbadness
- \vbadness\@M
- \setbox\@outputbox\vbox to\dimen@{%
- \@texttop
- \dimen@\dp\@outputbox
- \unvbox\@outputbox
- \vskip-\dimen@
- \@textbottom
- }%
- \vbadness\count@
-%}%
+ #1{%
+ \@combineinserts\@outputbox\footins
+ }{%
+ \combine@foot@inserts
+ }%
+ \set@adj@colht\dimen@
+ \count@\vbadness
+ \vbadness\@M
+ \setbox\@outputbox\vbox to\dimen@{%
+ \@texttop
+ \dimen@\dp\@outputbox
+ \unvbox\@outputbox
+ \vskip-\dimen@
+ \@textbottom
+ }%
+ \vbadness\count@
\global\maxdepth\@maxdepth
}%
\let\@makespecialcolbox\@undefined
@@ -1587,10 +1931,10 @@ in your filesystem where they will be found by \LaTeX.
\def\@combineinserts#1#2{%
\setbox#1\vbox{%
\unvbox#1%
-% {\tracingall\scrollmode\showbox#2}%
\vbox{%
\@ifvoid#2{}{%
- \vskip\skip\footins
+ \show@box@size{Combining inserts}#2%
+ \vskip\skip#2%
\color@begingroup
\normalcolor
\footnoterule
@@ -1659,13 +2003,14 @@ in your filesystem where they will be found by \LaTeX.
% in which the procedures that handle full-page width floats in a two-column page grid all have in their names
% the string `dbl', which erroneously suggests having something to do with ``double''. It does not:
% when you see `dbl', think ``full page width''.
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\mathchardef\do@startcolumn@pen=10005
\@namedef{output@-\the\do@startcolumn@pen}{\do@startcolumn}%
\def\do@startcolumn{%
- \setbox\@cclv\vbox{\unvbox\@cclv\setbox\z@\lastbox\unskip}%
+ \setbox\@cclv\vbox{\unvbox\@cclv\remove@lastbox\unskip}%
\clearpage@sw{\@clearfloatplacement}{\@floatplacement}%
- \set@colroom
+ \set@colht
\@booleanfalse\pfloat@avail@sw
\begingroup
\@colht\@colroom
@@ -1675,9 +2020,10 @@ in your filesystem where they will be found by \LaTeX.
\endgroup
\fcolmade@sw{%
\setbox\@cclv\vbox{\unvbox\@outputbox\unvbox\@cclv}%
-% \csname float@column@\thepagegrid\endcsname
-% \csname output@column@\thepagegrid\endcsname
- \outputpenalty-\pagebreak@pen % ask for a return visit, this time with insertions and all.
+% \end{macrocode}
+% Now ask for a return visit, this time with insertions and all.
+% \begin{macrocode}
+ \outputpenalty-\pagebreak@pen
\dead@cycle
}{%
\begingroup
@@ -1741,6 +2087,7 @@ in your filesystem where they will be found by \LaTeX.
%
% \begin{macro}{\do@startpage@pen}
% \begin{macro}{\forcefloats@sw}
+% \begin{macro}{\@output@combined@page}
% \begin{macro}{\@sdblcolelt}
% \begin{macro}{\test@dblfloat}
% \begin{macro}{\@if@notdblfloat}
@@ -1767,11 +2114,13 @@ in your filesystem where they will be found by \LaTeX.
% To differentiate between the two, the width of the float is compared to \cmd\textwidth.
% This comparison is encapsulated in the macro \cmd\@if@notdblfloat, which should be used whenever
% such a determination must be made. This procedure returns a Boolean.
+%
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\mathchardef\do@startpage@pen=10006
\@namedef{output@-\the\do@startpage@pen}{\do@startpage}%
\def\do@startpage{%
- \setbox\@cclv\vbox{\unvbox\@cclv\setbox\z@\lastbox\unskip}%
+ \setbox\@cclv\vbox{\unvbox\@cclv\remove@lastbox\unskip}%
\clearpage@sw{\@clearfloatplacement}{\@dblfloatplacement}%
\set@colht
\@booleanfalse\pfloat@avail@sw
@@ -1782,11 +2131,7 @@ in your filesystem where they will be found by \LaTeX.
\endgroup
\fcolmade@sw{%
\global\setbox\pagesofar\vbox{\unvbox\pagesofar\unvbox\@outputbox}%
- \@combinepage
- \@combinedblfloats
- \@outputpage
- \global\pagegrid@cur\@ne
- \protect@penalty\do@startpage@pen
+ \@output@combined@page
}{%
\begingroup
\@booleanfalse\float@avail@sw
@@ -1807,7 +2152,25 @@ in your filesystem where they will be found by \LaTeX.
}%
\check@deferlist@stuck\do@startpage
\set@colht
-%\set@colroom
+}%
+% \end{macrocode}
+%
+% Procedure \cmd\@output@combined@page\ is a utility that ships out a page consisting of the
+% result of \cmd\@combinepage\ and \cmd\@combinedblfloats, after which it prepares for
+% the process to repeat.
+%
+% It is coincidentally identical to what needs to happen with
+% a float page that has been built by \cmd\@tryfcolumn, in the multi-column page grid,
+% and also handles the case where a page needs to be shipped out when in multicolumn mode.
+% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}}
+% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument}
+% \begin{macrocode}
+\def\@output@combined@page{%
+ \@combinepage\true@sw
+ \@combinedblfloats
+ \@outputpage
+ \global\pagegrid@cur\@ne
+ \protect@penalty\do@startpage@pen
}%
\def\@sdblcolelt#1{\def\@currbox{#1}\@addtodblcol}%
\def\test@dblfloat#1{%
@@ -1822,6 +2185,7 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\@addtodblcol}
%
@@ -2028,7 +2392,7 @@ in your filesystem where they will be found by \LaTeX.
%
% 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.
% There may be material in \cmd\pagesofar, and (in a multi-column page grid) any number of columns of the page have been composed.
-% Also, there might be footnote material saved up in \cmd\footbox.
+% Also, there might be footnote material saved up in \cmd\footsofar.
%
% Because we did not want to perform multiple \cmd\shipout s per visit to the output routine,
% our multi-column page makeup will not compose multiple columns per visit.
@@ -2166,9 +2530,7 @@ in your filesystem where they will be found by \LaTeX.
% measured.
% \begin{macrocode}
\mathchardef\do@endpage@pen=10007
-\@namedef{output@-\the\do@endpage@pen}{%
- \csname end@column@\thepagegrid\endcsname
-}%
+\@namedef{output@-\the\do@endpage@pen}{\csname end@column@\thepagegrid\endcsname}%
% \end{macrocode}
% \end{macro}
%
@@ -2217,7 +2579,7 @@ in your filesystem where they will be found by \LaTeX.
%
% \begin{macro}{\clr@top@firstmark}
% \begin{macro}{\set@top@firstmark}
-% \begin{macro}{\@outputpage}
+% \begin{macro}{\@outputpage@tail}
% We want accurate values of \cmd\topmark\ and \cmd\firstmark, but we must deal with
% the fact that there are many different ways of contributing material
% to the page. Only upon the first contribution to the page is the value of \cmd\topmark\
@@ -2256,10 +2618,9 @@ in your filesystem where they will be found by \LaTeX.
%
% As soon as a page is shipped out, we initialize the two macros that
% hold the values of \cmd\topmark\ and \cmd\firstmark, respectively.
-% \LaTeX\ has exactly one procedure \cmd\@outputpage\ that does \cmd\shipout,
-% which is as it should be: we tailpatch it, and the job is done.
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}%
% \begin{macrocode}
-\appdef\@outputpage{%
+\appdef\@outputpage@tail{%
\clr@top@firstmark
}%
% \end{macrocode}
@@ -2283,36 +2644,46 @@ in your filesystem where they will be found by \LaTeX.
% and in the "dbl" version, \cmd\textwidth. However, an environment such as \env{turnpage}
% may change the meanings of these macros to allow turnpage floats.
%
+% \changes{4.0a}{2008/06/26 }{\cs{@yfloat}: de-fang \cs{set@footnotewidth} (see ltxutil.dtx): we have already done its job. }
+%
+% Note on \cmd\@xfloat: the optional argument must come to it fully expanded, because the macro
+% does a weird procedure on this argument, involving \cmd\@onelevel@sanitize, which I do not
+% understand, and which does not work if not so expanded.
+% \changes{4.1b}{2008/08/04}{Get rid of the \cs{reserved@a} idiom}
% \begin{macrocode}
\def\@float#1{%
- \@ifnextchar[{%}]{%Brace-matching klootch
+ \@ifnextchar[{%
+% \end{macrocode}
+% \verb+}]{+Brace-matching klootch
+% \begin{macrocode}
\@yfloat\width@float{#1}%
}{%
- \@ifxundefined@cs{fps@#1}{%
- \edef\reserved@a{\noexpand\@yfloat\noexpand\width@float{#1}[\csname fps@\endcsname]}\reserved@a
- }{%
- \edef\reserved@a{\noexpand\@yfloat\noexpand\width@float{#1}[\csname fps@#1\endcsname]}\reserved@a
- }%
+ \@ifxundefined@cs{fps@#1}{}{\expandafter\let\expandafter\fps@\csname fps@#1\endcsname}%
+ \expandafter\@argswap\expandafter{\expandafter[\fps@]}{\@yfloat\width@float{#1}}%
}%
}%
\def\@dblfloat#1{%
\@ifnum{\pagegrid@col=\@ne}{%
\@float{#1}%
}{%
- \@ifnextchar[{%}]{%Brace-matching klootch
+ \@ifnextchar[{%
+% \end{macrocode}
+% \verb+}]{+Brace-matching klootch
+% \begin{macrocode}
\@yfloat\widthd@float{#1}%
}{%
- \@ifxundefined@cs{fpsd@#1}{%
- \edef\reserved@a{\noexpand\@yfloat\noexpand\widthd@float{#1}[\csname fpsd@\endcsname]}\reserved@a
- }{%
- \edef\reserved@a{\noexpand\@yfloat\noexpand\widthd@float{#1}[\csname fpsd@#1\endcsname]}\reserved@a
- }%
+ \@ifxundefined@cs{fpsd@#1}{}{\expandafter\let\expandafter\fpsd@\csname fpsd@#1\endcsname}%
+ \expandafter\@argswap\expandafter{\expandafter[\fpsd@]}{\@yfloat\widthd@float{#1}}%
}%
}%
}%
+% \end{macrocode}
+% \changes{4.1b}{2008/08/04}{Turn off the \cs{set@footnotewidth} mechanism; a float `knows' its proper typesetting context}
+% \begin{macrocode}
\def\@yfloat#1#2[#3]{%
\@xfloat{#2}[#3]%
\hsize#1\linewidth\hsize
+ \let\set@footnotewidth\@empty
\minipagefootnote@init
}%
\def\fps@{tbp}%
@@ -2352,8 +2723,14 @@ in your filesystem where they will be found by \LaTeX.
% LaTeX Bug note: if a user types \cmd\begin{table*}[h], the float will never succeed in being placed!
% we try to catch such cases.
%
-% Note that the macro \cmd\check@currbox@count\ trys to catch cases where the float placement options
+% Note that the macro \cmd\check@currbox@count\ tries to catch cases where the float placement options
% are such that the float can never be placed.
+%
+% The calls to \cmd\@iffpsbit\ are part of a procedure to deny certain of the float placement
+% parameters: ``h'' and ``b'' are not possible, the former because the \cmd\marginpar\ mechanism
+% cannot place a full-page-width float within a multicolumn page grid, the latter because nobody
+% has yet written the code to do so (pretty bad reason, I know).
+% \changes{4.1b}{2008/08/04}{New procedure \cs{@iffpsbit} replaces \cs{@getfpsbit}}
% \begin{macrocode}
\def\end@float{%
\end@@float{%
@@ -2365,8 +2742,8 @@ in your filesystem where they will be found by \LaTeX.
\end@float
}{%
\end@@float{%
- \@boxfpsbit\@currbox{1}\@ifodd\@tempcnta{\global\advance\count\@currbox\m@ne}{}%
- \@boxfpsbit\@currbox{4}\@ifodd\@tempcnta{\global\advance\count\@currbox-4\relax}{}%
+ \@iffpsbit\@ne{\global\advance\count\@currbox\m@ne}{}%
+ \@iffpsbit\f@ur{\global\advance\count\@currbox-4\relax}{}%
\global\wd\@currbox\textwidth % Klootch
\check@currbox@count
}%
@@ -2374,7 +2751,6 @@ in your filesystem where they will be found by \LaTeX.
}%
\def\end@@float#1{%
\minipagefootnote@here
-%\minipagefootnotes
\@endfloatbox
#1%
\@ifnum{\@floatpenalty <\z@}{%
@@ -2388,19 +2764,117 @@ in your filesystem where they will be found by \LaTeX.
}%
}{}%
}%
+% \end{macrocode}
+% The \classname{float} package of Anselm Lingnau fails when used under \classname{ltxgrid}, but
+% we can fix things.
+% We also repair a bug in that package.
+%
+% \changes{4.1g}{2009/10/06}{(AO, 531) Fix package \classname{float} }
+% \begin{macrocode}
+\newcommand\float@end@float{%
+ \@endfloatbox
+ \global\setbox\@currbox\float@makebox\columnwidth
+ \let\@endfloatbox\relax
+ \end@float
+}%
+\newcommand\float@end@ltx{%
+ \end@@float{%
+ \global\setbox\@currbox\float@makebox\columnwidth
+ \check@currbox@count
+ }%
+}%
+\newcommand\newfloat@float[3]{%
+ \@namedef{ext@#1}{#3} %!
+ \let\float@do=\relax
+ \xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}%
+ \@tempa
+ \floatplacement{#1}{#2}%
+ \@ifundefined{fname@#1}{\floatname{#1}{#1}}{} %!
+ \expandafter\edef\csname ftype@#1\endcsname{\value{float@type}}%
+ \addtocounter{float@type}{\value{float@type}} %!
+ \restylefloat{#1}%
+ \expandafter\edef\csname fnum@#1\endcsname{%
+ \expandafter\noexpand\csname fname@#1\endcsname{} %!
+ \expandafter\noexpand\csname the#1\endcsname
+ }
+ \@ifnextchar[%]
+ {%
+ \float@newx{#1}%
+ }{%
+ \@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}{}%
+ }%
+}%
+\newcommand\newfloat@ltx[3]{%
+ \@namedef{ext@#1}{#3}%
+ \let\float@do=\relax
+ \xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}%
+ \@tempa
+ \floatplacement{#1}{#2}%
+ \@ifundefined{fname@#1}{\floatname{#1}{#1}}{}%
+ \expandafter\edef\csname ftype@#1\expandafter\endcsname\expandafter{\the\c@float@type}%
+ \addtocounter{float@type}{\value{float@type}}%
+ \restylefloat{#1}%
+ \expandafter\edef\csname fnum@#1\endcsname{%
+ \expandafter\noexpand\csname fname@#1\endcsname{}%
+ \expandafter\noexpand\csname the#1\endcsname
+ }
+ \@ifnextchar[%]
+ {%
+ \float@newx{#1}%
+ }{%
+ \@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}{}%
+ }%
+}%
+\appdef\document@inithook{%
+ \@ifxundefined\newfloat{}{%
+ \@ifx{\float@end\float@end@float}{%
+ \@ifx{\newfloat\newfloat@float}{\true@sw}{\false@sw}%
+ }{\false@sw}%
+ {%
+ \class@warn{Repair the float package}%
+ \let\float@end\float@end@ltx
+ \let\newfloat\newfloat@ltx
+ }{%
+ \class@warn{Failed to patch the float package}%
+ }%
+ }%
+}%
+% \end{macrocode}
+%
+% Boolean procedure \cmd\@iffpsbit\ is similar to the \cmd\@getfpsbit\ of \LaTeX, except
+% that we do not expose the scratch count register or even change its value.
+% \begin{macrocode}
+\def\@iffpsbit#1{%
+ \begingroup
+ \@tempcnta\count\@currbox
+ \divide\@tempcnta#1\relax
+ \@ifodd\@tempcnta{\aftergroup\true@sw}{\aftergroup\false@sw}%
+ \endgroup
+}%
+% \end{macrocode}
+%
+% In procedure \cmd\check@currbox@count, we calculate the net float placement
+% directive (encoded into \cmd\count\ \cmd\@currbox's least significant four bits).
+% If zero, issue a warning.
+% \changes{4.1b}{2008/08/04}{Tally the height of the float}
+% \begin{macrocode}
\def\check@currbox@count{%
\@ifnum{\count\@currbox>\z@}{%
- \count@\count\@currbox\divide\count@\sixt@@n\multiply\count@\sixt@@n
- \@tempcnta\count\@currbox\advance\@tempcnta-\count@
- \@ifnum{\@tempcnta=\z@}{%
+ \count@\count\@currbox\divide\count@\sixt@@n\multiply\count@\sixt@@n
+ \@tempcnta\count\@currbox\advance\@tempcnta-\count@
+ \@ifnum{\@tempcnta=\z@}{%
\ltxgrid@warn{Float cannot be placed}%
- }{}%
+ }{}%
+ \expandafter\tally@float\expandafter{\@captype}%
}{%
- % Is a \marginpar
+% \end{macrocode}
+% In this case, the float is a \cmd\marginpar.
+% \begin{macrocode}
}%
}%
\providecommand\minipagefootnote@init{}%
\providecommand\minipagefootnote@here{}%
+\providecommand\tally@float[1]{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2438,18 +2912,17 @@ in your filesystem where they will be found by \LaTeX.
\csname @floatselect@sw@\thepagegrid\endcsname\@currbox{%
\@ifnum{\count\@currbox>\z@}{%
\advance \@pageht \@pagedp
- \advance \@pageht \vsize \advance \@pageht -\pagegoal % do not assume \holdinginserts is cleared!
-% \@ifvbox\@kludgeins{%
-% \@ifdim{\wd\@kludgeins=\z@}{%
-% \advance \@pageht \ht\@kludgeins
-% }{}%
-% }{}%
-% \@reinserts
- \@addtocurcol % Commit an h float
- }{%
-% \@reinserts
- \@addmarginpar
- }%
+% \end{macrocode}
+% Do not assume \cmd\holdinginserts is cleared:
+% \begin{macrocode}
+ \advance \@pageht \vsize \advance \@pageht -\pagegoal
+% \end{macrocode}
+% Commit an `h' float:
+% \begin{macrocode}
+ \@addtocurcol
+ }{%
+ \@addmarginpar
+ }%
}{%
\@resethfps
\@cons\@deferlist\@currbox
@@ -2468,7 +2941,7 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
%
% \begin{macro}{\@reinserts}
-% The \cmd\@reinserts\ procedure of standard \LaTeX\ is now obsoleted.
+% The \cmd\@reinserts\ procedure of standard \LaTeX\ is now obsoleted (it had been erroneous anyway).
% \begin{macrocode}
\let\@reinserts\@undefined
% \end{macrocode}
@@ -2627,7 +3100,10 @@ in your filesystem where they will be found by \LaTeX.
\ltxgrid@warn{You must load the graphics or graphicx package in order to use the turnpage environment}%
#2%
}%
-\AtBeginDocument{%
+% \end{macrocode}
+% \changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}}
+% \begin{macrocode}
+\appdef\document@inithook{%
\@ifxundefined\rotatebox{\let\rotatebox\rotatebox@dummy}{}%
}%
% \end{macrocode}
@@ -2641,14 +3117,19 @@ in your filesystem where they will be found by \LaTeX.
% \begin{macro}{output@-1073741824}
% The first one-off output routine handles the end of the job, wherein
% \LaTeX\ executes \cmd\@@end, and breaks to the output with a penalty of
-% $"40000000 = 2^{32}/4$. We simply discard \cmd\box\cmd\@cclv\ and leave.
+% $"40000000 = 2^{32}/4 = 1073741824$.
+% We simply discard \cmd\box\cmd\@cclv\ and leave.
% This means that \LaTeX\ is obligated to do \cmd\clearpage\ as part of
% its \enve{document} processing, otherwise material will be lost.
% \begin{macrocode}
-\@namedef{output@-1073741824}{%"40000000
+\@namedef{output@-1073741824}{%
\deadcycles\z@
+% \end{macrocode}
+% \begin{verbatim}
%\showbox\@cclv
- \setbox\z@\box\@cclv
+% \end{verbatim}
+% \begin{macrocode}
+ \void@cclv
}%
% \end{macrocode}
% \end{macro}
@@ -2682,18 +3163,18 @@ in your filesystem where they will be found by \LaTeX.
% \begin{macrocode}
\def\save@column{%
\@ifvoid\@cclv@saved{%
- \set@top@firstmark
- \global\@topmark@saved\expandafter{\@@topmark}%
+ \set@top@firstmark
+ \global\@topmark@saved\expandafter{\@@topmark}%
}{}%
- \global\setbox\@cclv@saved\vbox{%
+ \global\setbox\@cclv@saved\vbox{%
\@ifvoid\@cclv@saved{}{%
- \unvbox\@cclv@saved
- \marry@baselines
- }%
- \unvbox\@cclv
- \lose@breaks
- \setbox\z@\lastbox
- }%
+ \unvbox\@cclv@saved
+ \marry@baselines
+ }%
+ \unvbox\@cclv
+ \lose@breaks
+ \remove@lastbox
+ }%
}%
\newtoks\@topmark@saved
% \end{macrocode}
@@ -2706,7 +3187,7 @@ in your filesystem where they will be found by \LaTeX.
% the one-off output routine associated with \cmd\save@column@pen.
% \begin{macrocode}
\def\prep@cclv{%
- \setbox\z@\box\@cclv
+ \void@cclv
\setbox\@cclv\box\@cclv@saved
\vbadness\@M
}%
@@ -2723,7 +3204,7 @@ in your filesystem where they will be found by \LaTeX.
% first with \cmd\holdinginserts\ set, then with it cleared.
% \begin{macrocode}
\mathchardef\save@column@insert@pen=10017
-\@namedef{output@-\the\save@column@insert@pen}{\toggle@insert\savecolumn@holding\savecolumn@moving}%
+\@namedef{output@-\the\save@column@insert@pen}{\toggle@insert{\savecolumn@holding}{\savecolumn@moving}}%
% \end{macrocode}
% The procedure \cmd\savecolumn@holding\ is the first phase of saving a column with its inserts.
% This phase must detect and remedy the one circumstance that will confound our efforts to propagate marks.
@@ -2732,16 +3213,17 @@ in your filesystem where they will be found by \LaTeX.
%
% If it appears that we have the pathological ``Big Bad Box'' case at hand, we use the \cmd\dead@cycle@repair@protected\
% procedure instead of \cmd\dead@cycle\ to do our dead cycle.
+% \changes{4.1b}{2008/08/04}{Use \cs{trace@box} instead of \cs{showbox}}
% \begin{macrocode}
\def\savecolumn@holding{%
- \@if@exceed@pagegoal{\unvcopy\@cclv\setbox\z@\lastbox}{%
- \setbox\z@\vbox{\unvcopy\@cclv\setbox\z@\lastbox}%
- \outputdebug@sw{{\tracingall\scrollmode\showbox\z@}}{}%
- \dimen@\ht\@cclv\advance\dimen@-\ht\z@
- \dead@cycle@repair@protected\dimen@
- }{%
- \dead@cycle
- }%
+ \@if@exceed@pagegoal{\unvcopy\@cclv\remove@lastbox}{%
+ \setbox\z@\vbox{\unvcopy\@cclv\remove@lastbox}%
+ \outputdebug@sw{\trace@box\z@}{}%
+ \dimen@\ht\@cclv\advance\dimen@-\ht\z@
+ \dead@cycle@repair@protected\dimen@
+ }{%
+ \dead@cycle
+ }%
}%
% \end{macrocode}
% The procedure \cmd\save@column@moving\ is the second phase of saving a column with its inserts.
@@ -2751,18 +3233,19 @@ in your filesystem where they will be found by \LaTeX.
%
% Note that the message that is about to be executed had better deal properly with the contents of
% the \cmd\footins@saved\ box.
+% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}}
% \begin{macrocode}
\def\savecolumn@moving{%
\@cclv@nontrivial@sw{%
- \save@column
+ \save@column
}{%
- {\setbox\z@\box\@cclv}%
+ \void@cclv
+ }%
+ \@ifvoid\footins{}{%
+ \outputdebug@sw{\trace@box\footins}{}%
+ \global\setbox\footins@saved\vbox{\unvbox\footins@saved\marry@baselines\unvbox\footins}%
+ \protect@penalty\save@column@insert@pen
}%
- \@ifvoid\footins{}{%
- \outputdebug@sw{{\tracingall\scrollmode\showbox\footins}}{}%
- \global\setbox\footins@saved\vbox{\unvbox\footins@saved\marry@baselines\unvbox\footins}%
- \protect@penalty\save@column@insert@pen
- }%
}%
\newbox\footins@saved
% \end{macrocode}
@@ -2779,17 +3262,19 @@ in your filesystem where they will be found by \LaTeX.
% namely \cmd\let@mark.
%
% Note: we expect that \cmd\box\cmd\@cclv's contents are well known:
-% \cmd\topskip, protection box, and a \cmd\mark, the latter havin the
-% message.
-% But if we came here via \cmd\penalty 10017, there might be an \cmd\insert\ node here as well, because
-% a footnote split.
+% \cmd\topskip, protection box, and a \cmd\mark, the latter containing the message.
+% But if we came here via \cmd\penalty 10017, there might be an \cmd\insert\ node present as well,
+% because a footnote may have split.
% Because this procedure simply voids out \cmd\box\cmd\@cclv, such material would be lost.
% Perhaps we can repair things by manipulating the \cmd\insert \ mechanism temporarily.
% \begin{macrocode}
\mathchardef\save@message@pen=10018
\@namedef{output@-\the\save@message@pen}{\save@message}%
\def\save@message{%
- \setbox\z@\box\@cclv %FIXME: what if \box\@cclv is not empty?
+ \void@cclv
+% \end{macrocode}
+%FIXME: what if \cmd\box\cmd\@cclv is not empty?
+% \begin{macrocode}
\toks@\expandafter{\@@firstmark}%
\expandafter\gdef\expandafter\@message@saved\expandafter{\the\toks@}%
\expandafter\do@@mark\expandafter{\the\@topmark@saved}%
@@ -2815,7 +3300,7 @@ in your filesystem where they will be found by \LaTeX.
% the output routine for execution in an environment appropriate to page makeup.
%
% How it works. We put down three large negative penalties, each of which will be handled by
-% the output dispatcher (not the output routine), each penalty being protected by
+% the output dispatcher (\emph{not} the natural output routine), each penalty being protected by
% a removable, non-discardable item (i.e., a box).
% Either three or four invocations of one-off output routines are involved per message.
%
@@ -2847,7 +3332,10 @@ in your filesystem where they will be found by \LaTeX.
% with a penalty value for the standard treatment.
% \begin{macrocode}
\def\execute@message{%
- \@execute@message\save@column@pen %Implicit #2
+ \@execute@message\save@column@pen
+% \end{macrocode}
+% Implicit second argument
+% \begin{macrocode}
}%
% \end{macrocode}
% \end{macro}
@@ -2863,7 +3351,7 @@ in your filesystem where they will be found by \LaTeX.
% must be dealt with in a way entirely analogous to \cmd\footins.
% \begin{macrocode}
\def\execute@message@insert#1{%
- \@execute@message\save@column@insert@pen{\setbox\footins\box\footins@saved#1}%
+ \@execute@message\save@column@insert@pen{\setbox \footins \box \footins@saved#1}%
}%
% \end{macrocode}
% \end{macro}
@@ -2893,7 +3381,11 @@ in your filesystem where they will be found by \LaTeX.
\toks@{\prep@cclv#2}%
\@@mark{\the\toks@}%
\penalty-\save@message@pen
+% \end{macrocode}
+%\begin{verbatim}
% \hbox{\vrule\@height\z@\@width\z@\@depth\dimen@}%
+%\end{verbatim}
+% \begin{macrocode}
\setbox\z@\null\dp\z@\dimen@\ht\z@-\dimen@
\nointerlineskip\box\z@
\penalty-\execute@message@pen
@@ -2940,7 +3432,10 @@ in your filesystem where they will be found by \LaTeX.
\def\lose@breaks{%
\loopwhile{%
\count@\lastpenalty
- \@ifnum{\count@=\@M}{% 10000 is a TeX magic number!
+ \@ifnum{\count@=\@M}{%
+% \end{macrocode}
+% Note: 10000 is a TeX magic number!
+% \begin{macrocode}
\unpenalty\true@sw
}{%
\false@sw
@@ -2968,7 +3463,7 @@ in your filesystem where they will be found by \LaTeX.
\vadjust{%
\execute@message{%
\unvbox\@cclv
- \setbox\z@\lastbox
+ \remove@lastbox
\unskip
\unskip
\unpenalty
@@ -3034,7 +3529,6 @@ in your filesystem where they will be found by \LaTeX.
%
% \begin{macro}{\move@insertions}
% \begin{macro}{\hold@insertions}
-% \begin{macro}{\move@insert@sw}
% In order to avoid bolluxing up \cmd\insert\ registers by our one-off
% output routines, we set \cmd\holdinginserts\ to zero by default and only
% clear it (briefly) while we handle cases where we want inserts to show up.
@@ -3042,14 +3536,12 @@ in your filesystem where they will be found by \LaTeX.
\def\move@insertions{\global\holdinginserts\z@}%
\def\hold@insertions{\global\holdinginserts\@ne}%
\hold@insertions
-\def\move@insert@sw{\@ifnum{\holdinginserts=\z@}}%
\def\toggle@insert#1#2{%
- \@ifnum{\holdinginserts=\z@}{\hold@insertions#2}{\move@insertions#1}%
+ \@ifnum{\holdinginserts>\z@}{\move@insertions#1}{\hold@insertions#2}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
-% \end{macro}
%
%
% \subsection{Messages to alter the page grid}%
@@ -3132,16 +3624,17 @@ in your filesystem where they will be found by \LaTeX.
% name of your page grid.
%
% The procedure \cmd\open@column@ name starts the new page grid. It should define \cmd\thepagegrid,
-% deal with \cmd\box\cmd\pagesofar\ and \cmd\box\cmd\footbox\ (perhaps by leaving them alone),
+% deal with \cmd\box\cmd\pagesofar\ and \cmd\box\cmd\footsofar\ (perhaps by leaving them alone),
% and it should set the values of \LaTeX's page layout parameters for the column size and height.
%
% The procedure \cmd\shut@column@ name should expect to be called with \cmd\holdinginserts\
% cleared (it can assume that \cmd\holdinginserts\ will automatically be restored).
-% It should properly deal with insertions (like footnotes); calling \cmd\@makecol\
-% is a good way to do this. It should know that the page grid is being terminated
+% It should properly deal with insertions (like footnotes); calling \cmd\@makecolumn\
+% with an argument of \cmd\false@sw\ will do this.
+% It should know that the page grid is being terminated
% in the middle of a page, so it should make arrangements to carry the footnotes down to the
% bottom of the column or page, and it should possibly salt away the material for later
-% incorporation into the page. The box registers \cmd\footbox\ and \cmd\pagesofar\ are customarily used
+% incorporation into the page. The box registers \cmd\footsofar\ and \cmd\pagesofar\ are customarily used
% for this purpose.
%
% The procedure \cmd\end@column@ name should kick out a possibly short page containing all the
@@ -3159,10 +3652,24 @@ in your filesystem where they will be found by \LaTeX.
% The former can be the basis for, say, a single-column page grid with a side column.
%
% \begin{macro}{\pagesofar}
-% \begin{macro}{\footbox}
+% \begin{macro}{\footsofar}
% \begin{macrocode}
\newbox\pagesofar
-\newbox\footbox
+\newbox\footsofar
+\def\combine@foot@inserts{%
+ \@ifvoid\footins{%
+ }{%
+ \@ifvoid\footsofar{%
+ \global\setbox\footsofar\box\footins
+ }{%
+ \global\setbox\footsofar\vbox\bgroup
+ \unvbox\footsofar
+ \marry@baselines
+ \unvbox\footins
+ \egroup
+ }%
+ }%
+}%
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -3194,6 +3701,7 @@ in your filesystem where they will be found by \LaTeX.
%
% The procedure \cmd\open@column@one\ takes advantage of the special nature of the one-column
% page grid to deal with \cmd\box\cmd\pagesofar, therefore it must also reset \cmd\@colroom.
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\def\open@column@one#1{%
\unvbox\pagesofar
@@ -3201,27 +3709,35 @@ in your filesystem where they will be found by \LaTeX.
\global\pagegrid@col#1%
\global\pagegrid@cur\@ne
\set@colht
-%\set@colroom
\set@column@hsize\pagegrid@col
}%
% \end{macrocode}
%
% The procedure \cmd\shut@column@one\ saves away the one-column material into the box register \cmd\pagesofar.
% Because it is called from a message handler, we are assured that marks are properly taken care of.
+%
+% This instance of \cmd\@makecolumn\ is building a column for saving into \cmd\pagesofar.
+% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
+% \changes{4.1f}{2009/07/15}{(AO, 519) Preserve footnotes that are in \cs{footsofar} across a page grid change}
% \begin{macrocode}
\def\shut@column@one{%
- \@makecol
+ \@makecolumn\false@sw
\global\setbox\pagesofar\vbox{\unvbox\@outputbox\recover@footins}%
+ \combine@foot@inserts
\set@colht
-%\set@colroom
}%
% \end{macrocode}
%
-% The procedure \cmd\float@column@one\ takes care of a float column that has been built by \cmd\@tryfcolumn,
-% in the single-column page grid.
+% The procedure \cmd\float@column@one\ takes care of a float column that has been built by
+% \cmd\@tryfcolumn, in the single-column page grid.
+%
+% This instance of \cmd\@makecolumn\ is followed by \cmd\@outputpage: it is building
+% a column for \cmd\shipout, rather than for saving into \cmd\pagesofar.
+% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
% \begin{macrocode}
\def\float@column@one{%
- \@makecol
+ \@makecolumn\true@sw
\@outputpage
}%
% \end{macrocode}
@@ -3239,17 +3755,17 @@ in your filesystem where they will be found by \LaTeX.
% upon which it relies to correctly do what \cmd\clearpage\ requires.
% \begin{macrocode}
\def\end@column@one{%
- \unvbox\@cclv\setbox\z@\lastbox
+ \unvbox\@cclv\remove@lastbox
\protect@penalty\do@newpage@pen
}%
% \end{macrocode}
%
% The procedure \cmd\output@column@one\ is dispatched from the output routine when
-% we have completed a page (that is, a column in a one-column page grid).
-% It ships out the page using the \cmd\@outputpage\ of standard \LaTeX,
-% which has been retained (it is needed also in \cmd\output@column@mlt,
-% and in any case should remain as the sole procedure in \LaTeX\ where \cmd\shipout\ is performed).
+% we have completed a page (that is, a column in a one-column page grid);
+% it ships out the page using the \cmd\@outputpage.
% It will be followed up with an output routine message to prepare a new column.
+%
+% Query: by what mechanism do the footnotes get placed onto such a page?
% \begin{macrocode}
\def\output@column@one{%
\@outputpage
@@ -3335,6 +3851,7 @@ in your filesystem where they will be found by \LaTeX.
% If your document class descends from one of \LaTeX's standard classes.dtx-derived
% classes, it will break. You must expunge from it all such commands.
%
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\def\open@column@mlt#1{%
\gdef\thepagegrid{mlt}%
@@ -3342,7 +3859,6 @@ in your filesystem where they will be found by \LaTeX.
\global\pagegrid@cur\@ne
\set@column@hsize\pagegrid@col
\set@colht
-%\set@colroom
}%
% \end{macrocode}
%
@@ -3350,41 +3866,47 @@ in your filesystem where they will be found by \LaTeX.
% salts away all in \cmd\pagesofar. Because it is called in a message handler,
% we are assured that marks are handled properly.
% Attention: because this procedure balances columns, all footnotes are
-% held aside in \cmd\footbox\ for placement at the bottom of the page.
+% held aside in \cmd\footsofar\ for placement at the bottom of the page.
%
-% Bug note: the last macro executed by this procedure is \cmd\set@colht, but had been erroneously \cmd\set@colroom.
+% Bug note: the last macro executed by this procedure is \cmd\set@colht,
+% but had been erroneously \cmd\set@colroom.
% I now believe that the latter should be changed pretty much everywhere to the former.
+%
+% This instance of \cmd\@makecolumn\ is building material for \cmd\pagesofar, rather than
+% for \cmd\shipout.
+% \changes{4.1b}{2008/08/04}{Change \cs{@makecol} to \cs{@makecolumn} with argument}
+% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument}
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\def\shut@column@mlt{%
\@cclv@nontrivial@sw{%
- \@makecol
- \@ifnum{\pagegrid@cur<\pagegrid@col}{%
- \expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox
- \global\advance\pagegrid@cur\@ne
- }{}%
+ \@makecolumn\false@sw
+ \@ifnum{\pagegrid@cur<\pagegrid@col}{%
+ \expandafter\global\expandafter\setbox\csname col@\the\pagegrid@cur\endcsname\box\@outputbox
+ \global\advance\pagegrid@cur\@ne
+ }{}%
}{%
- {\setbox\z@\box\@cclv}%
+ \void@cclv
}%
- \@ifnum{\pagegrid@cur>\@ne}{%
- \csname balance@\the\pagegrid@col\endcsname
- \grid@column{}%
- \@combinepage
- \@combinedblfloats
- \global\setbox\pagesofar\box\@outputbox
+ \@ifnum{\pagegrid@cur>\@ne}{%
+ \csname balance@\the\pagegrid@col\endcsname
+ \grid@column{}%
+ \@combinepage\false@sw
+ \@combinedblfloats
+ \global\setbox\pagesofar\box\@outputbox
+ \show@pagesofar@size
}{}%
\set@colht
}%
% \end{macrocode}
%
% The procedure \cmd\float@column@mlt\ takes care of a float page that has been built by \cmd\@tryfcolumn,
-% in the multi-column page grid.
+% in the multi-column page grid. It is coincidentally identical to what happens in
+% \cmd\do@startpage\ when a page needs to be shipped out.
+% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}}
% \begin{macrocode}
\def\float@column@mlt{%
- \@combinepage
- \@combinedblfloats
- \@outputpage
- \global\pagegrid@cur\@ne
- \protect@penalty\do@startpage@pen
+ \@output@combined@page
}%
% \end{macrocode}
%
@@ -3423,17 +3945,18 @@ in your filesystem where they will be found by \LaTeX.
% true = kick out a column and try again
{%
\@cclv@nontrivial@sw{%
- \unvbox\@cclv\setbox\z@\lastbox
+ \unvbox\@cclv\remove@lastbox
}{%
- \unvbox\@cclv\setbox\z@\lastbox\unskip\null
+ \unvbox\@cclv\remove@lastbox\unskip\null
}%
\protect@penalty\do@newpage@pen
\protect@penalty\do@endpage@pen
}{%
- \unvbox\@cclv\setbox\z@\lastbox
+ \unvbox\@cclv\remove@lastbox
}%
}%
% \end{macrocode}
+%
% The procedure \cmd\output@column@mlt (cf. \cmd\output@column@one)
% is dispatched from the output routine when
% we have completed a column in a multi-column page grid).
@@ -3443,6 +3966,9 @@ in your filesystem where they will be found by \LaTeX.
% full-page-width floats to the next page.
% Like \cmd\output@column@mlt, this is followed by
% an output routine message to prepare a new column.
+%
+% If a page needs to be shipped out, it uses the same mechanism as \cmd\do@startpage.
+% \changes{4.1b}{2008/08/04}{New procedure \cs{@output@combined@page}}
% \begin{macrocode}
\def\output@column@mlt{%
\@ifnum{\pagegrid@cur<\pagegrid@col}{%
@@ -3450,13 +3976,8 @@ in your filesystem where they will be found by \LaTeX.
\global\advance\pagegrid@cur\@ne
}{%
\set@adj@colht\dimen@
-% \advance\dimen@-\topskip
- \grid@column{}%{\dimen@}%
- \@combinepage
- \@combinedblfloats
- \@outputpage
- \global\pagegrid@cur\@ne
- \protect@penalty\do@startpage@pen
+ \grid@column{}%
+ \@output@combined@page
}%
}%
% \end{macrocode}
@@ -3556,8 +4077,7 @@ in your filesystem where they will be found by \LaTeX.
% The procedure \cmd\append@column\ appends columns for \cmd\grid@column,
% \cmd\box@column\ builds the columns for \cmd\append@column,
% and \cmd\marry@baselines\ pastes vertical things back together.
-% \changes{v4.0rc1}{2001/06/18}
-% {Introoduce \cs{marry@height} }
+% \changes{4.0a}{2001/06/18}{Introduce \cs{marry@height} }
%
% Note that \cmd\box@column\ makes an attempt to prevent excessive \cmd\topskip\
% or \cmd\baselineskip\ glue
@@ -3571,7 +4091,7 @@ in your filesystem where they will be found by \LaTeX.
% to use: it will change if floats have been placed in the last column of the page.
% I believe \cmd\textheight\ is the correct parameter to use here.
%
-% A REVTeX4 beta user, Sergey Strelkov (strelkov@maik.rssi.ru), wants the option
+% A REVTeX4 user, Sergey Strelkov (strelkov@maik.rssi.ru), wants the option
% of ragged-bottom columns. Implementing this feature properly means reboxing the
% columns to their natural height only if \cmd\raggedcolumn@sw\ is true.
% Otherwise, they get reboxed to their common height (\cmd\@colht?).
@@ -3624,20 +4144,21 @@ in your filesystem where they will be found by \LaTeX.
}%
}%
\def\marry@baselines{%
-%{\tracingall\scrollmode\showlists}%
-%\skip@\baselineskip\advance\skip@-\topskip %FIXME: cannot assume \baselineskip nor \topskip
\vskip\marry@skip\relax
}%
\gdef\marry@skip{\z@skip}%
\def\set@marry@skip{%
- \begingroup
+ \begingroup
\skip@\baselineskip\advance\skip@-\topskip
\@ifdim{\skip@>\z@}{%
\xdef\marry@skip{\the\skip@}%
}{}%
\endgroup
}%
-\AtBeginDocument{%
+% \end{macrocode}
+% \changes{4.1b}{2008/08/04}{Use \cs{document@inithook} instead of \cs{AtBeginDocument}}
+% \begin{macrocode}
+\appdef\document@inithook{%
\@ifxundefined\raggedcolumn@sw{\@booleanfalse\raggedcolumn@sw}{}%
}%
\def\raggedcolumn@skip{%
@@ -3649,9 +4170,18 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
%
% \begin{macro}{\@combinepage}
-% The procedure \cmd\@combinepage\ prepends the stored page to \cmd\@outputbox.
+% The procedure \cmd\@combinepage\ prepends the stored page (\cmd\pagesofar) to \cmd\@outputbox\ and
+% employs \cmd\@combineinserts\ to lay down the footnotes.
+% The next event will usually be shipping out the made-up page, but not always.
+% Therefore the argument of \cmd\@combinepage, which must be a Boolean, determines
+% if the footnotes are to be combined into this page.
+%
+% \changes{4.1b}{2008/08/04}{Change \cs{@combinepage} to \cs{@combinepage} with argument}
+% \changes{4.1b}{2008/08/04}{(AO, 452) Support length checking: show size of shipped out text.}
+%
+% QUERY: In the following, if \cmd\box\cmd\footins\ is not void, its contents are lost. Can this ever happen?
% \begin{macrocode}
-\def\@combinepage{%
+\def\@combinepage#1{%
\@ifvoid\pagesofar{}{%
\setbox\@outputbox\vbox{%
\unvbox\pagesofar
@@ -3659,17 +4189,60 @@ in your filesystem where they will be found by \LaTeX.
\unvbox\@outputbox
}%
}%
- \@ifvoid\footbox{}{%
- \setbox\@outputbox\vbox{%
- \unvbox\@outputbox
- \marry@baselines
- \unvbox\footbox
+ #1{%
+ \@ifvoid\footsofar{}{%
+ \show@box@size{Combining page footnotes}\footsofar
+ \setbox\footins\box\footsofar
+ \@combineinserts\@outputbox\footins
}%
+ }{%
+% \end{macrocode}
+%QUERY: The following line was removed, probably to fix a bug. When was this done?
+% \begin{verbatim}
+% \global\setbox\footins\box\footsofar
+% \end{verbatim}
+% \begin{macrocode}
}%
}%
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@cflt}
+% \begin{macro}{\@cflb}
+% \changes{4.1b}{2008/08/04}{}
+% We modify \LaTeX's \cmd\@cflt\ and \cmd\@cflb\ to remove the unwanted glue with \cmd\unskip.
+% \begin{macrocode}
+\def \@cflt{%
+ \let \@elt \@comflelt
+ \setbox\@tempboxa \vbox{}%
+ \@toplist
+ \setbox\@outputbox \vbox{%
+ \boxmaxdepth \maxdepth
+ \unvbox\@tempboxa\unskip
+ \topfigrule\vskip \textfloatsep
+ \unvbox\@outputbox
+ }%
+ \let\@elt\relax
+ \xdef\@freelist{\@freelist\@toplist}%
+ \global\let\@toplist\@empty
+}%
+\def \@cflb {%
+ \let\@elt\@comflelt
+ \setbox\@tempboxa \vbox{}%
+ \@botlist
+ \setbox\@outputbox \vbox{%
+ \unvbox\@outputbox
+ \vskip \textfloatsep\botfigrule
+ \unvbox\@tempboxa\unskip
+ }%
+ \let\@elt\relax
+ \xdef\@freelist{\@freelist\@botlist}%
+ \global \let \@botlist\@empty
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\@combinedblfloats}
% We modify \LaTeX's \cmd\@combinedblfloats\ to be more appropriate for incremental page building:
% we \cmd\unvbox\ the \cmd\@outputbox.
@@ -3696,8 +4269,7 @@ in your filesystem where they will be found by \LaTeX.
% The procedure \cmd\set@column@hsize\ takes care of setting up the horizontal dimensions
% for the current page grid. The present routine will certainly not be adequate for more
% complex page layouts (e.g., with a side column), but works for the common ones.
-% \changes{v4.0rc1}{2001/06/18}
-% {Introoduce \cs{set@marry@height} }
+% \changes{4.0a}{2001/06/18}{Introduce \cs{set@marry@height} }
% \begin{macrocode}
\def\set@column@hsize#1{%
\pagegrid@col#1%
@@ -3740,7 +4312,7 @@ in your filesystem where they will be found by \LaTeX.
%
% Question: what if there are committed floats? Footnotes?
% Answer: full-page-width floats are only committed at top, and they are already reckoned with in \cmd\@colht.
-% Column-width committed floats are incorporated by \cmd\@makecol; footnotes need help.
+% Column-width committed floats are incorporated by \cmd\@makecolumn; footnotes need help.
%
% Note: FIXME: adjusting for \cmd\pagesofar\ is done at not quite the right time. I need to reexamine \cmd\set@colht,
% because \cmd\@dbltoplist\ and \cmd\pagesofar\ really should be on the same footing.
@@ -3749,12 +4321,13 @@ in your filesystem where they will be found by \LaTeX.
% These concerns will be particularly germane if we ever extend this package to deal with full-page-width floats
% placed at the bottom of the page, or committed on the same page as called out.
%
-% It occurs to me that we should ditch \cmd\set@colroom\ and only ever execute \cmd\set@colht, which sets \cmd\@colroom\ as a side effect.
+% It occurs to me that we should ditch \cmd\set@colroom\ and only ever execute \cmd\set@colht,
+% which sets \cmd\@colroom\ as a side effect.
% If so, we can make \cmd\@colht\ take \cmd\pagesofar\ into account, as it should. Then \cmd\@colht\ will return to its
% original significance as the value that \cmd\@colroom\ is set to after a column is committed.
%
% On the other hand, why not simply forget all this caching and (re-)calculate \cmd\vsize\ as late as possible?
-% Paticularly, \cmd\@colht\ is an artifact of the old way of doing things, where once it was set, it would never change.
+% Particularly, \cmd\@colht\ is an artifact of the old way of doing things, where once it was set, it would never change.
%
% \begin{macrocode}
\def\set@colht{%
@@ -3767,9 +4340,6 @@ in your filesystem where they will be found by \LaTeX.
\def\@elt{\adj@page#1}%
\@booleantrue\firsttime@sw\@dbltoplist
\let\@elt\relax
-%\@ifvoid\pagesofar{}{%
-% \advance#1-\ht\pagesofar\advance#1-\dp\pagesofar
-%}%
\global#1#1\relax
\outputdebug@sw{\saythe#1}{}%
}%
@@ -3777,8 +4347,8 @@ in your filesystem where they will be found by \LaTeX.
\set@adj@colht\@colroom
\@if@empty\enlarge@colroom{}{%
\global\advance\@colroom\enlarge@colroom\relax
+ \outputdebug@sw{\saythe\@colroom}{}%
}%
- \outputdebug@sw{\saythe\@colroom}{}%
\@ifdim{\@colroom>\topskip}{}{%
\ltxgrid@info{Not enough room: \string\@colroom=\the\@colroom; increasing to \the\topskip}%
\@colroom\topskip
@@ -3791,28 +4361,53 @@ in your filesystem where they will be found by \LaTeX.
\global\vsize\@colroom
\outputdebug@sw{\saythe\vsize}{}%
}%
-%
+% \end{macrocode}
+% \changes{4.1b}{2008/08/04}{Procedure \cs{set@adj@footins} to adjust for footnotes and other inserts}
+% \begin{macrocode}
\def\set@adj@colht#1{%
#1\@colht
+ \outputdebug@sw{\saythe#1}{}%
\@ifvoid\pagesofar{}{%
\advance#1-\ht\pagesofar\advance#1-\dp\pagesofar
+ \outputdebug@sw{\saythe#1}{}%
}%
- \@ifvoid\footbox{}{%
- \advance#1-\ht\footbox\advance#1-\dp\footbox
- }%
+ \set@adj@footins#1%
\def\@elt{\adj@column#1}%
\@booleantrue\firsttime@sw\@toplist
\@booleantrue\firsttime@sw\@botlist
\let\@elt\relax
- \outputdebug@sw{\saythe#1}{}%
}%
\def\adj@column#1#2{%
\advance#1-\ht#2%
\advance#1-\firsttime@sw{\textfloatsep\@booleanfalse\firsttime@sw}{\floatsep}%
+ \outputdebug@sw{\saythe#1}{}%
}%
\def\adj@page#1#2{%
\advance#1-\ht#2%
\advance#1-\firsttime@sw{\dbltextfloatsep\@booleanfalse\firsttime@sw}{\dblfloatsep}%
+ \outputdebug@sw{\saythe#1}{}%
+}%
+% \end{macrocode}
+% \changes{4.1b}{2008/08/04}{Procedure \cs{set@adj@footins} to adjust for footnotes and other inserts}
+% \changes{4.1f}{2009/07/14}{(AO, 519) Do not use \cs{dimen@} register as a scratch register in \cs{set@adj@footins}}
+% Bug note (AO): I had used \cmd\dimen@\ as a scratch register within this procedure, because I had thought
+% that doing, e.g., \cmd\advance\cmd\dimen@-\cmd\skip\cmd\footins\ would not work in \TeX.
+% Not only was I wrong about that, but I then proceded to execute \cmd\set@adj@footins\cmd\dimen@,
+% which understandably did not work. Ah! The treachery of the human mind.
+% \begin{macrocode}
+\def\set@adj@footins#1{%
+ \@booleanfalse\temp@sw
+ \set@adj@box#1\footins
+ \set@adj@box#1\footins@saved
+ \set@adj@box#1\footsofar
+ \temp@sw{\advance#1-\skip\footins}{}%
+}%
+\def\set@adj@box#1#2{%
+ \@ifvoid#2{}{%
+ \advance#1-\ht#2\advance#1-\dp#2%
+ \@booleantrue\temp@sw
+ \outputdebug@sw{\saythe#1}{}%
+ }%
}%
% \end{macrocode}
% \end{macro}
@@ -3820,8 +4415,9 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\@outputpage}%
-% At the tail of \cmd\@outputpage, we set \cmd\@colht\ and the float placement parameters
+% \begin{macro}{\@outputpage@tail}%
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}%
+% In \cmd\@outputpage@tail, we set \cmd\@colht\ and the float placement parameters
% (this is the one point where it is appropriate to set \cmd\@colht).
% At \cmd\do@startpage\ time, we adjust \cmd\@colht's value to reflect committed
% full-page-width floats.
@@ -3829,7 +4425,7 @@ in your filesystem where they will be found by \LaTeX.
% Note: with a correctly written output routine, a call to \cmd\@outputpage\ will inevitably be
% followed by a call to \cmd\do@startpage, so these procedure calls would be unneeded.
% \begin{macrocode}
-\appdef\@outputpage{%
+\appdef\@outputpage@tail{%
\set@colht % FIXME: needed?
\@floatplacement % FIXME: needed?
\@dblfloatplacement % FIXME: needed?
@@ -3838,23 +4434,50 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
%
% \begin{macro}{balance@2}
+% \changes{4.1b}{2008/08/04}{Procedure \cs{balance@2} defined more transparently}%
% We define procedures for balancing columns in a multicolumn layout.
% For now, we define only one: a procedure for the two-column grid.
% All others will simply \cmd\relax\ out.
-% \begin{macrocode}
-\@namedef{balance@2}{%
- \expandafter\balance@two\csname col@1\endcsname\@outputbox
- % Avoid a bug by preventing a restore when leaving this group
- \global\setbox\csname col@1\endcsname\box\csname col@1\endcsname
- \@ifvoid\footbox{}{%
- \global\setbox\footbox\vbox{%
- \setbox\z@\box\@tempboxa
- \let\recover@footins\relax
- \balance@two\footbox\@tempboxa
- \hb@xt@\textwidth{\box\footbox\hfil\box\@tempboxa}%
+%
+% The following code defines \verb+\balance@2+ without all the clunky \cmd\csname\ commands
+% in the replacement part,
+% which appears on the right-hand side of the assignment to \cmd\toks@.
+%
+% The method is straightforward: balance the two columns of text, and balance the footnotes.
+% Later on, \cmd\@combineinserts\ will be called to place the footnotes after the now-balanced columns.
+%
+% \changes{4.1f}{2009/07/14}{(AO, 519) \cs{footins} content must be preserved and reintegrated}
+% It was necessary to deal with the case where \cmd\box\cmd\footsofar\ was not empty
+% upon execution of this balancing code. We store it away in \cmd\box\cmd\footins\ and
+% add it back in afterwards.
+% \begin{macrocode}
+\begingroup
+ \catcode`\1=\cat@letter
+ \catcode`\2=\cat@letter
+% \end{macrocode}
+% \cmd\toks@\ contains the repacement part for an effective \cmd\def\cs{balance@2}.
+% \begin{macrocode}
+ \toks@{%
+ \setbox\footins\box\footsofar
+ \balance@two\col@1\@outputbox
+% \end{macrocode}
+% \begin{verbatim}
+% \global\setbox\col@1\box\col@1
+% \end{verbatim}
+% \begin{macrocode}
+ \combine@foot@inserts
+ \@ifvoid\footsofar{}{%
+ \global
+ \setbox\footsofar\vbox\bgroup
+ \setbox\z@\box\@tempboxa
+ \let\recover@footins\relax
+ \balance@two\footsofar\@tempboxa
+ \hb@xt@\textwidth{\box\footsofar\hfil\box\@tempboxa}%
+ \egroup
}%
}%
-}%
+ \aftergroup\def\aftergroup\balance@2\expandafter
+\endgroup\expandafter{\the\toks@}%
% \end{macrocode}
% \end{macro}
%
@@ -3898,7 +4521,7 @@ in your filesystem where they will be found by \LaTeX.
% \cmd\z@\
% \cmd\vskip-%
% \cmd\dimen@.
-% The error here is that the shift of the last box in the vertical list will be lost in the process.
+% The error here is that the (horizontal) shift of the last box in the vertical list will be lost in the process.
% Simply put, \cmd\setbox\cmd\z@\cmd\lastbox\ fails to retain the shift of the box node in the vertical list,
% and when it is put down again via \cmd\box\cmd\z@, it will no longer have the correct shift.
%
@@ -3923,9 +4546,10 @@ in your filesystem where they will be found by \LaTeX.
%
% The dimension involved is checked against the current \cmd\@colroom\ to guard against the case where
% excessive material happens to fall in either column.
+% \changes{4.1b}{2008/08/04}{Change \cs{set@colroom} to \cs{set@colht}}
% \begin{macrocode}
\def\balance@two#1#2{%
- \outputdebug@sw{{\tracingall\scrollmode\showbox#1\showbox#2}}{}%
+ \outputdebug@sw{\trace@scroll{\showbox#1\showbox#2}}{}%
\setbox\@ne\vbox{%
\@ifvoid#1{}{%
\unvcopy#1\recover@footins
@@ -3945,11 +4569,11 @@ in your filesystem where they will be found by \LaTeX.
\setbox\z@\copy\@ne\setbox\tw@\vsplit\z@ to\dimen@
\setbox\z@ \vbox{%
\unvcopy\z@
- \setbox\z@\vbox{\unvbox\z@ \setbox\z@\lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax
+ \setbox\z@\vbox{\unvbox\z@ \remove@lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax
}%
\setbox\tw@\vbox{%
\unvcopy\tw@
- \setbox\z@\vbox{\unvbox\tw@\setbox\z@\lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax
+ \setbox\z@\vbox{\unvbox\tw@\remove@lastbox\aftergroup\vskip\aftergroup-\expandafter}\the\dp\z@\relax
}%
\dimen@ii\ht\tw@\advance\dimen@ii-\ht\z@
\@ifdim{\dimen@i>.5\p@}{%
@@ -3965,30 +4589,30 @@ in your filesystem where they will be found by \LaTeX.
}%
}%
\outputdebug@sw{\saythe\dimen@\saythe\dimen@i\saythe\dimen@ii}{}%
- \@ifdim{\ht\z@=\z@}{%
- \@ifdim{\ht\tw@=\z@}{%
- \true@sw
- }{%
- \false@sw
- }%
- }{%
- \true@sw
- }%
- {%
- }{%
- \ltxgrid@info{Unsatifactorily balanced columns: giving up}%
- \setbox\tw@\box#1%
- \setbox\z@ \box#2%
- }%
+ \@ifdim{\ht\z@=\z@}{%
+ \@ifdim{\ht\tw@=\z@}{%
+ \true@sw
+ }{%
+ \false@sw
+ }%
+ }{%
+ \true@sw
+ }%
+ {%
+ }{%
+ \ltxgrid@info{Unsatifactorily balanced columns: giving up}%
+ \setbox\tw@\box#1%
+ \setbox\z@ \box#2%
+ }%
\setbox\tw@\vbox{\unvbox\tw@\vskip\z@skip}%
\setbox\z@ \vbox{\unvbox\z@ \vskip\z@skip}%
- \set@colroom
- \dimen@\ht\z@\@ifdim{\dimen@<\ht\tw@}{\dimen@\ht\tw@}{}%
- \@ifdim{\dimen@>\@colroom}{\dimen@\@colroom}{}%
+ \set@colht
+ \dimen@\ht\z@\@ifdim{\dimen@<\ht\tw@}{\dimen@\ht\tw@}{}%
+ \@ifdim{\dimen@>\@colroom}{\dimen@\@colroom}{}%
\outputdebug@sw{\saythe{\ht\z@}\saythe{\ht\tw@}\saythe\@colroom\saythe\dimen@}{}%
- \setbox#1\vbox to\dimen@{\unvbox\tw@\unskip\raggedcolumn@skip}%
- \setbox#2\vbox to\dimen@{\unvbox\z@ \unskip\raggedcolumn@skip}%
- \outputdebug@sw{{\tracingall\scrollmode\showbox#1\showbox#2}}{}%
+ \setbox#1\vbox to\dimen@{\unvbox\tw@\unskip\raggedcolumn@skip}%
+ \setbox#2\vbox to\dimen@{\unvbox\z@ \unskip\raggedcolumn@skip}%
+ \outputdebug@sw{\trace@scroll{\showbox#1\showbox#2}}{}%
}%
% \end{macrocode}
% \end{macro}
@@ -3997,29 +4621,29 @@ in your filesystem where they will be found by \LaTeX.
% The procedure \cmd\recover@footins\ is the utility procedure for recovering the footnotes
% from the bottom of a column. It is used when the page grid is changed, so that footnotes can be
% set at the bottom of the shipped out page.
+% \changes{4.1b}{2008/08/04}{New procedure for showing a box contents, \cs{trace@box}}
% \begin{macrocode}
\def\recover@footins{%
\skip\z@ \lastskip\unskip
\skip\@ne\lastskip\unskip
\setbox\z@\lastbox
\@ifvbox\z@{%
- \setbox\z@\vbox{%
- \unvbox\z@
- \setbox\z@\lastbox
-% \outputdebug@sw{{\tracingall\showbox\lastbox}}{}%
- \@ifvoid\z@{}{%
- \global\setbox\footbox\vbox{%
- \unvbox\footbox
+ \setbox\z@\vbox{%
+ \unvbox\z@
+ \setbox\z@\lastbox
+ \@ifvoid\z@{}{%
+ \global\setbox\footsofar\vbox{%
+ \unvbox\footsofar
\@ifvbox\z@{%
- \unvbox\z@
- }{%
- \box\z@
- }%
- }%
- }%
- }%
+ \unvbox\z@
+ }{%
+ \box\z@
+ }%
+ }%
+ }%
+ }%
}{}%
- \outputdebug@sw{{\tracingall\scrollmode\showbox\footbox}}{}%
+ \outputdebug@sw{\trace@box\footsofar}{}%
}%
% \end{macrocode}
% \end{macro}
@@ -4081,7 +4705,6 @@ in your filesystem where they will be found by \LaTeX.
%
% These things can be accomodated easily by the \classname{ltxgrid} output
% routine hooks.
-%
%
% \begin{macro}{\longtable}
% \begin{macrocode}
@@ -4129,6 +4752,9 @@ in your filesystem where they will be found by \LaTeX.
\endgraf\penalty\z@\addvspace\LTpost
\ifvoid\footins\else\insert\footins{}\fi
}%
+% \end{macrocode}
+% \changes{4.1a}{2008/06/29}{Repair error in \cs{endlongtable@new} involving \cs{@ifx}: argument not delimited.}
+% \begin{macrocode}
\def\endlongtable@new{%
\crcr
\noalign{%
@@ -4148,7 +4774,7 @@ in your filesystem where they will be found by \LaTeX.
}%
}%
}{}%
- \@ifx\LT@save@row\LT@@save@row{}{%
+ \@ifx{\LT@save@row\LT@@save@row}{}{%
\LT@warn{%
Column \@width s have changed\MessageBreak in table \thetable
}\LT@final@warn
@@ -4166,34 +4792,40 @@ in your filesystem where they will be found by \LaTeX.
% \begin{macro}{\LT@start}
% \begin{macrocode}
\def\LT@start@longtable{%
- \let\LT@start\endgraf
- \endgraf
- \penalty\z@
- \vskip\LTpre
- \dimen@\pagetotal
- \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
- \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
- \advance\dimen@ \ht\LT@foot
- \dimen@ii\vfuzz\vfuzz\maxdimen
- \setbox\tw@\copy\z@
- \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
- \setbox\tw@\vbox{\unvbox\tw@}%
- \vfuzz\dimen@ii
- \advance\dimen@ \ht
- \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
- \advance\dimen@\dp
- \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
- \advance\dimen@ -\pagegoal
- \ifdim \dimen@>\z@\vfil\break\fi
- \global\@colroom\@colht
- \ifvoid\LT@foot\else
- \advance\vsize-\ht\LT@foot
- \global\advance\@colroom-\ht\LT@foot
- \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
- \maxdepth\z@
- \fi
- \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi
- \output{\LT@output}%
+ \let\LT@start\endgraf
+ \endgraf\penalty\z@\vskip\LTpre
+ \dimen@\pagetotal
+ \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
+ \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
+ \advance\dimen@ \ht\LT@foot
+ \dimen@ii\vfuzz
+ \vfuzz\maxdimen
+ \setbox\tw@\copy\z@
+ \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
+ \setbox\tw@\vbox{\unvbox\tw@}%
+ \vfuzz\dimen@ii
+ \advance\dimen@ \ht
+ \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
+ \advance\dimen@\dp
+ \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
+ \advance\dimen@ -\pagegoal
+ \ifdim \dimen@>\z@\vfil\break\fi
+ \global\@colroom\@colht
+ \ifvoid\LT@foot\else
+ \advance\vsize-\ht\LT@foot
+ \global\advance\@colroom-\ht\LT@foot
+ \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
+ \maxdepth\z@
+ \fi
+ \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi
+% \end{macrocode}
+% At some point before version 4.11, the \cmd\nobreak\ was added.
+% \begin{macrocode}
+\nobreak
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \output{\LT@output}%
}%
\def\LT@start@new{%
\let\LT@start\endgraf
@@ -4229,6 +4861,8 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
%
% \begin{macro}{\LT@array}
+%
+%
% \begin{macrocode}
\def\LT@array@longtable[#1]#2{%
\refstepcounter{table}\stepcounter{LT@tables}%
@@ -4275,15 +4909,18 @@ in your filesystem where they will be found by \LaTeX.
\global\advance\c@LT@chunks\@ne
\global\LT@rows\z@\setbox\z@\vbox\bgroup
\LT@setprevdepth
- \tabskip\LTleft\halign to\hsize\bgroup
+% \end{macrocode}
+% At some point before version 4.11, the \cmd\noexpand\ was added.
+% We need not change our own version, because we did it right, back in 1998 (using \cmd\appdef).
+% \begin{macrocode}
+ \tabskip\LTleft \noexpand\halign to\hsize\bgroup
\tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}%
\endgroup
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
\LT@make@row
\m@th\let\par\@empty
\everycr{}\lineskip\z@\baselineskip\z@
- \LT@bchunk
-}%
+ \LT@bchunk}%
\def\LT@LR@l{\LTleft\z@ \LTright\fill}%
\def\LT@LR@r{\LTleft\fill \LTright\z@ }%
\def\LT@LR@c{\LTleft\fill \LTright\fill}%
@@ -4312,12 +4949,24 @@ in your filesystem where they will be found by \LaTeX.
\def\@startpbox{\vtop\LT@startpbox}%
\let\@@startpbox\@startpbox
\let\@@endpbox\@endpbox
- \let\LT@LL@FM@cr\@tabularcr
+% \end{macrocode}
+% Because \classname{ltxutil} patches \LaTeX's \cmd\@tabularcr and \cmd\@xtabularcr,
+% we must restore these procedures in the scope of \env{longtable}.
+% Ironically, the patches in \classname{ltxutil} were for the purpose of extending
+% the \env{tabular} environment to prevent pagebreaks with the *-form of \cmd\\,
+% just the same as is being done here. But the two mechanisms conflict.
+% \changes{4.1a}{2008/06/29}{Change \cs{LT@array@new}: restore \cs{@tabularcr} and \cs{@xtabularcr}}
+% \begin{macrocode}
+ \let\LT@LL@FM@cr\@tabularcr@LaTeX
+ \let\@xtabularcr\@xtabularcr@LaTeX
}{%
\advance\@tempdima\extrarowheight
\col@sep\tabcolsep
\let\@startpbox\LT@startpbox
- \let\LT@LL@FM@cr\@arraycr
+% \end{macrocode}
+% \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}}
+% \begin{macrocode}
+ \let\LT@LL@FM@cr\@arraycr@array
}%
%
\let\@acoll\@tabacoll
@@ -4373,14 +5022,6 @@ in your filesystem where they will be found by \LaTeX.
% use the full page width for setting the table.
% You can think this way: \env{longtable*} is to \env{longtable} as \env{table*} is to \env{table}.
%
-%FIXME: the following is no longer true:
-%% Note that it is not enough to define the environment itself; we also have to create the corresponding
-%% \cmd\output\ routine procedures, which provide for continued footers and headers
-%% (the very feature of \env{longtable} requiring support in the output routine).
-%
-%% This same consideration would arise in defining any syntactic extension to \env{longtable}, because
-%% the environment name itself is exposed in the output routine.
-%
% \begin{macrocode}
\def\switch@longtable{%
\@ifpackageloaded{longtable}{%
@@ -4412,9 +5053,9 @@ in your filesystem where they will be found by \LaTeX.
\endlongtable
\onecolumngrid@pop
}%
-% \expandafter\let\csname output@init@longtable*\endcsname\output@init@longtable
-% \expandafter\let\csname output@prep@longtable*\endcsname\output@prep@longtable
-% \expandafter\let\csname output@post@longtable*\endcsname\output@post@longtable
+% \end{macrocode}
+% Removed obsolete code.
+% \begin{macrocode}
}{}%
}%
% \end{macrocode}
@@ -4477,8 +5118,11 @@ in your filesystem where they will be found by \LaTeX.
\let\output@prep@theindex\@empty
\def\output@post@theindex{%
\@ifodd\c@page{}{%
- \@ifnum{\pagegrid@cur=\@ne}{% we have the leftmost column of a verso page
- % insert the current top-level continued head
+ \@ifnum{\pagegrid@cur=\@ne}{%
+% \end{macrocode}
+% We have the leftmost column of a verso page:
+% Insert the current top-level continued head.
+% \begin{macrocode}
}%
}%
}%
@@ -4552,7 +5196,8 @@ in your filesystem where they will be found by \LaTeX.
% documents that exhaust \LaTeX's pool of float registers!
%
% \begin{macro}{\check@deferlist@stuck}
-% \begin{macro}{\@outputpage}
+% \begin{macro}{\@outputpage@tail}
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@tail} tailpatches \cs{@outputpage}}%
% We detect the case where, at the start of a fresh page, there are deferred floats, but none are
% committed. We memorize the \cmd\@deferlist\ at \cmd\shipout\ time, then examine it at the point where
% our efforts to commit floats to the new page are complete.
@@ -4574,7 +5219,9 @@ in your filesystem where they will be found by \LaTeX.
\force@deferlist@stuck#1%
}%
}{%
- %Successfully committed float(s)
+% \end{macrocode}
+% We have successfully committed float(s)
+% \begin{macrocode}
}%
\global\let\@deferlist@postshipout\@empty
}%
@@ -4582,7 +5229,7 @@ in your filesystem where they will be found by \LaTeX.
\def\@fltstk{%
\@latex@warning{A float is stuck (cannot be placed without \string\clearpage)}%
}%
-\appdef\@outputpage{%
+\appdef\@outputpage@tail{%
\global\let\@deferlist@postshipout\@deferlist
}%
% \end{macrocode}
@@ -4644,20 +5291,28 @@ in your filesystem where they will be found by \LaTeX.
%
% \begin{macrocode}
\def\force@deferlist@stuck#1{%
- \force@deferlist@sw{%
+ \force@deferlist@sw{%
\@booleantrue\clearpage@sw
\@booleantrue\forcefloats@sw
#1%
- }{%
- }%
+ }{%
+ }%
}%
\def\force@deferlist@empty{%
\force@deferlist@sw{%
+% \end{macrocode}
+% \begin{verbatim}
% \ltxgrid@info{#1, attempting rectification}%
+% \end{verbatim}
+% \begin{macrocode}
\penalty-\pagebreak@pen
\protect@penalty\do@forcecolumn@pen
}{%
+% \end{macrocode}
+% \begin{verbatim}
% \ltxgrid@info{#1}%
+% \end{verbatim}
+% \begin{macrocode}
}%
}%
\@booleanfalse\force@deferlist@sw
@@ -4666,9 +5321,13 @@ in your filesystem where they will be found by \LaTeX.
\def\do@forcecolumn{%
\@booleantrue\clearpage@sw
\@booleantrue\forcefloats@sw
+% \end{macrocode}
+% \begin{verbatim}
%\unvbox\@cclv
%\vfil
%\penalty-\pagebreak@pen
+% \end{verbatim}
+% \begin{macrocode}
\do@startcolumn
}%
% \end{macrocode}
@@ -4695,8 +5354,7 @@ in your filesystem where they will be found by \LaTeX.
%
% We provide support for the \cmd\enlargethispage\ command.
%
-% Note: using a command of this sort is questionable.
-% Instead, people should enlarge the entire spread.
+% Note: using a command of this sort does not automatically enlarge both pages of a spread, which would be the convention in page composition.
%
% Timing Note: In a multicolumn page grid, the user should issue the \cmd\enlargethispage\ command
% while the first column of the page is being typeset.
@@ -4711,11 +5369,11 @@ in your filesystem where they will be found by \LaTeX.
% will revert to its standard value.
% \begin{macrocode}
\def\enlargethispage{%
- \@ifstar{%
- \@enlargethispage{}%
- }{%
- \@enlargethispage{}%
- }%
+ \@ifstar{%
+ \@enlargethispage{}%
+ }{%
+ \@enlargethispage{}%
+ }%
}%
\def\@enlargethispage#1#2{%
\begingroup
@@ -4732,14 +5390,23 @@ in your filesystem where they will be found by \LaTeX.
}{%
\def\@tempa{mlt}%
\@ifx{\thepagegrid\@tempa}{%
- \@ifnum{\pagegrid@cur=\@ne}{% OK to adjust this page
- \gdef\enlarge@colroom{#2}%
+ \@ifnum{\pagegrid@cur=\@ne}{%
+% \end{macrocode}
+% OK to adjust this page
+% \begin{macrocode}
+ \gdef\enlarge@colroom{#2}%
\true@sw
- }{% Can only adjust this column; give up
+ }{%
+% \end{macrocode}
+% Can only adjust this column; give up
+% \begin{macrocode}
\ltxgrid@warn{Too late to enlarge this page; move the command to the first column.}%
\false@sw
}%
- }{% Unknown page grid
+ }{%
+% \end{macrocode}
+% Unknown page grid
+% \begin{macrocode}
\ltxgrid@warn{Unable to enlarge a page of this kind.}%
\false@sw
}%
@@ -4749,7 +5416,9 @@ in your filesystem where they will be found by \LaTeX.
\global\advance\@colroom#2\relax
\set@vsize
}{%
- % Could not adjust this page
+% \end{macrocode}
+% Could not adjust this page
+% \begin{macrocode}
}%
}%
\let\enlarge@colroom\@empty
@@ -4762,15 +5431,12 @@ in your filesystem where they will be found by \LaTeX.
%
% \subsubsection{Building the page for shipout}
%
-% \begin{macro}{\@outputpage}
-% The procedures that build \cmd\@outputbox\ just before a page is shipped out by \cmd\@outputpage\ are:
-% \cmd\@makecol,
-% \cmd\@combinepage, and
-% \cmd\@combinedblfloats.
-% We headpatch \cmd\@outputpage\ to make the \cmd\@outputbox\ be of fixed height.
+% \begin{macro}{\@outputpage@head}
+% We set \cmd\@outputpage@head\ to make the \cmd\@outputbox\ be of fixed height.
+% \changes{4.1b}{2008/08/04}{Procedure \cs{@outputpage@head} headpatches \cs{@outputpage}}%
% \begin{macrocode}
\@booleantrue\textheight@sw
-\prepdef\@outputpage{%
+\prepdef\@outputpage@head{%
\textheight@sw{%
\count@\vbadness\vbadness\@M
\dimen@\vfuzz\vfuzz\maxdimen
@@ -4801,10 +5467,860 @@ in your filesystem where they will be found by \LaTeX.
% \end{macro}
% \end{macro}
%
+% \section{Line-wise processing}%
+% Sometimes we wish to process each line of type that will be placed into the galley,
+% for example, applying line numbering to a document.
+% To accomplish the task, we have to force a visit to the output routine after each such line, whereupon
+% we can process it accordingly (in the case of line numbering, we could do as \filename{lineno.sty} and
+% append an appropriately formed box to the MVL).
+%
+% In implementing such a scheme, we will have to instantiate interrupts for the following cases:
+% \begin{description}
+%
+% \item[\cmd\interlinepenalty\ and friends] These include \cmd\clubpenalty, \cmd\widowpenalty, \cmd\displaywidowpenalty, and \cmd\brokenpenalty.
+%
+%
+% \item[Display math penalties] Includes \cmd\predisplaypenalty, \cmd\postdisplaypenalty, and \cmd\interdisplaylinepenalty.
+%
+%
+% \item[\cs{par}] The penalty following the last line of the paragraph.
+%
+%
+% \item[\cmd\vadjust] A trap for any \cmd\vadjust\ command that falls in the paragraph.
+%
+% \end{description}
+%
+% \begin{macro}{\def@next@handler}
+% \begin{macro}{\def@line@handler}
+% Utility procedures \cmd\def@next@handler\ and \cmd\def@line@handler\ help in the creation of
+% interrupt handlers.
+%
+% \cmd\def@next@handler\ increments the scratch count register (argument 1),
+% using this value to \cmd\mathchardef\ its second argument
+% as the negative of the flag value to be used as a penalty for exciting the interrupt (argument 3).
+% As a byproduct, it leaves the given scratch counter incremented.
+% \begin{macrocode}
+\def\def@next@handler#1#2#3{%
+ \advance#1\@ne\mathchardef#2\the#1%
+ \expandafter\def\csname output@-\the#1\endcsname{#3}%
+% \end{macrocode}
+% The following line is for diagnostic purposes.
+% \begin{verbatim}
+% \typeout{\string#2(\expandafter\string\csname output@\the#1\endcsname:\expandafter\meaning\csname output@\the#1\endcsname)}%
+% \end{verbatim}
+% \begin{macrocode}
+}%
+% \end{macrocode}
+% \cmd\def@line@handler\ uses \cmd\int@parpenalty\ as a base.
+% The interrupt is the sum of that base with the first argument,
+% and the handler is the second argument.
+% \begin{macrocode}
+\def\def@line@handler#1#2{%
+ \begingroup
+ \@tempcnta\int@parpenalty
+ \advance\@tempcnta-#1%
+% \end{macrocode}
+% The following line is for diagnostic purposes.
+% \begin{verbatim}
+% \typeout{Defining: \expandafter\string\csname output@\the\linenopenalty\endcsname}%
+% \end{verbatim}
+% \begin{macrocode}
+ \aftergroup\def
+ \expandafter\aftergroup\csname output@-\the\@tempcnta\endcsname
+ \endgroup{#2}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\int@parpenalty}
+% \begin{macro}{\@handle@line@ltx}
+% \begin{macro}{\@@handle@line@ltx}
+% We first set \cmd\int@parpenalty\ to our chosen base value${}\le -11012$.
+% We then define all the handlers for lines within a paragraph, of which there are 12 different cases.
+% \begin{macrocode}
+\mathchardef\int@parpenalty11012
+\def@line@handler\z@{\@handle@line@ltx{}{}{}}%
+\def@line@handler\@ne{\@handle@line@ltx{}{}{\brokenpenalty@ltx}}%
+\def@line@handler\tw@{\@handle@line@ltx{}{\clubpenalty@ltx}{}}%
+\def@line@handler\thr@@{\@handle@line@ltx{\clubpenalty@ltx}{}{\brokenpenalty@ltx}}%
+\def@line@handler\f@ur{\@handle@line@ltx{\widowpenalty@ltx}{}{}}%
+\def@line@handler{5}{\@handle@line@ltx{\widowpenalty@ltx}{}{\brokenpenalty@ltx}}%
+\def@line@handler{6}{\@handle@line@ltx{\widowpenalty@ltx}{\clubpenalty@ltx}{}}%
+\def@line@handler{7}{\@handle@line@ltx{\widowpenalty@ltx}{\clubpenalty@ltx}{\brokenpenalty@ltx}}%
+\def@line@handler{8}{\@handle@line@ltx{\displaywidowpenalty@ltx}{}{}}%
+\def@line@handler{9}{\@handle@line@ltx{\displaywidowpenalty@ltx}{}{\brokenpenalty@ltx}}%
+\def@line@handler{10}{\@handle@line@ltx{\displaywidowpenalty@ltx}{\clubpenalty@ltx}{}}%
+\def@line@handler{11}{\@handle@line@ltx{\displaywidowpenalty@ltx}{\clubpenalty@ltx}{\brokenpenalty@ltx}}%
+% \end{macrocode}
+%
+% The default handler for lines within a paragraph simply
+% restores the value of the \cmd\penalty\ to the normal value.
+% If something more useful needs to be done, we can change the definition of \cmd\@@handle@line@ltx.
+% \begin{macrocode}
+\def\@handle@line@ltx#1#2#3{%
+ \@@handle@line@ltx
+ \@tempcnta\lastpenalty
+ \@tempcntb\interlinepenalty@ltx\relax
+ \@if@empty{#1}{}{\advance\@tempcntb#1\relax}%
+ \@if@empty{#2}{}{\advance\@tempcntb#2\relax}%
+ \@if@empty{#3}{}{\advance\@tempcntb#3\relax}%
+ \penalty\@ifnum{\@tempcnta<\@tempcntb}{\@tempcntb}{\@tempcnta}%
+}%
+\let\@@handle@line@ltx\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\int@postparpenalty}
+% \begin{macro}{\int@vadjustpenalty}
+% \begin{macro}{\int@whatsitpenalty}
+% \begin{macro}{\int@predisplaypenalty}
+% \begin{macro}{\int@interdisplaylinepenalty}
+% \begin{macro}{\int@postdisplaypenalty}
+% \begin{macro}{\@handle@display@ltx}
+% \begin{macro}{\@@handle@display@ltx}
+% \begin{macro}{\handle@par@ltx}
+% We herewith define all the handlers for cases relating to display math:
+% last line before a display math,
+% last line of a display math, and a line within a display math.
+% We also handle the last line of a paragraph, a whatsit node, and a \cmd\vadjust.
+% \begin{macrocode}
+\@tempcnta\int@parpenalty
+\def@next@handler\@tempcnta\int@postparpenalty{\reset@queues@ltx\handle@par@ltx}%
+\def@next@handler\@tempcnta\int@vadjustpenalty{\handle@vadjust@ltx}%
+\def@next@handler\@tempcnta\int@whatsitpenalty{\handle@whatsit@ltx}%
+\def@next@handler\@tempcnta\int@predisplaypenalty{\reset@queues@ltx\@handle@display@ltx{\predisplaypenalty@ltx}}%
+\def@next@handler\@tempcnta\int@interdisplaylinepenalty{\@handle@display@ltx{\interdisplaylinepenalty@ltx}}%
+\def@next@handler\@tempcnta\int@postdisplaypenalty{\@handle@display@ltx{\postdisplaypenalty@ltx}}%
+% \end{macrocode}
+% The default handler for display math lines simply
+% restores the value of the \cmd\penalty\ to the normal value.
+% If something more useful needs to be done, we can change the definition of \cmd\@@handle@display@ltx.
+% \begin{macrocode}
+\def\@handle@display@ltx#1{%
+ \@@handle@display@ltx
+ \@tempcnta\lastpenalty
+ \@tempcntb#1%
+ \penalty\@ifnum{\@tempcnta<\@tempcntb}{\@tempcntb}{\@tempcnta}%
+}%
+\let\@@handle@display@ltx\@empty
+% \end{macrocode}
+%
+% 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).
+% There is no canonical penalty for such cases.
+% \begin{macrocode}
+\def\handle@par@ltx{}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% Note that a whatsit needs to be handled differently from a \cmd\vadjust:
+% a whatsit node does not affect the (crucial) depth of \cmd\box\cmd\@cclv, while the more
+% general \cmd\vadjust\ may cause any kind of vertical mode material to be interposed just below the line
+% we are trying to trap, in particular \cmd\vskip s and \cmd\penalty s.
+%
+% \begin{macro}{\set@linepenalties}
+% \begin{macro}{\restore@linepenalties}
+% \begin{macro}{\set@displaypenalties}
+% Now we define utility procedures that set up for a paragraph to be broken into lines,
+% restoring the penalties afterwards.
+%
+% Utility procedure \cmd\set@linepenalties\ systematically sets the penalties of paragraph breaking
+% to flag values, meanwhile storing away the normal values for access by the output routine.
+% \begin{macrocode}
+\def\set@linepenalties{%
+ \expandafter\def\expandafter\interlinepenalty@ltx\expandafter{\the\interlinepenalty}%
+ \interlinepenalty-\int@parpenalty
+ \expandafter\def\expandafter\brokenpenalty@ltx\expandafter{\the\brokenpenalty}%
+ \brokenpenalty\@ne
+ \expandafter\def\expandafter\clubpenalty@ltx\expandafter{\the\clubpenalty}%
+ \clubpenalty\tw@
+ \expandafter\def\expandafter\widowpenalty@ltx\expandafter{\the\widowpenalty}%
+ \widowpenalty\f@ur
+ \expandafter\def\expandafter\displaywidowpenalty@ltx\expandafter{\the\displaywidowpenalty}%
+ \displaywidowpenalty8\relax
+}%
+% \end{macrocode}
+%
+% Utility procedure \cmd\restore@linepenalties\ restores the values of the penalty parameters that were
+% modified by \cmd\set@linepenalties.
+% \begin{macrocode}
+\def\restore@linepenalties{%
+ \interlinepenalty\interlinepenalty@ltx
+ \brokenpenalty\brokenpenalty@ltx
+ \clubpenalty\clubpenalty@ltx
+ \widowpenalty\widowpenalty@ltx
+ \displaywidowpenalty\displaywidowpenalty@ltx
+ \relax
+}%
+% \end{macrocode}
+%
+% In the following, the first argument should be a boolean (either \cmd\true@sw\ or \cmd\false@sw).
+% \begin{macrocode}
+\def\set@displaypenalties#1{%
+ \expandafter\def\expandafter\predisplaypenalty@ltx\expandafter{\the\predisplaypenalty}%
+ \expandafter\def\expandafter\interdisplaylinepenalty@ltx\expandafter{\the\interdisplaylinepenalty}%
+ \expandafter\def\expandafter\postdisplaypenalty@ltx\expandafter{\the\postdisplaypenalty}%
+ \@ifhmode{\predisplaypenalty-\int@predisplaypenalty\relax}{}%
+ #1{\interdisplaylinepenalty-\int@interdisplaylinepenalty\relax}{}%
+ #1{\postdisplaypenalty-\int@postdisplaypenalty\relax}{}%
+}%
+% \end{macrocode}
+% We provide no procedure to restore the respective penalties, because they are altered within a group:
+% \TeX 's context stack will automatically restore things.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\enqueue@whatsit@ltx}%
+% \begin{macro}{\handle@whatsit@ltx}%
+% \begin{macro}{\do@whatsit}%
+% \begin{macro}{\@g@pop@ltx}%
+% Here is a facility for dealing with whatsit nodes while we are trapping paragraph lines.
+% We simply enqueue a macro that will create the desired whatsit node, dequeueing it in the output routine.
+% \begin{macrocode}
+\def\enqueue@whatsit@ltx#1{%
+ \gappdef\g@whatsit@queue{{#1}}%
+ \vadjust{\penalty-\int@whatsitpenalty}%
+}%
+\def\handle@whatsit@ltx{%
+ \unvbox\@cclv
+ \g@pop@ltx\g@whatsit@queue\@tempa
+ \expandafter\do@whatsit\expandafter{\@tempa}%
+}%
+\def\do@whatsit#1{}%
+\def\g@pop@ltx#1#2{%
+ \expandafter\@g@pop@ltx#1{}{}\@@#1#2%
+}%
+\def\@g@pop@ltx#1#2\@@#3#4{%
+ \gdef#3{#2}%
+ \def#4{#1}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\vspace}%
+% \begin{macro}{\pagebreak}%
+% \begin{macro}{\nopagebreak}%
+% \begin{macro}{\\}%
+% \begin{macro}{\@arrayparboxrestore}%
+% We wish to prevent \filename{lineno.sty} from patching \cmd\vspace\ and \cmd\pagebreak,
+% because that package does it through global assignments, which is prone to failure.
+%
+% We also wish to prevent that package from patching \cmd\@arrayparboxrestore, because
+% it prevents us from \cmd\unvbox ing vertical mode material into the MVL and numbering those
+% lines.
+%
+% We start by retaining the original definitions of these commands, so we can restore them
+% if \filename{lineno.sty} does get loaded.
+% \begin{macrocode}
+\let\vspace@ltx\vspace
+\let\pagebreak@ltx\pagebreak
+\let\nopagebreak@ltx\nopagebreak
+\let\endline@ltx\\
+\let\@arrayparboxrestore@ltx\@arrayparboxrestore
+% \end{macrocode}
+%
+% Next, we provide for line-wise processing by patching the procedures associated with these same three commands.
+%
+% There are exactly four core \LaTeX\ procedures that use \cmd\vadjust\ to insert vertical mode material
+% into the main vertical list: \cmd\vspace, \cmd\pagebreak, \cmd\nopagebreak, and \cmd\\.
+% Other commands may use \cmd\vadjust, but they are inserting an interrupt (via a penalty${}<10000$),
+% and such a thing does not mask the depth of \cmd\box\cmd\@cclv, hence is permissible.
+%
+% In each case, we replace the core \LaTeX\ procedure with one that itself replaces \cmd\vadjust\ with
+% \cmd\ex@vadjust@ltx. The meaning of this procedure can be left as \cmd\vadjust, or it can be changed to
+% one that accomplishes the equivalent without masking the depth of \cmd\box\cmd\@cclv.
+%
+% The first procedure is \cmd\@vspace, here shown in original form and in the patched alternative form.
+% This procedure and \cmd\@vspacer\ implement the \cmd\vspace\ command.
+% \begin{macrocode}
+\def\@vspace@org #1{%
+ \ifvmode
+ \vskip #1
+ \vskip\z@skip
+ \else
+ \@bsphack
+ \vadjust{\@restorepar
+ \vskip #1
+ \vskip\z@skip
+ }%
+ \@esphack
+ \fi
+}%
+\def\@vspace@ltx#1{%
+ \@ifvmode{%
+ \vskip#1\vskip\z@skip
+ }{%
+ \@bsphack
+ \ex@vadjust@ltx{%
+ \@restorepar
+ \nobreak
+ \vskip#1\vskip\z@skip
+ }%
+ \@esphack
+ }%
+}%
+% \end{macrocode}
+%
+% The second procedure is \cmd\@vspacer.
+% \begin{macrocode}
+\def\@vspacer@org#1{%
+ \ifvmode
+ \dimen@\prevdepth
+ \hrule \@height\z@
+ \nobreak
+ \vskip #1
+ \vskip\z@skip
+ \prevdepth\dimen@
+ \else
+ \@bsphack
+ \vadjust{\@restorepar
+ \hrule \@height\z@
+ \nobreak
+ \vskip #1
+ \vskip\z@skip}%
+ \@esphack
+\fi
+}%
+\def\@vspacer@ltx#1{%
+ \@ifvmode{%
+ \dimen@\prevdepth
+ \hrule\@height\z@
+ \nobreak
+ \vskip#1\vskip\z@skip
+ \prevdepth\dimen@
+ }{%
+ \@bsphack
+ \ex@vadjust@ltx{%
+ \@restorepar
+ \hrule\@height\z@
+ \nobreak
+ \vskip#1\vskip\z@skip
+ }%
+ \@esphack
+ }%
+}%
+% \end{macrocode}
+%
+% The procedure \cmd\@no@pgbk\ implements both \cmd\pagebreak\ and \cmd\nopagebreak.
+% \begin{macrocode}
+\def\@no@pgbk@org #1[#2]{%
+ \ifvmode
+ \penalty #1\@getpen{#2}%
+ \else
+ \@bsphack
+ \vadjust{\penalty #1\@getpen{#2}}%
+ \@esphack
+ \fi
+}%
+\def\@no@pgbk@ltx#1[#2]{%
+ \@ifvmode{%
+ \penalty#1\@getpen{#2}%
+ }{%
+ \@bsphack
+ \ex@vadjust@ltx{%
+ \penalty#1\@getpen{#2}%
+ }%
+ \@esphack
+ }%
+}%
+% \end{macrocode}
+%
+% The command to end a line of type, \cmd\\, is defined via \cmd\DeclareRobustCommand,
+% so we must proceed carefully:
+% A procedure is defined whose \cmd\long\cmd\csname\ is contructed via the incantation:
+% \cmd\csname\cmd\expandafter\cmd\@gobble\cmd\string\cmd\\ \cmd\endcsname.
+% Note the non-trivial space character after the \cmd\\: it is incorporated into
+% the \cmd\csname.
+%
+% Here is the original core \LaTeX\ definition for
+% the procedure involved, along with our revised version.
+% \begin{macrocode}
+\long\def\end@line@org{%
+ \let\reserved@e\relax
+ \let\reserved@f\relax
+ \@ifstar{%
+ \let\reserved@e\vadjust
+ \let\reserved@f\nobreak
+ \@xnewline
+ }%
+ \@xnewline
+}%
+\long\def\end@line@ltx{%
+ \let\reserved@e\relax
+ \let\reserved@f\relax
+ \@ifstar{%
+ \let\reserved@e\ex@vadjust@ltx
+ \let\reserved@f\nobreak
+ \@xnewline
+ }{%
+ \@xnewline
+ }%
+}%
+% \end{macrocode}
+% An additional procedure requiring patching has the following original core \LaTeX\
+% definition; we modify it correspondingly.
+% \begin{macrocode}
+\def\@newline@org[#1]{%
+ \let\reserved@e\vadjust
+ \@gnewline{\vskip#1}%
+}%
+\def\@newline@ltx[#1]{%
+ \let\reserved@e\ex@vadjust@ltx
+ \@gnewline{\vskip#1}%
+}%
+% \end{macrocode}
+% We now install our patches.
+% If some package overrides these macros, we will detect and complain.
+%
+% \begin{macrocode}
+ \@ifx{\@vspace\@vspace@org}{%
+ \@ifx{\@vspacer\@vspacer@org}{%
+ \@ifx{\@no@pgbk\@no@pgbk@org}{%
+ \@ifx{\@newline\@newline@org}{%
+ \expandafter\@ifx\expandafter{\csname\expandafter\@gobble\string\\ \endcsname\end@line@org}{%
+ \true@sw
+ }{\false@sw}%
+ }{\false@sw}%
+ }{\false@sw}%
+ }{\false@sw}%
+ }{\false@sw}%
+ {%
+ \class@info{Overriding \string\@vspace, \string\@vspacer, \string\@no@pgbk, \string\@newline, and \string\\ }%
+ \let\@normalcr\end@line@ltx
+ \expandafter\let\csname\expandafter\@gobble\string\\ \endcsname\@normalcr
+ \let\@newline\@newline@ltx
+ \let\@vspace\@vspace@ltx
+ \let\@vspacer\@vspacer@ltx
+ \let\@no@pgbk\@no@pgbk@ltx
+ }{%
+ \class@warn{%
+ Failed to recognize \string\@vspace, \string\@vspacer, \string\@no@pgbk, \string\@newline, and \string\\;
+ no patches applied. Please get a more up-to-date class,
+ }%
+ }%
+% \end{macrocode}
+% Note that we have assigned the same meaning to \cmd\@normalcr, which is necessary to \LaTeX.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ex@vadjust@ltx}
+% \begin{macro}{\enqueue@vadjust@ltx}
+% \begin{macro}{\handle@vadjust@ltx}
+% \begin{macro}{\g@vadjust@line}
+% \begin{macro}{\reset@queues@ltx}
+% Here we give the default definition for \cmd\ex@vadjust@ltx\ along with
+% the definitions for the alternative version and its the associated handler.
+% \begin{macrocode}
+\let\ex@vadjust@ltx\vadjust
+\def\enqueue@vadjust@ltx#1{%
+ \gappdef\g@vadjust@queue{{#1}}%
+ \vadjust{\penalty-\int@vadjustpenalty}%
+}%
+\def\handle@vadjust@ltx{%
+ \unvbox\@cclv
+ \g@pop@ltx\g@vadjust@queue\@tempa
+ \expandafter\gappdef\expandafter\g@vadjust@line\expandafter{\@tempa}%
+}%
+\let\g@vadjust@line\@empty
+% \end{macrocode}
+% Procedure \cmd\reset@queues@ltx\ resets the whatsit queue and the \cmd\vadjust\ queues
+% to their empty state. This should be done whenever we leave horizontal mode and
+% complete the processing of these queues: upon executing, effectively, primitive \cmd\par\
+% or interrupting a paragraph with display math.
+% \begin{macrocode}
+\def\reset@queues@ltx{%
+ \global\let\g@whatsit@queue\@empty
+ \global\let\g@vadjust@queue\@empty
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \section{Patching the lineno.sty package}
+%
+% \filename{lineno.sty} is a \LaTeX\ package that applies line numbering to a document.
+% The basic method is to give \cmd\interlinepenalty\ and like penalties such a value as
+% to force a visit to the output routine, where the line of type is given its number.
+% In order to properly measure the depth of \cmd\box\cmd\@cclv, it defers \cmd\vadjust\
+% commands that may insert \cmd\vskip\ or \cmd\penalty\ nodes.
+%
+% The implementation of that package, however, manipulates \cmd\holdinginserts\ in a dangerous
+% way: outside the safety of the output routine. It also alters the meaning of \cmd\vadjust\
+% using global assignments. We patch its code to avoid these problems. The \filename{ltxgrid}
+% package already has the needed mechanisms in place to do these jobs correctly.
+%
+% The methods we use can accomodate any values of penalties like \cmd\clubpenalty, etc:
+% we do not make assumptions about the range of values these penalty parameters could take.
+%
+%
+% \begin{macro}{\linenomathWithnumbers}
+% \begin{macro}{\linenomathNonumbers}
+% \begin{macro}{\endlinenomath}
+% \begin{macro}{\linenumberpar}
+% Here are the definitions of procedures in \filename{lineno.sty}
+% that alter \cmd\holdinginserts. They are current as of version v4.41, 2005/11/02.
+% 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.
+% Also, we will want \cmd\linenumberpar\ to set \cmd\interlinepenaly\ to dispatch to \cmd\MakeLineNo.
+%
+% \begin{macrocode}
+\newcommand\linenomathWithnumbers@LN{%
+ \ifLineNumbers
+ \ifnum\interlinepenalty>-\linenopenaltypar
+ \global\holdinginserts\thr@@
+ \advance\interlinepenalty \linenopenalty
+ \ifhmode
+ \advance\predisplaypenalty \linenopenalty
+ \fi
+ \advance\postdisplaypenalty \linenopenalty
+ \advance\interdisplaylinepenalty \linenopenalty
+ \fi
+ \fi
+ \ignorespaces
+}%
+\newcommand\linenomathNonumbers@LN{%
+ \ifLineNumbers
+ \ifnum\interlinepenalty>-\linenopenaltypar
+ \global\holdinginserts\thr@@
+ \advance\interlinepenalty \linenopenalty
+ \ifhmode
+ \advance\predisplaypenalty \linenopenalty
+ \fi
+ \fi
+ \fi
+ \ignorespaces
+}%
+\def\endlinenomath@LN{%
+ \ifLineNumbers
+ \global\holdinginserts\@LN@outer@holdins
+ \fi
+ \global\@ignoretrue
+}
+\def\linenumberpar@LN{%
+ \ifvmode \@@@par \else
+ \ifinner \@@@par \else
+ \xdef\@LN@outer@holdins{\the\holdinginserts}%
+ \advance \interlinepenalty \linenopenalty
+ \linenoprevgraf \prevgraf
+ \global \holdinginserts \thr@@
+ \@@@par
+ \ifnum\prevgraf>\linenoprevgraf
+ \penalty-\linenopenaltypar
+ \fi
+ \@LN@parpgbrk
+ \global\holdinginserts\@LN@outer@holdins
+ \advance\interlinepenalty -\linenopenalty
+ \fi
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\class@documenthook}
+% We patch only if we recognize the definitions of all the procedures we are to patch.
+% \begin{macrocode}
+\appdef\class@documenthook{%
+ \@ifpackageloaded{lineno}{%
+ \@ifx{\linenomathWithnumbers\linenomathWithnumbers@LN}{%
+ \@ifx{\linenomathNonumbers\linenomathNonumbers@LN}{%
+ \@ifx{\endlinenomath\endlinenomath@LN}{%
+ \@ifx{\linenumberpar\linenumberpar@LN}{%
+ \true@sw
+ }{\false@sw}%
+ }{\false@sw}%
+ }{\false@sw}%
+ }{\false@sw}%
+ {%
+ \class@info{Overriding lineo.sty, restoring output routine,}%
+% \end{macrocode}
+% We commence overriding the procedures of \filename{lineno.sty}.
+% \begin{macrocode}
+ \let\linenumberpar\linenumberpar@ltx
+ \let\endlinenomath\endlinenomath@ltx
+ \expandafter\let\csname endlinenomath*\endcsname\endlinenomath@ltx
+ \let\linenomathWithnumbers\linenomathWithnumbers@ltx
+ \let\linenomathNonumbers\linenomathNonumbers@ltx
+% \end{macrocode}
+% Override \filename{lineno.sty}'s equipment for \cmd\vadjust\ and \cmd\linelabel:
+% we have existing interrupts and handlers for these purposes.
+% \begin{macrocode}
+ \let\ex@vadjust@ltx\ex@vadjust@line
+ \let\@LN@postlabel\enqueue@whatsit@ltx
+ \let\do@whatsit\write@linelabel
+% \end{macrocode}
+% Redirect handlers to those provided by \filename{lineno.sty}, and
+% give an appropriate meaning to the respective headpatch within the handlers.
+% \begin{macrocode}
+ \let\handle@par@ltx\handle@par@LN
+ \let\@@handle@line@ltx\Make@LineNo@ltx
+ \let\@@handle@display@ltx\Make@LineNo@ltx
+% \end{macrocode}
+% Next, we undo the action taken by \filename{lineno.sty} wherein it
+% took over the output routine. Instead, we service \filename{lineno.sty}
+% existing equipment of \filename{ltxgrid}.
+% We also revert the core \LaTeX\ definitions of
+% \cmd\vspace, \cmd\pagebreak, \cmd\nopagebreak, and \cmd\\,
+% which that package takes over (we have our own ways of doing these things).
+% \begin{macrocode}
+ \output@latex{\natural@output}%
+ \let\vspace\vspace@ltx
+ \let\pagebreak\pagebreak@ltx
+ \let\nopagebreak\nopagebreak@ltx
+ \let\@arrayparboxrestore\@arrayparboxrestore@ltx
+ \let\\\endline@ltx
+% \end{macrocode}
+% \changes{4.1f}{2009/07/07}{(AO, 515) Prevent line numbering within a footnote}
+% When line numbering is in effect, we must avoid any attempt to number the lines of a footnote.
+% \begin{macrocode}
+ \appdef\set@footnotefont{%
+ \let\par\@@@par
+ \let\@@par\@@@par
+ }%
+% \end{macrocode}
+% At last, we detect if the \cmd\linenumbers\ command has already been given;
+% if so, we do its assignments again, because we have changed the meaning of \cmd\linenumberpar.
+% \begin{macrocode}
+ \@if@sw\ifLineNumbers\fi{%
+ \class@info{Reinvoke \string\linenumbers}%
+ \let\@@par\linenumberpar
+ \@ifx{\@par\linenumberpar@LN}{\let\@par\linenumberpar}{}%
+ \@ifx{\par\linenumberpar@LN}{\let\par\linenumberpar}{}%
+ }{%
+ \class@info{Line numbering not turned on yet}%
+ }%
+% \end{macrocode}
+% Here ends the ``true branch'' of the patch code.
+% \begin{macrocode}
+ }{%
+% \end{macrocode}
+% If the \filename{lineno.sty} package is loaded, but we fail to patch it, notify the user.
+% \begin{macrocode}
+ \class@warn{Failed to recognize lineno.sty procedures; no patches applied. Please get a more up-to-date class.}%
+ }%
+ }{%
+% \end{macrocode}
+% \filename{lineno.sty} is not loaded, so no patches are needed.
+% \begin{macrocode}
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\linenumberpar}
+% \begin{macro}{\@linenumberpar}
+% Procedure \cmd\linenumberpar\ takes the place of \cmd\par\ when line numbering is in effect;
+% It executes the \cmd\par\ primitive if we are in vertical mode.
+% Otherwise we are in horizontal mode in the MVL and wish to end the current paragraph,
+% or we have \cmd\unvbox ed material onto the MVL.
+%
+% \begin{macrocode}
+\def\linenumberpar@ltx{\@ifvmode{\@@@par}{\@linenumberpar}}%
+% \end{macrocode}
+%
+% Procedure \cmd\@linenumberpar
+% \begin{macrocode}
+\def\@linenumberpar{%
+% \end{macrocode}
+% Prepare for our trip into the output routine by
+% saving away the current value of \cmd\prevgraf.
+% \begin{macrocode}
+ \linenoprevgraf\prevgraf
+% \end{macrocode}
+% The following will be used in the output routine dispatcher
+% to sense that we came from here.
+% \begin{macrocode}
+ \set@linepenalties
+% \end{macrocode}
+% Finally, call primitive \cmd\par\ with the signal value of \cmd\interlinepenalty\ and friends.
+% \begin{macrocode}
+ \@@@par
+% \end{macrocode}
+% We are now in vertical mode.
+% If lines of type were contributed to the MVL (non-trivial paragraph),
+% we must force another trip into the output routine to apply
+% line numbering to the last line of the paragraph.
+% \begin{macrocode}
+ \@ifnum{\prevgraf>\linenoprevgraf}{
+ \penalty-\int@postparpenalty
+ }{}%
+% \end{macrocode}
+% Execute procedure \cmd\@LN@parpgbrk, which has been set up in the
+% output routine for us to invoke here.
+%
+% \begin{macrocode}
+ \@LN@parpgbrk
+% \end{macrocode}
+% To wrap things up, we restore the original value of \cmd\interlinepenalty\ and friends.
+%
+% Query: why not employ \TeX's context stack to do the restore?
+% Would there be something wrong with executing primitive \cmd\par\ within a group?
+% \begin{macrocode}
+ \restore@linepenalties
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\linenomathWithnumbers}
+% \begin{macro}{\linenomathNonumbers}
+% Here are the patched definitions for the commands enabling
+% line numbering in display math.
+% \begin{macrocode}
+\newcommand\linenomathWithnumbers@ltx{\@linenomathnumbers@ltx\true@sw}%
+\newcommand\linenomathNonumbers@ltx{\@linenomathnumbers@ltx\false@sw}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@linenomathnumbers}
+% \begin{macro}{\endlinenomath}
+% We have just begun a display math, and any paragraph we are setting will now end.
+% We set all relevant penalties to interrupt values; in the visit to the output routine,
+% we will replace the penalty with its normal value.
+% \begin{macrocode}
+\def\@linenomathnumbers@ltx#1{%
+ \@if@sw\ifLineNumbers\fi{%
+ \set@linepenalties
+ \set@displaypenalties#1%
+ }{}%
+ \ignorespaces
+}%
+\def\endlinenomath@ltx{%
+ \global\@ignoretrue
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% We provide a handler for the last line of a paragraph.
+% \begin{macrocode}
+\def\handle@par@LN{%
+ \Make@LineNo@ltx
+% \end{macrocode}
+% After setting the line number, we arrange for an appropriate penalty to
+% be laid down after this visit to the output routine ends.
+%
+% Query: why not contribute the penalty right here in the visit to the output routine?
+% \begin{macrocode}
+ \@tempcnta\lastpenalty
+ \@ifnum{\@tempcnta=\z@}{}{%
+ \expandafter\gdef
+ \expandafter\@LN@parpgbrk
+ \expandafter{%
+ \expandafter\penalty
+ \the\@tempcnta
+% \end{macrocode}
+% When \cmd\@LN@parpgbrk\ is executed, it resets itself to the default value,
+% \cmd\@LN@screenoff@pen.
+%
+% Query: \cmd\@LN@screenoff@pen\ appears to try to restore the depth of the last box:
+% why is this being done outside the safety of the output routine?
+% \begin{macrocode}
+ \global\let\@LN@parpgbrk\@LN@screenoff@pen
+ }%
+ }%
+}%
+% \end{macrocode}
+%
+% \begin{macro}{\Make@LineNo}
+% The procedure \cmd\Make@LineNo\ sets the box containing the line number itself.
+% \begin{macrocode}
+\def\Make@LineNo@ltx{%
+ \@LN@maybe@normalLineNumber
+% \end{macrocode}
+% We measure the depth of \cmd\box\cmd\@cclv\ and unbox it.
+% At this point, it is crucial that that box have the same depth as that of the last
+% box within it.
+%
+% In the simple case, \cmd\box\cmd\@cclv\ is
+% a \cmd\vbox\ containing as its last box the \cmd\hbox\ of the paragraph we are processing.
+%
+% Query: under what circumstances will this \emph{not} be the case?
+% \begin{macrocode}
+ \boxmaxdepth\maxdimen\setbox\z@\vbox{\unvbox\@cclv}%
+ \@tempdima\dp\z@
+ \unvbox\z@
+% \end{macrocode}
+% Then we create the box with the line number, setting its height to zero.
+% \begin{macrocode}
+ \sbox\@tempboxa{\hb@xt@\z@{\makeLineNumber}}%
+ \ht\@tempboxa\z@
+% \end{macrocode}
+% With these preparations, we invoke \cmd\@LN@depthbox, which
+% lays that box down (with its depth appropriately set):
+% this procedure depends on our having set \cmd\@tempdima\ and \cmd\@tempboxa
+% (kinda kludgy way of passing arguments, really).
+% \begin{macrocode}
+ \@LN@depthbox
+% \end{macrocode}
+% Now increment the line number. I have relocated this token past \cmd\@LN@depthbox:
+% this may induce a bug, but I am going to hereby force the issue:
+% why split up the procedure that lays down boxes with a procedure that sets a register value?
+% \begin{macrocode}
+ \stepLineNumber
+% \end{macrocode}
+% Finally, execute the \cmd\vadjust s that fell within the line that we just handled.
+%
+% Note that \cmd\enqueue@vadjust@ltx\ had queued up all the \cmd\vadjust\ commands for the paragraph
+% into \cmd\g@vadjust@queue, laying down an (\cmd\int@vadjustpenalty) interrupt in each ones' place.
+% The interrupts associated with this line of the paragraph have now moved the tokens to \cmd\g@vadjust@line,
+% which we now expand and execute.
+% \begin{macrocode}
+ \g@vadjust@line
+ \global\let\g@vadjust@line\@empty
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\write@linelabel#1{%
+ \protected@write\@auxout{}{%
+ \string\newlabel{#1}{{\theLineNumber}{\thepage}{}{}{}}%
+ }%
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\ex@vadjust@line{%
+ \@if@sw\ifLineNumbers\fi{\enqueue@vadjust@ltx}{\vadjust}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% Note that the \cmd\linelabel\ commands use a mechanism different from \cmd\vadjust,
+% embodied in the procedure \cmd\enqueue@vadjust@ltx, wherein the
+% \cmd\write\ primitives are enqueued while the paragraph is being processed, each replaced with
+% an interrupt, then dequeued and executed by the interrupt handler, leaving a \cmd\write\ node
+% in place of the interrupt (just where the \cmd\vadjust 's vertical mode material would had been)
+% just below the box containing the line of type. This \cmd\write, like all whatsits,
+% does not affect the depth of \cmd\box\cmd\@cclv, unlike the case of general vertical mode material,
+% which could have interfered.
+%
% \section{End of the \file{ltxgrid} {\sc docstrip} module}
% Here ends the module.
% \begin{macrocode}
-%</ltxgrid-krn>
+%</kernel>
% \end{macrocode}
%
% \Finale