% \iffalse ltxdoc klootch
% ltxutil.dtx: package to add utilties to LaTeX
% Copyright (c) 2000 Arthur Ogawa
%
% Disclaimer
% This file is distributed WITHOUT ANY WARRANTY;
% without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% ReadMe
% For the documentation and more detailed instructions for
% installation, typeset this document with \LaTeX.
% \fi
% \GetFileInfo{ltxutil.dtx}
%
% \iffalse ltxdoc klootch
%<*ltxutil>
%%% @LaTeX-file{
%%% filename = "ltxutil.dtx",
%%% version = "1.0d",
%%% date = "2020/09/30",
%%% author = "Arthur Ogawa (mailto:ogawa@teleport.com),
%%% Phelype Oleinik (mailto:phelype.oleinik at latex-project.org),
%%% commissioned by the American Physical Society.
%%% ",
%%% copyright = "Copyright (C) 1999 Arthur Ogawa,
%%% distributed under the terms of the
%%% LaTeX Project Public License, see
%%% ftp://ctan.tug.org/macros/latex/base/lppl.txt
%%% ",
%%% address = "Arthur Ogawa,
%%% USA",
%%% telephone = "",
%%% FAX = "",
%%% email = "ogawa@teleport.com",
%%% codetable = "ISO/ASCII",
%%% keywords = "latex, utility, kernel",
%%% supported = "yes",
%%% abstract = "package to add utilties to LaTeX",
%%% }
%
% \fi
%
% \iffalse ltxdoc klootch
% The following references the \file{00readme.txt} 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}%
%
% \subsection{Bill of Materials}
%
% Following is a list of the files in this distribution arranged
% according to provenance.
%
% \subsubsection{Primary Source}%
% One single file generates all.
%\begin{verbatim}
%ltxutil.dtx
%\end{verbatim}
%
% \subsubsection{Generated by \texttt{latex ltxutil.dtx}}%
% Typesetting the source file under \LaTeX\
% generates the readme and the installer.
%\begin{verbatim}
%00readme.txt ltxutil.ins
%\end{verbatim}
%
% \subsubsection{Generated by \texttt{tex ltxutil.ins}}%
% Typesetting the installer generates
% the package files.
%\begin{verbatim}
%ltxutil.sty
%\end{verbatim}
%
% \subsubsection{Documentation}%
% The following are the online documentation:
% \begin{verbatim}
%ltxutil.pdf
% \end{verbatim}
%
% \subsubsection{Auxiliary}%
% The following are auxiliary files generated
% in the course of running \LaTeX:
% \begin{verbatim}
%ltxutil.aux ltxutil.idx ltxutil.ind ltxutil.log ltxutil.toc
% \end{verbatim}
%
% \section{Code common to all modules}%
%
% The following may look a bit klootchy, but we
% want to require only one place in this file
% where the version number is stated,
% and we also want to ensure that the version
% number is embedded into every generated file.
%
% Now we declare that
% these files can only be used with \LaTeXe.
% An appropriate message is displayed if
% a different \TeX{} format is used.
% \begin{macrocode}
%<*doc|ltxutil>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
%
% \end{macrocode}
% As desired, the following modules all
% take common version information:
% \begin{macrocode}
%\ProvidesFile{ltxutil.sty}%
%<*doc>
\expandafter\ProvidesFile\expandafter{\jobname.dtx}%
%
% \end{macrocode}
%
% The following line contains, for once and for all,
% the version and date information.
% By various means, this information is reproduced
% consistently in all generated files and in the
% typeset documentation.
% \begin{macrocode}
%<*doc|ltxutil>
[2020/09/30 1.0d utilities package]% \fileversion
%
% \end{macrocode}
%
%
% \section{The driver module \texttt{doc}}
%
% This module, consisting of the present section,
% typesets the programmer's documentation,
% generating the \file{.ins} installer and \file{00readme.txt} as required.
%
% Because the only uncommented-out lines of code at the beginning of
% this file constitute the \file{doc} module itself,
% we can simply typeset the \file{.dtx} file directly,
% and there is thus rarely any need to
% generate the ``doc'' {\sc docstrip} module.
% Module delimiters are nonetheless required so that
% this code does not find its way into the other modules.
%
% The \enve{document} command concludes the typesetting run.
%
% \begin{macrocode}
%<*doc>
% \end{macrocode}
%
% \subsection{The Preamble}
% The programmers documentation is formatted
% with the \classname{ltxdoc} class with local customizations,
% and with the usual code line indexing.
% \begin{macrocode}
\documentclass{ltxdoc}
\RequirePackage{ltxdocext}%
\let\url\undefined
\RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}%
\pdfstringdefDisableCommands{%
\let\file\relax
\let\sc\relax
}
\makeatletter
\@ifundefined{package@font}{}%
{\expandafter\RequirePackage\expandafter{\csname package@font\endcsname}}
\makeatother
\CodelineIndex\EnableCrossrefs
% \end{macrocode}
%
% \subsubsection{Docstrip and info directives}
% We use so many {\sc docstrip} modules that we set the
% \texttt{StandardModuleDepth} counter to 1.
% \begin{macrocode}
\setcounter{StandardModuleDepth}{1}
% \end{macrocode}
% The following command retrieves the date and version information
% from this file.
% \begin{macrocode}
\expandafter\GetFileInfo\expandafter{\jobname.dtx}%
% \end{macrocode}
%
%
% \subsection{The installer file}
%
% The installer \file{ltxutil.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{ltxutil.drv}&driver for programmer's documentation\\
% ltxutil,ltxutil-krn &\file{ltxutil.sty}&this package\\
% ltxutil-krn& &the portion of this package suitable for inclusion within another package
% \end{tabular}
% \end{center}
%
% \begin{macrocode}
\begin{filecontents}{ltxutil.ins}
%% This file will generate documentation and runtime files
%% from ltxutil.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{ltxutil.drv}{\from{ltxutil.dtx}{doc}}%
\file{ltxutil.sty}{%
\from{ltxutil.dtx}{ltxutil,ltxutil-krn}%
}%
}%
\ifToplevel{
\Msg{***********************************************************}
\Msg{*}
\Msg{* To finish the installation, please move}
\Msg{* ltxutil.sty}
\Msg{* into a directory searched by TeX.}
\Msg{*}
\Msg{* To produce the documentation,
run ltxutil.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,
% since it also constitutes the beginining of the
% programmer's documentation. What better thing, after
% all, to have appear at the beginning of the
% typeset documentation?
%
% A good discussion of how to write a ReadMe file can be found in
% Engst, Tonya, ``Writing a ReadMe File? Read This''
% \emph{MacTech} October 1998, p. 58.
%
% Note the appearance of the
% \cmd\StopEventually\ command, which marks the
% dividing line between the user documentation
% and the programmer documentation.
%
% The usual user will not be asked to
% do a full build, not to speak
% of the bootstrap.
% Instructions for carrying these processes
% begin the programmer's manual.
%
% \begin{macrocode}
\begin{filecontents*}{00readme.txt}
\title{%
A \LaTeX\ Package of utility macros%
\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.
}%
}%
\author{%
Arthur Ogawa (\texttt{mailto:ogawa@teleport.com}),
\fileversion\\Copyright (C) 1999 Arthur Ogawa
}%
\maketitle
This file embodies the \classname{ltxutil} 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/ltxutil...},
which contains fully unpacked, prebuilt runtime files and documentation.
The \classname{ltxutil} package was commissioned by the American Physical Society
and is distributed under the terms of the \LaTeX\ Project Public License,
the same license under which all the portions of \LaTeX\ itself is distributed.
Please see \url{http://ctan.tug.org/macros/latex/base/lppl.txt} for details.
To use this document class, you must have a working
\TeX\ installation equipped with \LaTeXe\
and possibly pdftex and Adobe Acrobat Reader or equivalent.
To install, retrieve the distribution,
unpack it into a directory on the target computer,
and move the file \file{ltxutil.sty}
into a location in your filesystem where it will be found by \LaTeX.
To use, read the user documentation \file{ltxutil.pdf}.
\tableofcontents
\section{Processing Instructions}
The package file \file{ltxutil.sty}
is generated from this file, \file{ltxutil.dtx},
using the {\sc docstrip} facility of \LaTeX
via |tex ltxutil.ins|.
The typeset documentation that you are now reading is generated from
the same file by typesetting it with \LaTeX\ or pdftex
via |latex ltxutil.dtx| or |pdflatex ltxutil.dtx|.
\subsection{Build Instructions}
You may bootstrap this suite of files solely from \file{ltxutil.dtx}.
Prepare by installing \LaTeXe\ (and either tex or pdftex) on your computer,
then carry out the following steps:
\begin{enumerate}
\item
Within an otherwise empty directory,
typeset \file{ltxutil.dtx} with \LaTeX\ or pdflatex;
you will obtain the typeset documentation you are now reading,
along with
the installer \file{ltxutil.ins},
and the file \file{00readme.txt}.
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{ltxutil.ins},
thereby generating the package file \file{ltxutil.sty}.
\item
Install \classname{ltxutil.sty}
by moving it to a location
in your filesystem where they will be found by \LaTeX.
\end{enumerate}
\end{filecontents*}
% \end{macrocode}
%
% \subsection{The Document Body}
%
% Here is the document body, containing only a
% \cmd\DocInput\ directive---referring to this very file.
% This very cute self-reference is a common \classname{ltxdoc} idiom.
% \begin{macrocode}
\begin{document}%
\expandafter\DocInput\expandafter{\jobname.dtx}%
% ^^A\PrintChanges
\end{document}
% \end{macrocode}
%
% \begin{macrocode}
%
% \end{macrocode}
%
% \section{Using this package}
% Once this package is installed on your filesystem, you can employ it in
% adding functionality to \LaTeX\ by invoking it in your document or document class.
%
% \subsection{Invoking the package}
% In your document, you can simply call it up in your preamble:
% \begin{verbatim}
%\documentclass{book}%
%\usepackage{ltxutil}%
%\begin{document}
%
%\end{document}
% \end{verbatim}
% However, the preferred way is to invoke this package from within your
% customized document class:
% \begin{verbatim}
%\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
%\ProvidesClass{myclass}%
%\RequirePackage{ltxutil}%
%\LoadClass{book}%
%
%\endinput
% \end{verbatim}
%
% 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.
%
%
% \section{Compatability with \LaTeX's Required Packages}
% Certain packages, usually ones written by members of the
% \LaTeX\ Project itself, have been designated ``required'' and
% are distributed as part of standard \LaTeX.
% These packages have been placed in a priviledged position
% vis \'a vis the \LaTeX\ kernel in that they override the definitions of certain kernel macros.
%
% The \classname{ltxutil} package will be incompatible with any package that
% redefines any of the kernel macros that \classname{ltxutil} patches---if that
% package is loaded \emph{after} \classname{ltxutil}. This means that for
% greatest compatability, \classname{ltxutil} should be loaded \emph{after},
% say, \classname{ftnright}, which overwrites \LaTeX's kernel
% procedures \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol.
%
% Hereinafter follows some notes on specific \LaTeX\ packages.
%
% \subsection{array}
% This package alters the way tabular environments are done,
% therefore it could run afoul of the \LaTeX\ ``required'' package \classname{array} or any
% package that calls for it to be loaded.
% However, this package has provisions for remaining compatible with \classname{array}.
% So long as the version of \classname{array} that is used with this package has the appropriate
% meanings for the procedures it overwrites, all should be well.
%
% \subsection{longtable}
% David Carlisle's \classname{longtable} package modifies both the \LaTeX\ kernel and the
% \classname{array} package. This package must therefore alter \cmd\LT@array.
% For now, that job is handled by \classname{ltxgrid}.
%
%
%\StopEventually{}
%
% \section{Implementation of package}
%
% Special acknowledgment: this package uses concepts pioneered
% and first realized by William Baxter (mailto:web@superscript.com)
% in his SuperScript line of commercial typesetting tools, and
% which are used here with his permission.
%
% \subsection{Beginning of the \file{ltxutil} {\sc docstrip} module}
% \begin{macrocode}
%<*ltxutil>
\def\package@name{ltxutil}%
\expandafter\PackageInfo\expandafter{\package@name}{%
Utility macros for \protect\LaTeXe,
by A. Ogawa (ogawa@teleport.com)%
}%
%
% \end{macrocode}
%
% \subsection{Banner}%
% Credit where due.
% \begin{macrocode}
%<*ltxutil-krn>
\typeout{%
ltxutil: portions licensed from W. E. Baxter (web@superscript.com)%
}%
% \end{macrocode}
%
% \subsection{Errors and warnings}
%
% \begin{macro}{\class@err}
% \begin{macro}{\class@warn}
% \begin{macro}{\class@info}
% A few shorthands for Class messages.
% Your document class should define \cmd\class@name.
% \begin{macrocode}
\def\class@err#1{\ClassError{\class@name}{#1}\@eha}%
\def\class@warn#1{\ClassWarningNoLine{\class@name}{#1}}%
\def\class@info#1{\ClassInfo{\class@name}{#1}}%
\def\obsolete@command#1{%
\class@warn@end{Command \string#1\space is obsolete.^^JPlease remove from your document}%
\global\let#1\@empty
#1%
}%
\def\replace@command#1#2{%
\class@warn@end{Command \string#1\space is obsolete;^^JUse \string#2\space instead}%
\global\let#1#2%
#1%
}%
\def\replace@environment#1#2{%
\class@warn@end{Environment #1 is obsolete;^^JUse #2 instead}%
\glet@environment{#1}{#2}%
\@nameuse{#1}%
}%
\def\incompatible@package#1{%
\@ifpackageloaded{#1}{%
\def\@tempa{I cannot continue. You must remove the \string\usepackage\ statement that caused that package to be loaded.}%
\ClassError{\class@name}{The #1 package cannot be used with \class@name}%
\@tempa\stop
}{%
\class@info{#1 was not loaded (OK!)}%
}%
}%
\def\class@warn@end#1{%
\gappdef\class@enddocumenthook{\class@warn{#1}}%
}%
\AtEndOfClass{%
\@ifxundefined\class@name{\def\class@name{Generic Class}}{}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{New Tools}%
%
% \begin{macro}{\t@}
% \begin{macrocode}
\def\t@{to}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dimen@iii}
% \begin{macrocode}
\dimendef\dimen@iii\thr@@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\halignt@}
% \begin{macrocode}
\def\halignt@{\halign\t@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\f@ur}
% Analogous to \cmd\@ne, \cmd\tw@, and \cmd\thr@@.
% \begin{macrocode}
\chardef\f@ur=4\relax
\chardef\cat@letter=11\relax
\chardef\other=12\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\let@environment}
% \begin{macro}{\glet@environment}
% The directive \cmd\let@environment\ takes care of a common programming
% idiom whereby one environment is made a synonym for another.
% \begin{macrocode}
\def\let@environment#1#2{%
\expandafter\let
\csname#1\expandafter\endcsname\csname#2\endcsname
\expandafter\let
\csname end#1\expandafter\endcsname\csname end#2\endcsname
}%
\def\glet@environment#1#2{%
\global\expandafter\let
\csname#1\expandafter\endcsname\csname#2\endcsname
\global\expandafter\let
\csname end#1\expandafter\endcsname\csname end#2\endcsname
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tracingplain}
% The command \cmd\tracingplain\ causes \TeX's tracing parameters to
% return to the values set by default. This command is sometimes
% useful when you have said \cmd\tracingall\ somewhere and want to
% restore.
% The \cmd\traceoutput\ command causes \cmd\tracingoutput\ diagnostics
% upon \cmd\shipout.
% \begin{macrocode}
\newcommand\tracingplain{%
\tracingonline\z@\tracingcommands\z@\tracingstats\z@
\tracingpages\z@\tracingoutput\z@\tracinglostchars\@ne
\tracingmacros\z@\tracingparagraphs\z@\tracingrestores\z@
\showboxbreadth5\showboxdepth3\relax %\errorstopmode
}%
\newcommand\traceoutput{%
\appdef\@resetactivechars{\showoutput}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\say}
% \begin{macro}{\saythe}
% The commands \cmd\say\ and \cmd\saythe\ cause diagnostic messages in the
% \TeX\ log that give the value of a control sequence name or a register
% respectively.
% \begin{macrocode}
\newcommand\say[1]{\typeout{<\noexpand#1=\meaning#1>}}%
\newcommand\saythe[1]{\typeout{<\noexpand#1=\the#1>}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fullinterlineskip}
% Resets the \cmd\prevdepth\ so that the full amount of \cmd\baselineskip\ glue will be inserted by
% the \cmd\baselinesklip\ mechanism.
% Can be invoked just after a \cmd\hrule\ to undo its default suppression of base line skip.
% \begin{macrocode}
\def\fullinterlineskip{\prevdepth\z@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\count@i}
% \begin{macro}{\count@ii}
%
% \begin{macrocode}
\countdef\count@i\@ne
\countdef\count@ii\tw@
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Boolean Control}%
% We introduce just enough of the Boolean calculus for \TeX.
% Alan Jeffrey was the pioneer here, with an article in TUGboat
% (Vol. 11, No. 2, page 237).
% This implementation owes a debt to
% William Baxter (web@superscript.com).
% See articles by Baxter and Ogawa in the proceedings of the
% 1994 TUG meeting, TUGboat Vol.~15, No.~3.
%
% \begin{macro}{\prepdef}
% \begin{macro}{\appdef}
% \begin{macro}{\gappdef}
%
% Provide the capability of performing head- and tail patches.
% The procedure \cmd\prepdef\ prepends to the given macro
% the tokens specified in its second argument.
% Likewise for \cmd\appdef, except that it appends.
% Note that the first 10 toks registers are utility registers,
% and we simply make a control sequence name, \cmd\toks@ii, for one of
% them.
% \begin{macrocode}
\long\def\prepdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\edef#1{\the\toks@ii\the\toks@}%
}%
\long\def\appdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\edef#1{\the\toks@\the\toks@ii}%
}%
\long\def\gappdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\global\edef#1{\the\toks@\the\toks@ii}%
}%
\long\def\appdef@val#1#2{%
\appdef#1{{#2}}%
}%
\long\def\appdef@e#1#2{%
\expandafter\appdef
\expandafter#1%
\expandafter{#2}%
}%
\long\def\appdef@eval#1#2{%
\expandafter\appdef@val
\expandafter#1%
\expandafter{#2}%
}%
\toksdef\toks@ii=\tw@
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifxundefined}
% \begin{macro}{\@ifnotrelax}
% \begin{macro}{\@argswap}
% \begin{macro}{\@argswap@val}
%
% Certain utility procedures use \cmd\@ifxundefined,
% which is defined here in terms of \cmd\@ifx.
% Others use \cmd\@ifnotrelax, namely when
% the control sequence name is manufactured by
% the use of \cmd\csname.
%
% The procedures \cmd\@argswap and \cmd\@argswap@val
% are used to facilitate control of expansion.
%
% \begin{macrocode}
\long\def\@ifxundefined#1{\@ifx{\undefined#1}}%
\long\def\@ifnotrelax#1#2#3{\@ifx{\relax#1}{#3}{#2}}%
\long\def\@argswap#1#2{#2#1}%
\long\def\@argswap@val#1#2{#2{#1}}%
\def\@ifxundefined@cs#1{\expandafter\@ifx\expandafter{\csname#1\endcsname\relax}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rvtx@ifformat@geq}
% Some changes in the \LaTeX{} kernel requires us to conditionally
% define some macros depending on the version of the kernel.
% \cmd\rvtx@ifformat@geq{} will check if the release date of the
% currently-running \LaTeXe{} kernel is greater or equal to the
% argument (the argument should be in the format \texttt{yyyy-mm-dd}).
% \changes{4.2d}{2020/09/17}{(PHO) Add \cs{rvtx@ifformat@geq} (from 4.2).}%
% \begin{macrocode}
\ifx\IfFormatAtLeastTF\undefined
\def\rvtx@ifformat@geq{\@ifl@t@r\fmtversion}%
\else
\let\rvtx@ifformat@geq\IfFormatAtLeastTF
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@boolean}
% \begin{macro}{\@boole@def}
% In order to define \cmd\@ifx, we first must create the
% ``defining word'' (term taken form our Forth vocabulary)
% \cmd\@boole@def, which employs \cmd\@boolean\ to do its job.
% \begin{macrocode}
\def\@boolean#1#2{%
\long\def#1{%
#2% \if
\expandafter\true@sw
\else
\expandafter\false@sw
\fi
}%
}%
\def\@boole@def#1#{\@boolean{#1}}% Implicit #2
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@booleantrue}
% \begin{macro}{\@booleanfalse}
% The procedures \cmd\@booleantrue\ and
% \cmd\@booleanfalse\ are assignment operators
% for Boolean flags.
% \begin{macrocode}
\def\@booleantrue#1{\let#1\true@sw}%
\def\@booleanfalse#1{\let#1\false@sw}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifx}
% \begin{macro}{\@ifx@empty}
% \begin{macro}{\@if@empty}
% \begin{macro}{\@ifcat}%
% \begin{macro}{\@ifdim}%
% \begin{macro}{\@ifeof}%
% \begin{macro}{\@ifhbox}%
% \begin{macro}{\@ifhmode}%
% \begin{macro}{\@ifinner}%
% \begin{macro}{\@ifmmode}%
% \begin{macro}{\@ifnum}%
% \begin{macro}{\@ifodd}%
% \begin{macro}{\@ifvbox}%
% \begin{macro}{\@ifvmode}%
% \begin{macro}{\@ifvoid}%
% We can now invoke the defining word to create
% the procedures \cmd\@ifx\ and friends.
%
% Compatability Note: earlier versions of this package
% defined a procedure \cmd\@ifempty. However, for compatability with AMS\LaTeX,
% we must avoid the following three names:
% \cmd\@ifempty, \cmd\@xifempty, and \cmd\@ifnotempty.
%
% \begin{macrocode}
\@boole@def\@ifx#1{\ifx#1}%
\@boole@def\@ifx@empty#1{\ifx\@empty#1}%
\@boole@def\@if@empty#1{\if!#1!}%
%\@boole@def\@if@sw#1{\csname if#1\endcsname}%
\def\@if@sw#1#2{#1\expandafter\true@sw\else\expandafter\false@sw#2}%
\@boole@def\@ifdim#1{\ifdim#1}%
\@boole@def\@ifeof#1{\ifeof#1}%
\@boole@def\@ifhbox#1{\ifhbox#1}%
\@boole@def\@ifhmode{\ifhmode}%
\@boole@def\@ifinner{\ifinner}%
\@boole@def\@ifmmode{\ifmmode}%
\@boole@def\@ifnum#1{\ifnum#1}%
\@boole@def\@ifodd#1{\ifodd#1}%
\@boole@def\@ifvbox#1{\ifvbox#1}%
\@boole@def\@ifvmode{\ifvmode}%
\@boole@def\@ifvoid#1{\ifvoid#1}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\true@sw}
% \begin{macro}{\false@sw}
%
% Note that when a Boolean operator expands, it
% employs two macros that act as selectors, defined here.
%
% \begin{macrocode}
\long\def\true@sw#1#2{#1}%
\long\def\false@sw#1#2{#2}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\loopuntil}
% \begin{macro}{\loopwhile}
%
% Loop control using the Boolean idiom.
% Superior to \cmd\loop\dots\cmd\repeat\ because these can be nested.
% The tail of the argument must have a Boolean predicate.
%
% \begin{macrocode}
\long\def\loopuntil#1{#1{}{\loopuntil{#1}}}%
\long\def\loopwhile#1{#1{\loopwhile{#1}}{}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@provide}
%
% A defining word that refuses to clobber a prior meaning.
%
% \begin{macrocode}
\def\@provide#1{%
\@ifx{\undefined#1}{\true@sw}{\@ifx{\relax#1}{\true@sw}{\false@sw}}%
{\def#1}{\def\j@nk}%
}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Begin Document Structure}
% The standard \LaTeX\ mechanism \cmd\AtBeginDocument\
% is inadequate because the \cmd\vsize\ is bound much too early.
% We supply here a mechanism whereby decisions about the
% page layout can be deferred until \cmd\AtBeginDocument\ time.
%
% The problem we are working around is that the \cmd\AtBeginDocument\
% hook in \cmd\document\ appears long after the calculation of
% \cmd\vsize\ and \cmd\hsize, that is, \LaTeX\ provides no mechanism
% for deferring the decision about the page grid until \cmd\AtBeginDocument\ time.
% We fix things by prepending a hook at the very beginning of \cmd\document.
%
% \begin{macro}{\document}
% We begin by installing hooks into \cmd\document\ that
% we will manage ourselves.
%
% The 2020-10-01 \LaTeX{} release got a new hook management system and
% several new hooks (several previously provided by \textsf{etoolbox}).
% The one we want here is \texttt{begindocument/before}, the first thing
% executed by \cmd\document{}, right after ending the group started by
% \cmd\begin{}.
%
% Thus, if the \LaTeX{} kernel date is 2020-10-01 we just add to that
% hook, otherwise resort to the old method, patching \cmd\document:
% end the group started by \cmd\begin, apply our hook, and
% conclude our shenanigans by absorbing
% the first token of the expansion of \cmd\document, which
% we assume to be \cmd\endgroup{} (true until the aforementioned release).
% \changes{4.2d}{2020/09/17}{(PHO) Use \LaTeX's hook management system, if possible (from 4.2).}%
% \begin{macrocode}
\rvtx@ifformat@geq{2020-10-01}%
{%
\AddToHook{begindocument/before}{%
\init@documenthook
\set@typesize@hook
\normalsize
\set@pica@hook
}%
}{%
\prepdef\document{%
\endgroup
\init@documenthook
\set@typesize@hook
\normalsize
\set@pica@hook
\true@sw{}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\class@documenthook}
% \begin{macro}{\class@enddocumenthook}
% We install the first \cmd\AtBeginDocument\ hook, namely the
% procedure \cmd\class@documenthook. Within the document class,
% we will use this hook exclusively, so as to avoid interference from other packages.
% Similarly with \cmd\class@enddocumenthook, installed via \cmd\AtEndDocument.
%
% A document class using this package should do as this package does and
% just say, \cmd\appdef\cmd\class@documenthook\ and \cmd\appdef\cmd\class@enddocumenthook\
% instead of \cmd\AtBeginDocument\ and \cmd\AtEndDocument.
% \begin{macrocode}
\def\init@documenthook{}%
\AtBeginDocument{%
\class@documenthook
}%
\AtEndDocument{%
\class@enddocumenthook
}%
\def\class@documenthook{}%
\def\class@enddocumenthook{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\set@typesize@hook}
% \begin{macro}{\set@pica@hook}
% The macros \cmd\set@typesize@hook\ and \cmd\set@pica@hook\ provide everything we need.
% To use, simply \cmd\appdef\ your tokens to the appropriate hook.
% \begin{macrocode}
\def\set@typesize@hook{}%
\def\set@pica@hook{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\enddocument}
% \begin{macro}{\check@aux}
% \begin{macro}{\do@check@aux}
% The standard \LaTeX\ \enve{document} processing is a potential problem,
% particularly when the output routine has been changed by \classname{ltxgrid}.
% We separate out the procedure that checks the auxiliary file at the end of
% the job so that later it can be called from the safety of the output
% routine.
% We will do this to ensure that the \cmd\@mainaux\ stream is not closed until
% the last page of the job is shipped out, and that can only be done by coordinating
% with the output routine.
%
% \changes{4.2d}{2020/09/17}{(PHO) Only redefine \cs{enddocument} in older versions.}%
% This approach, however, will only be done for older versions of the
% \LaTeX{} kernel:
% \begin{macrocode}
\rvtx@ifformat@geq{2020-10-01}{%
%
}{%
%
\def\enddocument{%
\@enddocumenthook
\@checkend{document}%
\clear@document
\check@aux
\deadcycles\z@
\@@end
}%
\def\clear@document{\clearpage}%
\def\check@aux{\do@check@aux}%
\def\do@check@aux{%
\@if@sw\if@filesw\fi{%
\immediate\closeout\@mainaux
\let\@setckpt\@gobbletwo
\let\@newl@bel\@testdef
\@tempswafalse
\makeatletter
\input\jobname.aux\relax
}{}%
\@dofilelist
\@ifdim{\font@submax >\fontsubfuzz\relax}{%
\@font@warning{%
Size substitutions with differences\MessageBreak
up to \font@submax\space have occured.\@gobbletwo
}%
}{}%
\@defaultsubs
\@refundefined
\@if@sw\if@filesw\fi{%
\@ifx{\@multiplelabels\relax}{%
\@if@sw\if@tempswa\fi{%
\@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right%
}%
}{}%
}{%
\@multiplelabels
}%
}{}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{4.2d}{2020/09/17}{(PHO) Patch \cs{enddocument} at runtime in newer versions.}%
% \begin{macro}{\rvtx@enddocument@patch}
% For newer \LaTeX{} we'll try to be a bit more future-proof
% (no miracle though). The code for \cmd\enddocument{}
% (in pre-2020-10-01 \LaTeX) is roughly:
% \begin{verbatim}
% \def\enddocument{%
%
% \clearpage
%
% \@@end
% }
% \end{verbatim}
% and the patches above replace the \cmd\clearpage{} by its own
% \cmd\clear@document, and \verb|| by
% \cmd\do@check@aux, which it can later control the timing.
%
% Now we will apply the same changes, but this time without redefining
% \cmd\enddocument: we will instead replace tokens on-the-fly, when
% \cmd\enddocument{} is expanded. This will grant us a slightly safer
% approach that won't depend so much on the internals of
% \cmd\enddocument.
%
% This entire patch should work with the previous definition of
% \cmd\enddocument{} as well (except it cannot be used in the hook),
% but for now leave previous versions untouched.
%
% The entire patching will reside in the \texttt{enddocument} hook:
% \begin{macrocode}
\rvtx@ifformat@geq{2020-10-01}{%
\AddToHook{enddocument}{\rvtx@enddocument@patch{}}%
}{}
% \end{macrocode}
%
% This macro will be executed after \cmd\enddocument{} has expanded,
% so all its tokens are now exposed. Here we will assume that
% \cmd\enddocument{} contains the tokens \verb|\@checkend{document}|
% and \cmd\endgroup, and use them as delimiters:
% \begin{macrocode}
\protected\long\def\rvtx@enddocument@patch#1#2\@checkend#3{%
\begingroup
\edef\x{\detokenize{#3}}%
\edef\y{\detokenize{document}}%
\expandafter\endgroup
\ifx\x\y
\expandafter\rvtx@enddocument@patch@end
\else
\expandafter\rvtx@enddocument@patch@more
\fi
{#1#2}{#3}}
\def\rvtx@enddocument@patch@more#1#2{%
\rvtx@enddocument@patch{#1\@checkend{#2}}}
% \end{macrocode}
%
% When the \verb|\@checkend{document}| is reached, use \cmd\clearpage{}
% and \cmd\enddocument{} as delimiters for the
% \verb|| part, and save it in
% \cmd\do@check@aux{}:
% \begin{macrocode}
\long\def\rvtx@enddocument@patch@end#1#2\clearpage#3\endgroup{%
\def\do@check@aux{#3\endgroup}%
% \end{macrocode}
% Then execute the code consumed in the previous step:
% \begin{macrocode}
#1%
\@checkend{#2}%
% \end{macrocode}
% Do \cmd\clear@document{} instead of \cmd\clearpage{} and
% \cmd\check@aux{} instead of the code grabbed.
% \begin{macrocode}
\clear@document
\check@aux}
\def\check@aux{\do@check@aux}%
\def\clear@document{\clearpage}%
% \end{macrocode}
% \end{macro}
%
% \subsection{Type Tools}%
%
% \begin{macro}{\flushing}
% Undoes \cmd\centering. Should also undo \cmd\raggedleft\ and \cmd\raggedright.
% \begin{macrocode}
\def\flushing{%
\let\\\@normalcr
\leftskip\z@skip
\rightskip\z@skip
\@rightskip\z@skip
\parfillskip\@flushglue
}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Display Math}%
%
% \begin{macro}{\eqnarray@LaTeX}
% \begin{macro}{\eqnarray@fleqn@fixed}
% Team \LaTeX\ has stated they will never repair Leslie's broken definition of \env{eqnarray}.
% Let us be bold\dots.
%
% Note on \classname{hyperref} package compatability: that package overrides
% \cmd\eqnarray\ by wrapping it up in a larger procedure, so its changes
% are compatible with this package's changes.
%
% \begin{macrocode}
\def\eqnarray@LaTeX{%
\stepcounter{equation}%
\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue
\m@th
\global\@eqcnt\z@
\tabskip\@centering
\let\\\@eqncr
$$\everycr{}\halign\t@\displaywidth\bgroup
\hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
&\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
&\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}
\long\def\eqnarray@fleqn@fixed{%
\stepcounter{equation}\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue\m@th\global\@eqcnt\z@
\tabskip\mathindent
\let\\=\@eqncr
\setlength\abovedisplayskip{\topsep}%
\ifvmode\addtolength\abovedisplayskip{\partopsep}\fi
\addtolength\abovedisplayskip{\parskip}%
\setlength\belowdisplayskip{\abovedisplayskip}%
\setlength\belowdisplayshortskip{\abovedisplayskip}%
\setlength\abovedisplayshortskip{\abovedisplayskip}%
$$%
\everycr{}%
\halignt@\linewidth\bgroup
\hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
&\global\@eqcnt\@ne
\hskip\tw@\eqncolsep
\hfil${{}##{}}$\hfil
&\global\@eqcnt\tw@
\hskip\tw@\eqncolsep
$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@\hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}%
\@ifx{\eqnarray\eqnarray@LaTeX}{%
\class@info{Repairing broken LaTeX eqnarray}%
\let\eqnarray\eqnarray@fleqn@fixed
\newlength\eqncolsep
\setlength\eqncolsep\z@
\let\eqnarray@LaTeX\relax
\let\eqnarray@fleqn@fixed\relax
}{}%
\def\mathindent{\@centering}%
\def\set@eqnarray@skips{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Footnotes}
%
% \changes{v4.0beta 4}{2000/04/10}
% {New kernel fix. For bug 174}
%
% \begin{macro}{\footnote}
% \begin{macro}{\footnotemark}
% \begin{macro}{\@xfootnote}
% \begin{macro}{\@xfootnotemark}
% \begin{macro}{\@yfootnote}
% We repair an error in the \LaTeX\ kernel (see \file{ltfloat.dtx}) involving footnotes.
% The symptom is that the \cmd\footnotemark\ command does not work properly within a \env{minipage} environment.
% The source of the problem is in the way the \cmd\footnotemark\ and \cmd\@xfootnotemark\ procedures are defined:
% they do not share the method used by the \cmd\footnote\ and other procedures that allows a context switch to
% change the way footnotes behave within a minipage environment.
% This is a \LaTeX\ bug of long standing; this fix dates to 1987.
%
% While we are at it, we rewrite both the \cmd\footnote\ and \cmd\footnotemark\ procedures,
% achieving a slightly cleaner separation of syntax and semantics.
% Note that the \cmd\@footnotemark\ and \cmd\@footnotetext\ procedures are not altered here;
% they continue as the methods of formatting the footnote mark and footnote text, respectively.
%
% A note about the context switch mentioned above:
% the \env{minipage} environment executes the following in order to alter the way footnotes
% behave:
%\begin{verbatim}
%\def\@mpfn{mpfootnote}%
%\def\thempfn{\thempfootnote}%
%\let\@footnotetext\@mpfootnotetext
%\c@mpfootnote\z@
%\end{verbatim}
% This code changes the counter used in autonumbered footnotes, the choice of footnote marker,
% and the procedure used on the footnote text. Changing the counter is needed because minipage
% footnotes are in their own sequence, and the footnote marker is customarily different within
% a minipage. The procedure that works on the footnote text must be different because the footnotes
% are placed at the bottom of the minipage, not the bottom of the text column.
%
% Any procedure that establishes a minipage-like context (e.g., floats) can do the same.
% \begin{macrocode}
\def\footnote{%
\@ifnextchar[\@xfootnote{\@yfootnote\@footnotetext}%
}%
\def\footnotemark{%
\@ifnextchar[\@xfootnotemark{\@yfootnote}%
}%
\def\@xfootnote[#1]{%
\@xfootnotemark[#1]%
\@footnotetext
}%
\def\@xfootnotemark@ltx[#1]{%
\begingroup
\csname c@\@mpfn\endcsname #1\relax
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\endgroup
\H@@footnotemark
}%
\def\@yfootnote{%
\stepcounter\@mpfn
\protected@xdef\@thefnmark{\thempfn}%
\H@@footnotemark
}%
% \end{macrocode}
%
% Note on \classname{hyperref} compatability:
% In its ``Automated \LaTeX\ hypertext cross-references'',
% the \classname{hyperref} package alters footnote processing,
% thereby imperiling these fixes and necessiating defensive measures.
%
% The main thing \classname{hyperref} does is to take over the \cmd\@mpfootnotetext\ and
% \cmd\@footnotetext\ procedures, feeding its own arguments to these macros.
% It also rewrites \cmd\@footnotemark, making it a hyperlink.
%
% But at the same time, it attempts to turn off these changes during
% \cmd\maketitle\ processing, necessitating rewriting \cmd\@xfootnotemark.
% At this point it is on the slippery slope.
%
% We make ourself \classname{hyperref} friendly:
% we give \classname{hyperref} what it needs, but avoid its change to
% \cmd\@xfootnotemark.
%
% Any other package that rewrites \LaTeX's footnote macros will be incompatible
% with this package.
% \begin{macrocode}
\appdef\class@documenthook{%
\@ifxundefined\H@@footnotemark{%
\let\H@@footnotemark\@footnotemark
}{}%
\let\@xfootnotemark\@xfootnotemark@ltx
}%
% \end{macrocode}
%
% Two thoughts about \classname{hyperref}: what for does it define \cmd\realfootnote?
% Also: a document class that desires high hypertext capabilities might
% well wish to reimplement \cmd\maketitle\ so that footnotes called out from there
% are hypertext links: the \classname{hyperref} package's
% ``Automated \LaTeX\ hypertext cross-references''
% does not do any of this:
%\begin{quotation}
% But the special footnotes
% in |\maketitle| are much too hard to deal with
% properly. Let them revert to plain behaviour.
%\end{quotation}
% Note that the document class, in reimplementing \cmd\maketitle, must ensure
% that the \classname{hyperref} package does not clobber its own definition!
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@footnotetext}
% \begin{macro}{\@mpfootnotetext}
% \begin{macro}{\@tpfootnotetext}
% \begin{macro}{\make@footnotetext}
% \begin{macro}{\set@footnotewidth}
% The two procedures \cmd\@footnotetext\ and \cmd\@mpfootnotetext\ share code.
% We make that explicit here.
%
% Note that the procedure calling \cmd\make@footnotetext\ will open a group
% with \cmd\bgroup\ which is then closed by \cmd\minipagefootnote@drop.
%
% Difference from \LaTeX: here we do not set \cmd\floatingpenalty\ to infinity.
% Doing this must date back to a time when \LaTeX\ could not accomodate split insertions (footnotes).
% I cannot think of any other reason to do have done this.
% At any rate, with the \classname{ltxgrid} package, split insertions are specifically properly
% taken care of, so we allow it.
%
% We provide the hook \cmd\set@footnotewidth\
% that sets the footnote on a particular measure.
% Some page grids are such as to set a footnote in a context where \cmd\columnwidth
% is not the right parameter to use for the set width of a footnote.
% In such a case, for the applicable scope, you should define
% \cmd\set@footnotewidth\ to perform this job correctly.
%
% A procedure, \cmd\set@footnotewidth@ii, illustrates how to do this when in a two-column page grid.
% In general, remember that footnotes, like all insertions (including floats),
% are a step outside of the galley context, and all aspects of insertions need to be
% properly handled, including the set width.
% \begin{macrocode}
\long\def\@footnotetext{%
\insert\footins\bgroup
\make@footnotetext
}%
\long\def\@mpfootnotetext{%
\minipagefootnote@pick
\make@footnotetext
}%
\def\make@footnotetext#1{%
\reset@font\footnotesize
\interlinepenalty\interfootnotelinepenalty
\splittopskip\footnotesep
\splitmaxdepth\dp\strutbox
% \floatingpenalty\@MM
\set@footnotewidth
\@parboxrestore
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark
}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox
}%
\color@endgroup
\minipagefootnote@drop
}%
\def\set@footnotewidth{%
\hsize\columnwidth
\linewidth\hsize
}%
\def\set@footnotewidth@ii{%
\hsize\textwidth
\advance\hsize\columnsep
\divide\hsize\tw@
\advance\hsize-\columnsep
\linewidth\hsize
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Floats}
%
% \subsubsection{Usage notes}%
% We extend the \LaTeX\ kernel for three purposes:
% \begin{enumerate}
%
% \item
% When the \cmd\footnote\ command is used within the
% scope of a float, we do as \env{minipage} does.
%
% \item
% We provide a mechanism to write floats out to an external
% stream for temporary storage (deferred floats).
%
% \item
% We provide mechanism for placing a float \texttt{here}
% invariably, that is, floats are unfloated.
% This mechanism is used to read the external stream mentioned above.
%
% \end{enumerate}
%
% To use these mechanisms, the document class should
% define a float, say, \env{figure} as per usual, and in addition:
% \begin{enumerate}
%
% \item
% Optionally define an alternative, say \env{figure@write} as follows:
% \begin{verbatim}
%\newenvironment{figure@write}{%
% \write@float{figure}%
%}{%
% \endwrite@float
%}%
% \end{verbatim}
% That is, the alternative environment executes \cmd\write@float\
% instead of \cmd\@float.
% Note that this step is not needed if the float environment
% is defined in the simple way of \file{classes.dtx}.
% However, an environment like \env{longtable} will require it.
%
% \item
% Install into \cmd\AtBeginDocument\ a call to \cmd\do@if@floats,
% with the float name and an appropriate file extension as its arguments.
% \begin{verbatim}
%\AtBeginDocument{\do@if@floats{figure}{.fgx}}%
% \end{verbatim}
%
% \item
% Optionally define a text entity \cmd\figuresname\ that will
% be the text of the head that is set over the
% deferred floats.
% If not defined, there will be no head.
%
% \item
% Optionally define a user-level command to allow
% the document to determine where the figures are printed out
% (default is to print at end of document). E.g.,
% \begin{verbatim}
%\newcommand\printfigures{\print@float{figure}}%
% \end{verbatim}
% \item
% Install into \cmd\appdef\cmd\class@enddocumenthook\ a call to \cmd\printfigures,
% or, if the latter is not defined, as follows:
% \begin{verbatim}
%\appdef\class@enddocumenthook{\print@float{figure}}%
% \end{verbatim}
% Note that installing this command into \cmd\AtBeginDocument
% is best done earlier than calls that assume the last page of
% the document is at hand.
%
% \end{enumerate}
%
% \subsubsection{Robustifying fragile commands}%
% Certain of \LaTeX's commands cannot be written out to a file or appear within a \cmd\mark\ command argument
% because they do calculations during expansion.
% We provide for a little help, but without changing the meanings of these commands.
%
% \begin{macro}{\addtocontents}
%
% \begin{macrocode}
\def\addtocontents#1#2{%
\protected@write\@auxout{%
\let \label \@gobble \let \index \@gobble \let \glossary \@gobble
\def\({\string\(}%
\def\){\string\)}%
\def\\{\string\\}%
}{\string \@writefile {#1}{#2}}%
}%
% \end{macrocode}
%
% \end{macro}
%
% \subsubsection{Preparing for the \classname{hyperref package}}%
%
% \begin{macro}{\addcontentsline}
% \begin{macro}{\contentsline}
% The \classname{hyperref} package assumes that the \cmd\contentsline\ command will be given four arguments.
% Therefore it cannot successfully process a \filename{.toc} file that had been written by standard \LaTeX.
% We fix things up by always writing that fourth argument and by supplying a \cmd\contentsline\ command that
% can read them.
%
% We also give the \cmd\newlabel\ command's second argument five tokens.
%
% This means that a document class that uses this package will itself have trouble taking over a \filename{.toc} file that was written by standard \LaTeX. Sigh.
% \begin{macrocode}
\def\addcontentsline#1#2#3{%
\addtocontents{#1}{%
\protect\contentsline{#2}{#3}{\thepage}{}%
}%
}%
\def\contentsline#1#2#3#4{%
\csname l@#1\endcsname{#2}{#3}%
}%
\def\label#1{%
\@bsphack
\protected@write\@auxout{}{%
\string\newlabel{#1}{{\@currentlabel}{\thepage}{}{}{}}%
}%
\@esphack
}%
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \subsubsection{Footnotes within floats, unfloating floats, float font}%
%
% \begin{macro}{\caption}
% DPC: Er a bit of a hack, but seems best way of supporting normal
% \LaTeX\ syntax at this point: If a caption is used below a table,
% then put out the footnotes before the caption.
% \changes{v4.0beta 2}{1999/06/20}
% {Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time,
% since \classname{hyperref} clobbers \cs{caption}.}
% \begin{macrocode}
\appdef\class@documenthook{%
\prepdef\caption{\minipagefootnote@here}%
}%
% \end{macrocode}
%
% Note on \classname{hyperref} compatability:
% this change to the \cmd\caption\ command is compatible with the
% ``Automated \LaTeX\ hypertext cross-references'' patches of
% that package.
%
% All the same, I think Sebastian's changes to \cmd\caption\ and \cmd\@caption\
% could bear with some improvement.
% The following implementation requires knowing only the pattern part of the
% \cmd\@caption\ macro:
%\begin{verbatim}
%\def\caption{%
% \H@refstepcounter\@captype
% \hyper@makecurrent{\@captype}%
% \@dblarg{\H@caption\@captype}%
%}%
%\def\H@caption#1[#2]#3{%
% \@caption{#1}[#2]{%
% \ifHy@nesting
% \hyper@@anchor{\@currentHref}{#3}%
% \else
% \hyper@@anchor{\@currentHref}{\relax}#3%
% \fi
% }%
%}%
%
%\end{verbatim}
%
% \end{macro}
%
% \begin{macro}{\minipagefootnote@init}
% \begin{macro}{\minipagefootnote@here}
% \begin{macro}{\minipagefootnote@foot}
% \begin{macro}{\minipagefootnote@pick}
% \begin{macro}{\minipagefootnote@drop}
% Procedure to deal with footnotes accumulated within a minipage environment.
% These procedures encapsulate all uses of the \cmd\@mpfootins\ box.
%
%
% Note: \cmd\minipagefootnote@here\ must \emph{not} be executed within the MVL!
% \begin{macrocode}
\def\minipagefootnote@init{%
\setbox\@mpfootins\box\voidb@x
}%
\def\minipagefootnote@pick{%
\global\setbox\@mpfootins\vbox\bgroup
\unvbox\@mpfootins
}%
\def\minipagefootnote@drop{%
\egroup
}%
\def\minipagefootnote@here{%
\par
\@ifvoid\@mpfootins{}{%
\vskip\skip\@mpfootins
\fullinterlineskip
\@ifinner{%
\vtop{\unvcopy\@mpfootins}%
{\setbox\z@\lastbox}%
}{}%
\unvbox\@mpfootins
}%
}%
\def\minipagefootnote@foot{%
\@ifvoid\@mpfootins{}{%
\insert\footins\bgroup\unvbox\@mpfootins\egroup
}%
}%
\def\endminipage{%
\par
\unskip
\minipagefootnote@here
\@minipagefalse %% added 24 May 89
\color@endgroup
\egroup
\expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\floats@sw}
% The Boolean \cmd\floats@sw\ signifies that floats are to be floated;
% if false, that floats are to be deferred to the end of the document.
% Note that the state of this Boolean is to be changed by
% the document class in response to user-selected options.
% Here we display model code that assigns a default value
% at \cmd\AtBeginDocument\ time.
% \begin{verbatim}
%\AtBeginDocument{%
% \@ifxundefined\floats@sw{\@booleantrue\floats@sw}{}%
%}%
% \end{verbatim}
% \end{macro}
%
% \begin{macro}{\@xfloat}
% \begin{macro}{\@mpmakefntext}
% The float start-code is redefined to set up footnotes in the style of minipage.
% Also, the \cmd\floats@sw\ Boolean informs us that floats are to be
% all placed \texttt{here}.
% Note that, to protect against the Boolean being undefined
% at this late hour, we default it globally to true.
%
% \changes{v4.0beta 2}{1999/06/20}
% {AO: Removed superfluous \cs{def}s, changed to using \cs{floats@sw} as the flag.
% Also stopped using DPC's \cs{if@twocolumn} flag: using \cs{floats@sw} instead.
% Also added \cs{par}\cs{vskip}\cs{z@skip} after the \cs{minipagefootnotes}
% so that the float box would have zero depth like the kernel one.
% }
% \changes{v4.0beta 3}{1999/11/13}
% {bug fix 110. Install hooks for endfloats processing}
% \changes{v4.0beta 4}{2000/04/10}
% {bug fix 127. Floats placed [h] to allow page breaks}
% \changes{v4.0beta 4}{2000/05/19}
% {bug fix 224. Hyperref compatability.}
% \changes{v4.0beta 5}{2000/11/16}
% {bug fix 221. Remove samepage command from @xfloat@prep: If the float can break over pages, we want better control.}
%FIXME: why does hyperref override \cmd\@xfootnotenext?
%
% \begin{macrocode}
\let\@xfloat@LaTeX\@xfloat
\def\@xfloat#1[#2]{%
\@xfloat@prep
\@nameuse{fp@proc@#2}%
\@ifxundefined\floats@sw{\global\@booleantrue\floats@sw}{}%
\floats@sw{\@xfloat@LaTeX{#1}[#2]}{\@xfloat@anchored{#1}[]}%
}%
\def\@xfloat@prep{%
\let\footnote\footnote@latex
\def\@mpfn{mpfootnote}%
\def\thempfn{\thempfootnote}%
% \def\thefootnote{\thempfootnote}%
\c@mpfootnote\z@
\let\@footnotetext\@mpfootnotetext
\let\H@@footnotetext\@mpfootnotetext
\let\@makefntext\@mpmakefntext
% \samepage
}%
\appdef\class@documenthook{%
\let\footnote@latex\footnote
}%
%\def\fp@proc@h{\@booleanfalse\floats@sw}%
%\def\fp@proc@H{\@booleanfalse\floats@sw}%
\def\@xfloat@anchored#1[#2]{%
\def\@captype{#1}%
\begin@float@pagebreak
%\vbox\bgroup
\let\end@float\end@float@anchored
\let\end@dblfloat\end@float@anchored
% do as \@xfloat does:
\hsize\columnwidth
\@parboxrestore
\@floatboxreset
\minipagefootnote@init
% \pagegrid@col\@ne % Klootch to avoid processing as a float
}%
\def\end@float@anchored{%
\minipagefootnote@here
\par\vskip\z@skip %% \par\vskip\z@ added 15 Dec 87
%\egroup
\par
\end@float@pagebreak
}%
\def\begin@float@pagebreak{\par\addvspace\intextsep}%
\def\end@float@pagebreak{\par\addvspace\intextsep}%
\def\@mpmakefntext#1{%
\parindent=1em
\noindent
\hb@xt@1em{\hss\@makefnmark}%
#1%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Writing floats out to a file}%
%
% \begin{macro}{\do@if@floats}
% The procedure \cmd\do@if@floats\ should be executed at
% \cmd\AtBeginDocument\ time, and arranges to write out
% the floats of the given class to a temporary file, to be
% read back later (deferred floats),
% given that \cmd\floats@sw\ is false.
% Note that, to protect against the Boolean being undefined
% at this late hour, we default it globally to true.
% \begin{macrocode}
\def\do@if@floats#1#2{%
\@ifxundefined\floats@sw{\global\@booleantrue\floats@sw}{}%
\floats@sw{}{%
% \end{macrocode}
% Open the stream to save out the document's floats of this class.
% \begin{macrocode}
\expandafter\newwrite
\csname#1write\endcsname
\expandafter\def
\csname#1@stream\endcsname{\jobname#2}%
\expandafter\immediate
\expandafter\openout
\csname#1write\endcsname
\csname#1@stream\endcsname\relax
% \end{macrocode}
% Swap environments.
% If the class writer has defined, e.g., \env{figure@write},
% then we use this as the procedure to execute for writing
% the float out to the external stream.
% Otherwise, the replacement of \cmd\@float\ by \cmd\write@float\
% should do the right thing for float environments defined
% in the simple way of \classname{classes.dtx}.
% \begin{macrocode}
\@ifxundefined\@float@LaTeX{%
\let\@float@LaTeX\@float
\let\@dblfloat@LaTeX\@dblfloat
\let\@float\write@float
\let\@dblfloat\write@floats
}{}%
\let@environment{#1@float}{#1}%
\let@environment{#1@floats}{#1*}%
\@ifxundefined@cs{#1@write}{}{%
\let@environment{#1}{#1@write}%
}%
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\print@float}
% The procedure \cmd\print@float\ prints out the
% deferred floats.
% \changes{v4.0beta 2}{1999/06/20}
% {only execute if there really were floats of the given type}
% \changes{v4.0beta 3}{1999/11/13}
% {*-form mandates pagebreak at each float;
% only print section head if there is something there.}
% \changes{v4.0beta 4}{2000/05/23}
% {Allow things to break over pages by setting array@default.}
%
% \begin{macrocode}
\def\triggerpar{\leavevmode\@@par}%
\def\oneapage{\def\begin@float@pagebreak{\newpage}\def\end@float@pagebreak{\newpage}}%
\def\print@float#1#2{%
\@ifxundefined@cs{#1write}{}{%
\begingroup
\@booleanfalse\floats@sw
#2%
\raggedbottom
\def\array@default{v}% floats must
\let\@float\@float@LaTeX
\let\@dblfloat\@dblfloat@LaTeX
\let\trigger@float@par\triggerpar
\let@environment{#1}{#1@float}%
\let@environment{#1*}{#1@floats}%
\expandafter\prepdef\csname#1\endcsname{\trigger@float@par}%
\expandafter\prepdef\csname#1*\endcsname{\trigger@float@par}%
\@namedef{fps@#1}{h!}%
\expandafter\immediate
\expandafter\closeout
\csname#1write\endcsname
\everypar{%
\global\let\trigger@float@par\relax
\global\everypar{}\setbox\z@\lastbox
\@ifxundefined@cs{#1sname}{}{%
\begin@float@pagebreak
\expandafter\section
\expandafter*%
\expandafter{%
\csname#1sname\endcsname
}%
}%
}%
\input{\csname#1@stream\endcsname}%
\endgroup
\global\expandafter\let\csname#1write\endcsname\relax
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\write@float}
% \begin{macro}{\write@floats}
% \begin{macro}{\write@@float}
% Handles the case where the name of the float is the same as
% that of the stream. Note that
% \env{longtable} does \emph{not} fit this case.
% Note also: \cmd\write@float\ is \emph{not} a user-level environment
% therefore it is properly not defined with \cmd\newenvironment.
% \begin{macrocode}
\def\write@float#1{\write@@float{#1}{#1}}%
\def\endwrite@float{\@Esphack}%
\def\write@floats#1{\write@@float{#1*}{#1}}%
\def\endwrite@floats{\@Esphack}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\write@@float}
% \changes{v4.0beta 2}{1999/06/20}
% {AO: Fixed spurious \texttt{CR} and (return) characters in output file.
% Also, if the document did not have the \cs{end}\texttt{figure} on a line of its own,
% the macro wouldn't work. Fixed.}
% \begin{macrocode}
\def\write@@float#1#2{%
\ifhmode
\@bsphack
\fi
\chardef\@tempc\csname#2write\endcsname
\toks@{\begin{#1}}%
\def\@tempb{#1}%
\expandafter\let\csname end#1\endcsname\endwrite@float
\catcode`\^^M\active
\@makeother\{\@makeother\}\@makeother\%
\write@floatline
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\write@floatline}
% \begin{macro}{\@write@floatline}
% \begin{macro}{\float@end@tag}
% The procedure \cmd\write@floatline\ only parses, and passes
% its result to \cmd\@write@floatline, which
% writes the line to output, then tests the line
% for the \cmd\end\arg{float} tokens with
% aid of the \cmd\float@end@tag\ procedure.
% \begin{macrocode}
\begingroup
\catcode`\[\the\catcode`\{\catcode`\]\the\catcode`\}\@makeother\{\@makeother\}%
\gdef\float@end@tag#1\end{#2}#3\@nul[%
\def\@tempa[#2]%
\@ifx[\@tempa\@tempb][\end[#2]][\write@floatline]%
]%
\obeylines%
\gdef\write@floatline#1^^M[%
\begingroup%
\newlinechar`\^^M%
\toks@\expandafter[\the\toks@#1]\immediate\write\@tempc[\the\toks@]%
\endgroup%
\toks@[]%
\float@end@tag#1\end{}\@nul%
]%
\endgroup
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Counters}
% The following definitions override those of the \LaTeX\ kernel,
% providing for a greater range of inputs.
% \begin{macrocode}
\def\@alph#1{\ifcase#1\or a\or b\or c\or d\else\@ialph{#1}\fi}
% \end{macrocode}
%
% \begin{macrocode}
\def\@ialph#1{\ifcase#1\or \or \or \or \or e\or f\or g\or h\or i\or j\or
k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or
y\or z\or aa\or bb\or cc\or dd\or ee\or ff\or gg\or hh\or ii\or jj\or
kk\or ll\or mm\or nn\or oo\or pp\or qq\or rr\or ss\or tt\or uu\or
vv\or ww\or xx\or yy\or zz\else\@ctrerr\fi}
% \end{macrocode}
%
%
% \subsection{Customization of Sections}%
%
% Patch the standard \LaTeX\ sectioning procedure to:
%\begin{itemize}
%\item
% Allow a sectioning command to trigger the title page, or more generally
% to recognize that it is the first object in the document,
% so we headpatch \cmd\@startsection.
%
%\item
% Allow a tail command in |#6| to uppercase the title, so we retain
% DPC's braces.
%
%\item
% Allow each type of sectioning command to format its number differently,
% so we generalize \cmd\@seccntformat.
%
%\item
% Allow each type of sectioning command to format its argument differently,
% so we generalize \cmd\@hangfrom.
%
%\item
% Allow the starred form of the command to
% mark (the running head) and
% make an entry in the TOC,
% so we put \cmd\@ssect\ on the same footing as \cmd\@sect.
%
% Note that the tokens passed to the TOC now are \emph{not}
% the optional argument of the command, but the required.
% This means that the user can no longer use the former
% to put variant content in to the TOC as the Manual says.
%
% Instead, the optional argument is used to put an alternative
% title into the running headers, a better choice.
%
%\end{itemize}
%
% \begin{macro}{\@startsection}
% Patch a head hook into the basic sectioning command.
% Treat \cmd\@sect\ and \cmd\@ssect\ on an equal footing:
% now their pattern parts are identical.
% \begin{macrocode}
\def\@startsection#1#2#3#4#5#6{%
\@startsection@hook
\if@noskipsec \leavevmode \fi
\par
\@tempskipa #4\relax
\@afterindenttrue
\ifdim \@tempskipa <\z@
\@tempskipa -\@tempskipa \@afterindentfalse
\fi
\if@nobreak
\everypar{}%
\else
\addpenalty\@secpenalty\addvspace\@tempskipa
\fi
\@ifstar
{\@dblarg{\@ssect@ltx{#1}{#2}{#3}{#4}{#5}{#6}}}%
{\@dblarg{\@sect@ltx {#1}{#2}{#3}{#4}{#5}{#6}}}%
}%
\def\@startsection@hook{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sect}
% When defining \cmd\@svsec, do not expand \cmd\@seccntformat.
% Put brace characters back where they were before David Carlisle got at them
% (i.e., as if \cmd\@hangfrom\ had two arguments).
% Protect the mark mechanism from an undefined meaning.
% Pass |#8| to the TOC instead of |#7|.
% Remove \cmd\relax\ from the replacement part of \cmd\@svsec.
%
% The procedure \cmd\@hangfrom\ and \cmd\@runin@to\ can
% be used to process the argument of the head.
% The head can define, e.g., \cmd\@hangfrom@section, to
% do its own processing.
%
% In using \cmd\H@refstepcounter\ in place of \cmd\refstepcounter\ we rely on
% either loading before any package that patches the latter, or
% the convention that the former is the original \LaTeX\ procedure.
%
% \begin{macrocode}
\class@info
{Repairing broken LateX \string\@sect}%
\def\@sect@ltx#1#2#3#4#5#6[#7]#8{%
\@ifnum{#2>\c@secnumdepth}{%
\def\H@svsec{\phantomsection}%
\let\@svsec\@empty
}{%
\H@refstepcounter{#1}%
\def\H@svsec{%
\phantomsection
}%
\protected@edef\@svsec{{#1}}%
\@ifundefined{@#1cntformat}{%
\prepdef\@svsec\@seccntformat
}{%
\expandafter\prepdef
\expandafter\@svsec
\csname @#1cntformat\endcsname
}%
}%
\@tempskipa #5\relax
\@ifdim{\@tempskipa>\z@}{%
\begingroup
\interlinepenalty \@M
#6{%
\@ifundefined{@hangfrom@#1}{\@hang@from}{\csname @hangfrom@#1\endcsname}%
{\hskip#3\relax\H@svsec}{\@svsec}{#8}%
}%
\@@par
\endgroup
\@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
\addcontentsline{toc}{#1}{%
\@ifnum{#2>\c@secnumdepth}{%
\protect\numberline{}%
}{%
\protect\numberline{\csname the#1\endcsname}%
}%
#8}%
}{%
\def\@svsechd{%
#6{%
\@ifundefined{@runin@to@#1}{\@runin@to}{\csname @runin@to@#1\endcsname}%
{\hskip#3\relax\H@svsec}{\@svsec}{#8}%
}%
\@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
\addcontentsline{toc}{#1}{%
\@ifnum{#2>\c@secnumdepth}{%
\protect\numberline{}%
}{%
\protect\numberline{\csname the#1\endcsname}%
}%
#8}%
}%
}%
\@xsect{#5}%
}%
\def\@hang@from#1#2#3{\@hangfrom{#1#2}#3}%
\def\@runin@to #1#2#3{#1#2#3}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ssect}
% Put brace characters back where they were before David Carlisle got at them
% (as if \cmd\@hangfrom\ has two arguments).
% Possibly set a mark.
% Make a TOC entry.
%
% Note that, for compatability with the \classname{hyperref} package, we
% need to provide the interface required by that package
% (actually required by \file{pdfmark.def} and \file{nameref.sty}),
% namely
% the definition of \cmd\@currentlabelname\ (but now removed),
% the insertion of the procedure \cmd\Sectionformat\ (but why is this needed?), and
% the call to \cmd\phantomsection\ (which must precede the call to \cmd\addcontentsline).
% We also have to sidestep the patch to \cmd\@ssect\ in that same file, therefore
% we use a different control sequence name in the call from \cmd\@startsection.
% \changes{v4.0beta 3}{1999/11/13}
% {Bug 116: Hyperref compatability}
% \changes{v4.0rc3b}{2001/07/13}
% {Bug 404: Hyperref compatability}
% \begin{macrocode}
\def\@ssect@ltx#1#2#3#4#5#6[#7]#8{%
% \def\@currentlabelname{#8}%
\def\H@svsec{\phantomsection}%
\@tempskipa #5\relax
\@ifdim{\@tempskipa>\z@}{%
\begingroup
\interlinepenalty \@M
#6{%
\@ifundefined{@hangfroms@#1}{\@hang@froms}{\csname @hangfroms@#1\endcsname}%
% {\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}%
{\hskip#3\relax\H@svsec}{#8}%
}%
\@@par
\endgroup
\@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
\addcontentsline{toc}{#1}{\protect\numberline{}#8}%
}{%
\def\@svsechd{%
#6{%
\@ifundefined{@runin@tos@#1}{\@runin@tos}{\csname @runin@tos@#1\endcsname}%
% {\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}%
{\hskip#3\relax\H@svsec}{#8}%
}%
\@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
\addcontentsline{toc}{#1}{\protect\numberline{}#8}%
}%
}%
\@xsect{#5}%
}%
\def\@hang@froms#1#2{#1#2}%
\def\@runin@tos #1#2{#1#2}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\init@documenthook}
% Document classes that incorporate this package will be \classname{hyperref}-savvy.
% (To accomplish this, we ensure that \cmd\hyperanchor\ and \cmd\hyper@last\ are both defined.)
% Being \classname{hyperref}-savvy levels some requirements on us, but the benefits are many.
%
% One is that the TOC will not get amnesia and require a full set of three typesetting runs before its formatting is stable.
% Instead, only two runs are required: the first updates the auxiliary file, the second the TOC.
% However, the formatting of the document does not change.
%
% Another aspect of being \classname{hyperref}-savvy is that the syntax of commands in the \filename{.aux} file will now change
% if \classname{hyperref} is turned on or off.
%
% Note that \cmd\hyper@anchorstart\ and \cmd\hyper@anchorend\ constitute the programming interface
% for a hypertext anchor (the target of a hypertext link); \cmd\hyper@linkstart\ and \cmd\hyper@linkend\
% are the interface for a hypertext link.
% \begin{macrocode}
\appdef\init@documenthook{%
\providecommand\phantomsection{}%
%\@ifx{\Sectionformat\@undefined}{\let\Sectionformat\@firstoftwo}{}%
\providecommand\hyper@anchor[1]{}%
\providecommand\hyper@last{}%
\providecommand\Hy@raisedlink[1]{#1}%
\providecommand\hyper@anchorstart[1]{}%
\providecommand\hyper@anchorend{}%
\providecommand\hyper@linkstart[2]{}%
\providecommand\hyper@linkend{}%
}%
\let\H@refstepcounter\refstepcounter
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sec@upcase}
% Upper case for sections (optional upper case items). These are
% created so that some headings can be toggled between mixed case and
% upper case readily.
% Headings that might be changed can be wrapped in the style file in
% \cmd\sec@upcase\arg{text} constructs;
% the expansion of \cmd\sec@upcase\ is
% controlled here. It is \cmd\relax\ by default (mixed case heads), and
% can easily be changed to \cmd\uppercase\ if desired.
% If mixed-case headings are wanted by the editor, authors {\em must}
% supply mixed case text, although this is what authors should be doing
% anyway.
% (Mixed can be converted to upper,
% but the reverse transformation cannot be automated.)
%
% The following setting gives the \LaTeX\ default.
% \begin{macrocode}
\def\sec@upcase#1{\relax{#1}}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Patch the \env{tabular} and \env{array} Environments}
%
% \begin{macro}{\endtabular}
% \begin{macro}{\endarray}
% We headpatch the begin processing and tailpatch the end processing
% of the \env{tabular} and \env{array} environments.
% A document class can define these hooks as needed.
%
% We proceed with care to make further patches to
% support tabulars that break over pages.
% Our patches will not necessarily be effective for
% other packages that replace the \LaTeX\ \env{array} and \env{tabular}
% environments. I know of none that do so.
% \begin{macrocode}
\appdef\class@documenthook{%
\@ifpackageloaded{array}{\switch@array}{\switch@tabular}%
\prepdef\endtabular{\endtabular@hook}%
\@provide\endtabular@hook{}%
\prepdef\endarray{\endarray@hook}%
\@provide\endarray@hook{}%
\providecommand\array@hook{}%
% \end{macrocode}
% Install, effectively, a head patch to \cmd\tabular.
% In order to avoid interference from, e.g., the \classname{array} package,
% we must perform this patch only \emph{after} packages load.
% \changes{v4.0beta 3}{1999/11/13}
% {Bug 130. Interference from array package}
% \begin{macrocode}
\prepdef\@tabular{\tabular@hook}%
\@provide\tabular@hook{}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\switch@tabular}
% \begin{macro}{\switch@array}
% The two procedures \cmd\switch@tabular\ and \cmd\switch@array\
% apply needed patches to the various tabular procedures,
% the former applying to the \LaTeX\ kernel, the latter to the
% required \classname{array} package (and to the number of other
% required packages that load it).
%
% \begin{macrocode}
\def\switch@tabular{%
\let\@array@sw\@array@sw@array
\@ifx{\@array\@array@LaTeX}{%
\@ifx{\multicolumn\multicolumn@LaTeX}{%
\@ifx{\@tabular\@tabular@LaTeX}{%
\@ifx{\@tabarray\@tabarray@LaTeX}{%
\@ifx{\array\array@LaTeX}{%
\@ifx{\endarray\endarray@LaTeX}{%
\@ifx{\endtabular\endtabular@LaTeX}{%
\@ifx{\@mkpream\@mkpream@LaTeX}{%
\@ifx{\@addamp\@addamp@LaTeX}{%
\@ifx{\@arrayacol\@arrayacol@LaTeX}{%
\@ifx{\@tabacol\@tabacol@LaTeX}{%
\@ifx{\@arrayclassz\@arrayclassz@LaTeX}{%
\@ifx{\@tabclassiv\@tabclassiv@LaTeX}{%
\@ifx{\@arrayclassiv\@arrayclassiv@LaTeX}{%
\@ifx{\@tabclassz\@tabclassz@LaTeX}{%
\@ifx{\@classv\@classv@LaTeX}{%
\@ifx{\hline\hline@LaTeX}{%
\@ifx{\@tabularcr\@tabularcr@LaTeX}{%
\@ifx{\@xtabularcr\@xtabularcr@LaTeX}{%
\@ifx{\@xargarraycr\@xargarraycr@LaTeX}{%
\@ifx{\@yargarraycr\@yargarraycr@LaTeX}{%
\true@sw
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
{%
\class@info{Patching LaTeX tabular.}%
}{%
\class@info{Unrecognized LaTeX tabular. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\let\@array\@array@ltx
\let\multicolumn\multicolumn@ltx
\let\@tabular\@tabular@ltx
\let\@tabarray\@tabarray@ltx
\let\array\array@ltx
\let\endarray\endarray@ltx
\let\endtabular\endtabular@ltx
\let\@mkpream\@mkpream@ltx
\let\@addamp\@addamp@ltx
\let\@arrayacol\@arrayacol@ltx
\let\@tabacol\@tabacol@ltx
\let\@arrayclassz\@arrayclassz@ltx
\let\@tabclassiv\@tabclassiv@ltx
\let\@arrayclassiv\@arrayclassiv@ltx
\let\@tabclassz\@tabclassz@ltx
\let\@classv\@classv@ltx
\let\hline\hline@ltx
\let\@tabularcr\@tabularcr@ltx
\let\@xtabularcr\@xtabularcr@ltx
\let\@xargarraycr\@xargarraycr@ltx
\let\@yargarraycr\@yargarraycr@ltx
}%
\def\switch@array{%
\let\@array@sw\@array@sw@LaTeX
\@ifx{\@array\@array@array}{%
\@ifx{\@tabular\@tabular@array}{%
\@ifx{\@tabarray\@tabarray@array}{%
\@ifx{\array\array@array}{%
\@ifx{\endarray\endarray@array}{%
\@ifx{\endtabular\endtabular@array}{%
\@ifx{\@mkpream\@mkpream@array}{%
\@ifx{\@classx\@classx@array}{%
\@ifx{\insert@column\insert@column@array}{%
\@ifx{\@arraycr\@arraycr@array}{%
\@ifx{\@xarraycr\@xarraycr@array}{%
\@ifx{\@xargarraycr\@xargarraycr@array}{%
\@ifx{\@yargarraycr\@yargarraycr@array}{%
\true@sw
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}{%
\class@info{Patching array package.}%
}{%
\class@info{Unrecognized array package. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\let\@array \@array@array@new
\let\@@array \@array % Cosi fan tutti
\let\@tabular \@tabular@array@new
\let\@tabarray \@tabarray@array@new
\let\array \array@array@new
\let\endarray \endarray@array@new
\let\endtabular\endtabular@array@new
\let\@mkpream \@mkpream@array@new
\let\@classx \@classx@array@new
\let\@arrayacol\@arrayacol@ltx
\let\@tabacol \@tabacol@ltx
\let\insert@column\insert@column@array@new
\expandafter\let\csname endtabular*\endcsname\endtabular % Cosi fan tutti
\let\@arraycr \@arraycr@new
\let\@xarraycr \@xarraycr@new
\let\@xargarraycr\@xargarraycr@new
\let\@yargarraycr\@yargarraycr@new
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@array@sw}
% The Boolean \cmd\@array@sw\ must be different depending on
% whether the \classname{array} package is loaded.
% \begin{macrocode}
\def\@array@sw@LaTeX{\@ifx{\\\@tabularcr}}%
\def\@array@sw@array{\@ifx{\d@llarbegin\begingroup}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabular}
% We provide the old versions of \cmd\@tabular\ along with the respective new versions.
% The change here is to avoid committing to LR mode. That will be done later (as late as possible, naturally).
% \begin{macrocode}
\def\@tabular@LaTeX{%
\leavevmode
\hbox\bgroup$%
\let\@acol\@tabacol
\let\@classz\@tabclassz
\let\@classiv\@tabclassiv
\let\\\@tabularcr
\@tabarray
}%
\def\@tabular@ltx{%
\let\@acoll\@tabacoll
\let\@acolr\@tabacolr
\let\@acol\@tabacol
\let\@classz\@tabclassz
\let\@classiv\@tabclassiv
\let\\\@tabularcr
\@tabarray
}%
\def\@tabular@array{%
\leavevmode
\hbox\bgroup$%
\col@sep\tabcolsep
\let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@tabarray
}%
\def\@tabular@array@new{%
\let\@acoll\@tabacoll
\let\@acolr\@tabacolr
\let\@acol\@tabacol
\let\col@sep\@undefined
\let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@tabarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabarray}
% Here we provide old and new versions of the \cmd\@tabarray\ procedure.
% The change here is to parametrize the default vertical alignment,
% which is 'c' in standard \LaTeX.
% Under some circumstances, we want to change this to, say, 'v'.
%
% FIXME: must decouple \env{array} and \env{tabular}.
% \begin{macrocode}
\def\@tabarray@LaTeX{%
\m@th\@ifnextchar[\@array{\@array[c]}%
}%
\def\@tabarray@ltx{%
\m@th\@ifnextchar[\@array{\expandafter\@array\expandafter[\array@default]}%
}%
\def\@tabarray@array{%
\@ifnextchar[{\@@array}{\@@array[c]}%
}%
\def\@tabarray@array@new{%
\@ifnextchar[{\@@array}{\expandafter\@@array\expandafter[\array@default]}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabularcr}
% \begin{macro}{\@tbpen}
% \begin{macro}{\@tabularcr}
% \begin{macro}{\@xtabularcr}
% \begin{macro}{\@xargarraycr}
% \begin{macro}{\@yargarraycr}
% \begin{macro}{\@arraycr}
% \begin{macro}{\@xarraycr}
% We provide for the \cmd\\ command within \env{tabular} to provide control over page breaking, just the same as
% that of \env{eqnarray}.
%
% The count register \cmd\intertabularlinepenalty\ is similar to \cmd\interdisplaylinepenalty: it is the penalty
% associated with each row of a tabular. When it is set to \cmd\@M, the tabular will cleave together.
%
% The count register \cmd\@tbpen\ is similar to \cmd\@eqpen: it memorizes the penalty to use after the current tabular row.
% If the \cmd\\ command is in its star form, then \cmd\@eqpen\ is set to \cmd\@M.
%
% We append code to \cmd\samepage\ so that a tabular within its scope will cleave together.
%
% We keep the standard definition of \cmd\@tabularcr\ in \cmd\@tabularcr@LaTeX\ for reference,
% and provide a new definition that works like \cmd\@eqncr: it sets \cmd\@tbpen\ to \cmd\@M\ if the star was given.
%
% We also provide new versions of \cmd\@xtabularcr, \cmd\@xargarraycr, and \cmd\@yargarraycr, all of which invoke \cmd\@tbpen.
%
% The \cmd\switch@tabular\ procedure switches in the new definitions.
% \begin{macrocode}
\newcount\intertabularlinepenalty
\intertabularlinepenalty=100
\newcount\@tbpen
\appdef\samepage{\intertabularlinepenalty\@M}%
\def\@tabularcr@LaTeX{{\ifnum 0=`}\fi \@ifstar \@xtabularcr \@xtabularcr}%
\def\@tabularcr@ltx{{\ifnum 0=`}\fi \@ifstar {\global \@tbpen \@M \@xtabularcr }{\global \@tbpen \intertabularlinepenalty \@xtabularcr }}%
\def\@xtabularcr@LaTeX{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr }}%
\def\@xtabularcr@ltx{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr \noalign {\penalty \@tbpen }}}%
\def\@xargarraycr@LaTeX#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr}%
\def\@xargarraycr@ltx#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr \noalign {\penalty \@tbpen }}%
\def\@yargarraycr@LaTeX#1{\cr \noalign {\vskip #1}}%
\def\@yargarraycr@ltx#1{\cr \noalign {\penalty \@tbpen \vskip #1}}%
% \end{macrocode}
%
% If the \classname{array} package has been loaded, we must alter the meanings of
% \cmd\@arraycr, \cmd\@xarraycr, \cmd\@xargarraycr, and \cmd\@yargarraycr.
% In this case, it is \cmd\switch@array\ that switches in the new definitions.
% \begin{macrocode}
\def\@arraycr@array{%
\relax
\iffalse{\fi\ifnum 0=`}\fi
\@ifstar \@xarraycr \@xarraycr
}%
\def\@arraycr@new{%
\relax
\iffalse{\fi\ifnum 0=`}\fi
\@ifstar {\global \@tbpen \@M \@xarraycr }{\global \@tbpen \intertabularlinepenalty \@xarraycr }%
}%
\def\@xarraycr@array{%
\@ifnextchar [%]
\@argarraycr {\ifnum 0=`{}\fi\cr}%
}%
\def\@xarraycr@new{%
\@ifnextchar [%]
\@argarraycr {\ifnum 0=`{}\fi\cr \noalign {\penalty \@tbpen }}%
}%
\def\@xargarraycr@array#1{%
\unskip
\@tempdima #1\advance\@tempdima \dp\@arstrutbox
\vrule \@depth\@tempdima \@width\z@
\cr
}%
\def\@xargarraycr@new#1{%
\unskip
\@tempdima #1\advance\@tempdima \dp\@arstrutbox
\vrule \@depth\@tempdima \@width\z@
\cr
\noalign {\penalty \@tbpen }%
}%
\def\@yargarraycr@array#1{%
\cr
\noalign{\vskip #1}%
}%
\def\@yargarraycr@new#1{%
\cr
\noalign{\penalty \@tbpen \vskip #1}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\array}
% We provide old and new versions of the \cmd\array\ procedure for both \LaTeX\ and the \classname{array} package.
% The change here is to accomodate the new procedures that will be called for the array boundaries, even
% though at present they are not special.
% A thought: here is where matrices can be readily accomodated.
% \begin{macrocode}
\def\array@LaTeX{%
\let\@acol\@arrayacol
\let\@classz\@arrayclassz
\let\@classiv\@arrayclassiv
\let\\\@arraycr
\let\@halignto\@empty
\@tabarray
}%
\def\array@ltx{%
\@ifmmode{}{\@badmath$}%
\let\@acoll\@arrayacol
\let\@acolr\@arrayacol
\let\@acol\@arrayacol
\let\@classz\@arrayclassz
\let\@classiv\@arrayclassiv
\let\\\@arraycr
\let\@halignto\@empty
\@tabarray
}%
\def\array@array{%
\col@sep\arraycolsep
\def\d@llarbegin{$}\let\d@llarend\d@llarbegin\gdef\@halignto{}%
\@tabarray
}
\def\array@array@new{%
\@ifmmode{}{\@badmath$}%
\let\@acoll\@arrayacol
\let\@acolr\@arrayacol
\let\@acol\@arrayacol
\let\col@sep\@undefined
\def\d@llarbegin{$}%
\let\d@llarend\d@llarbegin
\gdef\@halignto{}%
\@tabarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array}
% Here we provide old and new versions of \cmd\@array.
% The change here is to provide a convenient, flexible, and extensible
% mechanism for new vertical alignment options.
%
% Instead of testing the optional argument with \cmd\if, we
% use a dispatcher based on \cmd\csname.
%
% We also refrain from using \cmd\ialign, which would set
% the \cmd\tabskip\ to the wrong value.
%
% Finally, the procedure to set the \cmd\@arstrutbox\
% is broken out so that it can be patched.
% \begin{macrocode}
\def\@array@LaTeX[#1]#2{%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
\bgroup
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@}%
\@mkpream{#2}%
\edef\@preamble{%
\ialign \noexpand\@halignto
\bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\ifhmode \@preamerr\z@ \@@par\fi
\@preamble
}%
\def\@array@ltx[#1]#2{%
\@nameuse{@array@align@#1}%
\set@arstrutbox
\@mkpream{#2}%
\prepdef\@preamble{%
\tabskip\tabmid@skip
\@arstrut
}%
\appdef\@preamble{%
\tabskip\tabright@skip
\cr
\array@row@pre
}%
% \let\@startpbox\@@startpbox
% \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\tabskip\tableft@skip\relax
\ifhmode \@preamerr\z@ \@@par\fi
\everycr{}%
\expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
}%
%
\def\set@arstrutbox{%
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array@array}
%
% \begin{macrocode}
\def\@array@array[#1]#2{%
\@tempdima \ht \strutbox
\advance \@tempdima by\extrarowheight
\setbox \@arstrutbox \hbox{\vrule
\@height \arraystretch \@tempdima
\@depth \arraystretch \dp \strutbox
\@width \z@}%
\begingroup
\@mkpream{#2}%
\xdef\@preamble{\noexpand \ialign \@halignto
\bgroup \@arstrut \@preamble
\tabskip \z@ \cr}%
\endgroup
\@arrayleft
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
\bgroup
\let \@sharp ##\let \protect \relax
\lineskip \z@
\baselineskip \z@
\m@th
\let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble
}%
\def\@array@array@new[#1]#2{%
\@tempdima\ht\strutbox
\advance\@tempdima by\extrarowheight
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\@tempdima
\@depth \arraystretch\dp\strutbox
\@width \z@
}%
\begingroup
\@mkpream{#2}%
\xdef\@preamble{\@preamble}%
\endgroup
\prepdef\@preamble{%
\tabskip\tabmid@skip
\@arstrut
}%
\appdef\@preamble{%
\tabskip\tabright@skip
\cr
\array@row@pre
}%
\@arrayleft
\@nameuse{@array@align@#1}%
\m@th
\let\\\@arraycr
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@\baselineskip\z@
\tabskip\tableft@skip
\everycr{}%
\expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endarray}
% Here we provide old and new versions of \cmd\endarray.
% The change here is to use a single procedure to close
% out any array-like structure, namely \cmd\endarray@ltx.
% It merely closes out the \cmd\halign.
% \begin{macrocode}
\def\endarray@LaTeX{%
\crcr\egroup\egroup
}%
\def\endarray@ltx{%
\crcr\array@row@pst\egroup\egroup
}%
\def\endarray@array{%
\crcr \egroup \egroup \@arrayright \gdef\@preamble{}%
}%
\def\endarray@array@new{%
\crcr\array@row@pst\egroup\egroup % Same as \endarray@ltx
\@arrayright
\global\let\@preamble\@empty
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endtabular}
%
% \begin{macrocode}
\def\endtabular@LaTeX{%
\crcr\egroup\egroup $\egroup
}%
\def\endtabular@ltx{%
\endarray
}%
\def\endtabular@array{%
\endarray $\egroup
}%
\def\endtabular@array@new{%
\endarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{endtabular*}
% Here we provide a proper definition for the star-form of \enve{endtabular}.
% It is one of the enduring curiosities that the \LaTeX\ kernel continues to use
% dangerously and inappropriately ``optimized'' definitions for such commands.
% \begin{macrocode}
\@namedef{endtabular*}{\endtabular}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multicolumn}
%
% \begin{macrocode}
\long\def\multicolumn@LaTeX#1#2#3{%
\multispan{#1}\begingroup
\@mkpream{#2}%
\def\@sharp{#3}\set@typeset@protect
\let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
\@arstrut \@preamble\hbox{}\endgroup\ignorespaces
}%
\long\def\multicolumn@ltx#1#2#3{%
\multispan{#1}%
\begingroup
\@mkpream{#2}%
\def\@sharp{#3}%
\set@typeset@protect
%\let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
\@arstrut
\@preamble
\hbox{}%
\endgroup
\ignorespaces
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array@align@}
% \begin{macro}{\array@default}
% Here are the various procedures for the vertical alignment options.
% The change from standard \LaTeX\ is that we do not go into math mode
% in every case: only when required by \cmd\vcenter.
% Also, we use \cmd\aftergroup\ to close out the boxes and modes we have started.
% It requires only that each procedure issue exactly one unmatched \cmd\bgroup.
%
% We establish here the default vertical alignment.
% \begin{macrocode}
\def\@array@align@t{\leavevmode\vtop\bgroup}%
\def\@array@align@b{\leavevmode\vbox\bgroup}%
\def\@array@align@c{\leavevmode\@ifmmode{\vcenter\bgroup}{$\vcenter\bgroup\aftergroup$\aftergroup\relax}}%
\def\@array@align@v{%
\@ifmmode{%
\@badmath
\vcenter\bgroup
}{%
\@ifinner{%
$\vcenter\bgroup\aftergroup$
}{%
\@@par\bgroup
}%
}%
}%
\def\array@default{c}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\array@row@pre}
% \begin{macro}{\array@row@pst}
% \begin{macro}{\array@row@rst}
% The procedure \cmd\array@row@rst\ reestablishes a default context for
% an alignment, so that they can be nested.
% Any environment or procedure that alters the way alignments are formatted
% must patch this procedure to restore from that alteration.
% To start things off, we equate \cmd\@array@align@v\ to \cmd\@array@align@c,
% because it does not make sense to do the former in any context other
% than the MVL or in a list that will be unboxed onto the MVL.
% \begin{macrocode}
\def\array@row@rst{%
\let\@array@align@v\@array@align@c
}%
\def\array@row@pre{}%
\def\array@row@pst{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toprule}
% \begin{macro}{\colrule}
% \begin{macro}{\botrule}
% Default definitions for \cmd\toprule, \cmd\colrule, \cmd\botrule
% \begin{macrocode}
\newcommand\toprule{\tab@rule{\column@font}{\column@fil}{\frstrut}}%
\newcommand\colrule{\unskip\lrstrut\\\tab@rule{\body@font}{}{\frstrut}}%
\newcommand\botrule{\unskip\lrstrut\\\noalign{\hline@rule}{}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hline}
% \begin{macrocode}
\def\hline@LaTeX{%
\noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
\reserved@a\@xhline
}%
\def\hline@ltx{%
\noalign{%
\ifnum0=`}\fi
\hline@rule
\futurelet\reserved@a\@xhline
% \noalign ended in \@xhline
}%
\def\@xhline@unneeded{%
\say\reserved@a
\ifx\reserved@a\hline
\vskip\doublerulesep
\vskip-\arrayrulewidth
\fi
\ifnum0=`{\fi}%
}%
\def\tab@rule#1#2#3{%
\crcr
\noalign{%
\hline@rule
\gdef\@arstrut@hook{%
\global\let\@arstrut@hook\@empty
#3%
}%
\gdef\cell@font{#1}%
\gdef\cell@fil{#2}%
}%
}%
\def\column@font{}%
\def\column@fil{}%
\def\body@font{}%
\def\cell@font{}%
\def\frstrut{}%
\def\lrstrut{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arstrut@hline}
% \begin{macro}{\@arstrut@org}
% \begin{macro}{\@arstrut@hook}
% \begin{macro}{\@arstrutbox@hline}
% \begin{macro}{\set@arstrutbox}
% \begin{macro}{\hline@rule}
% The procedure \cmd\@arstrut@hline\ is substantially the same as
% \cmd\@arstrut, except the strut copied in is \cmd\@arstrutbox@hline
% instead of \cmd\@arstrutbox.
%
% The procedure \cmd\@arstrut@hook\ is redefined in \cmd\tab@rule!
%
% The register \cmd\@arstrutbox@hline.
%
% We append to \cmd\set@arstrutbox\ the code necessary to set a strut following an \cmd\hline.
%
% The procedure \cmd\hline@rule\ lays down a rule, and changes the meaning of \cmd\@arstrut\
% so that the next line will be correctly strutted.
%
% The \cmd\@arstrut@hline@clnc\ is a klootch, a magic number.
% \begin{macrocode}
\def\@arstrut@hline{%
\relax
\@ifmmode{\copy}{\unhcopy}\@arstrutbox@hline
\@arstrut@hook
}%
%
\let\@arstrut@org\@arstrut
\def\@arstrut@hook{%
\global\let\@arstrut\@arstrut@org
}%
%
\newbox\@arstrutbox@hline
\appdef\set@arstrutbox{%
\setbox\@arstrutbox@hline\hbox{%
\setbox\z@\hbox{$0^{0}_{}$}%
\dimen@\ht\z@\advance\dimen@\@arstrut@hline@clnc
\@ifdim{\dimen@<\arraystretch\ht\strutbox}{\dimen@=\arraystretch\ht\strutbox}{}%
\vrule \@height\dimen@
\@depth\arraystretch \dp\strutbox
\@width\z@
}%
}%
%
\def\hline@rule{%
\hrule \@height \arrayrulewidth
\global\let\@arstrut\@arstrut@hline
}%
\def\@arstrut@hline@clnc{2\p@}% % Klootch: magic number
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tableft@skip}
% \begin{macrocode}
\def\tableft@skip{\z@skip}%
\def\tabmid@skip{\z@skip}%\@flushglue
\def\tabright@skip{\z@skip}%
\def\tableftsep{\tabcolsep}%
\def\tabmidsep{\tabcolsep}%
\def\tabrightsep{\tabcolsep}%
\def\cell@fil{}%
\def\pbox@hook{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arstrut}
% \begin{macrocode}
\appdef\@arstrut{\@arstrut@hook}%
\let\@arstrut@hook\@empty
\def\@addtopreamble{\appdef\@preamble}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream}
% \begin{macrocode}
\def\@mkpream@LaTeX#1{%
\@firstamptrue\@lastchclass6
\let\@preamble\@empty
\let\protect\@unexpandable@protect
\let\@sharp\relax
\let\@startpbox\relax\let\@endpbox\relax
\@expast{#1}%
\expandafter\@tfor \expandafter
\@nextchar \expandafter:\expandafter=\reserved@a\do
{\@testpach\@nextchar
\ifcase \@chclass \@classz \or \@classi \or \@classii \or \@classiii
\or \@classiv \or\@classv \fi\@lastchclass\@chclass}%
\ifcase \@lastchclass \@acol
\or \or \@preamerr \@ne\or \@preamerr \tw@\or \or \@acol \fi
}%
\def\@mkpream@ltx#1{%
\@firstamptrue
\@lastchclass6
\let\@preamble\@empty
\let\protect\@unexpandable@protect
\let\@sharp\relax
%\let\@startpbox\relax\let\@endpbox\relax
\@expast{#1}%
\expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\reserved@a
\do{%
\expandafter\@testpach\expandafter{\@nextchar}%
\ifcase\@chclass
\@classz
\or
\@classi
\or
\@classii
\or
\@classiii
\or
\@classiv
\or
\@classv
\fi
\@lastchclass\@chclass
}%
\ifcase\@lastchclass
\@acolr % right-hand column
\or
\or
\@preamerr\@ne
\or
\@preamerr\tw@
\or
\or
\@acolr % right-hand column
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\insert@column}
% \begin{macrocode}
\def\insert@column@array{%
\the@toks \the \@tempcnta
\ignorespaces \@sharp \unskip
\the@toks \the \count@ \relax
}%
\def\insert@column@array@new{%
\the@toks\the\@tempcnta
\array@row@rst\cell@font
\ignorespaces\@sharp\unskip
\the@toks\the\count@
\relax
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream@relax}
% The procedure \cmd\@mkpream@relax\ participates in a strange and wonderful
% method of binding the alignment procedure---but only certain parts thereof.
%
% Here is how it works: in \LaTeX, the \classname{array} package, and in the
% \classname{longtable} package alike, there is a need to create an alignment
% preamble (using \cmd\@mkpream) for use by the upcoming \cmd\halign.
% Then, in both \classname{array} and \classname{longtable}, \TeX's \cmd\edef\
% is used to `compile in place' that alignment preamble.
%
% In the case of \classname{array}, the operation is done in order to
% pre-expand the use of \texttt{*}, in \classname{longtable}, it is to
% set the widths of the columns.
%
% Now, during this \cmd\edef, certain control sequence names must \emph{not}
% be expanded, and those are robustified by \cmd\@mkpream@relax.
%
% \begin{macrocode}
\def\@mkpream@relax{%
\let\tableftsep\relax
\let\tabmidsep\relax
\let\tabrightsep\relax
\let\array@row@rst\relax
\let\cell@font\relax
\let\@startpbox\relax
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream}
% \begin{macrocode}
\def\@mkpream@array#1{%
\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
\let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
\@temptokena{#1}\@tempswatrue
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
\count@\m@ne
\let\the@toks\relax
\prepnext@tok
\expandafter \@tfor \expandafter \@nextchar
\expandafter :\expandafter =\the\@temptokena \do
{\@testpach
\ifcase \@chclass \@classz \or \@classi \or \@classii
\or \save@decl \or \or \@classv \or \@classvi
\or \@classvii \or \@classviii
\or \@classx
\or \@classx \fi
\@lastchclass\@chclass}%
\ifcase\@lastchclass
\@acol \or
\or
\@acol \or
\@preamerr \thr@@ \or
\@preamerr \tw@ \@addtopreamble\@sharp \or
\or
\else \@preamerr \@ne \fi
\def\the@toks{\the\toks}%
}%
\def\@mkpream@array@new#1{%
\gdef\@preamble{}%
\@lastchclass\f@ur
\@firstamptrue
\let\@sharp\relax
\@mkpream@relax
%\let\@startpbox\relax\let\@endpbox\relax
\@temptokena{#1}\@tempswatrue
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
\count@\m@ne
\let\the@toks\relax
\prepnext@tok
\expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\the\@temptokena
\do{%
\@testpach
\ifcase\@chclass
\@classz
\or
\@classi
\or
\@classii
\or
\save@decl
\or
\or
\@classv
\or
\@classvi
\or
\@classvii
\or
\@classviii
\or
\@classx
\or
\@classx
\fi
\@lastchclass\@chclass
}%
\ifcase\@lastchclass
\@acolr % right-hand column
\or
\or
\@acolr % right-hand column
\or
\@preamerr\thr@@
\or
\@preamerr\tw@\@addtopreamble\@sharp
\or
\or
\else
\@preamerr\@ne
\fi
\def\the@toks{\the\toks}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@addamp}
% \begin{macrocode}
\def\@addamp@LaTeX{%
\if@firstamp\@firstampfalse\else\edef\@preamble{\@preamble &}\fi
}%
\def\@addamp@ltx{%
\if@firstamp\@firstampfalse\else\@addtopreamble{&}\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayacol}
% \begin{macrocode}
\def\@arrayacol@LaTeX{%
\edef\@preamble{\@preamble \hskip \arraycolsep}%
}%
\def\@arrayacol@ltx{%
\@addtopreamble{\hskip\arraycolsep}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabacol}
% \begin{macrocode}
\def\@tabacoll{%
\@addtopreamble{\hskip\tableftsep\relax}%
}%
\def\@tabacol@LaTeX{%
\edef\@preamble{\@preamble \hskip \tabcolsep}%
}%
\def\@tabacol@ltx{%
\@addtopreamble{\hskip\tabmidsep\relax}%
}%
\def\@tabacolr{%
\@addtopreamble{\hskip\tabrightsep\relax}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayclassz}
% \begin{macrocode}
\def\@arrayclassz@LaTeX{%
\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
\or \or \@addamp \or
\@acolampacol \or \@firstampfalse \@acol \fi
\edef\@preamble{\@preamble
\ifcase \@chnum
\hfil$\relax\@sharp$\hfil \or $\relax\@sharp$\hfil
\or \hfil$\relax\@sharp$\fi}%
}%
\def\@arrayclassz@ltx{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acoll
\fi
\ifcase\@chnum
\@addtopreamble{%
\hfil\array@row@rst$\relax\@sharp$\hfil
}%
\or
\@addtopreamble{%
\array@row@rst$\relax\@sharp$\hfil
}%
\or
\@addtopreamble{%
\hfil\array@row@rst$\relax\@sharp$%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabclassz}
% \begin{macrocode}
\def\@tabclassz@LaTeX{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acol
\fi
\edef\@preamble{%
\@preamble{%
\ifcase\@chnum
\hfil\ignorespaces\@sharp\unskip\hfil
\or
\hskip1sp\ignorespaces\@sharp\unskip\hfil
\or
\hfil\hskip1sp\ignorespaces\@sharp\unskip
\fi}}%
}%
\def\@tabclassz@ltx{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acoll
\fi
\ifcase\@chnum
\@addtopreamble{%
{\hfil\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
}%
\or
\@addtopreamble{%
{\cell@fil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
}%
\or
\@addtopreamble{%
{\hfil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\cell@fil}%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabclassiv}
% \begin{macrocode}
\def\@tabclassiv@LaTeX{%
\@addtopreamble\@nextchar
}%
\def\@tabclassiv@ltx{%
\expandafter\@addtopreamble\expandafter{\@nextchar}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayclassiv}
% \begin{macrocode}
\def\@arrayclassiv@LaTeX{%
\@addtopreamble{$\@nextchar$}%
}%
\def\@arrayclassiv@ltx{%
\expandafter\@addtopreamble\expandafter{\expandafter$\@nextchar$}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@classv}
% \begin{macrocode}
\def\@classv@LaTeX{%
\@addtopreamble{\@startpbox{\@nextchar}\ignorespaces
\@sharp\@endpbox}%
}%
\def\@classv@ltx{%
\expandafter\@addtopreamble
\expandafter{%
\expandafter \@startpbox
\expandafter {\@nextchar}%
\pbox@hook\array@row@rst\cell@font\ignorespaces\@sharp\@endpbox
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@classx}
% \begin{macrocode}
\def\@classx@array{%
\ifcase \@lastchclass
\@acolampacol \or
\@addamp \@acol \or
\@acolampacol \or
\or
\@acol \@firstampfalse \or
\@addamp
\fi
}%
\def\@classx@array@new{%
\ifcase \@lastchclass
\@acolampacol
\or
\@addamp \@acol
\or
\@acolampacol
\or
\or
\@firstampfalse\@acoll
\or
\@addamp
\fi
}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Repair other broken parts of \LaTeX}
%
% \begin{macro}{\@xbitor}
% Expansion part has extraneous space token. Removed.
% \begin{macrocode}
\def\@xbitor@LaTeX #1{\@tempcntb \count#1
\ifnum \@tempcnta =\z@
\else
\divide\@tempcntb\@tempcnta
\ifodd\@tempcntb \@testtrue\fi
\fi}%
\def\@xbitor@ltx#1{%
\@tempcntb\count#1%
\@ifnum{\@tempcnta=\z@}{}{%
\divide\@tempcntb\@tempcnta
\@ifodd\@tempcntb{\@testtrue}{}%
}%
}%
\@ifx{\@xbitor\@xbitor@LaTeX}{%
\class@info{Repairing broken LaTeX \string\@xbitor}%
}{%
\class@info{Unrecognized LaTeX \string\@xbitor. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\let\@xbitor\@xbitor@ltx
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Syntax}
% \begin{macro}{\@gobble@opt@one}
% The \cmd\@gobble@opt@one\ command eats up an optional argument
% and one required argument.
% \begin{macrocode}
\newcommand*\@gobble@opt@one[2][]{}%
% \end{macrocode}
% \end{macro}
%
% \subsection{Auto-indented Contents}
% Facility to automatically determine the proper indentation of
% the TOC entries.
%
% Note on \classname{hyperref} compatibility:
% We must respect that
% \cmd\contentsline now has a 4th argument.
% So, instead of trying to override the meaning of \cmd\contentsline,
% we use the aux file to remember max values from one run to the next.
%
% In this respect, this package retains compatability with
% \classname{hyperref}.
%
% \begin{macro}{\@starttoc}
% Install hooks at beginning and end of the TOC processing.
% \begin{macrocode}
\def\@starttoc#1{%
\begingroup
\toc@pre
\makeatletter
\@input{\jobname.#1}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
\toc@post
\endgroup
}%
\def\toc@pre{}%
\def\toc@post{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@@font}
% Interface for setting the formatting characteristics of this part
% of the TOC.
%
% Note: \cmd\toc@@font\ is the common font for all auto-sizing toc commands,
% although this, too, could become a dispatcher.
% \begin{macrocode}
\def\toc@@font{}%{\footnotesize\rmfamily}%
\def\@dotsep{\z@}%{5.5pt}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@section}
% Interface for determining which TOC elements are automatically indented.
%
% All of the \cmd\l@\dots\ commands simply go through the
% bottleproc \cmd\l@@sections. The calling convention is
% to pass the name of self and the name of parent.
% If you want to exclude any of these from the indentation
% scheme, simply leave the \cmd\l@\dots\ command undefined.
%
% Note that the parent of ``section'' is nil, so we have to
% define a stub.
% \begin{verbatim}
%\def\l@section{%
% \l@@sections{}{section}% Implicit #3#4
%}%
%\def\tocleft@{\z@}%
%\def\l@subsection{%
% \l@@sections{section}{subsection}% Implicit #3#4
%}%
%\def\l@subsubsection{%
% \l@@sections{subsection}{subsubsection}% Implicit #3#4
%}%
%\def\l@paragraph{%
% \l@@sections{subsubsection}{paragraph}% Implicit #3#4
%}%
%\def\l@subparagraph#1#2{%
% \l@@sections{paragraph}{subparagraph}% Implicit #3#4
%}%
% \end{verbatim}
% \end{macro}
%
% Glom some \cmd\dimen\ registers.
% \begin{macrocode}
\let\tocdim@section \leftmargini
\let\tocdim@subsection \leftmarginii
\let\tocdim@subsubsection \leftmarginiii
\let\tocdim@paragraph \leftmarginiv
\let\tocdim@appendix \leftmarginv
\let\tocdim@pagenum \leftmarginvi
% \end{macrocode}
%
% \begin{macro}{\toc@pre@auto}
% \begin{macro}{\toc@post@auto}
% We patch \cmd\@starttoc\ to:
% 1) before TOC processing,
% initialize the max registers and
% set the needed dimensions from
% the values stored in the auxiliary file, and
% 2) after TOC processing,
% store out those max register values into the auxiliary file.
%
% Note that the font is set here: all other TOC entries must
% override these font settings.
%
% To activate this override of the standard \LaTeX\ processing,
% the substyle does: \cmd\let\cmd\toc@pre\cmd\toc@pre@auto\
% and \cmd\let\cmd\toc@post\cmd\toc@post@auto.
% \begin{macrocode}
\def\toc@pre@auto{%
\toc@@font
\@tempdima\z@
\toc@setindent\@tempdima{section}%
\toc@setindent\@tempdima{subsection}%
\toc@setindent\@tempdima{subsubsection}%
\toc@setindent\@tempdima{paragraph}%
\toc@letdimen{appendix}%
\toc@letdimen{pagenum}%
}%
\def\toc@post@auto{%
\if@filesw
\begingroup
\toc@writedimen{section}%
\toc@writedimen{subsection}%
\toc@writedimen{subsubsection}%
\toc@writedimen{paragraph}%
\toc@writedimen{appendix}%
\toc@writedimen{pagenum}%
\endgroup
\fi
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toc@setindent}
% \begin{macrocode}
\def\toc@setindent#1#2{%
\csname tocdim@#2\endcsname\tocdim@min\relax
\@ifundefined{tocmax@#2}{\@namedef{tocmax@#2}{\z@}}{}%
\advance#1\@nameuse{tocmax@#2}\relax
\expandafter\edef\csname tocleft@#2\endcsname{\the#1}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@letdimen}
% \begin{macrocode}
\def\toc@letdimen#1{%
\csname tocdim@#1\endcsname\tocdim@min\relax
\@ifundefined{tocmax@#1}{\@namedef{tocmax@#1}{\z@}}{}%
\expandafter\let\csname tocleft@#1\expandafter\endcsname\csname tocmax@#1\endcsname
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@writedimen}
% \begin{macrocode}
\def\toc@writedimen#1{%
\immediate\write\@auxout{%
\gdef\expandafter\string\csname tocmax@#1\endcsname{%
\expandafter\the\csname tocdim@#1\endcsname
}%
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@@sections}
% The procedure for formatting the indented TOC entries.
% We use control sequence names such as \cmd\tocmax@section\ and
% \cmd\tocleft@section, the former being written to the auxiliary file
% and the latter only defined for the duration of the TOC processing.
%
% Note that the assignment of \cmd\box\cmd\z@\ must endure
% over the invocation of |#3|.
% \begin{macrocode}
\def\l@@sections#1#2#3#4{%
% #1 - superior section
% #2 - this section
% #3 - content, including possible \numberline
% #4 - page number
\begingroup
\everypar{}%
\set@tocdim@pagenum{#4}%
\global\@tempdima\csname tocdim@#2\endcsname
\leftskip\csname tocleft@#2\endcsname\relax
\dimen@\csname tocleft@#1\endcsname\relax
\parindent-\leftskip\advance\parindent\dimen@
\rightskip\tocleft@pagenum plus 1fil\relax
\skip@\parfillskip\parfillskip\z@
\let\numberline\numberline@@sections
\@nameuse{l@f@#2}%
\ignorespaces#3\unskip\nobreak\hskip\skip@
\hb@xt@\rightskip{\hfil\unhbox\@tempboxa}\hskip-\rightskip\hskip\z@skip
\par
\expandafter\aftergroup\csname tocdim@#2\endcsname\expandafter
\endgroup\the\@tempdima\relax
}%
\def\set@tocdim@pagenum#1{%
\setbox\@tempboxa\hbox{\ignorespaces#1}%
\@ifdim{\tocdim@pagenum<\wd\z@}{\global\tocdim@pagenum\wd\z@}{}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numberline@@sections}
% The bottleproc for all \cmd\numberline\ processing in indented TOC entries.
% The first argument is self.
%
% We use \cmd\@tempdima\ to pass a value around (via global assignment) because
% \cmd\numberline\ executes inside a group if the
% \classname{hyperref} package is loaded.
% Would that it were not so!
% \begin{macrocode}
\def\numberline@@sections#1{%
\leavevmode\hb@xt@-\parindent{%
\hfil
\@if@empty{#1}{}{%
\setbox\z@\hbox{#1.\kern\@dotsep}%
\@ifdim{\@tempdima<\wd\z@}{\global\@tempdima\wd\z@}{}%
\unhbox\z@
}%
}%
\ignorespaces
}%
\def\tocdim@min{\z@}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Lists}
% \begin{macro}{\list}
% Using \cmd\parshape\ to implement lists was always suspect
% (can you get behind \cmd\parshape\cmd\@ne?) and we now see that
% it was a mistake all along. Why? Because \cmd\parshape, like
% \cmd\hangindent, achieves its effect via ``shifting'' the \cmd\hbox es
% in a paragraph
% instead of using \cmd\leftskip\ and \cmd\parindent, which is
% robust during column balancing.
%
% We introduce the alternative method with a hook into
% the \LaTeX\ kernel procedure \cmd\list, which is
% the implementation of all lists.
%
% \begin{macrocode}
\def\list#1#2{%
\ifnum \@listdepth >5\relax
\@toodeep
\else
\global\advance\@listdepth\@ne
\fi
\rightmargin\z@
\listparindent\z@
\itemindent\z@
\csname @list\romannumeral\the\@listdepth\endcsname
\def\@itemlabel{#1}%
\let\makelabel\@mklab
\@nmbrlistfalse
#2\relax
\@trivlist
\parskip\parsep
\set@listindent
\ignorespaces
}%
\def\set@listindent@parshape{%
\parindent\listparindent
\advance\@totalleftmargin\leftmargin
\advance\linewidth-\rightmargin
\advance\linewidth-\leftmargin
\parshape\@ne\@totalleftmargin\linewidth
}%
\def\set@listindent@{%
\parindent\listparindent
\advance\@totalleftmargin\leftmargin
\advance\rightskip\rightmargin
\advance\leftskip\@totalleftmargin
}%
\let\set@listindent\set@listindent@parshape
% \end{macrocode}
% \end{macro}
%
% \subsection{End of the \file{ltxutil} {\sc docstrip} module}
% Here ends the module.
% \begin{macrocode}
%
% \end{macrocode}
%
%
% \Finale
% %Here ends the programmer's documentation.
% \endinput
%
\endinput
%%EOF