diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/revtex/ltxutil.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/revtex/ltxutil.dtx | 1404 |
1 files changed, 987 insertions, 417 deletions
diff --git a/Master/texmf-dist/source/latex/revtex/ltxutil.dtx b/Master/texmf-dist/source/latex/revtex/ltxutil.dtx index 5553e3a863e..bf9000c82af 100644 --- a/Master/texmf-dist/source/latex/revtex/ltxutil.dtx +++ b/Master/texmf-dist/source/latex/revtex/ltxutil.dtx @@ -1,29 +1,125 @@ -% \iffalse ltxdoc klootch -% ltxutil.dtx: package to add utilties to LaTeX -% Copyright (c) 2000 Arthur Ogawa +% \iffalse meta-comment balanced on line 107 +% ltxutil.dtx: utilities package +% Copyright (c) 2009 Arthur Ogawa % % Disclaimer % This file is distributed WITHOUT ANY WARRANTY; % without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +% License +% You may distribute this file under the conditions of the +% LaTeX Project Public License 1.3 or later +% (http://www.latex-project.org/lppl.txt). % ReadMe % For the documentation and more detailed instructions for % installation, typeset this document with \LaTeX. +% Maintenance Status +% This work has the LPPL maintenance status "maintained"; +% Current Maintainer of this work is Arthur Ogawa. +% +% This work consists of the main source file ltxutil.dtx +% and the derived files +% ltxutil.sty, ltxutil.pdf +% Distribution: +% CTAN:macros/latex/contrib/revtex/ +% +% Unpacking: +% tex ltxutil.dtx +% +% Documentation: +% latex ltxutil.dtx; ... +% +% Program calls to get the documentation (example): +% pdflatex ltxutil.dtx +% makeindex -s gind.ist ltxutil.idx +% makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo +% pdflatex ltxutil.dtx +% makeindex -s gind.ist ltxutil.idx +% pdflatex ltxutil.dtx +% +% Installation: +% TDS:doc/latex/revtex/ +% TDS:source/latex/revtex/ +% TDS:tex/latex/revtex/ +% +% Thanks, Heiko! +% This method of letting a single .dtx file serve as both +% documentation (via latex) and installer (via tex) follows +% the example of Heiko Oberdiek. Thanks! +%<*ignore> +\begingroup + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase + 0\expandafter\ifx\csname processbatchFile\endcsname\relax\else1\fi\ifx\fmtname\x\else 1\fi + \relax +\else + \csname fi\endcsname +%</ignore> +%<*install> +\input docstrip +\preamble + +This is a generated file; +altering it directly is inadvisable; +instead, modify the original source file. +See the URL in the file 00readme.tex. + +License + You may distribute this file under the conditions of the + LaTeX Project Public License 1.3 or later + (http://www.latex-project.org/lppl.txt). + + This file is distributed WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. + +\endpreamble +\askforoverwritefalse +\keepsilent + \generate{% + %{ignore} +% \usedir{tex/latex/revtex}% + \file{ltxutil.sty}{% + \from{ltxutil.dtx}{package,kernel}%{ltxutil,ltxutil-krn}% + }% + }% +\ifToplevel{ +\Msg{***********************************************************} +\Msg{*} +\Msg{* To finish the installation, please move} +\Msg{* ltxutil.sty} +\Msg{* into a directory searched by TeX;} +\Msg{* in a TDS-compliant installation:} +\Msg{* texmf/tex/macros/latex/revtex/.} +\Msg{*} +\Msg{* To produce the documentation, + run ltxutil.dtx through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing} +\Msg{***********************************************************} +} +\endbatchfile +%</install> +%<*ignore> +\fi +%</ignore> % \fi -% \GetFileInfo{ltxutil.dtx}\CheckSum{3641} +% +% \GetFileInfo{ltxutil.dtx}\CheckSum{4094} % % \iffalse ltxdoc klootch -%<*ltxutil> +%<*package> %%% @LaTeX-file{ %%% filename = "ltxutil.dtx", -%%% version = "1.0rc5b", -%%% date = "2001/07/31", -%%% time = "12:23:00 GMT+8", -%%% checksum = "3641", -%%% author = "Arthur Ogawa (mailto:ogawa@teleport.com), +%%% version = "4.1h", +%%% date = "2009/10/09", +%%% time = "11:23:00 GMT+8", +%%% checksum = "4094", +%%% author = "Arthur Ogawa (mailto:arthur_ogawa at sbcglobal.net), %%% commissioned by the American Physical Society. %%% ", -%%% copyright = "Copyright (C) 1999 Arthur Ogawa, +%%% copyright = "Copyright (C) 1999, 2009 Arthur Ogawa, %%% distributed under the terms of the %%% LaTeX Project Public License, see %%% ftp://ctan.tug.org/macros/latex/base/lppl.txt @@ -32,23 +128,23 @@ %%% USA", %%% telephone = "", %%% FAX = "", -%%% email = "ogawa@teleport.com", +%%% email = "mailto colon arthur_ogawa at sbcglobal.net", %%% codetable = "ISO/ASCII", -%%% keywords = "latex, utility, kernel", +%%% keywords = "latex, page grid, main vertical list", %%% supported = "yes", -%%% abstract = "package to add utilties to LaTeX", +%%% abstract = "utilities package", %%% docstring = "The checksum field above generated by ltxdoc", %%% } -%</ltxutil> +%</package> % \fi % % \iffalse ltxdoc klootch -% The following references the \file{00readme.txt} file, +% The following references the \file{00readme} file, % which contains basic information about this package. % The contents of this file are generated when % you typeset the programmer's documentation. -% Search on "{filecontents*}{00readme.txt}" to locate it. -% \fi\input{00readme.txt}% +% Search on "{filecontents*}{00readme}" to locate it. +% \fi\input{00readme}% % % \subsection{Bill of Materials} % @@ -62,25 +158,19 @@ %\end{verbatim} % % \subsubsection{Generated by \texttt{latex ltxutil.dtx}}% -% Typesetting the source file under \LaTeX\ -% generates the readme and the installer. +% Typesetting the source file under pdflatex +% generates the readme and the documentation. %\begin{verbatim} -%00readme.txt ltxutil.ins +%00readme ltxutil.pdf %\end{verbatim} % -% \subsubsection{Generated by \texttt{tex ltxutil.ins}}% -% Typesetting the installer generates -% the package files. +% \subsubsection{Generated by \texttt{tex ltxutil.dtx}}% +% Typesetting this file with \TeX\ generates +% the package file. %\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: @@ -90,8 +180,7 @@ % % \section{Code common to all modules}% % -% The following may look a bit klootchy, but we -% want to require only one place in this file +% 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. @@ -101,14 +190,14 @@ % An appropriate message is displayed if % a different \TeX{} format is used. % \begin{macrocode} -%<*doc|ltxutil> +%<*doc|package> \NeedsTeXFormat{LaTeX2e}[1995/12/01]% -%</doc|ltxutil> +%</doc|package> % \end{macrocode} % As desired, the following modules all % take common version information: % \begin{macrocode} -%<ltxutil>\ProvidesFile{ltxutil.sty}% +%<package>\ProvidesFile{ltxutil.sty}% %<*doc> \expandafter\ProvidesFile\expandafter{\jobname.dtx}% %</doc> @@ -120,9 +209,9 @@ % consistently in all generated files and in the % typeset documentation. % \begin{macrocode} -%<*doc|ltxutil> - [2001/07/31 1.0rc5b utilities package]% \fileversion -%</doc|ltxutil> +%<*doc|package> + [2009/10/09 4.1h utilities package]% \fileversion +%</doc|package> % \end{macrocode} % % @@ -130,7 +219,7 @@ % % This module, consisting of the present section, % typesets the programmer's documentation, -% generating the \file{.ins} installer and \file{00readme.txt} as required. +% generating the \file{00readme} as required. % % Because the only uncommented-out lines of code at the beginning of % this file constitute the \file{doc} module itself, @@ -158,7 +247,8 @@ \expandafter\ifx\csname package@font\endcsname\@undefined\else \expandafter\RequirePackage\expandafter{\csname package@font\endcsname}% \fi -\CodelineIndex\EnableCrossrefs +\CodelineIndex\EnableCrossrefs % makeindex -s gind.ist ltxutil +\RecordChanges % makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo % \end{macrocode} % % \subsubsection{Docstrip and info directives} @@ -173,76 +263,6 @@ \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, @@ -263,38 +283,43 @@ Copyright notice. % The usual user will not be asked to % do a full build, not to speak % of the bootstrap. -% Instructions for carrying these processes +% Instructions for carrying out these procedures % begin the programmer's manual. % % \begin{macrocode} -\begin{filecontents*}{00readme.txt} +\begin{filecontents*}{00readme} \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. + }% + \thanks{% + Version \fileversion\ \copyright\ 2009 The American Physical Society }% }% - \author{% -Arthur Ogawa (\texttt{mailto:ogawa@teleport.com}), -\fileversion\\Copyright (C) 1999 Arthur Ogawa -}% + Arthur Ogawa% + \thanks{\texttt{mailto:arthur\_ogawa at sbcglobal.net}}% +}% +%\iffalse +% For version number and date, +% search on "\fileversion" in the .dtx file, +% or see the end of the 00readme file. +%\fi \maketitle This file embodies the \classname{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. +\url{publish.aps.org/revtex}, +which contains prebuilt runtime files, documentation, and full source, +ready to add to a TDS-compliant \TeX\ installation. 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. +the same license under which all the portions of \LaTeX\ itself are 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 @@ -315,7 +340,7 @@ To use, read the user documentation \file{ltxutil.pdf}. 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|. +via |tex ltxutil.dtx| (Note: do \emph{not} use \LaTeX\ for this task). 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|. @@ -330,20 +355,79 @@ then carry out the following steps: 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}. +along with the file \file{00readme}. -Note: you will have to run \LaTeX\ twice, then \file{makeindex}, then +Note: you will have to run \LaTeX, then +\file{makeindex} \texttt{-s gind.ist ltxutil.idx}, then +\file{makeindex} \texttt{-s gglo.ist -o ltxutil.gls ltxutil.glo}, then \LaTeX\ again in order to obtain a valid index and table of contents. \item -Now typeset \file{ltxutil.ins}, +Now typeset \file{ltxutil.dtx} with \TeX (not \LaTeX), 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. +Install the following files into indicated locations within your +TDS-compliant \texttt{texmf} tree (you may need root access): +\begin{itemize} +\item +\file{$TEXMF/}\file{tex/}\file{latex/}\file{revtex/}\classname{ltxutil.sty} +\item +\file{$TEXMF/}\file{source/}\file{latex/}\file{revtex/}\classname{ltxutil.dtx} +\item +\file{$TEXMF/}\file{doc/}\file{latex/}\file{revtex/}\classname{ltxutil.pdf} +\end{itemize} +where \file{$TEXMF/} stands for \file{texmf-local/}, or some other \texttt{texmf} tree +in your installation. +\item +Run \texttt{mktexlsr} on \file{$TEXMF/} (you may need root access). +\item +Build and installation are now complete; +now put a \cmd\usepackage\texttt{\{ltxutil\}} in your document preamble! \end{enumerate} + +\subsection{Change Log} +\changes{4.0b}{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.} +\changes{4.0b}{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{4.0b}{1999/06/20}{only execute if there really were floats of the given type} +\changes{4.0b}{1999/06/20}{Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time, since \classname{hyperref} clobbers \cs{caption}.} +\changes{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing} +\changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility} +\changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package} +\changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.} +\changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks} +\changes{4.0d}{2000/04/10}{(AO, 174) kernel fix} +\changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.} +\changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.} +\changes{4.0e}{2000/11/16}{(AO, 221) Remove samepage command from @xfloat@prep: If the float can break over pages, we want better control.} +\changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility} +\changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}% +\changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}% +\changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}% +\changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}% +\changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}% +\changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}% +\changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.} +\changes{4.1a}{2008/07/07}{\cs{@xfloat@prep} calls \cs{ltx@footnote@pop} to restore the original \cs{ltx@footmark} and \cs{ltx@foottext} procedures, in case footnote processing has switched.} +\changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now} +\changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.} +\changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.} +\changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}% +\changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}% +\changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} +\changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire} +\changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}% +\changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.} +\changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}} +\changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.} +\changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}% +\changes{4.1b}{2008/08/12}{Tally and log the height of a float class} +\changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}% +\changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote} +\changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long} +\changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}% +\changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}% +\changes{4.1g}{2009/10/07}{(AO, 539) Use of double-backslash in argument of \cs{section} gives error. The \classname{textcase} package is involved.}% + + \end{filecontents*} % \end{macrocode} % @@ -355,7 +439,6 @@ in your filesystem where they will be found by \LaTeX. % \begin{macrocode} \begin{document}% \expandafter\DocInput\expandafter{\jobname.dtx}% -% ^^A\PrintChanges \end{document} % \end{macrocode} % @@ -374,8 +457,7 @@ in your filesystem where they will be found by \LaTeX. %\usepackage{ltxutil}% %\begin{document} %<your document here> -%\end{document} -% \end{verbatim} +%\end{document}\end{verbatim} % However, the preferred way is to invoke this package from within your % customized document class: % \begin{verbatim} @@ -384,14 +466,13 @@ in your filesystem where they will be found by \LaTeX. %\RequirePackage{ltxutil}% %\LoadClass{book}% %<class customization commands> -%\endinput -% \end{verbatim} +%\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} +% \section{Compatibility 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. @@ -401,7 +482,7 @@ in your filesystem where they will be found by \LaTeX. % 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}, +% greatest compatibility, \classname{ltxutil} should be loaded \emph{after}, % say, \classname{ftnright}, which overwrites \LaTeX's kernel % procedures \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol. % @@ -426,27 +507,27 @@ in your filesystem where they will be found by \LaTeX. % \section{Implementation of package} % % Special acknowledgment: this package uses concepts pioneered -% and first realized by William Baxter (mailto:web@superscript.com) +% and first realized by William Baxter (mailto:web at superscript.com) % in his SuperScript line of commercial typesetting tools, and % which are used here with his permission. % -% \subsection{Beginning of the \file{ltxutil} {\sc docstrip} module} +% \subsection{Beginning of the \file{package} {\sc docstrip} module} % \begin{macrocode} -%<*ltxutil> +%<*package> \def\package@name{ltxutil}% \expandafter\PackageInfo\expandafter{\package@name}{% Utility macros for \protect\LaTeXe, - by A. Ogawa (ogawa@teleport.com)% + by A. Ogawa (arthur_ogawa at sbcglobal.net)% }% -%</ltxutil> +%</package> % \end{macrocode} % -% \subsection{Banner}% +% \subsection{Banner and beginning of the \file{kernel} {\sc docstrip} module}% % Credit where due. % \begin{macrocode} -%<*ltxutil-krn> +%<*kernel> \typeout{% - ltxutil: portions licensed from W. E. Baxter (web@superscript.com)% + ltxutil [2009/07/07 4.1f]: portions licensed from W. E. Baxter (web at superscript.com)% }% % \end{macrocode} % @@ -488,14 +569,20 @@ in your filesystem where they will be found by \LaTeX. \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} % +% \changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}% +% Give \cmd\class@name\ a meaning if it does not already have one. +% \begin{macrocode} +\ifx\undefined\class@name + \def\class@name{ltxutil}% + \class@warn{You should define the class name before reading in this package. Using default}% +\fi +% \end{macrocode} +% % \subsection{New Tools}% % % \begin{macro}{\t@} @@ -603,7 +690,7 @@ in your filesystem where they will be found by \LaTeX. % 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). +% William Baxter (web at superscript.com). % See articles by Baxter and Ogawa in the proceedings of the % 1994 TUG meeting, TUGboat Vol.~15, No.~3. % @@ -729,8 +816,8 @@ in your filesystem where they will be found by \LaTeX. % 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, +% Compatibility Note: earlier versions of this package +% defined a procedure \cmd\@ifempty. However, for compatibility with AMS\LaTeX, % we must avoid the following three names: % \cmd\@ifempty, \cmd\@xifempty, and \cmd\@ifnotempty. % @@ -820,7 +907,11 @@ in your filesystem where they will be found by \LaTeX. % 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. % -% The price we pay for this facility is to depend on the stability of this part +% As it turns out, though, it appears feasible to simply invoke the desired +% column grid command at \cmd\AtBeginDocument\ time, since the MVL has nothing in it +% at that time that would be problematical. +% +% The facility depends on the stability of this part % of \LaTeX's kernel code (the first token of \cmd\document), % which could change, you see. But considering that \LaTeX\ is % at this point essentially stagnant once more, we risk it. @@ -832,49 +923,43 @@ in your filesystem where they will be found by \LaTeX. % begun by \cmd\begin. Last, we conclude our shenanigans by absorbing % the first token of the expansion of \cmd\document, which % we assume to be \cmd\endgroup. +% \changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}% % \begin{macrocode} \prepdef\document{% \endgroup - \init@documenthook - \set@typesize@hook - \normalsize - \set@pica@hook + \document@inithook \true@sw{}% }% % \end{macrocode} % \end{macro} % +% \begin{macro}{\document@inithook} +% To use, simply \cmd\appdef\cmd\document@inithook\arg{your tokens here}. +% \begin{macrocode} +\let\document@inithook\@empty +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\class@documenthook} % \begin{macro}{\class@enddocumenthook} -% We install the first \cmd\AtBeginDocument\ hook, namely the +% \changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now} +% We install the last \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. +% A document class using this package should do as this package does and just say, +% \cmd\appdef\ \cmd\class@documenthook\ instead of \cmd\AtBeginDocument, +% and \cmd\appdef\ \cmd\class@enddocumenthook\ instead of \cmd\AtEndDocument. % \begin{macrocode} -\def\init@documenthook{}% -\AtBeginDocument{% - \class@documenthook +\appdef\document@inithook{% + \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{}% +\let\class@documenthook\@empty +\let\class@enddocumenthook\@empty % \end{macrocode} % \end{macro} % \end{macro} @@ -938,6 +1023,108 @@ in your filesystem where they will be found by \LaTeX. % \end{macro} % % +% \subsection{Class Extensions}% +% \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.} +% The \LaTeX\ procedure \cmd\@onefilewithoptions\ is the vehicle for reading in +% a \LaTeX\ class or package. +% The APS RevTeX class implements the use of what are called ``substyles'', +% actually extensions to the class itself. +% Any document class can do likewise. +% +% \begin{macro}{\class@extension} +% \begin{macro}{\class@extensionfile} +% \begin{macro}{\class@ext@hook} +% A procedure similar to \LaTeX's \cmd\@onefilewithoptions, but as an extension to the +% current document class. +% +% Read in the given file as if it were a document class file. +% Usage: \cmd\class@extensionfile\ \arg{class} \cmd\@extension, +% where \marg{class} is a file (similar to \file{aps.rtx}) and where \cmd\@extension\ is +% the file extension for \marg{class}. +% For instance, to read in the file \file{aps.rtx}, +% do \cmd\class@extensionfile\ \texttt{\{aps\}} \cmd\substyle@ext, +% where the latter has been define to expand to \file{.rtx}. +% +% Features supported include +% passing existing class options on to the class extension, +% \cmd\AtEndOfClass\ processing, +% a stack that restores \cmd\@currname, \cmd\@currext, \cmd\@clsextension, and the \cmd\catcode\ of `@', +% fall-back to a control sequence name (with leading `rtx@') if no file exists. +% +% Note that \cmd\LoadClass\ gives one the ability to write a class that calls in +% another class as a (sort of) module: this scheme is like \cmd\LoadClass, but +% turned inside out. +% \begin{macrocode} +\def\class@extension#1#2{% + \IfFileExists{#1.#2}{% + \expandafter\class@extensionfile\csname ver@\@currname.\@currext\endcsname{#1}#2% + }{% + \csname rtx@#1\endcsname + }% +}% +\def\class@extensionfile#1#2#3{% + \@pass@ptions#3\@unusedoptionlist{#2}% + \global\let\@unusedoptionlist\@empty + \expandafter\class@ext@hook\csname#2.#3-h@@k\endcsname#1{#2}#3% +}% +\def\class@ext@hook#1#2#3#4{% + \@pushfilename@ltx + \makeatletter + \let\CurrentOption\@empty + \@reset@ptions + \let#1\@empty + \xdef\@currname{#3}% + \global\let\@currext#4% + \global\let\@clsextension\@currext + \input{#3.#4}% + \@ifl@ter#4{#3}#2{% + \class@info{Class extension later than: #2}% + }{% + \class@info{Class extension earlier: #2}% + \@@end + }% + #1% + \let#1\@undefined + \expandafter\@p@pfilename@ltx\@currnamestack@ltx\@nil + \@reset@ptions +}% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@pushfilename} +% \begin{macro}{\@p@pfilename} +% \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.} +% But! \LaTeX\ does not provide for a class extension other than \file{.cls}, therefore we +% must extend \LaTeX's file name stack with the file extension of a class extension. +% This way, procedures like +% \cmd\ProvidesPackage, \cmd\OptionNotUsed, \cmd\ProcessOptions, \cmd\@reset@ptions\ +% will still work properly. +% \begin{macrocode} +\def\@pushfilename@ltx{% + \xdef\@currnamestack@ltx{% + {\@currname}% + {\@currext}% + {\@clsextension}% + {\the\catcode`\@}% + \@currnamestack@ltx + }% +}% +\def\@p@pfilename@ltx#1#2#3#4#5\@nil{% + \gdef\@currname{#1}% + \gdef\@currext{#2}% + \gdef\@clsextension{#3}% + \catcode`\@#4\relax + \gdef\@currnamestack@ltx{#5}% +}% +\global\let\@currnamestack@ltx\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% We carefully patch \LaTeX\ so that the current value of \cmd\@clsextension\ can be +% restored after reading in a class file. +% % \subsection{Type Tools}% % % \begin{macro}{\flushing} @@ -953,6 +1140,31 @@ in your filesystem where they will be found by \LaTeX. % \end{macrocode} % \end{macro} % +% \changes{4.1g}{2009/10/07}{(AO, 539) Use of double-backslash in argument of \cs{section} gives error. The \classname{textcase} package is involved.}% +% \begin{macro}{\@centercr} +% The \cmd\@centercr\ command is the replacement for \cmd\@normalcr\ when setting type centered or ragged. +% Normally, the meaning of \cmd\\ is \cmd\@normalcr, which \LaTeX\ defines via \cmd\DeclareRobustCommand. +% In centered or ragged typesetting, the meaning of \cmd\\ is \cmd\@centercr, +% therefore it ought to to be defined via \cmd\DeclareRobustCommand\ (but unfortunately is not). +% The fact that it is not is yet another of \LaTeX's early failures that will never get fixed. +% +% The following exemplar fails under \LaTeX\ version 2005/12/01, package \classname{textcase} 2004/10/07 v0.07: +% \begin{verbatim} +%\documentclass{article}% +%\usepackage[overload]{textcase} +%\begin{document} +%\centering +%\section{\MakeTextUppercase{Section\\title}} +%Text +%\end{document} +% \end{verbatim} +% The solution is to promote \cmd\@centercr\ to a robust command, just the same as \cmd\\. +% We do that here without needing to know the meaning of the command. +% \begin{macrocode} +\expandafter\DeclareRobustCommand\expandafter\@centercr\expandafter{\@centercr}% +% \end{macrocode} +% \end{macro} +% % % \subsection{Display Math}% % @@ -961,10 +1173,11 @@ in your filesystem where they will be found by \LaTeX. % 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 +% Note on \classname{hyperref} package compatibility: that package overrides % \cmd\eqnarray\ by wrapping it up in a larger procedure, so its changes % are compatible with this package's changes. % +% \changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}% % \begin{macrocode} \def\eqnarray@LaTeX{% \stepcounter{equation}% @@ -974,7 +1187,7 @@ in your filesystem where they will be found by \LaTeX. \global\@eqcnt\z@ \tabskip\@centering \let\\\@eqncr - $$\everycr{}\halign\t@\displaywidth\bgroup + $$\everycr{}\halign to\displaywidth\bgroup \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep @@ -986,7 +1199,7 @@ in your filesystem where they will be found by \LaTeX. \long\def\eqnarray@fleqn@fixed{% \stepcounter{equation}\def\@currentlabel{\p@equation\theequation}% \global\@eqnswtrue\m@th\global\@eqcnt\z@ - \tabskip\mathindent + \tabskip\ltx@mathindent \let\\=\@eqncr \setlength\abovedisplayskip{\topsep}% \ifvmode\addtolength\abovedisplayskip{\partopsep}\fi @@ -1016,114 +1229,254 @@ in your filesystem where they will be found by \LaTeX. \let\eqnarray@LaTeX\relax \let\eqnarray@fleqn@fixed\relax }{}% -\def\mathindent{\@centering}% +% \end{macrocode} +% The macro \cmd\ltx@mathindent\ is assigned to the \cmd\tabskip\ glue just +% before the alignment preamble is expanded, the value therefore applying at the +% left of the first column. +% +% The below value specifies the display math to be set centered, as is common practice. +% Alternatively, \cmd\tabskip\ can be set to a different glue value, accomplishing +% flush-left display math. +% +% Note that the \filename{fleqn.clo} package provides its own meaning for +% the eqnarray environment, which is also broken. We do not patch that package, however. +% +% \changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}% +% Bug note: The \filename{lineno.sty} package detects \filename{fleqn.clo} +% by testing whether \cmd\mathindent\ is defined, instead of using correct \LaTeXe\ means. +% Even though our eqnarray environment is modelled after \filename{fleqn.clo}, +% we must program defensively here. +% \begin{macrocode} +\def\ltx@mathindent{\@centering}% \def\set@eqnarray@skips{}% % \end{macrocode} % \end{macro} % \end{macro} +% +% \changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}% +%\begin{macro}{\prep@math} +%\begin{macro}{\prep@math@patch} +% If we are in vertical mode when display math mode is entered (via \verb+$$+), +% \TeX\ will first enter horizontal mode, then display math mode; this results in a phantom paragraph +% containing a single \cmd\hbox\ consisting of the \cmd\parindent\ box followed by the \cmd\parskipfillskip\ glue. +% Of course, that \cmd\hbox\ is accompanied by \cmd\parskip\ glue and \cmd\baselineskip\ glue. +% +% The \cmd\prep@math\ procedure removes the \cmd\parindent\ box, thereby (magically) eliminating the phantom paragraph. +% The \cmd\prep@math@patch\ procedure headpatches the \env{equation} and \env{eqnarray} environments +% to accomplish this removal of the phantom paragraph. +% +% Note that there are three remaining ways to enter display math mode that we do not treat: +% the \env{displaymath} environment (equivalent to \cmd\[/\cmd\]), and the primitive the \verb+$$+ markup. +% I refrain from treating the first case because \env{displaymath} already detects the case +% where it is entered from vertical mode: I do not wish to engage in the dubious enterprise of attempting to correct a procedure that is ill conceived from the outset. +% As to the primitive \verb+$$+, there is no help for users who insist upon employing procedural markup in their documents. +% in their documents. +% \begin{macrocode} +\def\prep@math{% + \@ifvmode{\everypar{{\setbox\z@\lastbox}}}{}% +}% +\def\prep@math@patch{% + \prepdef\equation{\prep@math}% + \prepdef\eqnarray{\prep@math}% +}% +% \end{macrocode} +% A document class may invoke \cmd\prep@math@patch\ at any point it wishes to prevent the appearance +% of the phantom paragraph: it may be a global declaration or a local one. +% \end{macro} +% \end{macro} % +% We fail to patch \cmd\[, \cmd\equation, however. % % \subsection{Footnotes} % -% \changes{v4.0beta 4}{2000/04/10} -% {New kernel fix. For bug 174} +% \changes{4.0d}{2000/04/10}{(AO, 174) kernel fix} % -% \begin{macro}{\footnote} % \begin{macro}{\footnotemark} -% \begin{macro}{\@xfootnote} -% \begin{macro}{\@xfootnotemark} -% \begin{macro}{\@yfootnote} +% \begin{macro}{\footnotetest} +% \begin{macro}{\ltx@xfootnote} +% \begin{macro}{\ltx@footmark} +% \begin{macro}{\ltx@foottext} +% \begin{macro}{\ltx@make@current@footnote} % 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 +% they do not share the method, used by \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. +% This is a \LaTeX\ bug of long standing; our 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. +% While we are at it, we rewrite both the \cmd\footnote, \cmd\footnotemark\ and \cmd\footnotetext\ procedures, +% achieving a cleaner separation of syntax and semantics. +% Note that the \cmd\@footnotetext\ procedure is not involved in context switching; +% \classname{hyperref} will take over that procedure, substituting its own processing around +% its argument and passing this to \cmd\H@@footnotetext. +% We anticipate this, and do our context switching on \cmd\H@@footnotetext. +% +% The \cmd\@makefnmark\ continues as the method of formatting the footnote mark. % % 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} +% behave:\begin{verbatim} %\def\@mpfn{mpfootnote}% %\def\thempfn{\thempfootnote}% %\let\@footnotetext\@mpfootnotetext -%\c@mpfootnote\z@ -%\end{verbatim} +%\let\@makefnmark\@mpmakefnmark +%\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. +% Note that \LaTeX\ initially defines \cmd\@mpfn\ as \texttt{footnote} and \cmd\thempfn\ as \cmd\thefootnote, +% so we are initially doing general footnotes. +% +% Any procedure that establishes a minipage-like context (e.g., floats) can do the same as the mimipage context switch +% illustrated above. +% \changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.} +% +% Three user-level command, \cmd\footnote, \cmd\footnotemark, and \cmd\footnotetext\ are defined (see the \LaTeX\ manual for user-level details). +% \begin{macro}{\footnote} +% The first user-level command is \cmd\footnote. +% A simple way to look at this command is to think of it as +% \cmd\footnotemark\ \oarg{number} \cmd\footnotetext\ \oarg{number} \arg{text}, +% where the optional argument is the same in both calls. +% We also define a syntactical helper procedure \cmd\ltx@xfootnote. +% +% We employ the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc, +% passing in the procedure to execute, in this case \cmd\ltx@footmark, +% which sets the footnote mark. +% In any case, we end on the procedure \cmd\ltx@foottext, which sets the footnote text. % \begin{macrocode} -\def\footnote{% - \@ifnextchar[\@xfootnote{\@yfootnote\@footnotetext}% +\def\footnote{\@ifnextchar[\ltx@xfootnote\ltx@yfootnote}% +\def\ltx@xfootnote[#1]{% + \ltx@def@footproc\ltx@footmark[#1]% + \expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}% }% -\def\footnotemark{% - \@ifnextchar[\@xfootnotemark{\@yfootnote}% +\def\ltx@yfootnote{% + \ltx@stp@footproc\ltx@footmark + \expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}% }% -\def\@xfootnote[#1]{% - \@xfootnotemark[#1]% - \@footnotetext +% \end{macrocode} +% The \cmd\footmark\ user-level command is next. +% Here we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc\ again, +% but unlike \cmd\footnote, we do not set the footnote text. +% \begin{macrocode} +\def\footnotemark{\@ifnextchar[\ltx@xfootmark\ltx@yfootmark}% +\def\ltx@xfootmark{\ltx@def@footproc\ltx@footmark}% +\def\ltx@yfootmark{\ltx@stp@footproc\ltx@footmark}% +\def\ltx@footmark#1{% + \leavevmode + \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi + \begingroup + \expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}% + \expandafter\@argswap@val\expandafter{\Hy@footnote@currentHref}{\hyper@linkstart {link}}% + \@makefnmark + \hyper@linkend + \endgroup + \ifhmode\spacefactor\@x@sf\fi + \relax }% -\def\@xfootnotemark@ltx[#1]{% +% \end{macrocode} +% The third user-level command is \cmd\footnotetext. +% As with \cmd\footnotemark, we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc, +% this time passing in the procedure \cmd\ltx@foottext, which sets the footnote text. +% \begin{macrocode} +\def\footnotetext{\@ifnextchar[\ltx@xfoottext\ltx@yfoottext}% +\def\ltx@xfoottext{\ltx@def@footproc\ltx@foottext}% +\def\ltx@yfoottext{\ltx@stp@footproc\ltx@foottext}% +\long\def\ltx@foottext#1#2{% \begingroup - \csname c@\@mpfn\endcsname #1\relax - \unrestored@protected@xdef\@thefnmark{\thempfn}% + \expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}% + \@footnotetext{#2}% \endgroup - \H@@footnotemark }% -\def\@yfootnote{% - \stepcounter\@mpfn +% \end{macrocode} +% Here are the definitions of the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc. +% The require argument is the procedure to execute afterwards, and +% \cmd\ltx@def@footproc\ parses a bracket-delimited argument (it is not optional). +% In each case the given procedure is executed with an argument prepared for it: +% the value of the footnote counter. +% \begin{macrocode} +\def\ltx@def@footproc#1[#2]{% + \begingroup + \csname c@\@mpfn\endcsname #2\relax + \unrestored@protected@xdef\@thefnmark{\thempfn}% + \expandafter\endgroup + \expandafter#1% + \expandafter{\the\csname c@\@mpfn\endcsname}% +}% +\def\ltx@stp@footproc#1{% + \expandafter\stepcounter\expandafter{\@mpfn}% \protected@xdef\@thefnmark{\thempfn}% - \H@@footnotemark + \expandafter#1% + \expandafter{\the\csname c@\@mpfn\endcsname}% +}% +% \end{macrocode} +% Here we provide for our good friend \classname{hyperref} +% to enter in like a bull in a china shop. If it is not loaded, +% we do what it would have done, but gentlier and without hypertext functionality. +% \begin{macrocode} +\appdef\class@documenthook{% + \let\footnote@latex\footnote + \@ifpackageloaded{hyperref}{}{% + \let\H@@footnotetext\@footnotetext + \def\@footnotetext{\H@@footnotetext}% + \let\H@@mpfootnotetext\@mpfootnotetext + \def\@mpfootnotetext{\H@@mpfootnotetext}% + }% }% % \end{macrocode} +% In the following, we must use \LaTeX's rococco equipment in the form of \cmd\protected@edef, +% because of the presence of a font switch in the meaning of \cmd\thempfootnote. +% But, really, isn't this a sloppy conflation of semantics and presentation? +% \begin{macrocode} +\def\ltx@make@current@footnote#1#2{% + \csname c@#1\endcsname#2\relax + \protected@edef\Hy@footnote@currentHref{\@currentHref-#1.\csname the#1\endcsname}% +}% +\def\thempfootnote@latex{{\itshape \@alph \c@mpfootnote }}% +\def\ltx@thempfootnote{\@alph\c@mpfootnote}% +\@ifx{\thempfootnote\thempfootnote@latex}{% + \class@info{Repairing hyperref-unfriendly LaTeX definition of \string\mpfootnote}% + \let\thempfootnote\ltx@thempfootnote +}{}% +% \end{macrocode} % -% Note on \classname{hyperref} compatability: +% Note on \classname{hyperref} compatibility: % In its ``Automated \LaTeX\ hypertext cross-references'', % the \classname{hyperref} package alters footnote processing, -% thereby imperiling these fixes and necessiating defensive measures. +% but it does nothing to address the several issues of concern to us. +% +% The \classname{hyperref} package takes over the \cmd\@mpfootnotetext\ and +% \cmd\@footnotetext\ procedures, wrapping the argument in its own code. +% It also rewrites \cmd\@footnotemark, making it a hyperlink, and +% \cmd\@xfootnotenext, removing from it all hypertext capabilities. % -% 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. +% However, if the \cmd\footnotemark\ command has been supplied with an optional argument, +% \classname{hyperref}'s changes do not apply: it punts in this case. % -% 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. +% At the same time, it attempts to turn off its changes during +% \cmd\maketitle\ processing, destroying one of the capabilities we desire. % -% We make ourself \classname{hyperref} friendly: -% we give \classname{hyperref} what it needs, but avoid its change to -% \cmd\@xfootnotemark. +% We make ourself \classname{hyperref} savvy: +% we re-implement footnote processing, using \classname{hyperref} capabilities if that +% package has been loaded. % % 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} +% \changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}% % % Two thoughts about \classname{hyperref}: what for does it define \cmd\realfootnote? +% Apparently even SR himself cannot remember. +% % 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. +% 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! @@ -1133,6 +1486,8 @@ in your filesystem where they will be found by \LaTeX. % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\@footnotetext} % \begin{macro}{\@mpfootnotetext} @@ -1148,7 +1503,7 @@ in your filesystem where they will be found by \LaTeX. % 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 +% At any rate, with the \classname{ltxgrid} package, split insertions are properly % taken care of, so we allow it. % % We provide the hook \cmd\set@footnotewidth\ @@ -1163,20 +1518,32 @@ in your filesystem where they will be found by \LaTeX. % are a step outside of the galley context, and all aspects of insertions need to be % properly handled, including the set width. % \begin{macrocode} +\def\@makefnmark{% + \hbox{% + \@textsuperscript{% + \normalfont\itshape\@thefnmark + }% + }% +}% +% \end{macrocode} +% \begin{macrocode} \long\def\@footnotetext{% \insert\footins\bgroup \make@footnotetext }% +% \end{macrocode} +% \begin{macrocode} \long\def\@mpfootnotetext{% \minipagefootnote@pick \make@footnotetext }% -\def\make@footnotetext#1{% - \reset@font\footnotesize - \interlinepenalty\interfootnotelinepenalty - \splittopskip\footnotesep - \splitmaxdepth\dp\strutbox -% \floatingpenalty\@MM +% \end{macrocode} +% \begin{macrocode} +\long\def\make@footnotetext#1{% + \set@footnotefont +% \end{macrocode} +% As noted above, we do \emph{not} do \cmd\floatingpenalty\ \cmd\@MM. +% \begin{macrocode} \set@footnotewidth \@parboxrestore \protected@edef\@currentlabel{% @@ -1189,10 +1556,26 @@ in your filesystem where they will be found by \LaTeX. \color@endgroup \minipagefootnote@drop }% +% \end{macrocode} +% \changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote} +% \cmd\set@footnotefont\ is the procedure for setting the font of a footnote. +% Other aspects of the environment may be set using this hook. +% \begin{macrocode} +\def\set@footnotefont{% + \reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \splittopskip\footnotesep + \splitmaxdepth\dp\strutbox +}% +% \end{macrocode} +% \cmd\set@footnotewidth\ is the procedure for setting the width of a footnote. +% \begin{macrocode} \def\set@footnotewidth{% \hsize\columnwidth \linewidth\hsize }% +% \end{macrocode} +% \begin{macrocode} \def\set@footnotewidth@ii{% \hsize\textwidth \advance\hsize\columnsep @@ -1235,13 +1618,11 @@ in your filesystem where they will be found by \LaTeX. % % \item % Optionally define an alternative, say \env{figure@write} as follows: -% \begin{verbatim} -%\newenvironment{figure@write}{% +% \begin{verbatim}\newenvironment{figure@write}{% % \write@float{figure}% %}{% % \endwrite@float -%}% -% \end{verbatim} +%}\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 @@ -1251,9 +1632,7 @@ in your filesystem where they will be found by \LaTeX. % \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} +% \begin{verbatim}\appdef\class@documenthook{\do@if@floats{figure}{.fgx}}\end{verbatim} % % \item % Optionally define a text entity \cmd\figuresname\ that will @@ -1265,15 +1644,11 @@ in your filesystem where they will be found by \LaTeX. % 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} +% \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} +% \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. @@ -1286,24 +1661,33 @@ in your filesystem where they will be found by \LaTeX. % We provide for a little help, but without changing the meanings of these commands. % % \begin{macro}{\addtocontents} +% \begin{macro}{\robustify@contents} % +% \changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}% % \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}}% +\def\robustify@contents{% + \let \label \@gobble + \let \index \@gobble + \let \glossary \@gobble + \let\footnote \@gobble + \def\({\string\(}% + \def\){\string\)}% + \def\\{\string\\}% +}% +\long\def\addtocontents#1#2{% + \protected@write\@auxout{\robustify@contents}{\string \@writefile {#1}{#2}}% }% % \end{macrocode} % % \end{macro} +% \end{macro} % % \subsubsection{Preparing for the \classname{hyperref package}}% % % \begin{macro}{\addcontentsline} -% \begin{macro}{\contentsline} +% \begin{macro}{\label} +% \begin{macro}{\ltx@contentsline} +% \changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}% % 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 @@ -1311,16 +1695,16 @@ in your filesystem where they will be found by \LaTeX. % % 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. +% Finally, we wrap \LaTeX's \cmd\contentsline\ command with code to detect the case +% where the expected procedure is not defined, and we give it a syntax with no semantics. +% +% We switch over to this new definition only after \classname{hyperref} has loaded. % \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{}{% @@ -1328,10 +1712,21 @@ in your filesystem where they will be found by \LaTeX. }% \@esphack }% +\def\ltx@contentsline#1{% + \expandafter\@ifnotrelax\csname l@#1\endcsname{}{% + \expandafter\let\csname l@#1\endcsname\@gobbletwo + }% + \contentsline@latex{#1}% +}% +\appdef\document@inithook{% + \let\contentsline@latex\contentsline + \let\contentsline\ltx@contentsline +}% % \end{macrocode} % % \end{macro} % \end{macro} +% \end{macro} % % \subsubsection{Footnotes within floats, unfloating floats, float font}% % @@ -1339,19 +1734,16 @@ in your filesystem where they will be found by \LaTeX. % 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}.} +% \changes{4.0b}{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: +% Note on \classname{hyperref} compatibility: % this change to the \cmd\caption\ command is compatible with the -% ``Automated \LaTeX\ hypertext cross-references'' patches of -% that package. +% ``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. @@ -1371,9 +1763,7 @@ in your filesystem where they will be found by \LaTeX. % \hyper@@anchor{\@currentHref}{\relax}#3% % \fi % }% -%}% -% -%\end{verbatim} +%}\end{verbatim} % % \end{macro} % @@ -1432,17 +1822,14 @@ in your filesystem where they will be found by \LaTeX. % \end{macro} % % \begin{macro}{\floats@sw} +% \changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}% % 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 +% Note that the assignment of this Boolean is to be overridden 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} +% \begin{macrocode} +\@booleantrue\floats@sw +% \end{macrocode} % \end{macro} % % \begin{macro}{\@xfloat} @@ -1453,63 +1840,42 @@ in your filesystem where they will be found by \LaTeX. % 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? +% \changes{4.0b}{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{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing} +% \changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks} +% \changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.} +% \changes{4.0e}{2000/11/16}{(AO, 221) Remove samepage command from @xfloat@prep: If the float can break over pages, we want better control.} +% \changes{4.1a}{2008/07/07}{\cs{@xfloat@prep} calls \cs{ltx@footnote@pop} to restore the original \cs{ltx@footmark} and \cs{ltx@foottext} procedures, in case footnote processing has switched.} +% \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}} % % \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 + \ltx@footnote@pop \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 + \let\H@@footnotetext\H@@mpfootnotetext }% -%\def\fp@proc@h{\@booleanfalse\floats@sw}% -%\def\fp@proc@H{\@booleanfalse\floats@sw}% +\let\ltx@footnote@pop\@empty \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\vskip\z@skip \par \end@float@pagebreak }% @@ -1529,8 +1895,9 @@ in your filesystem where they will be found by \LaTeX. % \subsubsection{Writing floats out to a file}% % % \begin{macro}{\do@if@floats} +% \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}} % The procedure \cmd\do@if@floats\ should be executed at -% \cmd\AtBeginDocument\ time, and arranges to write out +% \cmd\class@documenthook\ time: it 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. @@ -1538,7 +1905,6 @@ in your filesystem where they will be found by \LaTeX. % 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. @@ -1579,18 +1945,20 @@ in your filesystem where they will be found by \LaTeX. % \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.} +% \changes{4.0b}{1999/06/20}{only execute if there really were floats of the given type} +% \changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.} +% \changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.} +% \changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.} % +% Here, we make use of the \cmd\floats@sw\ Boolean to select +% the non-floating type of processing. % \begin{macrocode} \def\triggerpar{\leavevmode\@@par}% \def\oneapage{\def\begin@float@pagebreak{\newpage}\def\end@float@pagebreak{\newpage}}% \def\print@float#1#2{% + \lengthcheck@sw{% + \total@float{#1}% + }{}% \@ifxundefined@cs{#1write}{}{% \begingroup \@booleanfalse\floats@sw @@ -1628,13 +1996,93 @@ in your filesystem where they will be found by \LaTeX. % \end{macrocode} % \end{macro} % +% \begin{macro}{\tally@float} +% \begin{macro}{\total@float} +% \changes{4.1b}{2008/08/12}{Tally and log the height of a float class} +% If we are tallying column inches, \cmd\tally@float\ tallies a contribution to \cmd\ftype@\ \cmd\@captype, +% depending upon the width of \cmd\@currbox. +% In effect, each float class is tallied in two sections, one for narrow, one for wide floats. +% +% If statistics are wanted, \cmd\total@float\ logs the tally for the given float class. +% \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long} +% The quantity \cmd\@twopowerfourteen\ is $2^{14}$, \cmd\@twopowertwo\ is $2^{2}$. +% \begin{macrocode} +\chardef\@xvi=16\relax +\mathchardef\@twopowerfourteen="4000 +\mathchardef\@twopowertwo="4 +\def\tally@float#1{% + \begingroup +% \end{macrocode} +% We strip all but the least significant 5 bits from \cmd\count\ \cmd\@currbox, +% and put them into \cmd\@tempcnta. We then subtract 16 from \cmd\count\ \cmd\@currbox +% (unless this would make it negative), effectively reversing the process +% carried out in \cmd\@float. +% \begin{macrocode} + \@tempcnta\count\@currbox + \divide\@tempcnta\@xxxii + \multiply\@tempcnta\@xxxii + \advance\count\@currbox-\@tempcnta + \divide\@tempcnta\@xxxii + \@ifnum{\count\@currbox>\@xvi}{% + \advance\count\@currbox-\@xvi\@booleantrue\@temp@sw + }{% + \@booleanfalse\@temp@sw + }% +% \end{macrocode} +% If so desired, we log the characteristics of this float object: +% float class and float placement parameters, height, depth, and width. +% \begin{macrocode} + \show@box@size@sw{% + \class@info{Float #1 + (\the\@tempcnta)[\@temp@sw{16+}{}\the\count\@currbox]^^J% + (\the\ht\@currbox+\the\dp\@currbox)X\the\wd\@currbox + }% + }{}% + \endgroup +% \end{macrocode} +% Here we tally the height of this float object. +% \begin{macrocode} + \expandafter\let + \expandafter\@tempa + \csname fbox@\csname ftype@#1\endcsname\endcsname + \@ifnotrelax\@tempa{% + \@ifhbox\@tempa{% + \setbox\@tempboxa\vbox{\unvcopy\@currbox\hrule}% + \dimen@\ht\@tempboxa + \divide\dimen@\@twopowerfourteen + \@ifdim{\wd\@tempboxa<\textwidth}{% + \advance\dimen@\ht\@tempa + \global\ht\@tempa\dimen@ + }{% + \advance\dimen@\dp\@tempa + \global\dp\@tempa\dimen@ + }% + }{}% + }{}% +}% +\def\total@float#1{% + \expandafter\let + \expandafter\@tempa + \csname fbox@\csname ftype@#1\endcsname\endcsname + \@ifnotrelax\@tempa{% + \@ifhbox\@tempa{% + \@tempdima\the\ht\@tempa\divide\@tempdima\@twopowertwo\@tempcnta\@tempdima + \@tempdimb\the\dp\@tempa\divide\@tempdimb\@twopowertwo\@tempcntb\@tempdimb + \class@info{Total #1: Column(\the\@tempcnta pt), Page(\the\@tempcnta pt)}% + }{}% + }{}% +}% +% \end{macrocode} +% \end{macro} +% \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 +% 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}}% @@ -1645,10 +2093,7 @@ in your filesystem where they will be found by \LaTeX. % \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.} +% \changes{4.0b}{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 @@ -1670,8 +2115,8 @@ in your filesystem where they will be found by \LaTeX. % \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 +% The procedure \cmd\write@floatline\ only parses; +% it 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. @@ -1797,8 +2242,7 @@ in your filesystem where they will be found by \LaTeX. % the convention that the former is the original \LaTeX\ procedure. % % \begin{macrocode} -\class@info - {Repairing broken LateX \string\@sect}% +\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}% @@ -1864,7 +2308,7 @@ in your filesystem where they will be found by \LaTeX. % Possibly set a mark. % Make a TOC entry. % -% Note that, for compatability with the \classname{hyperref} package, we +% Note that, for compatibility 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 @@ -1873,13 +2317,13 @@ in your filesystem where they will be found by \LaTeX. % 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} +% \changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility} +% \changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility} % \begin{macrocode} \def\@ssect@ltx#1#2#3#4#5#6[#7]#8{% -% \def\@currentlabelname{#8}% +% \end{macrocode} +% Removed |\def\@currentlabelname{#8}| +% \begin{macrocode} \def\H@svsec{\phantomsection}% \@tempskipa #5\relax \@ifdim{\@tempskipa>\z@}{% @@ -1887,7 +2331,9 @@ in your filesystem where they will be found by \LaTeX. \interlinepenalty \@M #6{% \@ifundefined{@hangfroms@#1}{\@hang@froms}{\csname @hangfroms@#1\endcsname}% -% {\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}% +% \end{macrocode} +% Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}| +% \begin{macrocode} {\hskip#3\relax\H@svsec}{#8}% }% \@@par @@ -1898,7 +2344,9 @@ in your filesystem where they will be found by \LaTeX. \def\@svsechd{% #6{% \@ifundefined{@runin@tos@#1}{\@runin@tos}{\csname @runin@tos@#1\endcsname}% -% {\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}% +% \end{macrocode} +% Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}| +% \begin{macrocode} {\hskip#3\relax\H@svsec}{#8}% }% \@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}% @@ -1912,7 +2360,8 @@ in your filesystem where they will be found by \LaTeX. % \end{macrocode} % \end{macro} % -% \begin{macro}{\init@documenthook} +% \begin{macro}{\init@hyperref} +% \changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire} % 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. @@ -1921,25 +2370,27 @@ in your filesystem where they will be found by \LaTeX. % 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 +% Another aspect of being \classname{hyperref}-savvy is that the syntax of commands in the \file{.aux} file will not 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{% +\def\init@hyperref{% \providecommand\phantomsection{}% -%\@ifx{\Sectionformat\@undefined}{\let\Sectionformat\@firstoftwo}{}% - \providecommand\hyper@anchor[1]{}% - \providecommand\hyper@last{}% - \providecommand\Hy@raisedlink[1]{#1}% + \providecommand\hyper@makecurrent[1]{}% + \providecommand\Hy@raisedlink[1]{}% \providecommand\hyper@anchorstart[1]{}% \providecommand\hyper@anchorend{}% \providecommand\hyper@linkstart[2]{}% \providecommand\hyper@linkend{}% + \providecommand\@currentHref{}% }% \let\H@refstepcounter\refstepcounter +\appdef\document@inithook{% + \init@hyperref +}% % \end{macrocode} % \end{macro} % @@ -1969,6 +2420,7 @@ in your filesystem where they will be found by \LaTeX. % % \begin{macro}{\endtabular} % \begin{macro}{\endarray} +% \changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.} % 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. @@ -1979,7 +2431,7 @@ in your filesystem where they will be found by \LaTeX. % other packages that replace the \LaTeX\ \env{array} and \env{tabular} % environments. I know of none that do so. % \begin{macrocode} -\appdef\class@documenthook{% +\appdef\document@inithook{% \@ifpackageloaded{array}{\switch@array}{\switch@tabular}% \prepdef\endtabular{\endtabular@hook}% \@provide\endtabular@hook{}% @@ -1990,8 +2442,7 @@ in your filesystem where they will be found by \LaTeX. % 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} +% \changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package} % \begin{macrocode} \prepdef\@tabular{\tabular@hook}% \@provide\tabular@hook{}% @@ -2123,7 +2574,11 @@ in your filesystem where they will be found by \LaTeX. \let\@xargarraycr\@xargarraycr@ltx \let\@yargarraycr\@yargarraycr@ltx }% +% \end{macrocode} +% \changes{4.1b}{2008/08/12}{(AO, 505) Try to accommodate \classname{colortbl}.} +% \begin{macrocode} \def\switch@array{% + \@ifpackageloaded{colortbl}{\let\switch@array@info\colortbl@message}{\let\switch@array@info\array@message}% \let\@array@sw\@array@sw@LaTeX \@ifx{\@array\@array@array}{% \@ifx{\@tabular\@tabular@array}{% @@ -2139,18 +2594,18 @@ in your filesystem where they will be found by \LaTeX. \@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 }% @@ -2180,7 +2635,7 @@ in your filesystem where they will be found by \LaTeX. }{% \class@info{Patching array package.}% }{% - \class@info{Unrecognized array package. Please update this document class! (Proceeding with fingers crossed.)}% + \switch@array@info }% \let\@array \@array@array@new \let\@@array \@array % Cosi fan tutti @@ -2200,6 +2655,12 @@ in your filesystem where they will be found by \LaTeX. \let\@xargarraycr\@xargarraycr@new \let\@yargarraycr\@yargarraycr@new }% +\def\array@message{% + \class@info{Unrecognized array package. Please update this document class! (Proceeding with fingers crossed.)}% +}% +\def\colortbl@message{% + \class@info{colortbl package is loaded. (Proceeding with fingers crossed.)}% +}% % \end{macrocode} % \end{macro} % \end{macro} @@ -2214,8 +2675,12 @@ in your filesystem where they will be found by \LaTeX. % \end{macro} % % \begin{macro}{\@tabular} +% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} % 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). +% +% Compatibility note: I had done \cmd\let\ \cmd\col@sep\ \cmd\@undefined\ here, but +% this was not compatible with \classname{colortbl}. I have removed that statement. % \begin{macrocode} \def\@tabular@LaTeX{% \leavevmode @@ -2247,7 +2712,9 @@ in your filesystem where they will be found by \LaTeX. \let\@acoll\@tabacoll \let\@acolr\@tabacolr \let\@acol\@tabacol - \let\col@sep\@undefined +% \end{macrocode} +% \let\col@sep\@undefined +% \begin{macrocode} \let\d@llarbegin\begingroup \let\d@llarend\endgroup \@tabarray @@ -2261,7 +2728,13 @@ in your filesystem where they will be found by \LaTeX. % 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}. +% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} +% FIXME: must decouple \env{array} and \env{tabular}. Done (it seems). +% +% Note on \classname{colortbl}: this package head-patches \cmd\@tabarray +% with its own command \cmd\CT@start, and tails onto \cmd\endarray\ with \cmd\CT@end. +% It fortuitously does the former at \cmd\AtBeginDocument\ time, and, fortuitously, +% we do not patch \cmd\endarray, which it overwrites. % \begin{macrocode} \def\@tabarray@LaTeX{% \m@th\@ifnextchar[\@array{\@array[c]}% @@ -2406,7 +2879,10 @@ in your filesystem where they will be found by \LaTeX. \let\@acoll\@arrayacol \let\@acolr\@arrayacol \let\@acol\@arrayacol -\let\col@sep\@undefined +% \end{macrocode} +% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} +% Removed: \verb+\let\col@sep\@undefined+ +% \begin{macrocode} \def\d@llarbegin{$}% \let\d@llarend\d@llarbegin \gdef\@halignto{}% @@ -2892,26 +3368,34 @@ in your filesystem where they will be found by \LaTeX. % 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. +% 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\tableftsep \relax + \let\tabmidsep \relax + \let\tabrightsep \relax \let\array@row@rst\relax - \let\cell@font\relax - \let\@startpbox\relax + \let\cell@font \relax + \let\@startpbox \relax }% % \end{macrocode} % \end{macro} % % \begin{macro}{\@mkpream} +% We insert \cmd\@mkpream@relax\ at the head of the procedure. +% The robustifying of \cmd\@startpbox\ and \cmd\@endpbox\ is taken over by this mechanism. +% We also invoke \cmd\@acolr\ instead of \cmd\@acol\ when a right-hand column is at hand. +% +% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} +% Note on \classname{colortbl}: this package head-patches \cmd\@mkpream\ to robustify +% a number of its commands during the construction of the alignment preamble. +% The best we can do is to supplement the \cmd\@mkpream@relax\ procedure to perform this action. % \begin{macrocode} \def\@mkpream@array#1{% \gdef\@preamble{}\@lastchclass 4 \@firstamptrue @@ -2998,6 +3482,26 @@ in your filesystem where they will be found by \LaTeX. % \end{macrocode} % \end{macro} % +% \begin{macro}{\@mkpream@relax} +% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.} +% David P. Carlisle's \classname{colortbl} package headpatches \cmd\@mkpream\ in place +% during package loading, so it does not know whom it is working on. +% Let us try to accomodate this package by doing what it would have liked to have done. +% +% Note: it would be far better to break out this mechanism in the \classname{array} package. +% \begin{macrocode} +\appdef\@mkpream@relax{% + \let\CT@setup \relax + \let\CT@color \relax + \let\CT@do@color \relax + \let\color \relax + \let\CT@column@color\relax + \let\CT@row@color \relax + \let\CT@cell@color \relax +}% +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@addamp} % \begin{macrocode} \def\@addamp@LaTeX{% @@ -3217,7 +3721,7 @@ in your filesystem where they will be found by \LaTeX. \ifodd\@tempcntb \@testtrue\fi \fi}% \def\@xbitor@ltx#1{% - \@tempcntb\count#1% + \@tempcntb\count#1\relax \@ifnum{\@tempcnta=\z@}{}{% \divide\@tempcntb\@tempcnta \@ifodd\@tempcntb{\@testtrue}{}% @@ -3248,11 +3752,11 @@ in your filesystem where they will be found by \LaTeX. % % Note on \classname{hyperref} compatibility: % We must respect that -% \cmd\contentsline now has a 4th argument. +% \cmd\contentsline\ now has a fourth 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 +% In this respect, this package retains compatibility with % \classname{hyperref}. % % \begin{macro}{\@starttoc} @@ -3282,9 +3786,10 @@ in your filesystem where they will be found by \LaTeX. % % Note: \cmd\toc@@font\ is the common font for all auto-sizing toc commands, % although this, too, could become a dispatcher. +% \changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}% % \begin{macrocode} -\def\toc@@font{}%{\footnotesize\rmfamily}% -\def\@dotsep{\z@}%{5.5pt}% +\def\toc@@font{}% +\def\ltxu@dotsep{\z@}% % \end{macrocode} % \end{macro} % @@ -3292,31 +3797,18 @@ in your filesystem where they will be found by \LaTeX. % 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 +% utility procedure \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} +% 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\end{verbatim} +% \begin{verbatim}\def\tocleft@{\z@}%\end{verbatim} +% \begin{verbatim}\def\l@subsection{\l@@sections{section}{subsection}}% Implicit #3#4\end{verbatim} +% \begin{verbatim}\def\l@subsubsection{\l@@sections{subsection}{subsubsection}}% Implicit #3#4\end{verbatim} +% \begin{verbatim}\def\l@paragraph{\l@@sections{subsubsection}{paragraph}}% Implicit #3#4\end{verbatim} +% \begin{verbatim}\def\l@subparagraph#1#2{\l@@sections{paragraph}{subparagraph}}% Implicit #3#4\end{verbatim} % \end{macro} % % Glom some \cmd\dimen\ registers. @@ -3411,17 +3903,20 @@ in your filesystem where they will be found by \LaTeX. % \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|. +% Note that the assignment of \cmd\box\cmd\@tempboxa\ by \cmd\set@tocdim@pagenum\ +% must endure over the invocation of |#3|: it contains the +% page number which will be set just before the \cmd\par. +% +% The arguments:\begin{enumerate} +% \item[\#1] superior section +% \item[\#2] this section +% \item[\#3] content, including possible \cmd\numberline +% \item[\#4] page number\end{enumerate} % \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}% + \set@tocdim@pagenum\@tempboxa{#4}% \global\@tempdima\csname tocdim@#2\endcsname \leftskip\csname tocleft@#2\endcsname\relax \dimen@\csname tocleft@#1\endcsname\relax @@ -3436,15 +3931,21 @@ in your filesystem where they will be found by \LaTeX. \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} +% \changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}% +% In the call to \cmd\set@tocdim@pagenum, I am now exposing the +% use of the particular box register. +% \begin{macrocode} +\def\set@tocdim@pagenum#1#2{% + \setbox#1\hbox{\ignorespaces#2}% + \@ifdim{\tocdim@pagenum<\wd#1}{\global\tocdim@pagenum\wd#1}{}% }% % \end{macrocode} % \end{macro} % % \begin{macro}{\numberline@@sections} -% The bottleproc for all \cmd\numberline\ processing in indented TOC entries. +% \changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}% +% The utility procedure 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 @@ -3456,7 +3957,7 @@ in your filesystem where they will be found by \LaTeX. \leavevmode\hb@xt@-\parindent{% \hfil \@if@empty{#1}{}{% - \setbox\z@\hbox{#1.\kern\@dotsep}% + \setbox\z@\hbox{#1.\kern\ltxu@dotsep}% \@ifdim{\@tempdima<\wd\z@}{\global\@tempdima\wd\z@}{}% \unhbox\z@ }% @@ -3519,15 +4020,84 @@ in your filesystem where they will be found by \LaTeX. % \end{macrocode} % \end{macro} % -% \subsection{End of the \file{ltxutil} {\sc docstrip} module} -% Here ends the module. +% +% \subsection{Hypertext capabilities} +% +% \begin{macro}{\href} +% \begin{macro}{\url} +% \begin{macro}{\URL@prefix} +% \changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}% +% We provide support for the \cmd\href\ and \cmd\url\ commands. +% Packages, like \classname{hyperref}, may override these definitions +% and provide better semantics. +% \changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}% +% \begin{macrocode} +\providecommand\href[0]{\begingroup\@sanitize\@href}% +\def\@href#1{\@@startlink{#1}\@@href}% +\def\@@href#1{\endgroup#1\@@endlink}% +\providecommand \url [0]{\begingroup\@sanitize \@url }% +\def \@url #1{\endgroup\@href {#1}{\URL@prefix#1}}% +\providecommand \URL@prefix [0]{URL }% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@startlink} +% \begin{macro}{\@@endlink} +% \begin{macro}{\pdfstartlink@attr} +% How we define \cmd\@@startlink\ and \cmd\@@endlink\ will depend on +% whether we are running under \textsc{pdflatex}. +% If so, and if PDF output is requested, then we use its primitives +% to implement hypertext, +% breaking out the link attributes in \cmd\pdfstartlink@attr\ +% and using the \classname{hyperref} defaults; +% \cmd\pdfstartlink@attr\ can be redefined by a client package. +% Otherwise we fall back the Hyper\TeX\ standard and leave things to the DVI translator. % \begin{macrocode} -%</ltxutil-krn> +\@ifxundefined \pdfoutput {\true@sw}{\@ifnum{\z@=\pdfoutput}{\true@sw}{\false@sw}}% +{% + \def\@@startlink#1{\leavevmode\special{html:<a href="#1">}}% + \def\@@endlink{\special{html:</a>}}% +}{% + \def\@@startlink#1{% + \leavevmode + \pdfstartlink\pdfstartlink@attr + user{/Subtype/Link/A<</Type/Action/S/URI/URI(#1)>>}% + \relax + }% + \def\@@endlink{\pdfendlink}% + \def\pdfstartlink@attr{attr{/Border[0 0 1 ]/H/I/C[0 1 1]}}% +}% +\def\typeout@org#1{% + \begingroup + \set@display@protect + \immediate\write\@unused{#1}% + \endgroup +}% +\long\def\typeout@ltx#1{% + \begingroup + \set@display@protect + \immediate\write\@unused{#1}% + \endgroup +}% +\@ifx{\typeout\typeout@org}{% + \class@info{Making \string\typeout\space \string\long}% + \let\typeout\typeout@ltx +}{}% % \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} % +% \subsection{End of the \file{kernel} {\sc docstrip} module} +% Here ends the module. +% \begin{macrocode} +%</kernel> +% \end{macrocode} % % \Finale -% %Here ends the programmer's documentation. +% \iffalse Here ends the programmer's documentation.\fi % \endinput % \endinput |