Debian Codegraph @

texmf-dist/source/latex/revtex/ltxutil.dtx

raw
1 % \iffalse meta-comment balanced on line 107
2 % ltxutil.dtx: utilities package
3 % Copyright (c) 2009 Arthur Ogawa
4 %
5 % Disclaimer
6 % This file is distributed WITHOUT ANY WARRANTY;
7 % without even the implied warranty of
8 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 % License
10 % You may distribute this file under the conditions of the
11 % LaTeX Project Public License 1.3c or later
12 % (http://www.latex-project.org/lppl.txt).
13 % ReadMe
14 % For the documentation and more detailed instructions for
15 % installation, typeset this document with \LaTeX.
16 % Maintenance Status
17 % This work has the LPPL maintenance status "maintained";
18 % Current Maintainer of this work is Arthur Ogawa
19 % changes for version 4.2d--4.2f by Phelype Oleinik.
20 %
21 % This work consists of the main source file ltxutil.dtx
22 % and the derived files
23 % ltxutil.sty, ltxutil.pdf
24 % Distribution:
25 % CTAN:macros/latex/contrib/revtex/
26 %
27 % Unpacking:
28 % tex ltxutil.dtx
29 %
30 % Documentation:
31 % latex ltxutil.dtx; ...
32 %
33 % Program calls to get the documentation (example):
34 % pdflatex ltxutil.dtx
35 % makeindex -s gind.ist ltxutil.idx
36 % makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo
37 % pdflatex ltxutil.dtx
38 % makeindex -s gind.ist ltxutil.idx
39 % pdflatex ltxutil.dtx
40 %
41 % Installation:
42 % TDS:doc/latex/revtex/
43 % TDS:source/latex/revtex/
44 % TDS:tex/latex/revtex/
45 %
46 % Thanks, Heiko!
47 % This method of letting a single .dtx file serve as both
48 % documentation (via latex) and installer (via tex) follows
49 % the example of Heiko Oberdiek. Thanks!
50 %<*ignore>
51 \begingroup
52 \def\x{LaTeX2e}%
53 \expandafter\endgroup
54 \ifcase
55 0\expandafter\ifx\csname processbatchFile\endcsname\relax\else1\fi\ifx\fmtname\x\else 1\fi
56 \relax
57 \else
58 \csname fi\endcsname
59 %</ignore>
60 %<*install>
61 \input docstrip
62 \preamble
63
64 This is a generated file;
65 altering it directly is inadvisable;
66 instead, modify the original source file.
67 See the URL in the file README-LTXUTIL.tex.
68
69 License
70 You may distribute this file under the conditions of the
71 LaTeX Project Public License 1.3c or later
72 (http://www.latex-project.org/lppl.txt).
73
74 This file is distributed WITHOUT ANY WARRANTY;
75 without even the implied warranty of MERCHANTABILITY
76 or FITNESS FOR A PARTICULAR PURPOSE.
77
78 \endpreamble
79 \askforoverwritefalse
80 \keepsilent
81 \generate{%
82 %{ignore}
83 \file{ltxutil.sty}{%
84 \from{ltxutil.dtx}{package,kernel}%
85 }%
86 \file{ltxutil.krn}{%
87 \from{ltxutil.dtx}{kernel}%
88 }%
89 }%
90 \ifToplevel{
91 \Msg{***********************************************************}
92 \Msg{*}
93 \Msg{* To finish the installation, please move}
94 \Msg{* ltxutil.sty}
95 \Msg{* into a directory searched by TeX;}
96 \Msg{* in a TDS-compliant installation:}
97 \Msg{* texmf/tex/macros/latex/revtex/.}
98 \Msg{*}
99 \Msg{* To produce the documentation,
100 run ltxutil.dtx through LaTeX.}
101 \Msg{*}
102 \Msg{* Happy TeXing}
103 \Msg{***********************************************************}
104 }
105 \endbatchfile
106 %</install>
107 %<*ignore>
108 \fi
109 %</ignore>
110 % \fi
111 %
112 % \GetFileInfo{ltxutil.dtx}
113 %
114 % \iffalse ltxdoc klootch
115 %<*package>
116 %%% @LaTeX-file{
117 %%% filename = "ltxutil.dtx",
118 %%% version = "4.2f",
119 %%% date = "2022/06/05",
120 %%% author = "Arthur Ogawa (mailto:arthur_ogawa at sbcglobal.net),
121 %%% Phelype Oleinik (mailto:phelype.oleinik at latex-project.org),
122 %%% commissioned by the American Physical Society. Minor changes by Mark Doyle for version 4.2a-c.
123 %%% ",
124 %%% copyright = "Copyright (C) 1999, 2009 Arthur Ogawa,
125 %%% distributed under the terms of the
126 %%% LaTeX Project Public License 1.3c, see
127 %%% ftp://ctan.tug.org/macros/latex/base/lppl.txt
128 %%% ",
129 %%% address = "Arthur Ogawa,
130 %%% USA",
131 %%% telephone = "",
132 %%% FAX = "",
133 %%% email = "mailto colon arthur_ogawa at sbcglobal.net",
134 %%% codetable = "ISO/ASCII",
135 %%% keywords = "latex, page grid, main vertical list",
136 %%% supported = "yes",
137 %%% abstract = "utilities package",
138 %%% }
139 %</package>
140 % \fi
141 %
142 % \iffalse ltxdoc klootch
143 % The following references the \file{README-LTXUTIL} file,
144 % which contains basic information about this package.
145 % The contents of this file are generated when
146 % you typeset the programmer's documentation.
147 % Search on "{filecontents*}{README-LTXUTIL}" to locate it.
148 % \fi\input{README-LTXUTIL}%
149 %
150 % \subsection{Bill of Materials}
151 %
152 % Following is a list of the files in this distribution arranged
153 % according to provenance.
154 %
155 % \subsubsection{Primary Source}%
156 % One single file generates all.
157 %\begin{verbatim}
158 %ltxutil.dtx
159 %\end{verbatim}
160 %
161 % \subsubsection{Generated by \texttt{latex ltxutil.dtx}}%
162 % Typesetting the source file under pdflatex
163 % generates the readme and the documentation.
164 %\begin{verbatim}
165 %README-LTXUTIL ltxutil.pdf
166 %\end{verbatim}
167 %
168 % \subsubsection{Generated by \texttt{tex ltxutil.dtx}}%
169 % Typesetting this file with \TeX\ generates
170 % the package file.
171 %\begin{verbatim}
172 %ltxutil.sty
173 %\end{verbatim}
174 %
175 % \subsubsection{Auxiliary}%
176 % The following are auxiliary files generated
177 % in the course of running \LaTeX:
178 % \begin{verbatim}
179 %ltxutil.aux ltxutil.idx ltxutil.ind ltxutil.log ltxutil.toc
180 % \end{verbatim}
181 %
182 % \section{Code common to all modules}%
183 %
184 % We want to require only one place in this file
185 % where the version number is stated,
186 % and we also want to ensure that the version
187 % number is embedded into every generated file.
188 %
189 % Now we declare that
190 % these files can only be used with \LaTeXe.
191 % An appropriate message is displayed if
192 % a different \TeX{} format is used.
193 % \begin{macrocode}
194 %<*doc|package>
195 \NeedsTeXFormat{LaTeX2e}[1995/12/01]%
196 %</doc|package>
197 % \end{macrocode}
198 % As desired, the following modules all
199 % take common version information:
200 % \begin{macrocode}
201 %<kernel&!package&!doc>\typeout{%
202 %<*package|doc>
203 \ProvidesFile{%
204 %</package|doc>
205 %<*kernel|package|doc>
206 ltxutil%
207 %</kernel|package|doc>
208 %<*doc>
209 .dtx%
210 %</doc>
211 %<package>.sty%
212 %<*package|doc>
213 }%
214 %</package|doc>
215 % \end{macrocode}
216 %
217 % The following line contains, for once and for all,
218 % the version and date information.
219 % By various means, this information is reproduced
220 % consistently in all generated files and in the
221 % typeset documentation.
222 % Give credit where due.
223 % \begin{macrocode}
224 %<*doc|package|kernel>
225 %<version>
226 [2022/06/05 4.2f utilities package (portions licensed from W. E. Baxter web at superscript.com)]% \fileversion
227 %</doc|package|kernel>
228 %<kernel&!package&!doc>}%
229 % \end{macrocode}
230 %
231 %
232 % \section{The driver module \texttt{doc}}
233 %
234 % This module, consisting of the present section,
235 % typesets the programmer's documentation,
236 % generating the \file{README-LTXUTIL} as required.
237 %
238 % Because the only uncommented-out lines of code at the beginning of
239 % this file constitute the \file{doc} module itself,
240 % we can simply typeset the \file{.dtx} file directly,
241 % and there is thus rarely any need to
242 % generate the ``doc'' {\sc docstrip} module.
243 % Module delimiters are nonetheless required so that
244 % this code does not find its way into the other modules.
245 %
246 % The \enve{document} command concludes the typesetting run.
247 %
248 % \begin{macrocode}
249 %<*doc>
250 % \end{macrocode}
251 %
252 % \subsection{The Preamble}
253 % The programmers documentation is formatted
254 % with the \classname{ltxdoc} class with local customizations,
255 % and with the usual code line indexing.
256 % \begin{macrocode}
257 \documentclass{ltxdoc}
258 \RequirePackage{ltxdocext}%
259 \let\url\undefined
260 \RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}%
261 \pdfstringdefDisableCommands{%
262 \let\file\relax
263 \let\sc\relax
264 }
265 %\expandafter\ifx\csname package@font\endcsname\@undefined\else
266 % \expandafter\RequirePackage\expandafter{\csname package@font\endcsname}%
267 %\fi
268 \CodelineIndex\EnableCrossrefs % makeindex -s gind.ist ltxutil
269 \RecordChanges % makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo
270 % \end{macrocode}
271 %
272 % \subsubsection{Docstrip and info directives}
273 % We use so many {\sc docstrip} modules that we set the
274 % \texttt{StandardModuleDepth} counter to 1.
275 % \begin{macrocode}
276 \setcounter{StandardModuleDepth}{1}
277 % \end{macrocode}
278 % The following command retrieves the date and version information
279 % from this file.
280 % \begin{macrocode}
281 \expandafter\GetFileInfo\expandafter{\jobname.dtx}%
282 % \end{macrocode}
283 %
284 % \subsection{The ``Read Me'' File}
285 % As promised above, here is the contents of the
286 % ``Read Me'' file. That file serves a double purpose,
287 % since it also constitutes the beginining of the
288 % programmer's documentation. What better thing, after
289 % all, to have appear at the beginning of the
290 % typeset documentation?
291 %
292 % A good discussion of how to write a ReadMe file can be found in
293 % Engst, Tonya, ``Writing a ReadMe File? Read This''
294 % \emph{MacTech} October 1998, p. 58.
295 %
296 % Note the appearance of the
297 % \cmd\StopEventually\ command, which marks the
298 % dividing line between the user documentation
299 % and the programmer documentation.
300 %
301 % The usual user will not be asked to
302 % do a full build, not to speak
303 % of the bootstrap.
304 % Instructions for carrying out these procedures
305 % begin the programmer's manual.
306 %
307 % \begin{macrocode}
308 \begin{filecontents*}{README-LTXUTIL}
309 \title{%
310 A \LaTeX\ Package of utility macros%
311 \thanks{%
312 This file has version number \fileversion,
313 last revised \filedate.%
314 }%
315 \thanks{%
316 Version \fileversion\ \copyright\ 2019--2022 American Physical Society
317 }%
318 }%
319 \author{%
320 Arthur Ogawa%
321 \thanks{\texttt{mailto:arthur\_ogawa at sbcglobal.net}}%
322 }%
323 %\iffalse
324 % For version number and date,
325 % search on "\fileversion" in the .dtx file,
326 % or see the end of the README-LTXUTIL file.
327 %\fi
328 \maketitle
329
330 This file embodies the \classname{ltxutil} package,
331 the implementation and its user documentation.
332
333 The distribution point for this work is
334 \url{journals.aps.org/revtex},
335 which contains prebuilt runtime files, documentation, and full source,
336 ready to add to a TDS-compliant \TeX\ installation.
337
338 The \classname{ltxutil} package was commissioned by the American Physical Society
339 and is distributed under the terms of the \LaTeX\ Project Public License 1.3c,
340 the same license under which all the portions of \LaTeX\ itself are distributed.
341 Please see \url{http://ctan.tug.org/macros/latex/base/lppl.txt} for details.
342
343 To use this document class, you must have a working
344 \TeX\ installation equipped with \LaTeXe\
345 and possibly pdftex and Adobe Acrobat Reader or equivalent.
346
347 To install, retrieve the distribution,
348 unpack it into a directory on the target computer,
349 and move the file \file{ltxutil.sty}
350 into a location in your filesystem where it will be found by \LaTeX.
351
352 To use, read the user documentation \file{ltxutil.pdf}.
353
354 \tableofcontents
355
356 \section{Processing Instructions}
357
358 The package file \file{ltxutil.sty}
359 is generated from this file, \file{ltxutil.dtx},
360 using the {\sc docstrip} facility of \LaTeX
361 via |tex ltxutil.dtx| (Note: do \emph{not} use \LaTeX\ for this task).
362 The typeset documentation that you are now reading is generated from
363 the same file by typesetting it with \LaTeX\ or pdftex
364 via |latex ltxutil.dtx| or |pdflatex ltxutil.dtx|.
365
366 \subsection{Build Instructions}
367
368 You may bootstrap this suite of files solely from \file{ltxutil.dtx}.
369 Prepare by installing \LaTeXe\ (and either tex or pdftex) on your computer,
370 then carry out the following steps:
371 \begin{enumerate}
372 \item
373 Within an otherwise empty directory,
374 typeset \file{ltxutil.dtx} with \LaTeX\ or pdflatex;
375 you will obtain the typeset documentation you are now reading,
376 along with the file \file{README-LTXUTIL}.
377
378 Note: you will have to run \LaTeX, then
379 \file{makeindex} \texttt{-s gind.ist ltxutil.idx}, then
380 \file{makeindex} \texttt{-s gglo.ist -o ltxutil.gls ltxutil.glo}, then
381 \LaTeX\ again in order to obtain a valid index and table of contents.
382 \item
383 Now typeset \file{ltxutil.dtx} with \TeX (not \LaTeX),
384 thereby generating the package file \file{ltxutil.sty}.
385 \item
386 Install the following files into indicated locations within your
387 TDS-compliant \texttt{texmf} tree (you may need root access):
388 \begin{itemize}
389 \item
390 \file{$TEXMF/}\file{tex/}\file{latex/}\file{revtex/}\classname{ltxutil.sty}
391 \item
392 \file{$TEXMF/}\file{source/}\file{latex/}\file{revtex/}\classname{ltxutil.dtx}
393 \item
394 \file{$TEXMF/}\file{doc/}\file{latex/}\file{revtex/}\classname{ltxutil.pdf}
395 \end{itemize}
396 where \file{$TEXMF/} stands for \file{texmf-local/}, or some other \texttt{texmf} tree
397 in your installation.
398 \item
399 Run \texttt{mktexlsr} on \file{$TEXMF/} (you may need root access).
400 \item
401 Build and installation are now complete;
402 now put a \cmd\usepackage\texttt{\{ltxutil\}} in your document preamble!
403 \end{enumerate}
404
405 \subsection{Change Log}
406 \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.}
407 \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. }
408 \changes{4.0b}{1999/06/20}{only execute if there really were floats of the given type}
409 \changes{4.0b}{1999/06/20}{Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time, since \classname{hyperref} clobbers \cs{caption}.}
410 \changes{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing}
411 \changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility}
412 \changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package}
413 \changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.}
414 \changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks}
415 \changes{4.0d}{2000/04/10}{(AO, 174) kernel fix}
416 \changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.}
417 \changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.}
418 \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.}
419 \changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility}
420 \changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}%
421 \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.)}%
422 \changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}%
423 \changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}%
424 \changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}%
425 \changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}%
426 \changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.}
427 \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.}
428 \changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now}
429 \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.}
430 \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.}
431 \changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}%
432 \changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}%
433 \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
434 \changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire}
435 \changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}%
436 \changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.}
437 \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
438 \changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.}
439 \changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}%
440 \changes{4.1b}{2008/08/12}{Tally and log the height of a float class}
441 \changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}%
442 \changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote}
443 \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
444 \changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}%
445 \changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}%
446 \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.}%
447 \changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
448 \changes{4.1n}{2009/12/06}{(AO) Incorporate change to ltmiscen.dtx v1.1i 2000/05/19}%
449 \changes{4.1n}{2009/12/09}{(AO, 569) execute \classname{atveryend}'s \cs{Call@AfterLastShipout} at the proper time}%
450 \changes{4.1n}{2009/12/13}{(AO, 574) protect against \classname{lineno.sty}, which forces a visit to the output routine, which appears to destroy the value of \cs{@tempdima}}%
451 \changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}%
452 \changes{4.1n}{2010/01/02}{(AO, 571) allow split after last line of footnote}%
453 \changes{4.1n}{2010/01/06}{(AO, 572) title block footnotes numbered independently from body footnotes}%
454 \changes{4.1p}{2010/02/24}{(AO, 582) A patch of \classname{hyperref.sty} to provide backward compatibility to \TeX Live 2007's version 6.75r}%
455 \changes{4.2a}{2017/11/21}{(MD) Use updated best practice to use https and doi.org}%
456 \changes{4.2a}{2018/12/12}{(MD) Updated name of README file and use standard fonts when typesetting}%
457 \changes{4.2d}{2020/09/19}{(PHO) Adapt \cs{document} and \cs{enddocument} hooks to the 2020-10-01 \LaTeX{} release.}%
458
459 \end{filecontents*}
460 % \end{macrocode}
461 %
462 % \subsection{The Document Body}
463 %
464 % Here is the document body, containing only a
465 % \cmd\DocInput\ directive---referring to this very file.
466 % This very cute self-reference is a common \classname{ltxdoc} idiom.
467 % \begin{macrocode}
468 \begin{document}%
469 \expandafter\DocInput\expandafter{\jobname.dtx}%
470 \end{document}
471 % \end{macrocode}
472 %
473 % \begin{macrocode}
474 %</doc>
475 % \end{macrocode}
476 %
477 % \section{Using this package}
478 % Once this package is installed on your filesystem, you can employ it in
479 % adding functionality to \LaTeX\ by invoking it in your document or document class.
480 %
481 % \subsection{Invoking the package}
482 % In your document, you can simply call it up in your preamble:
483 % \begin{verbatim}
484 %\documentclass{book}%
485 %\usepackage{ltxutil}%
486 %\begin{document}
487 %<your document here>
488 %\end{document}\end{verbatim}
489 % However, the preferred way is to invoke this package from within your
490 % customized document class:
491 % \begin{verbatim}
492 %\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
493 %\ProvidesClass{myclass}%
494 %\RequirePackage{ltxutil}%
495 %\LoadClass{book}%
496 %<class customization commands>
497 %\endinput\end{verbatim}
498 %
499 % Once loaded, the package gives you acccess to certain procedures,
500 % usually to be invoked by a \LaTeX\ command or environment, but not at the document level.
501 %
502 %
503 % \section{Compatibility with \LaTeX's Required Packages}
504 % Certain packages, usually ones written by members of the
505 % \LaTeX\ Project itself, have been designated ``required'' and
506 % are distributed as part of standard \LaTeX.
507 % These packages have been placed in a priviledged position
508 % vis \'a vis the \LaTeX\ kernel in that they override the definitions of certain kernel macros.
509 %
510 % The \classname{ltxutil} package will be incompatible with any package that
511 % redefines any of the kernel macros that \classname{ltxutil} patches---if that
512 % package is loaded \emph{after} \classname{ltxutil}. This means that for
513 % greatest compatibility, \classname{ltxutil} should be loaded \emph{after},
514 % say, \classname{ftnright}, which overwrites \LaTeX's kernel
515 % procedures \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol.
516 %
517 % Hereinafter follows some notes on specific \LaTeX\ packages.
518 %
519 % \subsection{array}
520 % This package alters the way tabular environments are done,
521 % therefore it could run afoul of the \LaTeX\ ``required'' package \classname{array} or any
522 % package that calls for it to be loaded.
523 % However, this package has provisions for remaining compatible with \classname{array}.
524 % So long as the version of \classname{array} that is used with this package has the appropriate
525 % meanings for the procedures it overwrites, all should be well.
526 %
527 % \subsection{longtable}
528 % David Carlisle's \classname{longtable} package modifies both the \LaTeX\ kernel and the
529 % \classname{array} package. This package must therefore alter \cmd\LT@array.
530 % For now, that job is handled by \classname{ltxgrid}.
531 %
532 %
533 %\StopEventually{}
534 %
535 % \section{Implementation of package}
536 %
537 % Special acknowledgment: this package uses concepts pioneered
538 % and first realized by William Baxter (mailto:web at superscript.com)
539 % in his SuperScript line of commercial typesetting tools, and
540 % which are used here with his permission.
541 %
542 % \subsection{Beginning of the \file{package} {\sc docstrip} module}
543 % \begin{macrocode}
544 %<*package>
545 \def\package@name{ltxutil}%
546 \expandafter\PackageInfo\expandafter{\package@name}{%
547 Utility macros for \protect\LaTeXe,
548 by A. Ogawa (arthur_ogawa at sbcglobal.net)%
549 }%
550 %</package>
551 % \end{macrocode}
552 %
553 % \subsection{Banner and beginning of the \file{kernel} {\sc docstrip} module}%
554 % \begin{macrocode}
555 %<*kernel>
556 % \end{macrocode}
557 %
558 % \subsection{Errors and warnings}
559 %
560 % \begin{macro}{\class@err}
561 % \begin{macro}{\class@warn}
562 % \begin{macro}{\class@info}
563 % A few shorthands for Class messages.
564 % Your document class should define \cmd\class@name.
565 % \begin{macrocode}
566 \def\class@err#1{\ClassError{\class@name}{#1}\@eha}%
567 \def\class@warn#1{\ClassWarningNoLine{\class@name}{#1}}%
568 \def\class@info#1{\ClassInfo{\class@name}{#1}}%
569 \def\obsolete@command#1{%
570 \class@warn@end{Command \string#1\space is obsolete.^^JPlease remove from your document}%
571 \global\let#1\@empty
572 #1%
573 }%
574 \def\replace@command#1#2{%
575 \class@warn@end{Command \string#1\space is obsolete;^^JUse \string#2\space instead}%
576 \global\let#1#2%
577 #1%
578 }%
579 \def\replace@environment#1#2{%
580 \class@warn@end{Environment #1 is obsolete;^^JUse #2 instead}%
581 \glet@environment{#1}{#2}%
582 \@nameuse{#1}%
583 }%
584 \def\incompatible@package#1{%
585 \@ifpackageloaded{#1}{%
586 \def\@tempa{I cannot continue. You must remove the \string\usepackage\ statement that caused that package to be loaded.}%
587 \ClassError{\class@name}{The #1 package cannot be used with \class@name}%
588 \@tempa\stop
589 }{%
590 \class@info{#1 was not loaded (OK!)}%
591 }%
592 }%
593 \def\class@warn@end#1{%
594 \gappdef\class@enddocumenthook{\class@warn{#1}}%
595 }%
596 % \end{macrocode}
597 % \end{macro}
598 % \end{macro}
599 % \end{macro}
600 %
601 % \changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}%
602 % Give \cmd\class@name\ a meaning if it does not already have one.
603 % \begin{macrocode}
604 \ifx\undefined\class@name
605 \def\class@name{ltxutil}%
606 \class@warn{You should define the class name before reading in this package. Using default}%
607 \fi
608 % \end{macrocode}
609 %
610 % \subsection{New Tools}%
611 %
612 % \begin{macro}{\t@}
613 % \begin{macrocode}
614 \def\t@{to}%
615 % \end{macrocode}
616 % \end{macro}
617 %
618 % \begin{macro}{\dimen@iii}
619 % \begin{macrocode}
620 \dimendef\dimen@iii\thr@@
621 % \end{macrocode}
622 % \end{macro}
623 %
624 % \begin{macro}{\halignt@}
625 % \begin{macrocode}
626 \def\halignt@{\halign\t@}%
627 % \end{macrocode}
628 % \end{macro}
629 %
630 % \begin{macro}{\f@ur}
631 % Analogous to \cmd\@ne, \cmd\tw@, and \cmd\thr@@.
632 % \begin{macrocode}
633 \chardef\f@ur=4\relax
634 \chardef\cat@letter=11\relax
635 \chardef\other=12\relax
636 % \end{macrocode}
637 % \end{macro}
638 %
639 % \begin{macro}{\let@environment}
640 % \begin{macro}{\glet@environment}
641 % The directive \cmd\let@environment\ takes care of a common programming
642 % idiom whereby one environment is made a synonym for another.
643 % \begin{macrocode}
644 \def\let@environment#1#2{%
645 \expandafter\let
646 \csname#1\expandafter\endcsname\csname#2\endcsname
647 \expandafter\let
648 \csname end#1\expandafter\endcsname\csname end#2\endcsname
649 }%
650 \def\glet@environment#1#2{%
651 \global\expandafter\let
652 \csname#1\expandafter\endcsname\csname#2\endcsname
653 \global\expandafter\let
654 \csname end#1\expandafter\endcsname\csname end#2\endcsname
655 }%
656 % \end{macrocode}
657 % \end{macro}
658 % \end{macro}
659 %
660 % \begin{macro}{\tracingplain}
661 % The command \cmd\tracingplain\ causes \TeX's tracing parameters to
662 % return to the values set by default. This command is sometimes
663 % useful when you have said \cmd\tracingall\ somewhere and want to
664 % restore.
665 % The \cmd\traceoutput\ command causes \cmd\tracingoutput\ diagnostics
666 % upon \cmd\shipout.
667 % \begin{macrocode}
668 \newcommand\tracingplain{%
669 \tracingonline\z@\tracingcommands\z@\tracingstats\z@
670 \tracingpages\z@\tracingoutput\z@\tracinglostchars\@ne
671 \tracingmacros\z@\tracingparagraphs\z@\tracingrestores\z@
672 \showboxbreadth5\showboxdepth3\relax %\errorstopmode
673 }%
674 \newcommand\traceoutput{%
675 \appdef\@resetactivechars{\showoutput}%
676 }%
677 % \end{macrocode}
678 % \end{macro}
679 %
680 % \begin{macro}{\say}
681 % \begin{macro}{\saythe}
682 % The commands \cmd\say\ and \cmd\saythe\ cause diagnostic messages in the
683 % \TeX\ log that give the value of a control sequence name or a register
684 % respectively.
685 % \begin{macrocode}
686 \newcommand\say[1]{\typeout{<\noexpand#1=\meaning#1>}}%
687 \newcommand\saythe[1]{\typeout{<\noexpand#1=\the#1>}}%
688 % \end{macrocode}
689 % \end{macro}
690 % \end{macro}
691 %
692 % \begin{macro}{\fullinterlineskip}
693 % Resets the \cmd\prevdepth\ so that the full amount of \cmd\baselineskip\ glue will be inserted by
694 % the \cmd\baselinesklip\ mechanism.
695 % Can be invoked just after a \cmd\hrule\ to undo its default suppression of base line skip.
696 % \begin{macrocode}
697 \def\fullinterlineskip{\prevdepth\z@}%
698 % \end{macrocode}
699 % \end{macro}
700 %
701 % \begin{macro}{\count@i}
702 % \begin{macro}{\count@ii}
703 %
704 % \begin{macrocode}
705 \countdef\count@i\@ne
706 \countdef\count@ii\tw@
707 % \end{macrocode}
708 % \end{macro}
709 % \end{macro}
710 %
711 %
712 % \subsection{Boolean Control}%
713 % We introduce just enough of the Boolean calculus for \TeX.
714 % Alan Jeffrey was the pioneer here, with an article in TUGboat
715 % (Vol. 11, No. 2, page 237).
716 % This implementation owes a debt to
717 % William Baxter (web at superscript.com).
718 % See articles by Baxter and Ogawa in the proceedings of the
719 % 1994 TUG meeting, TUGboat Vol.~15, No.~3.
720 %
721 % \begin{macro}{\prepdef}
722 % \begin{macro}{\appdef}
723 % \begin{macro}{\gappdef}
724 %
725 % Provide the capability of performing head- and tail patches.
726 % The procedure \cmd\prepdef\ prepends to the given macro
727 % the tokens specified in its second argument.
728 % Likewise for \cmd\appdef, except that it appends.
729 % Note that the first 10 toks registers are utility registers,
730 % and we simply make a control sequence name, \cmd\toks@ii, for one of
731 % them.
732 % \begin{macrocode}
733 \long\def\prepdef#1#2{%
734 \@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
735 \toks@ii{#2}%
736 \edef#1{\the\toks@ii\the\toks@}%
737 }%
738 \long\def\appdef#1#2{%
739 \@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
740 \toks@ii{#2}%
741 \edef#1{\the\toks@\the\toks@ii}%
742 }%
743 \long\def\gappdef#1#2{%
744 \@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
745 \toks@ii{#2}%
746 \global\edef#1{\the\toks@\the\toks@ii}%
747 }%
748 \long\def\appdef@val#1#2{%
749 \appdef#1{{#2}}%
750 }%
751 \long\def\appdef@e#1#2{%
752 \expandafter\appdef
753 \expandafter#1%
754 \expandafter{#2}%
755 }%
756 \long\def\appdef@eval#1#2{%
757 \expandafter\appdef@val
758 \expandafter#1%
759 \expandafter{#2}%
760 }%
761 \toksdef\toks@ii=\tw@
762 % \end{macrocode}
763 % \end{macro}
764 % \end{macro}
765 % \end{macro}
766 %
767 % \begin{macro}{\@ifxundefined}
768 % \begin{macro}{\@ifnotrelax}
769 % \begin{macro}{\@argswap}
770 % \begin{macro}{\@argswap@val}
771 %
772 % Certain utility procedures use \cmd\@ifxundefined,
773 % which is defined here in terms of \cmd\@ifx.
774 % Others use \cmd\@ifnotrelax, namely when
775 % the control sequence name is manufactured by
776 % the use of \cmd\csname.
777 %
778 % The procedures \cmd\@argswap and \cmd\@argswap@val
779 % are used to facilitate control of expansion.
780 %
781 % \begin{macrocode}
782 \long\def\@ifxundefined#1{\@ifx{\undefined#1}}%
783 \long\def\@ifnotrelax#1#2#3{\@ifx{\relax#1}{#3}{#2}}%
784 \long\def\@argswap#1#2{#2#1}%
785 \long\def\@argswap@val#1#2{#2{#1}}%
786 \def\@ifxundefined@cs#1{\expandafter\@ifx\expandafter{\csname#1\endcsname\relax}}%
787 % \end{macrocode}
788 % \end{macro}
789 % \end{macro}
790 % \end{macro}
791 % \end{macro}
792 %
793 % \begin{macro}{\rvtx@ifformat@geq}
794 % Some changes in the \LaTeX{} kernel requires us to conditionally
795 % define some macros depending on the version of the kernel.
796 % \cmd\rvtx@ifformat@geq{} will check if the release date of the
797 % currently-running \LaTeXe{} kernel is greater or equal to the
798 % argument (the argument should be in the format \texttt{yyyy-mm-dd}).
799 % \changes{4.2d}{2020/09/17}{(PHO) Add \cs{rvtx@ifformat@geq}.}%
800 % \begin{macrocode}
801 \ifx\IfFormatAtLeastTF\undefined
802 \def\rvtx@ifformat@geq{\@ifl@t@r\fmtversion}%
803 \else
804 \let\rvtx@ifformat@geq\IfFormatAtLeastTF
805 \fi
806 % \end{macrocode}
807 % \end{macro}
808 %
809 % \begin{macro}{\@boolean}
810 % \begin{macro}{\@boole@def}
811 % In order to define \cmd\@ifx, we first must create the
812 % ``defining word'' (term taken form our Forth vocabulary)
813 % \cmd\@boole@def, which employs \cmd\@boolean\ to do its job.
814 % \begin{macrocode}
815 \def\@boolean#1#2{%
816 \long\def#1{%
817 #2% \if<something>
818 \expandafter\true@sw
819 \else
820 \expandafter\false@sw
821 \fi
822 }%
823 }%
824 \def\@boole@def#1#{\@boolean{#1}}% Implicit #2
825 % \end{macrocode}
826 % \end{macro}
827 % \end{macro}
828 %
829 % \begin{macro}{\@booleantrue}
830 % \begin{macro}{\@booleanfalse}
831 % The procedures \cmd\@booleantrue\ and
832 % \cmd\@booleanfalse\ are assignment operators
833 % for Boolean flags.
834 % \begin{macrocode}
835 \def\@booleantrue#1{\let#1\true@sw}%
836 \def\@booleanfalse#1{\let#1\false@sw}%
837 % \end{macrocode}
838 % \end{macro}
839 % \end{macro}
840 %
841 % \begin{macro}{\@ifx}
842 % \begin{macro}{\@ifx@empty}
843 % \begin{macro}{\@if@empty}
844 % \begin{macro}{\@ifcat}%
845 % \begin{macro}{\@ifdim}%
846 % \begin{macro}{\@ifeof}%
847 % \begin{macro}{\@ifhbox}%
848 % \begin{macro}{\@ifhmode}%
849 % \begin{macro}{\@ifinner}%
850 % \begin{macro}{\@ifmmode}%
851 % \begin{macro}{\@ifnum}%
852 % \begin{macro}{\@ifodd}%
853 % \begin{macro}{\@ifvbox}%
854 % \begin{macro}{\@ifvmode}%
855 % \begin{macro}{\@ifvoid}%
856 % We can now invoke the defining word to create
857 % the procedures \cmd\@ifx\ and friends.
858 %
859 % Compatibility Note: earlier versions of this package
860 % defined a procedure \cmd\@ifempty. However, for compatibility with AMS\LaTeX,
861 % we must avoid the following three names:
862 % \cmd\@ifempty, \cmd\@xifempty, and \cmd\@ifnotempty.
863 %
864 % \begin{macrocode}
865 \@boole@def\@ifx#1{\ifx#1}%
866 \@boole@def\@ifx@empty#1{\ifx\@empty#1}%
867 \@boole@def\@if@empty#1{\if!#1!}%
868 %\@boole@def\@if@sw#1{\csname if#1\endcsname}%
869 \def\@if@sw#1#2{#1\expandafter\true@sw\else\expandafter\false@sw#2}%
870 \@boole@def\@ifdim#1{\ifdim#1}%
871 \@boole@def\@ifeof#1{\ifeof#1}%
872 \@boole@def\@ifhbox#1{\ifhbox#1}%
873 \@boole@def\@ifhmode{\ifhmode}%
874 \@boole@def\@ifinner{\ifinner}%
875 \@boole@def\@ifmmode{\ifmmode}%
876 \@boole@def\@ifnum#1{\ifnum#1}%
877 \@boole@def\@ifodd#1{\ifodd#1}%
878 \@boole@def\@ifvbox#1{\ifvbox#1}%
879 \@boole@def\@ifvmode{\ifvmode}%
880 \@boole@def\@ifvoid#1{\ifvoid#1}%
881 % \end{macrocode}
882 % \end{macro}
883 % \end{macro}
884 % \end{macro}
885 % \end{macro}
886 % \end{macro}
887 % \end{macro}
888 % \end{macro}
889 % \end{macro}
890 % \end{macro}
891 % \end{macro}
892 % \end{macro}
893 % \end{macro}
894 % \end{macro}
895 % \end{macro}
896 % \end{macro}
897 %
898 % \begin{macro}{\true@sw}
899 % \begin{macro}{\false@sw}
900 %
901 % Note that when a Boolean operator expands, it
902 % employs two macros that act as selectors, defined here.
903 %
904 % \begin{macrocode}
905 \long\def\true@sw#1#2{#1}%
906 \long\def\false@sw#1#2{#2}%
907 % \end{macrocode}
908 % \end{macro}
909 % \end{macro}
910 %
911 % \begin{macro}{\loopuntil}
912 % \begin{macro}{\loopwhile}
913 %
914 % Loop control using the Boolean idiom.
915 % Superior to \cmd\loop\dots\cmd\repeat\ because these can be nested.
916 % The tail of the argument must have a Boolean predicate.
917 %
918 % \begin{macrocode}
919 \long\def\loopuntil#1{#1{}{\loopuntil{#1}}}%
920 \long\def\loopwhile#1{#1{\loopwhile{#1}}{}}%
921 % \end{macrocode}
922 % \end{macro}
923 % \end{macro}
924 %
925 % \begin{macro}{\@provide}
926 %
927 % A defining word that refuses to clobber a prior meaning.
928 %
929 % \begin{macrocode}
930 \def\@provide#1{%
931 \@ifx{\undefined#1}{\true@sw}{\@ifx{\relax#1}{\true@sw}{\false@sw}}%
932 {\def#1}{\def\j@nk}%
933 }%
934 % \end{macrocode}
935 % \end{macro}
936 %
937 %
938 % \subsection{Begin Document Structure}
939 % The standard \LaTeX\ mechanism \cmd\AtBeginDocument\
940 % is inadequate because the \cmd\vsize\ is bound much too early.
941 % We supply here a mechanism whereby decisions about the
942 % page layout can be deferred until \cmd\AtBeginDocument\ time.
943 %
944 % The problem we are working around is that the \cmd\AtBeginDocument\
945 % hook in \cmd\document\ appears long after the calculation of
946 % \cmd\vsize\ and \cmd\hsize, that is, \LaTeX\ provides no mechanism
947 % for deferring the decision about the page grid until \cmd\AtBeginDocument\ time.
948 % We fix things by prepending a hook at the very beginning of \cmd\document.
949 %
950 % As it turns out, though, it appears feasible to simply invoke the desired
951 % column grid command at \cmd\AtBeginDocument\ time, since the MVL has nothing in it
952 % at that time that would be problematical.
953 %
954 % \begin{macro}{\document}
955 % We begin by installing hooks into \cmd\document\ that
956 % we will manage ourselves.
957 %
958 % The 2020-10-01 \LaTeX{} release got a new hook management system and
959 % several new hooks (several previously provided by \textsf{etoolbox}).
960 % The one we want here is \texttt{begindocument/before}, the first thing
961 % executed by \cmd\document{}, right after ending the group started by
962 % \cmd\begin{}.
963 %
964 % Thus, if the \LaTeX{} kernel date is 2020-10-01 we just add to that
965 % hook, otherwise resort to the old method, patching \cmd\document:
966 % end the group started by \cmd\begin, apply our hook, and
967 % conclude our shenanigans by absorbing
968 % the first token of the expansion of \cmd\document, which
969 % we assume to be \cmd\endgroup{} (true until the aforementioned release).
970 % \changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}%
971 % \changes{4.2d}{2020/09/17}{(PHO) Use \LaTeX's hook management system, if possible.}%
972 % \begin{macrocode}
973 \rvtx@ifformat@geq{2020/10/01}%
974 {%
975 \AddToHook{begindocument/before}{\document@inithook}%
976 }{%
977 \prepdef\document{%
978 \endgroup
979 \document@inithook
980 \true@sw{}%
981 }%
982 }
983 % \end{macrocode}
984 % \end{macro}
985 %
986 % \begin{macro}{\document@inithook}
987 % To use, simply \cmd\appdef\cmd\document@inithook\arg{your tokens here}.
988 % \begin{macrocode}
989 \let\document@inithook\@empty
990 % \end{macrocode}
991 % \end{macro}
992 %
993 % \begin{macro}{\class@documenthook}
994 % \begin{macro}{\class@enddocumenthook}
995 % \changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now}
996 % We install the last \cmd\AtBeginDocument\ hook, namely the
997 % procedure \cmd\class@documenthook. Within the document class,
998 % we will use this hook exclusively, so as to avoid interference from other packages.
999 % Similarly with \cmd\class@enddocumenthook, installed via \cmd\AtEndDocument.
1000 %
1001 % A document class using this package should do as this package does and just say,
1002 % \cmd\appdef\ \cmd\class@documenthook\ instead of \cmd\AtBeginDocument,
1003 % and \cmd\appdef\ \cmd\class@enddocumenthook\ instead of \cmd\AtEndDocument.
1004 % \begin{macrocode}
1005 \appdef\document@inithook{%
1006 \AtBeginDocument{\class@documenthook}%
1007 }%
1008 \AtEndDocument{%
1009 \class@enddocumenthook
1010 }%
1011 \let\class@documenthook\@empty
1012 \let\class@enddocumenthook\@empty
1013 % \end{macrocode}
1014 % \end{macro}
1015 % \end{macro}
1016 %
1017 % \begin{macro}{\enddocument}
1018 % \begin{macro}{\check@aux}
1019 % \begin{macro}{\do@check@aux}
1020 % \changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
1021 % The standard \LaTeX\ \enve{document} processing is a potential problem,
1022 % particularly when the output routine has been changed by \classname{ltxgrid}.
1023 % We separate out the procedure that checks the auxiliary file at the end of
1024 % the job so that later it can be called from the safety of the output
1025 % routine.
1026 % We will do this to ensure that the \cmd\@mainaux\ stream is not closed until
1027 % the last page of the job is shipped out, and that can only be done by coordinating
1028 % with the output routine.
1029 %
1030 % \changes{4.2d}{2020/09/17}{(PHO) Only redefine \cs{enddocument} in older versions.}%
1031 % This approach, however, will only be done for older versions of the
1032 % \LaTeX{} kernel:
1033 % \begin{macrocode}
1034 \rvtx@ifformat@geq{2020/10/01}{%
1035 % <definitions for newer LaTeX later>
1036 }{%
1037 % <definitions for older LaTeX>
1038 \def\enddocument{%
1039 % \end{macrocode}
1040 % \changes{4.1n}{2009/12/06}{(AO) Incorporate change to ltmiscen.dtx v1.1i 2000/05/19}%
1041 % The following line from \filename{ltmiscen.dtx} `resets \cmd\AtEndDocument for latex/3060'.
1042 % \begin{macrocode}
1043 \let\AtEndDocument\@firstofone
1044 % \end{macrocode}
1045 % \begin{macrocode}
1046 \@enddocumenthook
1047 \@checkend{document}%
1048 % \end{macrocode}
1049 % The \cmd\clear@document\ statement ends the current page (we must guarantee no further shipouts),
1050 % then executes all cleanup procedures that must occur only after the last shipout.
1051 % Clients will queue up their procedures via \cmd\AfterLastShipout, if it exists, otherwise by doing \cmd\appdef\cmd\clear@document.
1052 % \begin{macrocode}
1053 \clear@document
1054 % \end{macrocode}
1055 % We are very close to ending the \TeX\ run, now.
1056 % \begin{macrocode}
1057 \check@aux
1058 \deadcycles\z@
1059 \@@end
1060 }%
1061 \def\check@aux{\do@check@aux}%
1062 \def\do@check@aux{%
1063 \@if@sw\if@filesw\fi{%
1064 \immediate\closeout\@mainaux
1065 \let\@setckpt\@gobbletwo
1066 \let\@newl@bel\@testdef
1067 \@tempswafalse
1068 \makeatletter
1069 \input\jobname.aux\relax
1070 }{}%
1071 \@dofilelist
1072 \@ifdim{\font@submax >\fontsubfuzz\relax}{%
1073 \@font@warning{%
1074 Size substitutions with differences\MessageBreak
1075 up to \font@submax\space have occured.\@gobbletwo
1076 }%
1077 }{}%
1078 \@defaultsubs
1079 \@refundefined
1080 \@if@sw\if@filesw\fi{%
1081 \@ifx{\@multiplelabels\relax}{%
1082 \@if@sw\if@tempswa\fi{%
1083 \@latex@warning@no@line{%
1084 Label(s) may have changed.
1085 Rerun to get cross-references right%
1086 }%
1087 }{}%
1088 }{%
1089 \@multiplelabels
1090 }%
1091 }{}%
1092 }%
1093 }
1094 % \end{macrocode}
1095 %
1096 % \changes{4.2d}{2020/09/17}{(PHO) Patch \cs{enddocument} at runtime in newer versions.}%
1097 % \begin{macro}{\rvtx@enddocument@patch}
1098 % For newer \LaTeX{} we'll try to be a bit more future-proof
1099 % (no miracle though). The code for \cmd\enddocument{}
1100 % (in pre-2020-10-01 \LaTeX) is roughly:
1101 % \begin{verbatim}
1102 % \def\enddocument{%
1103 % <hooks and bookkeeping>
1104 % \clearpage
1105 % <read main .aux and final checks>
1106 % \@@end
1107 % }
1108 % \end{verbatim}
1109 % and the patches above replace the \cmd\clearpage{} by its own
1110 % \cmd\clear@document, and \verb|<read main .aux and final checks>| by
1111 % \cmd\do@check@aux, which it can later control the timing.
1112 %
1113 % Now we will apply the same changes, but this time without redefining
1114 % \cmd\enddocument: we will instead replace tokens on-the-fly, when
1115 % \cmd\enddocument{} is expanded. This will grant us a slightly safer
1116 % approach that won't depend so much on the internals of
1117 % \cmd\enddocument.
1118 %
1119 % This entire patch should work with the previous definition of
1120 % \cmd\enddocument{} as well (except it cannot be used in the hook),
1121 % but for now leave previous versions untouched.
1122 %
1123 % The entire patching will reside in the \texttt{enddocument} hook:
1124 % \begin{macrocode}
1125 \rvtx@ifformat@geq{2020/10/01}{%
1126 \AddToHook{enddocument}{\rvtx@enddocument@patch{}}%
1127 }{}
1128 % \end{macrocode}
1129 %
1130 % This macro will be executed after \cmd\enddocument{} has expanded,
1131 % so all its tokens are now exposed. Here we will assume that
1132 % \cmd\enddocument{} contains the tokens \verb|\@checkend{document}|
1133 % and \cmd\endgroup, and use them as delimiters:
1134 % \begin{macrocode}
1135 \protected\long\def\rvtx@enddocument@patch#1#2\@checkend#3{%
1136 \begingroup
1137 \edef\x{\detokenize{#3}}%
1138 \edef\y{\detokenize{document}}%
1139 \expandafter\endgroup
1140 \ifx\x\y
1141 \expandafter\rvtx@enddocument@patch@end
1142 \else
1143 \expandafter\rvtx@enddocument@patch@more
1144 \fi
1145 {#1#2}{#3}}
1146 \def\rvtx@enddocument@patch@more#1#2{%
1147 \rvtx@enddocument@patch{#1\@checkend{#2}}}
1148 % \end{macrocode}
1149 %
1150 % When the \verb|\@checkend{document}| is reached, use \cmd\clearpage{}
1151 % and \cmd\enddocument{} as delimiters for the
1152 % \verb|<read main .aux and final checks>| part, and save it in
1153 % \cmd\do@check@aux{}:
1154 % \begin{macrocode}
1155 \long\def\rvtx@enddocument@patch@end#1#2\clearpage#3\endgroup{%
1156 \def\do@check@aux{#3\endgroup}%
1157 % \end{macrocode}
1158 % Then execute the code consumed in the previous step:
1159 % \begin{macrocode}
1160 #1%
1161 \@checkend{#2}%
1162 % \end{macrocode}
1163 % Do \cmd\clear@document{} instead of \cmd\clearpage{} and
1164 % \cmd\check@aux{} instead of the code grabbed.
1165 % \begin{macrocode}
1166 \clear@document
1167 \check@aux}
1168 \def\check@aux{\do@check@aux}%
1169 % \end{macrocode}
1170 % \end{macro}
1171 %
1172 % \end{macro}
1173 % \end{macro}
1174 % \end{macro}
1175 %
1176 % \begin{macro}{\clear@document}
1177 % \changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
1178 % The procedure \cmd\clear@document\ is responsible for flushing out the last page of the document,
1179 % if not already done.
1180 % The procedure then executes those procedures that must wait for execution until
1181 % after the last page is shipped out.
1182 % Clients of \classname{ltxutil}, such as \classname{ltxgrid} and \classname{revtex4}
1183 % will queue these procedures up via \cmd\AfterLastShipout, if it exists, otherwise by doing \cmd\appdef\cmd\clear@document.
1184 %
1185 % The command \cmd\Call@AfterLastShipout\ is provided by Heiko Oberdiek's \classname{atveryend} package.
1186 % This package is compatible with \classname{ltxutil}.
1187 %
1188 % Note on compatibility with \classname{atveryend}:
1189 % we arrange for \cmd\Call@AfterLastShipout\ to be called from the safety of the output routine,
1190 % thereby ensuring that all of the procedures queued up by that package's
1191 % \cmd\AfterLastShipout\ are executed at the right time.
1192 % We also ensure that \cmd\Call@AfterLastShipout\ has a default definition, in case the package was never loaded.
1193 % \changes{4.1n}{2009/12/09}{(AO, 569) execute \classname{atveryend}'s \cs{Call@AfterLastShipout} at the proper time}%
1194 % \begin{macrocode}
1195 \def\clear@document{%
1196 \clearpage
1197 \do@output@cclv{%
1198 \Call@AfterLastShipout
1199 }%
1200 }%
1201 \appdef\class@documenthook{%
1202 \providecommand\Call@AfterLastShipout{}%
1203 }%
1204 % \end{macrocode}
1205 % \end{macro}
1206 %
1207 % \subsection{Class Extensions}%
1208 % \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.}
1209 % The \LaTeX\ procedure \cmd\@onefilewithoptions\ is the vehicle for reading in
1210 % a \LaTeX\ class or package.
1211 % The APS RevTeX class implements the use of what are called ``substyles'',
1212 % actually extensions to the class itself.
1213 % Any document class can do likewise.
1214 %
1215 % \begin{macro}{\class@extension}
1216 % \begin{macro}{\class@extensionfile}
1217 % \begin{macro}{\class@ext@hook}
1218 % A procedure similar to \LaTeX's \cmd\@onefilewithoptions, but as an extension to the
1219 % current document class.
1220 %
1221 % Read in the given file as if it were a document class file.
1222 % Usage: \cmd\class@extensionfile\ \arg{class} \cmd\@extension,
1223 % where \marg{class} is a file (similar to \file{aps.rtx}) and where \cmd\@extension\ is
1224 % the file extension for \marg{class}.
1225 % For instance, to read in the file \file{aps.rtx},
1226 % do \cmd\class@extensionfile\ \texttt{\{aps\}} \cmd\substyle@ext,
1227 % where the latter has been define to expand to \file{.rtx}.
1228 %
1229 % Features supported include
1230 % passing existing class options on to the class extension,
1231 % \cmd\AtEndOfClass\ processing,
1232 % a stack that restores \cmd\@currname, \cmd\@currext, \cmd\@clsextension, and the \cmd\catcode\ of `@',
1233 % fall-back to a control sequence name (with leading `rtx@') if no file exists.
1234 %
1235 % Note that \cmd\LoadClass\ gives one the ability to write a class that calls in
1236 % another class as a (sort of) module: this scheme is like \cmd\LoadClass, but
1237 % turned inside out.
1238 % \begin{macrocode}
1239 \def\class@extension#1#2{%
1240 \IfFileExists{#1.#2}{%
1241 \expandafter\class@extensionfile\csname ver@\@currname.\@currext\endcsname{#1}#2%
1242 }{%
1243 \csname rtx@#1\endcsname
1244 }%
1245 }%
1246 \def\class@extensionfile#1#2#3{%
1247 \@pass@ptions#3\@unusedoptionlist{#2}%
1248 \global\let\@unusedoptionlist\@empty
1249 \expandafter\class@ext@hook\csname#2.#3-h@@k\endcsname#1{#2}#3%
1250 }%
1251 \def\class@ext@hook#1#2#3#4{%
1252 \@pushfilename@ltx
1253 \makeatletter
1254 \let\CurrentOption\@empty
1255 \@reset@ptions
1256 \let#1\@empty
1257 \xdef\@currname{#3}%
1258 \global\let\@currext#4%
1259 \global\let\@clsextension\@currext
1260 \input{#3.#4}%
1261 \@ifl@ter#4{#3}#2{%
1262 \class@info{Class extension later than: #2}%
1263 }{%
1264 \class@info{Class extension earlier: #2}%
1265 \@@end
1266 }%
1267 #1%
1268 \let#1\@undefined
1269 \expandafter\@p@pfilename@ltx\@currnamestack@ltx\@nil
1270 \@reset@ptions
1271 }%
1272 % \end{macrocode}
1273 % \end{macro}
1274 % \end{macro}
1275 % \end{macro}
1276 %
1277 % \begin{macro}{\@pushfilename}
1278 % \begin{macro}{\@p@pfilename}
1279 % \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.}
1280 % But! \LaTeX\ does not provide for a class extension other than \file{.cls}, therefore we
1281 % must extend \LaTeX's file name stack with the file extension of a class extension.
1282 % This way, procedures like
1283 % \cmd\ProvidesPackage, \cmd\OptionNotUsed, \cmd\ProcessOptions, \cmd\@reset@ptions\
1284 % will still work properly.
1285 % \begin{macrocode}
1286 \def\@pushfilename@ltx{%
1287 \xdef\@currnamestack@ltx{%
1288 {\@currname}%
1289 {\@currext}%
1290 {\@clsextension}%
1291 {\the\catcode`\@}%
1292 \@currnamestack@ltx
1293 }%
1294 }%
1295 \def\@p@pfilename@ltx#1#2#3#4#5\@nil{%
1296 \gdef\@currname{#1}%
1297 \gdef\@currext{#2}%
1298 \gdef\@clsextension{#3}%
1299 \catcode`\@#4\relax
1300 \gdef\@currnamestack@ltx{#5}%
1301 }%
1302 \global\let\@currnamestack@ltx\@empty
1303 % \end{macrocode}
1304 % \end{macro}
1305 % \end{macro}
1306 % We carefully patch \LaTeX\ so that the current value of \cmd\@clsextension\ can be
1307 % restored after reading in a class file.
1308 %
1309 % \subsection{Type Tools}%
1310 %
1311 % \begin{macro}{\flushing}
1312 % Undoes \cmd\centering. Should also undo \cmd\raggedleft\ and \cmd\raggedright.
1313 % \begin{macrocode}
1314 \def\flushing{%
1315 \let\\\@normalcr
1316 \leftskip\z@skip
1317 \rightskip\z@skip
1318 \@rightskip\z@skip
1319 \parfillskip\@flushglue
1320 }%
1321 % \end{macrocode}
1322 % \end{macro}
1323 %
1324 % \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.}%
1325 % \begin{macro}{\@centercr}
1326 % The \cmd\@centercr\ command is the replacement for \cmd\@normalcr\ when setting type centered or ragged.
1327 % Normally, the meaning of \cmd\\ is \cmd\@normalcr, which \LaTeX\ defines via \cmd\DeclareRobustCommand.
1328 % In centered or ragged typesetting, the meaning of \cmd\\ is \cmd\@centercr,
1329 % therefore it ought to to be defined via \cmd\DeclareRobustCommand\ (but unfortunately is not).
1330 % The fact that it is not is yet another of \LaTeX's early failures that will never get fixed.
1331 %
1332 % The following exemplar fails under \LaTeX\ version 2005/12/01, package \classname{textcase} 2004/10/07 v0.07:
1333 % \begin{verbatim}
1334 %\documentclass{article}%
1335 %\usepackage[overload]{textcase}
1336 %\begin{document}
1337 %\centering
1338 %\section{\MakeTextUppercase{Section\\title}}
1339 %Text
1340 %\end{document}
1341 % \end{verbatim}
1342 % The solution is to promote \cmd\@centercr\ to a robust command, just the same as \cmd\\.
1343 % We do that here without needing to know the meaning of the command.
1344 % \begin{macrocode}
1345 \expandafter\DeclareRobustCommand\expandafter\@centercr\expandafter{\@centercr}%
1346 % \end{macrocode}
1347 % \end{macro}
1348 %
1349 %
1350 % \subsection{Display Math}%
1351 %
1352 % \begin{macro}{\eqnarray@LaTeX}
1353 % \begin{macro}{\eqnarray@fleqn@fixed}
1354 % Team \LaTeX\ has stated they will never repair Leslie's broken definition of \env{eqnarray}.
1355 % Let us be bold\dots.
1356 %
1357 % Note on \classname{hyperref} package compatibility: that package overrides
1358 % \cmd\eqnarray\ by wrapping it up in a larger procedure, so its changes
1359 % are compatible with this package's changes.
1360 %
1361 % \changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}%
1362 % \changes{4.2f}{2022/06/05}{(PHO) Fix detection of \cs{eqnarray} in newer \LaTeX.}%
1363 % \begin{macrocode}
1364 \def\rvtx@tmpa#1{%
1365 \def\eqnarray@LaTeX{%
1366 \stepcounter{equation}%
1367 \def\@currentlabel{\p@equation\theequation}%
1368 #1% \def\@currentcounter{equation} on newer LaTeX
1369 \global\@eqnswtrue
1370 \m@th
1371 \global\@eqcnt\z@
1372 \tabskip\@centering
1373 \let\\\@eqncr
1374 $$\everycr{}\halign to\displaywidth\bgroup
1375 \hskip\@centering$\displaystyle\tabskip\z@skip{####}$\@eqnsel
1376 &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${####}$\hfil
1377 &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
1378 $\displaystyle{####}$\hfil\tabskip\@centering
1379 &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss####\egroup
1380 \tabskip\z@skip
1381 \cr
1382 }%
1383 \long\def\eqnarray@fleqn@fixed{%
1384 \stepcounter{equation}\def\@currentlabel{\p@equation\theequation}%
1385 #1% \def\@currentcounter{equation} on newer LaTeX
1386 \global\@eqnswtrue\m@th\global\@eqcnt\z@
1387 \tabskip\ltx@mathindent
1388 \let\\=\@eqncr
1389 \setlength\abovedisplayskip{\topsep}%
1390 \ifvmode\addtolength\abovedisplayskip{\partopsep}\fi
1391 \addtolength\abovedisplayskip{\parskip}%
1392 \setlength\belowdisplayskip{\abovedisplayskip}%
1393 \setlength\belowdisplayshortskip{\abovedisplayskip}%
1394 \setlength\abovedisplayshortskip{\abovedisplayskip}%
1395 $$%
1396 \everycr{}%
1397 \halignt@\linewidth\bgroup
1398 \hskip\@centering$\displaystyle\tabskip\z@skip{####}$\@eqnsel
1399 &\global\@eqcnt\@ne
1400 \hskip\tw@\eqncolsep
1401 \hfil${{}####{}}$\hfil
1402 &\global\@eqcnt\tw@
1403 \hskip\tw@\eqncolsep
1404 $\displaystyle{####}$\hfil\tabskip\@centering
1405 &\global\@eqcnt\thr@@\hb@xt@\z@\bgroup\hss####\egroup
1406 \tabskip\z@skip
1407 \cr
1408 }%
1409 }
1410 \rvtx@tmpa{}% older LaTeX
1411 \@ifx{\eqnarray\eqnarray@LaTeX}{\@firstofone}
1412 {%
1413 \rvtx@tmpa{\def\@currentcounter{equation}}% newer LaTeX
1414 \@ifx{\eqnarray\eqnarray@LaTeX}{\@firstofone}
1415 {\@gobble}
1416 }
1417 {%
1418 \class@info{Repairing broken LaTeX eqnarray}%
1419 \let\eqnarray\eqnarray@fleqn@fixed
1420 \newlength\eqncolsep
1421 \setlength\eqncolsep\z@
1422 \let\eqnarray@LaTeX\relax
1423 \let\eqnarray@fleqn@fixed\relax
1424 }%
1425 % \end{macrocode}
1426 % The macro \cmd\ltx@mathindent\ is assigned to the \cmd\tabskip\ glue just
1427 % before the alignment preamble is expanded, the value therefore applying at the
1428 % left of the first column.
1429 %
1430 % The below value specifies the display math to be set centered, as is common practice.
1431 % Alternatively, \cmd\tabskip\ can be set to a different glue value, accomplishing
1432 % flush-left display math.
1433 %
1434 % Note that the \filename{fleqn.clo} package provides its own meaning for
1435 % the eqnarray environment, which is also broken. We do not patch that package, however.
1436 %
1437 % \changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}%
1438 % Bug note: The \filename{lineno.sty} package detects \filename{fleqn.clo}
1439 % by testing whether \cmd\mathindent\ is defined, instead of using correct \LaTeXe\ means.
1440 % Even though our eqnarray environment is modelled after \filename{fleqn.clo},
1441 % we must program defensively here.
1442 % \begin{macrocode}
1443 \def\ltx@mathindent{\@centering}%
1444 \def\set@eqnarray@skips{}%
1445 % \end{macrocode}
1446 % \end{macro}
1447 % \end{macro}
1448 %
1449 % \changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}%
1450 %\begin{macro}{\prep@math}
1451 %\begin{macro}{\prep@math@patch}
1452 % If we are in vertical mode when display math mode is entered (via \verb+$$+),
1453 % \TeX\ will first enter horizontal mode, then display math mode; this results in a phantom paragraph
1454 % containing a single \cmd\hbox\ consisting of the \cmd\parindent\ box followed by the \cmd\parskipfillskip\ glue.
1455 % Of course, that \cmd\hbox\ is accompanied by \cmd\parskip\ glue and \cmd\baselineskip\ glue.
1456 %
1457 % The \cmd\prep@math\ procedure removes the \cmd\parindent\ box, thereby (magically) eliminating the phantom paragraph.
1458 % The \cmd\prep@math@patch\ procedure headpatches the \env{equation} and \env{eqnarray} environments
1459 % to accomplish this removal of the phantom paragraph.
1460 %
1461 % Note that there are three remaining ways to enter display math mode that we do not treat:
1462 % the \env{displaymath} environment (equivalent to \cmd\[/\cmd\]), and the primitive the \verb+$$+ markup.
1463 % I refrain from treating the first case because \env{displaymath} already detects the case
1464 % 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.
1465 % As to the primitive \verb+$$+, there is no help for users who insist upon employing procedural markup in their documents.
1466 % in their documents.
1467 % \begin{macrocode}
1468 \def\prep@math{%
1469 \@ifvmode{\everypar{{\setbox\z@\lastbox}}}{}%
1470 }%
1471 \def\prep@math@patch{%
1472 \prepdef\equation{\prep@math}%
1473 \prepdef\eqnarray{\prep@math}%
1474 }%
1475 % \end{macrocode}
1476 % A document class may invoke \cmd\prep@math@patch\ at any point it wishes to prevent the appearance
1477 % of the phantom paragraph: it may be a global declaration or a local one.
1478 % \end{macro}
1479 % \end{macro}
1480 %
1481 % We fail to patch \cmd\[, \cmd\equation, however.
1482 %
1483 % \subsection{Footnotes}
1484 %
1485 % \changes{4.0d}{2000/04/10}{(AO, 174) kernel fix}
1486 %
1487 % \begin{macro}{\footnotemark}
1488 % \begin{macro}{\footnotetest}
1489 % \begin{macro}{\ltx@xfootnote}
1490 % \begin{macro}{\ltx@footmark}
1491 % \begin{macro}{\ltx@foottext}
1492 % \begin{macro}{\ltx@make@current@footnote}
1493 % We repair an error in the \LaTeX\ kernel (see \file{ltfloat.dtx}) involving footnotes.
1494 % The symptom is that the \cmd\footnotemark\ command does not work properly within a \env{minipage} environment.
1495 % The source of the problem is in the way the \cmd\footnotemark\ and \cmd\@xfootnotemark\ procedures are defined:
1496 % they do not share the method, used by \cmd\footnote\ and other procedures, that allows a context switch to
1497 % change the way footnotes behave within a minipage environment.
1498 % This is a \LaTeX\ bug of long standing; our fix dates to 1987.
1499 %
1500 % While we are at it, we rewrite both the \cmd\footnote, \cmd\footnotemark\ and \cmd\footnotetext\ procedures,
1501 % achieving a cleaner separation of syntax and semantics.
1502 % Note that the \cmd\@footnotetext\ procedure is not involved in context switching;
1503 % \classname{hyperref} will take over that procedure, substituting its own processing around
1504 % its argument and passing this to \cmd\H@@footnotetext.
1505 % We anticipate this, and do our context switching on \cmd\H@@footnotetext.
1506 %
1507 % The \cmd\@makefnmark\ continues as the method of formatting the footnote mark.
1508 %
1509 % A note about the context switch mentioned above:
1510 % the \env{minipage} environment executes the following in order to alter the way footnotes
1511 % behave:\begin{verbatim}
1512 %\def\@mpfn{mpfootnote}%
1513 %\def\thempfn{\thempfootnote}%
1514 %\let\@footnotetext\@mpfootnotetext
1515 %\let\@makefnmark\@mpmakefnmark
1516 %\c@mpfootnote\z@\end{verbatim}
1517 % This code changes the counter used in autonumbered footnotes, the choice of footnote marker,
1518 % and the procedure used on the footnote text. Changing the counter is needed because minipage
1519 % footnotes are in their own sequence, and the footnote marker is customarily different within
1520 % a minipage. The procedure that works on the footnote text must be different because the footnotes
1521 % are placed at the bottom of the minipage, not the bottom of the text column.
1522 %
1523 % Note that \LaTeX\ initially defines \cmd\@mpfn\ as \texttt{footnote} and \cmd\thempfn\ as \cmd\thefootnote,
1524 % so we are initially doing general footnotes.
1525 %
1526 % Any procedure that establishes a minipage-like context (e.g., floats) can do the same as the mimipage context switch
1527 % illustrated above.
1528 % \changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.}
1529 %
1530 % Three user-level command, \cmd\footnote, \cmd\footnotemark, and \cmd\footnotetext\ are defined (see the \LaTeX\ manual for user-level details).
1531 % \begin{macro}{\footnote}
1532 % The first user-level command is \cmd\footnote.
1533 % A simple way to look at this command is to think of it as
1534 % \cmd\footnotemark\ \oarg{number} \cmd\footnotetext\ \oarg{number} \arg{text},
1535 % where the optional argument is the same in both calls.
1536 % We also define a syntactical helper procedure \cmd\ltx@xfootnote.
1537 %
1538 % We employ the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc,
1539 % passing in the procedure to execute, in this case \cmd\ltx@footmark,
1540 % which sets the footnote mark.
1541 % In any case, we end on the procedure \cmd\ltx@foottext, which sets the footnote text.
1542 % \begin{macrocode}
1543 \def\footnote{\@ifnextchar[\ltx@xfootnote\ltx@yfootnote}%
1544 \def\ltx@xfootnote[#1]{%
1545 \ltx@def@footproc\ltx@footmark[#1]%
1546 \expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}%
1547 }%
1548 \def\ltx@yfootnote{%
1549 \ltx@stp@footproc\ltx@footmark
1550 \expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}%
1551 }%
1552 % \end{macrocode}
1553 % The \cmd\footmark\ user-level command is next.
1554 % Here we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc\ again,
1555 % but unlike \cmd\footnote, we do not set the footnote text.
1556 % \begin{macrocode}
1557 \def\footnotemark{\@ifnextchar[\ltx@xfootmark\ltx@yfootmark}%
1558 \def\ltx@xfootmark{\ltx@def@footproc\ltx@footmark}%
1559 \def\ltx@yfootmark{\ltx@stp@footproc\ltx@footmark}%
1560 \def\ltx@footmark#1{%
1561 \leavevmode
1562 \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
1563 \begingroup
1564 \expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}%
1565 \expandafter\@argswap@val\expandafter{\Hy@footnote@currentHref}{\hyper@linkstart {link}}%
1566 \@makefnmark
1567 \hyper@linkend
1568 \endgroup
1569 \ifhmode\spacefactor\@x@sf\fi
1570 \relax
1571 }%
1572 % \end{macrocode}
1573 % The third user-level command is \cmd\footnotetext.
1574 % As with \cmd\footnotemark, we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc,
1575 % this time passing in the procedure \cmd\ltx@foottext, which sets the footnote text.
1576 % \begin{macrocode}
1577 \def\footnotetext{\@ifnextchar[\ltx@xfoottext\ltx@yfoottext}%
1578 \def\ltx@xfoottext{\ltx@def@footproc\ltx@foottext}%
1579 \def\ltx@yfoottext{\ltx@stp@footproc\ltx@foottext}%
1580 \long\def\ltx@foottext#1#2{%
1581 \begingroup
1582 \expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}%
1583 \@footnotetext{#2}%
1584 \endgroup
1585 }%
1586 % \end{macrocode}
1587 % Here are the definitions of the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc.
1588 % The require argument is the procedure to execute afterwards, and
1589 % \cmd\ltx@def@footproc\ parses a bracket-delimited argument (it is not optional).
1590 % In each case the given procedure is executed with an argument prepared for it:
1591 % the value of the footnote counter.
1592 % \begin{macrocode}
1593 \def\ltx@def@footproc#1[#2]{%
1594 \begingroup
1595 \csname c@\@mpfn\endcsname #2\relax
1596 \unrestored@protected@xdef\@thefnmark{\thempfn}%
1597 \expandafter\endgroup
1598 \expandafter#1%
1599 \expandafter{\the\csname c@\@mpfn\endcsname}%
1600 }%
1601 \def\ltx@stp@footproc#1{%
1602 \expandafter\stepcounter\expandafter{\@mpfn}%
1603 \protected@xdef\@thefnmark{\thempfn}%
1604 \expandafter#1%
1605 \expandafter{\the\csname c@\@mpfn\endcsname}%
1606 }%
1607 % \end{macrocode}
1608 % Here we provide for our good friend \classname{hyperref}
1609 % to enter in like a bull in a china shop. If it is not loaded,
1610 % we do what it would have done, but gentlier and without hypertext functionality.
1611 % \begin{macrocode}
1612 \appdef\class@documenthook{%
1613 \let\footnote@latex\footnote
1614 \@ifpackageloaded{hyperref}{}{%
1615 \let\H@@footnotetext\@footnotetext
1616 \def\@footnotetext{\H@@footnotetext}%
1617 \let\H@@mpfootnotetext\@mpfootnotetext
1618 \def\@mpfootnotetext{\H@@mpfootnotetext}%
1619 }%
1620 }%
1621 % \end{macrocode}
1622 % In the following, we must use \LaTeX's rococco equipment in the form of \cmd\protected@edef,
1623 % because of the presence of a font switch in the meaning of \cmd\thempfootnote.
1624 % But, really, isn't this a sloppy conflation of semantics and presentation?
1625 % \begin{macrocode}
1626 \def\ltx@make@current@footnote#1#2{%
1627 \csname c@#1\endcsname#2\relax
1628 \protected@edef\Hy@footnote@currentHref{\@currentHref-#1.\csname the#1\endcsname}%
1629 }%
1630 \def\thempfootnote@latex{{\itshape \@alph \c@mpfootnote }}%
1631 \def\ltx@thempfootnote{\@alph\c@mpfootnote}%
1632 \@ifx{\thempfootnote\thempfootnote@latex}{%
1633 \class@info{Repairing hyperref-unfriendly LaTeX definition of \string\mpfootnote}%
1634 \let\thempfootnote\ltx@thempfootnote
1635 }{}%
1636 % \end{macrocode}
1637 %
1638 % Note on \classname{hyperref} compatibility:
1639 % In its ``Automated \LaTeX\ hypertext cross-references'',
1640 % the \classname{hyperref} package alters footnote processing,
1641 % but it does nothing to address the several issues of concern to us.
1642 %
1643 % The \classname{hyperref} package takes over the \cmd\@mpfootnotetext\ and
1644 % \cmd\@footnotetext\ procedures, wrapping the argument in its own code.
1645 % It also rewrites \cmd\@footnotemark, making it a hyperlink, and
1646 % \cmd\@xfootnotenext, removing from it all hypertext capabilities.
1647 %
1648 % However, if the \cmd\footnotemark\ command has been supplied with an optional argument,
1649 % \classname{hyperref}'s changes do not apply: it punts in this case.
1650 %
1651 % At the same time, it attempts to turn off its changes during
1652 % \cmd\maketitle\ processing, destroying one of the capabilities we desire.
1653 %
1654 % We make ourself \classname{hyperref} savvy:
1655 % we re-implement footnote processing, using \classname{hyperref} capabilities if that
1656 % package has been loaded.
1657 %
1658 % Any other package that rewrites \LaTeX's footnote macros will be incompatible
1659 % with this package.
1660 % \changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}%
1661 %
1662 % Two thoughts about \classname{hyperref}: what for does it define \cmd\realfootnote?
1663 % Apparently even SR himself cannot remember.
1664 %
1665 % Also: a document class that desires high hypertext capabilities might
1666 % well wish to reimplement \cmd\maketitle\ so that footnotes called out from there
1667 % are hypertext links: the \classname{hyperref} package's
1668 % ``Automated \LaTeX\ hypertext cross-references''
1669 % does not do any of this:
1670 %\begin{quotation}
1671 % But the special footnotes in |\maketitle| are much too hard to deal with properly.
1672 % Let them revert to plain behaviour.
1673 %\end{quotation}
1674 % Note that the document class, in reimplementing \cmd\maketitle, must ensure
1675 % that the \classname{hyperref} package does not clobber its own definition!
1676 %
1677 % \end{macro}
1678 % \end{macro}
1679 % \end{macro}
1680 % \end{macro}
1681 % \end{macro}
1682 % \end{macro}
1683 % \end{macro}
1684 %
1685 % \begin{macro}{\@footnotetext}
1686 % \begin{macro}{\@mpfootnotetext}
1687 % \begin{macro}{\@tpfootnotetext}
1688 % \begin{macro}{\make@footnotetext}
1689 % \begin{macro}{\set@footnotewidth}
1690 % The two procedures \cmd\@footnotetext\ and \cmd\@mpfootnotetext\ share code.
1691 % We make that explicit here.
1692 %
1693 % Note that the procedure calling \cmd\make@footnotetext\ will open a group
1694 % with \cmd\bgroup\ which is then closed by \cmd\minipagefootnote@drop.
1695 %
1696 % Difference from \LaTeX: here we do not set \cmd\floatingpenalty\ to infinity.
1697 % Doing this must date back to a time when \LaTeX\ could not accomodate split insertions (footnotes).
1698 % I cannot think of any other reason to do have done this.
1699 % At any rate, with the \classname{ltxgrid} package, split insertions are properly
1700 % taken care of, so we allow it.
1701 %
1702 % We provide the hook \cmd\set@footnotewidth\
1703 % that sets the footnote on a particular measure.
1704 % Some page grids are such as to set a footnote in a context where \cmd\columnwidth
1705 % is not the right parameter to use for the set width of a footnote.
1706 % In such a case, for the applicable scope, you should define
1707 % \cmd\set@footnotewidth\ to perform this job correctly.
1708 %
1709 % If we are setting type on multiple page grids, we must still ensure that all footnotes that
1710 % find their way into the \cmd\footins\ insert register are set on the same width.
1711 % This implies the need for a document to have an ``overall'' page grid, which determines the set width of all footnotes
1712 % with the exception of minipage footnotes.
1713 %
1714 % In general, remember that footnotes, like all insertions (including floats),
1715 % are a step outside of the galley context, and all aspects of insertions need to be
1716 % properly handled, including the set width.
1717 % \begin{macrocode}
1718 \def\@makefnmark{%
1719 \hbox{%
1720 \@textsuperscript{%
1721 \normalfont\itshape\@thefnmark
1722 }%
1723 }%
1724 }%
1725 % \end{macrocode}
1726 % \begin{macrocode}
1727 \long\def\@footnotetext{%
1728 \insert\footins\bgroup
1729 \make@footnotetext
1730 }%
1731 % \end{macrocode}
1732 % \begin{macrocode}
1733 \long\def\@mpfootnotetext{%
1734 \minipagefootnote@pick
1735 \make@footnotetext
1736 }%
1737 % \end{macrocode}
1738 % Procedure \cmd\make@footnotetext\ sets the footnote \verb+#1+ into type, with the proper
1739 % font, color, leading, width, and label in effect.
1740 % It also establishes a strut and null glue at the end of the last paragraph of the footnote;
1741 % The strut helps compensate for the lack of \cmd\interlineskip\ glue between \cmd\insert s;
1742 % the glue establishes a feasible \cmd\vsplit\ point between footnotes.
1743 %
1744 % Note that in the title block (\classname{ltxfront}), the alternative definition, under the name \cmd\frontmatter@footnotetext, is used.
1745 % The only material difference there is the reference to \cmd\frontmatter@makefntext\ instead of \cmd\@makefntext.
1746 %
1747 % Dependency note: the \cmd\@makefntext\ procedure is used to further process the footnote text
1748 % and to execute the \cmd\@makefnmark\ procedure to produce the footnote mark.
1749 % The definition of the former is customarily found in the document class (hereunder that of \filename{article.cls}),
1750 % the latter in \filename{latex.ltx}. They are as follows:
1751 % \begin{verbatim}
1752 %\newcommand\@makefntext[1]{%
1753 % \parindent 1em\noindent
1754 % \hb@[email protected]{\hss\@makefnmark}%
1755 % #1%
1756 %}%
1757 %\def\@makefnmark{%
1758 % \hbox{\@textsuperscript{\normalfont\@thefnmark}}%
1759 %}%
1760 % \end{verbatim}
1761 %
1762 % \changes{4.1n}{2010/01/06}{(AO, 572) title block footnotes numbered independently from body footnotes}%
1763 % \begin{macrocode}
1764 \long\def\make@footnotetext#1{%
1765 \set@footnotefont
1766 % \end{macrocode}
1767 % As noted above, we do \emph{not} do \cmd\floatingpenalty\ \cmd\@MM, as in standard \LaTeX.
1768 % \begin{macrocode}
1769 \set@footnotewidth
1770 \@parboxrestore
1771 \protected@edef\@currentlabel{%
1772 % \end{macrocode}
1773 % Note that we employ \cmd\@mpfn\ as a level of redirection for the footnotecounter.
1774 % \begin{macrocode}
1775 \csname p@\@mpfn\endcsname\@thefnmark
1776 }%
1777 \color@begingroup
1778 \@makefntext{%
1779 \rule\z@\footnotesep\ignorespaces#1%
1780 % \end{macrocode}
1781 % \changes{4.1n}{2010/01/02}{(AO, 571) allow split after last line of footnote}%
1782 % The following strut and glue are for spacing and splitting, as mentioned above.
1783 % \begin{macrocode}
1784 \@finalstrut\strutbox\vadjust{\vskip\z@skip}%
1785 }%
1786 \color@endgroup
1787 \minipagefootnote@drop
1788 }%
1789 % \end{macrocode}
1790 % \changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote}
1791 % \cmd\set@footnotefont\ is the procedure for setting the font of a footnote.
1792 % Other aspects of the environment may be set using this hook.
1793 % \begin{macrocode}
1794 \def\set@footnotefont{%
1795 \reset@font\footnotesize
1796 \interlinepenalty\interfootnotelinepenalty
1797 \splittopskip\footnotesep
1798 \splitmaxdepth\dp\strutbox
1799 }%
1800 % \end{macrocode}
1801 % \cmd\set@footnotewidth\ is the procedure for setting the width of a footnote.
1802 % The default page grid, a single, full-width column, sets footnotes on the width of the text.
1803 % \changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}%
1804 % \begin{macrocode}
1805 \def\set@footnotewidth{\set@footnotewidth@one}%
1806 % \end{macrocode}
1807 % \end{macro}
1808 % \end{macro}
1809 % \end{macro}
1810 % \end{macro}
1811 % \end{macro}
1812 %
1813 %
1814 % \subsection{Floats}
1815 %
1816 % \subsubsection{Usage notes}%
1817 % We extend the \LaTeX\ kernel for three purposes:
1818 % \begin{enumerate}
1819 %
1820 % \item
1821 % When the \cmd\footnote\ command is used within the
1822 % scope of a float, we do as \env{minipage} does.
1823 %
1824 % \item
1825 % We provide a mechanism to write floats out to an external
1826 % stream for temporary storage (deferred floats).
1827 %
1828 % \item
1829 % We provide mechanism for placing a float \texttt{here}
1830 % invariably, that is, floats are unfloated.
1831 % This mechanism is used to read the external stream mentioned above.
1832 %
1833 % \end{enumerate}
1834 %
1835 % To use these mechanisms, the document class should
1836 % define a float, say, \env{figure} as per usual, and in addition:
1837 % \begin{enumerate}
1838 %
1839 % \item
1840 % Optionally define an alternative, say \env{figure@write} as follows:
1841 % \begin{verbatim}\newenvironment{figure@write}{%
1842 % \write@float{figure}%
1843 %}{%
1844 % \endwrite@float
1845 %}\end{verbatim}
1846 % That is, the alternative environment executes \cmd\write@float\
1847 % instead of \cmd\@float.
1848 % Note that this step is not needed if the float environment
1849 % is defined in the simple way of \file{classes.dtx}.
1850 % However, an environment like \env{longtable} will require it.
1851 %
1852 % \item
1853 % Install into \cmd\AtBeginDocument\ a call to \cmd\do@if@floats,
1854 % with the float name and an appropriate file extension as its arguments.
1855 % \begin{verbatim}\appdef\class@documenthook{\do@if@floats{figure}{.fgx}}\end{verbatim}
1856 %
1857 % \item
1858 % Optionally define a text entity \cmd\figuresname\ that will
1859 % be the text of the head that is set over the
1860 % deferred floats.
1861 % If not defined, there will be no head.
1862 %
1863 % \item
1864 % Optionally define a user-level command to allow
1865 % the document to determine where the figures are printed out
1866 % (default is to print at end of document). E.g.,
1867 % \begin{verbatim}\newcommand\printfigures{\print@float{figure}}\end{verbatim}
1868 % \item
1869 % Install into \cmd\appdef\cmd\class@enddocumenthook\ a call to \cmd\printfigures,
1870 % or, if the latter is not defined, as follows:
1871 % \begin{verbatim}\appdef\class@enddocumenthook{\print@float{figure}}\end{verbatim}
1872 % Note that installing this command into \cmd\AtBeginDocument
1873 % is best done earlier than calls that assume the last page of
1874 % the document is at hand.
1875 %
1876 % \end{enumerate}
1877 %
1878 % \subsubsection{Robustifying fragile commands}%
1879 % Certain of \LaTeX's commands cannot be written out to a file or appear within a \cmd\mark\ command argument
1880 % because they do calculations during expansion.
1881 % We provide for a little help, but without changing the meanings of these commands.
1882 %
1883 % \begin{macro}{\addtocontents}
1884 % \begin{macro}{\robustify@contents}
1885 %
1886 % \changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}%
1887 % \begin{macrocode}
1888 \def\robustify@contents{%
1889 \let \label \@gobble
1890 \let \index \@gobble
1891 \let \glossary \@gobble
1892 \let\footnote \@gobble
1893 \def\({\string\(}%
1894 \def\){\string\)}%
1895 \def\\{\string\\}%
1896 }%
1897 \long\def\addtocontents#1#2{%
1898 \protected@write\@auxout{\robustify@contents}{\string \@writefile {#1}{#2}}%
1899 }%
1900 % \end{macrocode}
1901 %
1902 % \end{macro}
1903 % \end{macro}
1904 %
1905 % \subsubsection{Preparing for the \classname{hyperref package}}%
1906 %
1907 % \begin{macro}{\addcontentsline}
1908 % \begin{macro}{\label}
1909 % \begin{macro}{\ltx@contentsline}
1910 % \changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}%
1911 % The \classname{hyperref} package assumes that the \cmd\contentsline\ command will be given four arguments.
1912 % Therefore it cannot successfully process a \filename{.toc} file that had been written by standard \LaTeX.
1913 % We fix things up by always writing that fourth argument and by supplying a \cmd\contentsline\ command that
1914 % can read them.
1915 %
1916 % We also give the \cmd\newlabel\ command's second argument five tokens.
1917 %
1918 % Finally, we wrap \LaTeX's \cmd\contentsline\ command with code to detect the case
1919 % where the expected procedure is not defined, and we give it a syntax with no semantics.
1920 %
1921 % We switch over to this new definition only after \classname{hyperref} has loaded.
1922 % \begin{macrocode}
1923 \def\addcontentsline#1#2#3{%
1924 \addtocontents{#1}{%
1925 \protect\contentsline{#2}{#3}{\thepage}{}%
1926 }%
1927 }%
1928 \def\label#1{%
1929 \@bsphack
1930 \protected@write\@auxout{}{%
1931 \string\newlabel{#1}{{\@currentlabel}{\thepage}{}{}{}}%
1932 }%
1933 \@esphack
1934 }%
1935 \def\ltx@contentsline#1{%
1936 \expandafter\@ifnotrelax\csname l@#1\endcsname{}{%
1937 \expandafter\let\csname l@#1\endcsname\@gobbletwo
1938 }%
1939 \contentsline@latex{#1}%
1940 }%
1941 \appdef\document@inithook{%
1942 \let\contentsline@latex\contentsline
1943 \let\contentsline\ltx@contentsline
1944 }%
1945 % \end{macrocode}
1946 %
1947 % \end{macro}
1948 % \end{macro}
1949 % \end{macro}
1950 %
1951 % \subsubsection{Footnotes within floats, unfloating floats, float font}%
1952 %
1953 % \begin{macro}{\caption}
1954 % DPC: Er a bit of a hack, but seems best way of supporting normal
1955 % \LaTeX\ syntax at this point: If a caption is used below a table,
1956 % then put out the footnotes before the caption.
1957 % \changes{4.0b}{1999/06/20}{Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time, since \classname{hyperref} clobbers \cs{caption}.}
1958 % \begin{macrocode}
1959 \appdef\class@documenthook{%
1960 \prepdef\caption{\minipagefootnote@here}%
1961 }%
1962 % \end{macrocode}
1963 %
1964 % Note on \classname{hyperref} compatibility:
1965 % this change to the \cmd\caption\ command is compatible with the
1966 % ``Automated \LaTeX\ hypertext cross-references'' patches of that package.
1967 %
1968 % All the same, I think Sebastian's changes to \cmd\caption\ and \cmd\@caption\
1969 % could bear with some improvement.
1970 % The following implementation requires knowing only the pattern part of the
1971 % \cmd\@caption\ macro:
1972 %\begin{verbatim}
1973 %\def\caption{%
1974 % \H@refstepcounter\@captype
1975 % \hyper@makecurrent{\@captype}%
1976 % \@dblarg{\H@caption\@captype}%
1977 %}%
1978 %\def\H@caption#1[#2]#3{%
1979 % \@caption{#1}[#2]{%
1980 % \ifHy@nesting
1981 % \hyper@@anchor{\@currentHref}{#3}%
1982 % \else
1983 % \hyper@@anchor{\@currentHref}{\relax}#3%
1984 % \fi
1985 % }%
1986 %}\end{verbatim}
1987 %
1988 % \end{macro}
1989 %
1990 % \begin{macro}{\minipagefootnote@init}
1991 % \begin{macro}{\minipagefootnote@here}
1992 % \begin{macro}{\minipagefootnote@foot}
1993 % \begin{macro}{\minipagefootnote@pick}
1994 % \begin{macro}{\minipagefootnote@drop}
1995 % Procedure to deal with footnotes accumulated within a minipage environment.
1996 % These procedures encapsulate all uses of the \cmd\@mpfootins\ box.
1997 %
1998 %
1999 % Note: \cmd\minipagefootnote@here\ must \emph{not} be executed within the MVL!
2000 % \begin{macrocode}
2001 \def\minipagefootnote@init{%
2002 \setbox\@mpfootins\box\voidb@x
2003 }%
2004 \def\minipagefootnote@pick{%
2005 \global\setbox\@mpfootins\vbox\bgroup
2006 \unvbox\@mpfootins
2007 }%
2008 \def\minipagefootnote@drop{%
2009 \egroup
2010 }%
2011 \def\minipagefootnote@here{%
2012 \par
2013 \@ifvoid\@mpfootins{}{%
2014 \vskip\skip\@mpfootins
2015 \fullinterlineskip
2016 \@ifinner{%
2017 \vtop{\unvcopy\@mpfootins}%
2018 {\setbox\z@\lastbox}%
2019 }{}%
2020 \unvbox\@mpfootins
2021 }%
2022 }%
2023 \def\minipagefootnote@foot{%
2024 \@ifvoid\@mpfootins{}{%
2025 \insert\footins\bgroup\unvbox\@mpfootins\egroup
2026 }%
2027 }%
2028 \def\endminipage{%
2029 \par
2030 \unskip
2031 \minipagefootnote@here
2032 \@minipagefalse %% added 24 May 89
2033 \color@endgroup
2034 \egroup
2035 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}%
2036 }%
2037 % \end{macrocode}
2038 % \end{macro}
2039 % \end{macro}
2040 % \end{macro}
2041 % \end{macro}
2042 % \end{macro}
2043 %
2044 % \begin{macro}{\floats@sw}
2045 % \changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}%
2046 % The Boolean \cmd\floats@sw\ signifies that floats are to be floated;
2047 % if false, that floats are to be deferred to the end of the document.
2048 % Note that the assignment of this Boolean is to be overridden by
2049 % the document class in response to user-selected options.
2050 % \begin{macrocode}
2051 \@booleantrue\floats@sw
2052 % \end{macrocode}
2053 % \end{macro}
2054 %
2055 % \begin{macro}{\@xfloat}
2056 % \begin{macro}{\@mpmakefntext}
2057 % The float start-code is redefined to set up footnotes in the style of minipage.
2058 % Also, the \cmd\floats@sw\ Boolean informs us that floats are to be
2059 % all placed \texttt{here}.
2060 % Note that, to protect against the Boolean being undefined
2061 % at this late hour, we default it globally to true.
2062 %
2063 % \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. }
2064 % \changes{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing}
2065 % \changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks}
2066 % \changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.}
2067 % \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.}
2068 % \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.}
2069 % \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
2070 %
2071 % \begin{macrocode}
2072 \let\@xfloat@LaTeX\@xfloat
2073 \def\@xfloat#1[#2]{%
2074 \@xfloat@prep
2075 \@nameuse{fp@proc@#2}%
2076 \floats@sw{\@xfloat@LaTeX{#1}[#2]}{\@xfloat@anchored{#1}[]}%
2077 }%
2078 \def\@xfloat@prep{%
2079 \ltx@footnote@pop
2080 \def\@mpfn{mpfootnote}%
2081 \def\thempfn{\thempfootnote}%
2082 \c@mpfootnote\z@
2083 \let\H@@footnotetext\H@@mpfootnotetext
2084 }%
2085 \let\ltx@footnote@pop\@empty
2086 \def\@xfloat@anchored#1[#2]{%
2087 \def\@captype{#1}%
2088 \begin@float@pagebreak
2089 \let\end@float\end@float@anchored
2090 \let\end@dblfloat\end@float@anchored
2091 \hsize\columnwidth
2092 \@parboxrestore
2093 \@floatboxreset
2094 \minipagefootnote@init
2095 }%
2096 \def\end@float@anchored{%
2097 \minipagefootnote@here
2098 \par\vskip\z@skip
2099 \par
2100 \end@float@pagebreak
2101 }%
2102 \def\begin@float@pagebreak{\par\addvspace\intextsep}%
2103 \def\end@float@pagebreak{\par\addvspace\intextsep}%
2104 \def\@mpmakefntext#1{%
2105 \parindent=1em
2106 \noindent
2107 \hb@xt@1em{\hss\@makefnmark}%
2108 #1%
2109 }%
2110 % \end{macrocode}
2111 % \end{macro}
2112 % \end{macro}
2113 %
2114 %
2115 % \subsubsection{Writing floats out to a file}%
2116 %
2117 % \begin{macro}{\do@if@floats}
2118 % \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
2119 % The procedure \cmd\do@if@floats\ should be executed at
2120 % \cmd\class@documenthook\ time: it arranges to write out
2121 % the floats of the given class to a temporary file, to be
2122 % read back later (deferred floats),
2123 % given that \cmd\floats@sw\ is false.
2124 % Note that, to protect against the Boolean being undefined
2125 % at this late hour, we default it globally to true.
2126 % \begin{macrocode}
2127 \def\do@if@floats#1#2{%
2128 \floats@sw{}{%
2129 % \end{macrocode}
2130 % Open the stream to save out the document's floats of this class.
2131 % \begin{macrocode}
2132 \expandafter\newwrite
2133 \csname#1write\endcsname
2134 \expandafter\def
2135 \csname#1@stream\endcsname{\jobname#2}%
2136 \expandafter\immediate
2137 \expandafter\openout
2138 \csname#1write\endcsname
2139 \csname#1@stream\endcsname\relax
2140 % \end{macrocode}
2141 % Swap environments.
2142 % If the class writer has defined, e.g., \env{figure@write},
2143 % then we use this as the procedure to execute for writing
2144 % the float out to the external stream.
2145 % Otherwise, the replacement of \cmd\@float\ by \cmd\write@float\
2146 % should do the right thing for float environments defined
2147 % in the simple way of \classname{classes.dtx}.
2148 % \begin{macrocode}
2149 \@ifxundefined\@float@LaTeX{%
2150 \let\@float@LaTeX\@float
2151 \let\@dblfloat@LaTeX\@dblfloat
2152 \let\@float\write@float
2153 \let\@dblfloat\write@floats
2154 }{}%
2155 \let@environment{#1@float}{#1}%
2156 \let@environment{#1@floats}{#1*}%
2157 \@ifxundefined@cs{#1@write}{}{%
2158 \let@environment{#1}{#1@write}%
2159 }%
2160 }%
2161 }%
2162 % \end{macrocode}
2163 % \end{macro}
2164 %
2165 % \begin{macro}{\print@float}
2166 % The procedure \cmd\print@float\ prints out the
2167 % deferred floats.
2168 % \changes{4.0b}{1999/06/20}{only execute if there really were floats of the given type}
2169 % \changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.}
2170 % \changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.}
2171 % \changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.}
2172 %
2173 % Here, we make use of the \cmd\floats@sw\ Boolean to select
2174 % the non-floating type of processing.
2175 % \begin{macrocode}
2176 \def\triggerpar{\leavevmode\@@par}%
2177 \def\oneapage{\def\begin@float@pagebreak{\newpage}\def\end@float@pagebreak{\newpage}}%
2178 \def\print@float#1#2{%
2179 \lengthcheck@sw{%
2180 \total@float{#1}%
2181 }{}%
2182 \@ifxundefined@cs{#1write}{}{%
2183 \begingroup
2184 \@booleanfalse\floats@sw
2185 #2%
2186 \raggedbottom
2187 \def\array@default{v}% floats must
2188 \let\@float\@float@LaTeX
2189 \let\@dblfloat\@dblfloat@LaTeX
2190 \let\trigger@float@par\triggerpar
2191 \let@environment{#1}{#1@float}%
2192 \let@environment{#1*}{#1@floats}%
2193 \expandafter\prepdef\csname#1\endcsname{\trigger@float@par}%
2194 \expandafter\prepdef\csname#1*\endcsname{\trigger@float@par}%
2195 \@namedef{fps@#1}{h!}%
2196 \expandafter\immediate
2197 \expandafter\closeout
2198 \csname#1write\endcsname
2199 \everypar{%
2200 \global\let\trigger@float@par\relax
2201 \global\everypar{}\setbox\z@\lastbox
2202 \@ifxundefined@cs{#1sname}{}{%
2203 \begin@float@pagebreak
2204 \expandafter\section
2205 \expandafter*%
2206 \expandafter{%
2207 \csname#1sname\endcsname
2208 }%
2209 }%
2210 }%
2211 \input{\csname#1@stream\endcsname}%
2212 \endgroup
2213 \global\expandafter\let\csname#1write\endcsname\relax
2214 }%
2215 }%
2216 % \end{macrocode}
2217 % \end{macro}
2218 %
2219 % \begin{macro}{\tally@float}
2220 % \begin{macro}{\total@float}
2221 % \changes{4.1b}{2008/08/12}{Tally and log the height of a float class}
2222 % If we are tallying column inches, \cmd\tally@float\ tallies a contribution to \cmd\ftype@\ \cmd\@captype,
2223 % depending upon the width of \cmd\@currbox.
2224 % In effect, each float class is tallied in two sections, one for narrow, one for wide floats.
2225 %
2226 % If statistics are wanted, \cmd\total@float\ logs the tally for the given float class.
2227 % \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
2228 % The quantity \cmd\@twopowerfourteen\ is $2^{14}$, \cmd\@twopowertwo\ is $2^{2}$.
2229 % \begin{macrocode}
2230 \chardef\@xvi=16\relax
2231 \mathchardef\@twopowerfourteen="4000
2232 \mathchardef\@twopowertwo="4
2233 \def\tally@float#1{%
2234 \begingroup
2235 % \end{macrocode}
2236 % We strip all but the least significant 5 bits from \cmd\count\ \cmd\@currbox,
2237 % and put them into \cmd\@tempcnta. We then subtract 16 from \cmd\count\ \cmd\@currbox
2238 % (unless this would make it negative), effectively reversing the process
2239 % carried out in \cmd\@float.
2240 % \begin{macrocode}
2241 \@tempcnta\count\@currbox
2242 \divide\@tempcnta\@xxxii
2243 \multiply\@tempcnta\@xxxii
2244 \advance\count\@currbox-\@tempcnta
2245 \divide\@tempcnta\@xxxii
2246 \@ifnum{\count\@currbox>\@xvi}{%
2247 \advance\count\@currbox-\@xvi\@booleantrue\@temp@sw
2248 }{%
2249 \@booleanfalse\@temp@sw
2250 }%
2251 % \end{macrocode}
2252 % If so desired, we log the characteristics of this float object:
2253 % float class and float placement parameters, height, depth, and width.
2254 % \begin{macrocode}
2255 \show@box@size@sw{%
2256 \class@info{Float #1
2257 (\the\@tempcnta)[\@temp@sw{16+}{}\the\count\@currbox]^^J%
2258 (\the\ht\@currbox+\the\dp\@currbox)X\the\wd\@currbox
2259 }%
2260 }{}%
2261 \endgroup
2262 % \end{macrocode}
2263 % Here we tally the height of this float object.
2264 % \begin{macrocode}
2265 \expandafter\let
2266 \expandafter\@tempa
2267 \csname fbox@\csname ftype@#1\endcsname\endcsname
2268 \@ifnotrelax\@tempa{%
2269 \@ifhbox\@tempa{%
2270 \setbox\@tempboxa\vbox{\unvcopy\@currbox\hrule}%
2271 \dimen@\ht\@tempboxa
2272 \divide\dimen@\@twopowerfourteen
2273 \@ifdim{\wd\@tempboxa<\textwidth}{%
2274 \advance\dimen@\ht\@tempa
2275 \global\ht\@tempa\dimen@
2276 }{%
2277 \advance\dimen@\dp\@tempa
2278 \global\dp\@tempa\dimen@
2279 }%
2280 }{}%
2281 }{}%
2282 }%
2283 \def\total@float#1{%
2284 \expandafter\let
2285 \expandafter\@tempa
2286 \csname fbox@\csname ftype@#1\endcsname\endcsname
2287 \@ifnotrelax\@tempa{%
2288 \@ifhbox\@tempa{%
2289 \@tempdima\the\ht\@tempa\divide\@tempdima\@twopowertwo\@tempcnta\@tempdima
2290 \@tempdimb\the\dp\@tempa\divide\@tempdimb\@twopowertwo\@tempcntb\@tempdimb
2291 \class@info{Total #1: Column(\the\@tempcnta pt), Page(\the\@tempcnta pt)}%
2292 }{}%
2293 }{}%
2294 }%
2295 % \end{macrocode}
2296 % \end{macro}
2297 % \end{macro}
2298 %
2299 % \begin{macro}{\write@float}
2300 % \begin{macro}{\write@floats}
2301 % \begin{macro}{\write@@float}
2302 % Handles the case where the name of the float is the same as
2303 % that of the stream. Note that
2304 % \env{longtable} does \emph{not} fit this case.
2305 % Note also: \cmd\write@float\ is \emph{not} a user-level environment,
2306 % therefore it is properly not defined with \cmd\newenvironment.
2307 % \begin{macrocode}
2308 \def\write@float#1{\write@@float{#1}{#1}}%
2309 \def\endwrite@float{\@Esphack}%
2310 \def\write@floats#1{\write@@float{#1*}{#1}}%
2311 \def\endwrite@floats{\@Esphack}%
2312 % \end{macrocode}
2313 % \end{macro}
2314 %
2315 % \begin{macro}{\write@@float}
2316 % \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.}
2317 % \begin{macrocode}
2318 \def\write@@float#1#2{%
2319 \ifhmode
2320 \@bsphack
2321 \fi
2322 \chardef\@tempc\csname#2write\endcsname
2323 \toks@{\begin{#1}}%
2324 \def\@tempb{#1}%
2325 \expandafter\let\csname end#1\endcsname\endwrite@float
2326 \catcode`\^^M\active
2327 \@makeother\{\@makeother\}\@makeother\%
2328 \write@floatline
2329 }%
2330 % \end{macrocode}
2331 % \end{macro}
2332 % \end{macro}
2333 % \end{macro}
2334 %
2335 % \begin{macro}{\write@floatline}
2336 % \begin{macro}{\@write@floatline}
2337 % \begin{macro}{\float@end@tag}
2338 % The procedure \cmd\write@floatline\ only parses;
2339 % it passes its result to \cmd\@write@floatline, which
2340 % writes the line to output, then tests the line
2341 % for the \cmd\end\arg{float} tokens with
2342 % aid of the \cmd\float@end@tag\ procedure.
2343 % \begin{macrocode}
2344 \begingroup
2345 \catcode`\[\the\catcode`\{\catcode`\]\the\catcode`\}\@makeother\{\@makeother\}%
2346 \gdef\float@end@tag#1\end{#2}#3\@nul[%
2347 \def\@tempa[#2]%
2348 \@ifx[\@tempa\@tempb][\end[#2]][\write@floatline]%
2349 ]%
2350 \obeylines%
2351 \gdef\write@floatline#1^^M[%
2352 \begingroup%
2353 \newlinechar`\^^M%
2354 \toks@\expandafter[\the\toks@#1]\immediate\write\@tempc[\the\toks@]%
2355 \endgroup%
2356 \toks@[]%
2357 \float@end@tag#1\end{}\@nul%
2358 ]%
2359 \endgroup
2360 % \end{macrocode}
2361 % \end{macro}
2362 % \end{macro}
2363 % \end{macro}
2364 %
2365 %
2366 %
2367 % \subsection{Counters}
2368 % The following definitions override those of the \LaTeX\ kernel,
2369 % providing for a greater range of inputs.
2370 % \begin{macrocode}
2371 \def\@alph#1{\ifcase#1\or a\or b\or c\or d\else\@ialph{#1}\fi}
2372 % \end{macrocode}
2373 %
2374 % \begin{macrocode}
2375 \def\@ialph#1{\ifcase#1\or \or \or \or \or e\or f\or g\or h\or i\or j\or
2376 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
2377 y\or z\or aa\or bb\or cc\or dd\or ee\or ff\or gg\or hh\or ii\or jj\or
2378 kk\or ll\or mm\or nn\or oo\or pp\or qq\or rr\or ss\or tt\or uu\or
2379 vv\or ww\or xx\or yy\or zz\else\@ctrerr\fi}
2380 % \end{macrocode}
2381 %
2382 %
2383 % \subsection{Customization of Sections}%
2384 %
2385 % Patch the standard \LaTeX\ sectioning procedure to:
2386 %\begin{itemize}
2387 %\item
2388 % Allow a sectioning command to trigger the title page, or more generally
2389 % to recognize that it is the first object in the document,
2390 % so we headpatch \cmd\@startsection.
2391 %
2392 %\item
2393 % Allow a tail command in |#6| to uppercase the title, so we retain
2394 % DPC's braces.
2395 %
2396 %\item
2397 % Allow each type of sectioning command to format its number differently,
2398 % so we generalize \cmd\@seccntformat.
2399 %
2400 %\item
2401 % Allow each type of sectioning command to format its argument differently,
2402 % so we generalize \cmd\@hangfrom.
2403 %
2404 %\item
2405 % Allow the starred form of the command to
2406 % mark (the running head) and
2407 % make an entry in the TOC,
2408 % so we put \cmd\@ssect\ on the same footing as \cmd\@sect.
2409 %
2410 % Note that the tokens passed to the TOC now are \emph{not}
2411 % the optional argument of the command, but the required.
2412 % This means that the user can no longer use the former
2413 % to put variant content in to the TOC as the Manual says.
2414 %
2415 % Instead, the optional argument is used to put an alternative
2416 % title into the running headers, a better choice.
2417 %
2418 %\end{itemize}
2419 %
2420 % \begin{macro}{\@startsection}
2421 % Patch a head hook into the basic sectioning command.
2422 % Treat \cmd\@sect\ and \cmd\@ssect\ on an equal footing:
2423 % now their pattern parts are identical.
2424 % \begin{macrocode}
2425 \def\@startsection#1#2#3#4#5#6{%
2426 \@startsection@hook
2427 \if@noskipsec \leavevmode \fi
2428 \par
2429 \@tempskipa #4\relax
2430 \@afterindenttrue
2431 \ifdim \@tempskipa <\z@
2432 \@tempskipa -\@tempskipa \@afterindentfalse
2433 \fi
2434 \if@nobreak
2435 \everypar{}%
2436 \else
2437 \addpenalty\@secpenalty\addvspace\@tempskipa
2438 \fi
2439 \@ifstar
2440 {\@dblarg{\@ssect@ltx{#1}{#2}{#3}{#4}{#5}{#6}}}%
2441 {\@dblarg{\@sect@ltx {#1}{#2}{#3}{#4}{#5}{#6}}}%
2442 }%
2443 \def\@startsection@hook{}%
2444 % \end{macrocode}
2445 % \end{macro}
2446 %
2447 % \begin{macro}{\@sect}
2448 % When defining \cmd\@svsec, do not expand \cmd\@seccntformat.
2449 % Put brace characters back where they were before David Carlisle got at them
2450 % (i.e., as if \cmd\@hangfrom\ had two arguments).
2451 % Protect the mark mechanism from an undefined meaning.
2452 % Pass |#8| to the TOC instead of |#7|.
2453 % Remove \cmd\relax\ from the replacement part of \cmd\@svsec.
2454 %
2455 % The procedure \cmd\@hangfrom\ and \cmd\@runin@to\ can
2456 % be used to process the argument of the head.
2457 % The head can define, e.g., \cmd\@hangfrom@section, to
2458 % do its own processing.
2459 %
2460 % In using \cmd\H@refstepcounter\ in place of \cmd\refstepcounter\ we rely on
2461 % either loading before any package that patches the latter, or
2462 % the convention that the former is the original \LaTeX\ procedure.
2463 %
2464 % \begin{macrocode}
2465 \class@info{Repairing broken LateX \string\@sect}%
2466 \def\@sect@ltx#1#2#3#4#5#6[#7]#8{%
2467 \@ifnum{#2>\c@secnumdepth}{%
2468 \def\H@svsec{\phantomsection}%
2469 \let\@svsec\@empty
2470 }{%
2471 \H@refstepcounter{#1}%
2472 \def\H@svsec{%
2473 \phantomsection
2474 }%
2475 \protected@edef\@svsec{{#1}}%
2476 \@ifundefined{@#1cntformat}{%
2477 \prepdef\@svsec\@seccntformat
2478 }{%
2479 \expandafter\prepdef
2480 \expandafter\@svsec
2481 \csname @#1cntformat\endcsname
2482 }%
2483 }%
2484 \@tempskipa #5\relax
2485 \@ifdim{\@tempskipa>\z@}{%
2486 \begingroup
2487 \interlinepenalty \@M
2488 #6{%
2489 \@ifundefined{@hangfrom@#1}{\@hang@from}{\csname @hangfrom@#1\endcsname}%
2490 {\hskip#3\relax\H@svsec}{\@svsec}{#8}%
2491 }%
2492 \@@par
2493 \endgroup
2494 \@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
2495 \addcontentsline{toc}{#1}{%
2496 \@ifnum{#2>\c@secnumdepth}{%
2497 \protect\numberline{}%
2498 }{%
2499 \protect\numberline{\csname the#1\endcsname}%
2500 }%
2501 #8}%
2502 }{%
2503 \def\@svsechd{%
2504 #6{%
2505 \@ifundefined{@runin@to@#1}{\@runin@to}{\csname @runin@to@#1\endcsname}%
2506 {\hskip#3\relax\H@svsec}{\@svsec}{#8}%
2507 }%
2508 \@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
2509 \addcontentsline{toc}{#1}{%
2510 \@ifnum{#2>\c@secnumdepth}{%
2511 \protect\numberline{}%
2512 }{%
2513 \protect\numberline{\csname the#1\endcsname}%
2514 }%
2515 #8}%
2516 }%
2517 }%
2518 \@xsect{#5}%
2519 }%
2520 \def\@hang@from#1#2#3{\@hangfrom{#1#2}#3}%
2521 \def\@runin@to #1#2#3{#1#2#3}%
2522 % \end{macrocode}
2523 % \end{macro}
2524 %
2525 % \begin{macro}{\@ssect}
2526 % Put brace characters back where they were before David Carlisle got at them
2527 % (as if \cmd\@hangfrom\ has two arguments).
2528 % Possibly set a mark.
2529 % Make a TOC entry.
2530 %
2531 % Note that, for compatibility with the \classname{hyperref} package, we
2532 % need to provide the interface required by that package
2533 % (actually required by \file{pdfmark.def} and \file{nameref.sty}),
2534 % namely
2535 % the definition of \cmd\@currentlabelname\ (but now removed),
2536 % the insertion of the procedure \cmd\Sectionformat\ (but why is this needed?), and
2537 % the call to \cmd\phantomsection\ (which must precede the call to \cmd\addcontentsline).
2538 % We also have to sidestep the patch to \cmd\@ssect\ in that same file, therefore
2539 % we use a different control sequence name in the call from \cmd\@startsection.
2540 % \changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility}
2541 % \changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility}
2542 % \begin{macrocode}
2543 \def\@ssect@ltx#1#2#3#4#5#6[#7]#8{%
2544 % \end{macrocode}
2545 % Removed |\def\@currentlabelname{#8}|
2546 % \begin{macrocode}
2547 \def\H@svsec{\phantomsection}%
2548 \@tempskipa #5\relax
2549 \@ifdim{\@tempskipa>\z@}{%
2550 \begingroup
2551 \interlinepenalty \@M
2552 #6{%
2553 \@ifundefined{@hangfroms@#1}{\@hang@froms}{\csname @hangfroms@#1\endcsname}%
2554 % \end{macrocode}
2555 % Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}|
2556 % \begin{macrocode}
2557 {\hskip#3\relax\H@svsec}{#8}%
2558 }%
2559 \@@par
2560 \endgroup
2561 \@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
2562 \addcontentsline{toc}{#1}{\protect\numberline{}#8}%
2563 }{%
2564 \def\@svsechd{%
2565 #6{%
2566 \@ifundefined{@runin@tos@#1}{\@runin@tos}{\csname @runin@tos@#1\endcsname}%
2567 % \end{macrocode}
2568 % Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}|
2569 % \begin{macrocode}
2570 {\hskip#3\relax\H@svsec}{#8}%
2571 }%
2572 \@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
2573 \addcontentsline{toc}{#1}{\protect\numberline{}#8}%
2574 }%
2575 }%
2576 \@xsect{#5}%
2577 }%
2578 \def\@hang@froms#1#2{#1#2}%
2579 \def\@runin@tos #1#2{#1#2}%
2580 % \end{macrocode}
2581 % \end{macro}
2582 %
2583 % \begin{macro}{\init@hyperref}
2584 % \changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire}
2585 % Document classes that incorporate this package will be \classname{hyperref}-savvy.
2586 % (To accomplish this, we ensure that \cmd\hyperanchor\ and \cmd\hyper@last\ are both defined.)
2587 % Being \classname{hyperref}-savvy levels some requirements on us, but the benefits are many.
2588 %
2589 % One is that the TOC will not get amnesia and require a full set of three typesetting runs before its formatting is stable.
2590 % Instead, only two runs are required: the first updates the auxiliary file, the second the TOC.
2591 % However, the formatting of the document does not change.
2592 %
2593 % Another aspect of being \classname{hyperref}-savvy is that the syntax of commands in the \file{.aux} file will not change
2594 % if \classname{hyperref} is turned on or off.
2595 %
2596 % Note that \cmd\hyper@anchorstart\ and \cmd\hyper@anchorend\ constitute the programming interface
2597 % for a hypertext anchor (the target of a hypertext link); \cmd\hyper@linkstart\ and \cmd\hyper@linkend\
2598 % are the interface for a hypertext link.
2599 % \begin{macrocode}
2600 \def\init@hyperref{%
2601 \providecommand\phantomsection{}%
2602 \providecommand\hyper@makecurrent[1]{}%
2603 \providecommand\Hy@raisedlink[1]{}%
2604 \providecommand\hyper@anchorstart[1]{}%
2605 \providecommand\hyper@anchorend{}%
2606 \providecommand\hyper@linkstart[2]{}%
2607 \providecommand\hyper@linkend{}%
2608 \providecommand\@currentHref{}%
2609 }%
2610 \let\H@refstepcounter\refstepcounter
2611 \appdef\document@inithook{%
2612 \init@hyperref
2613 }%
2614 % \end{macrocode}
2615 % \end{macro}
2616 %
2617 % \begin{macro}{\sec@upcase}
2618 % Upper case for sections (optional upper case items). These are
2619 % created so that some headings can be toggled between mixed case and
2620 % upper case readily.
2621 % Headings that might be changed can be wrapped in the style file in
2622 % \cmd\sec@upcase\arg{text} constructs;
2623 % the expansion of \cmd\sec@upcase\ is
2624 % controlled here. It is \cmd\relax\ by default (mixed case heads), and
2625 % can easily be changed to \cmd\uppercase\ if desired.
2626 % If mixed-case headings are wanted by the editor, authors {\em must}
2627 % supply mixed case text, although this is what authors should be doing
2628 % anyway.
2629 % (Mixed can be converted to upper,
2630 % but the reverse transformation cannot be automated.)
2631 %
2632 % The following setting gives the \LaTeX\ default.
2633 % \begin{macrocode}
2634 \def\sec@upcase#1{\relax{#1}}%
2635 % \end{macrocode}
2636 % \end{macro}
2637 %
2638 %
2639 % \subsection{Patch the \env{tabular} and \env{array} Environments}
2640 %
2641 % \begin{macro}{\endtabular}
2642 % \begin{macro}{\endarray}
2643 % \changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.}
2644 % We headpatch the begin processing and tailpatch the end processing
2645 % of the \env{tabular} and \env{array} environments.
2646 % A document class can define these hooks as needed.
2647 %
2648 % We proceed with care to make further patches to
2649 % support tabulars that break over pages.
2650 % Our patches will not necessarily be effective for
2651 % other packages that replace the \LaTeX\ \env{array} and \env{tabular}
2652 % environments. I know of none that do so.
2653 % \begin{macrocode}
2654 \appdef\document@inithook{%
2655 \@ifpackageloaded{array}{\switch@array}{\switch@tabular}%
2656 \prepdef\endtabular{\endtabular@hook}%
2657 \@provide\endtabular@hook{}%
2658 \prepdef\endarray{\endarray@hook}%
2659 \@provide\endarray@hook{}%
2660 \providecommand\array@hook{}%
2661 % \end{macrocode}
2662 % Install, effectively, a head patch to \cmd\tabular.
2663 % In order to avoid interference from, e.g., the \classname{array} package,
2664 % we must perform this patch only \emph{after} packages load.
2665 % \changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package}
2666 % \begin{macrocode}
2667 \prepdef\@tabular{\tabular@hook}%
2668 \@provide\tabular@hook{}%
2669 }%
2670 % \end{macrocode}
2671 % \end{macro}
2672 % \end{macro}
2673 %
2674 % \begin{macro}{\switch@tabular}
2675 % \begin{macro}{\switch@array}
2676 % The two procedures \cmd\switch@tabular\ and \cmd\switch@array\
2677 % apply needed patches to the various tabular procedures,
2678 % the former applying to the \LaTeX\ kernel, the latter to the
2679 % required \classname{array} package (and to the number of other
2680 % required packages that load it).
2681 %
2682 % \begin{macrocode}
2683 \def\switch@tabular{%
2684 \let\@array@sw\@array@sw@array
2685 \@ifx{\@array\@array@LaTeX}{%
2686 \@ifx{\multicolumn\multicolumn@LaTeX}{%
2687 \@ifx{\@tabular\@tabular@LaTeX}{%
2688 \@ifx{\@tabarray\@tabarray@LaTeX}{%
2689 \@ifx{\array\array@LaTeX}{%
2690 \@ifx{\endarray\endarray@LaTeX}{%
2691 \@ifx{\endtabular\endtabular@LaTeX}{%
2692 \@ifx{\@mkpream\@mkpream@LaTeX}{%
2693 \@ifx{\@addamp\@addamp@LaTeX}{%
2694 \@ifx{\@arrayacol\@arrayacol@LaTeX}{%
2695 \@ifx{\@tabacol\@tabacol@LaTeX}{%
2696 \@ifx{\@arrayclassz\@arrayclassz@LaTeX}{%
2697 \@ifx{\@tabclassiv\@tabclassiv@LaTeX}{%
2698 \@ifx{\@arrayclassiv\@arrayclassiv@LaTeX}{%
2699 \@ifx{\@tabclassz\@tabclassz@LaTeX}{%
2700 \@ifx{\@classv\@classv@LaTeX}{%
2701 \@ifx{\hline\hline@LaTeX}{%
2702 \@ifx{\@tabularcr\@tabularcr@LaTeX}{%
2703 \@ifx{\@xtabularcr\@xtabularcr@LaTeX}{%
2704 \@ifx{\@xargarraycr\@xargarraycr@LaTeX}{%
2705 \@ifx{\@yargarraycr\@yargarraycr@LaTeX}{%
2706 \true@sw
2707 }{%
2708 \false@sw
2709 }%
2710 }{%
2711 \false@sw
2712 }%
2713 }{%
2714 \false@sw
2715 }%
2716 }{%
2717 \false@sw
2718 }%
2719 }{%
2720 \false@sw
2721 }%
2722 }{%
2723 \false@sw
2724 }%
2725 }{%
2726 \false@sw
2727 }%
2728 }{%
2729 \false@sw
2730 }%
2731 }{%
2732 \false@sw
2733 }%
2734 }{%
2735 \false@sw
2736 }%
2737 }{%
2738 \false@sw
2739 }%
2740 }{%
2741 \false@sw
2742 }%
2743 }{%
2744 \false@sw
2745 }%
2746 }{%
2747 \false@sw
2748 }%
2749 }{%
2750 \false@sw
2751 }%
2752 }{%
2753 \false@sw
2754 }%
2755 }{%
2756 \false@sw
2757 }%
2758 }{%
2759 \false@sw
2760 }%
2761 }{%
2762 \false@sw
2763 }%
2764 }{%
2765 \false@sw
2766 }%
2767 }{%
2768 \false@sw
2769 }%
2770 {%
2771 \class@info{Patching LaTeX tabular.}%
2772 }{%
2773 \class@info{Unrecognized LaTeX tabular. Please update this document class! (Proceeding with fingers crossed.)}%
2774 }%
2775 \let\@array\@array@ltx
2776 \let\multicolumn\multicolumn@ltx
2777 \let\@tabular\@tabular@ltx
2778 \let\@tabarray\@tabarray@ltx
2779 \let\array\array@ltx
2780 \let\endarray\endarray@ltx
2781 \let\endtabular\endtabular@ltx
2782 \let\@mkpream\@mkpream@ltx
2783 \let\@addamp\@addamp@ltx
2784 \let\@arrayacol\@arrayacol@ltx
2785 \let\@tabacol\@tabacol@ltx
2786 \let\@arrayclassz\@arrayclassz@ltx
2787 \let\@tabclassiv\@tabclassiv@ltx
2788 \let\@arrayclassiv\@arrayclassiv@ltx
2789 \let\@tabclassz\@tabclassz@ltx
2790 \let\@classv\@classv@ltx
2791 \let\hline\hline@ltx
2792 \let\@tabularcr\@tabularcr@ltx
2793 \let\@xtabularcr\@xtabularcr@ltx
2794 \let\@xargarraycr\@xargarraycr@ltx
2795 \let\@yargarraycr\@yargarraycr@ltx
2796 }%
2797 % \end{macrocode}
2798 % \changes{4.1b}{2008/08/12}{(AO, 505) Try to accommodate \classname{colortbl}.}
2799 % \begin{macrocode}
2800 \def\switch@array{%
2801 \@ifpackageloaded{colortbl}{\let\switch@array@info\colortbl@message}{\let\switch@array@info\array@message}%
2802 \let\@array@sw\@array@sw@LaTeX
2803 \@ifx{\@array\@array@array}{%
2804 \@ifx{\@tabular\@tabular@array}{%
2805 \@ifx{\@tabarray\@tabarray@array}{%
2806 \@ifx{\array\array@array}{%
2807 \@ifx{\endarray\endarray@array}{%
2808 \@ifx{\endtabular\endtabular@array}{%
2809 \@ifx{\@mkpream\@mkpream@array}{%
2810 \@ifx{\@classx\@classx@array}{%
2811 \@ifx{\insert@column\insert@column@array}{%
2812 \@ifx{\@arraycr\@arraycr@array}{%
2813 \@ifx{\@xarraycr\@xarraycr@array}{%
2814 \@ifx{\@xargarraycr\@xargarraycr@array}{%
2815 \@ifx{\@yargarraycr\@yargarraycr@array}{%
2816 \true@sw
2817 }{%
2818 \false@sw
2819 }%
2820 }{%
2821 \false@sw
2822 }%
2823 }{%
2824 \false@sw
2825 }%
2826 }{%
2827 \false@sw
2828 }%
2829 }{%
2830 \false@sw
2831 }%
2832 }{%
2833 \false@sw
2834 }%
2835 }{%
2836 \false@sw
2837 }%
2838 }{%
2839 \false@sw
2840 }%
2841 }{%
2842 \false@sw
2843 }%
2844 }{%
2845 \false@sw
2846 }%
2847 }{%
2848 \false@sw
2849 }%
2850 }{%
2851 \false@sw
2852 }%
2853 }{%
2854 \false@sw
2855 }{%
2856 \class@info{Patching array package.}%
2857 }{%
2858 \switch@array@info
2859 }%
2860 \let\@array \@array@array@new
2861 \let\@@array \@array % Cosi fan tutti
2862 \let\@tabular \@tabular@array@new
2863 \let\@tabarray \@tabarray@array@new
2864 \let\array \array@array@new
2865 \let\endarray \endarray@array@new
2866 \let\endtabular\endtabular@array@new
2867 \let\@mkpream \@mkpream@array@new
2868 \let\@classx \@classx@array@new
2869 \let\@arrayacol\@arrayacol@ltx
2870 \let\@tabacol \@tabacol@ltx
2871 \let\insert@column\insert@column@array@new
2872 \expandafter\let\csname endtabular*\endcsname\endtabular % Cosi fan tutti
2873 \let\@arraycr \@arraycr@new
2874 \let\@xarraycr \@xarraycr@new
2875 \let\@xargarraycr\@xargarraycr@new
2876 \let\@yargarraycr\@yargarraycr@new
2877 }%
2878 \def\array@message{%
2879 \class@info{Unrecognized array package. Please update this document class! (Proceeding with fingers crossed.)}%
2880 }%
2881 \def\colortbl@message{%
2882 \class@info{colortbl package is loaded. (Proceeding with fingers crossed.)}%
2883 }%
2884 % \end{macrocode}
2885 % \end{macro}
2886 % \end{macro}
2887 %
2888 % \begin{macro}{\@array@sw}
2889 % The Boolean \cmd\@array@sw\ must be different depending on
2890 % whether the \classname{array} package is loaded.
2891 % \begin{macrocode}
2892 \def\@array@sw@LaTeX{\@ifx{\\\@tabularcr}}%
2893 \def\@array@sw@array{\@ifx{\d@llarbegin\begingroup}}%
2894 % \end{macrocode}
2895 % \end{macro}
2896 %
2897 % \begin{macro}{\@tabular}
2898 % \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
2899 % We provide the old versions of \cmd\@tabular\ along with the respective new versions.
2900 % The change here is to avoid committing to LR mode. That will be done later (as late as possible, naturally).
2901 %
2902 % Compatibility note: I had done \cmd\let\ \cmd\col@sep\ \cmd\@undefined\ here, but
2903 % this was not compatible with \classname{colortbl}. I have removed that statement.
2904 % \begin{macrocode}
2905 \def\@tabular@LaTeX{%
2906 \leavevmode
2907 \hbox\bgroup$%
2908 \let\@acol\@tabacol
2909 \let\@classz\@tabclassz
2910 \let\@classiv\@tabclassiv
2911 \let\\\@tabularcr
2912 \@tabarray
2913 }%
2914 \def\@tabular@ltx{%
2915 \let\@acoll\@tabacoll
2916 \let\@acolr\@tabacolr
2917 \let\@acol\@tabacol
2918 \let\@classz\@tabclassz
2919 \let\@classiv\@tabclassiv
2920 \let\\\@tabularcr
2921 \@tabarray
2922 }%
2923 \def\@tabular@array{%
2924 \leavevmode
2925 \hbox\bgroup$%
2926 \col@sep\tabcolsep
2927 \let\d@llarbegin\begingroup
2928 \let\d@llarend\endgroup
2929 \@tabarray
2930 }%
2931 \def\@tabular@array@new{%
2932 \let\@acoll\@tabacoll
2933 \let\@acolr\@tabacolr
2934 \let\@acol\@tabacol
2935 % \end{macrocode}
2936 % \let\col@sep\@undefined
2937 % \begin{macrocode}
2938 \let\d@llarbegin\begingroup
2939 \let\d@llarend\endgroup
2940 \@tabarray
2941 }%
2942 % \end{macrocode}
2943 % \end{macro}
2944 %
2945 % \begin{macro}{\@tabarray}
2946 % Here we provide old and new versions of the \cmd\@tabarray\ procedure.
2947 % The change here is to parametrize the default vertical alignment,
2948 % which is 'c' in standard \LaTeX.
2949 % Under some circumstances, we want to change this to, say, 'v'.
2950 %
2951 % \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
2952 % FIXME: must decouple \env{array} and \env{tabular}. Done (it seems).
2953 %
2954 % Note on \classname{colortbl}: this package head-patches \cmd\@tabarray
2955 % with its own command \cmd\CT@start, and tails onto \cmd\endarray\ with \cmd\CT@end.
2956 % It fortuitously does the former at \cmd\AtBeginDocument\ time, and, fortuitously,
2957 % we do not patch \cmd\endarray, which it overwrites.
2958 % \begin{macrocode}
2959 \def\@tabarray@LaTeX{%
2960 \m@th\@ifnextchar[\@array{\@array[c]}%
2961 }%
2962 \def\@tabarray@ltx{%
2963 \m@th\@ifnextchar[\@array{\expandafter\@array\expandafter[\array@default]}%
2964 }%
2965 \def\@tabarray@array{%
2966 \@ifnextchar[{\@@array}{\@@array[c]}%
2967 }%
2968 \def\@tabarray@array@new{%
2969 \@ifnextchar[{\@@array}{\expandafter\@@array\expandafter[\array@default]}%
2970 }%
2971 % \end{macrocode}
2972 % \end{macro}
2973 %
2974 % \begin{macro}{\@tabularcr}
2975 % \begin{macro}{\@tbpen}
2976 % \begin{macro}{\@tabularcr}
2977 % \begin{macro}{\@xtabularcr}
2978 % \begin{macro}{\@xargarraycr}
2979 % \begin{macro}{\@yargarraycr}
2980 % \begin{macro}{\@arraycr}
2981 % \begin{macro}{\@xarraycr}
2982 % We provide for the \cmd\\ command within \env{tabular} to provide control over page breaking, just the same as
2983 % that of \env{eqnarray}.
2984 %
2985 % The count register \cmd\intertabularlinepenalty\ is similar to \cmd\interdisplaylinepenalty: it is the penalty
2986 % associated with each row of a tabular. When it is set to \cmd\@M, the tabular will cleave together.
2987 %
2988 % The count register \cmd\@tbpen\ is similar to \cmd\@eqpen: it memorizes the penalty to use after the current tabular row.
2989 % If the \cmd\\ command is in its star form, then \cmd\@eqpen\ is set to \cmd\@M.
2990 %
2991 % We append code to \cmd\samepage\ so that a tabular within its scope will cleave together.
2992 %
2993 % We keep the standard definition of \cmd\@tabularcr\ in \cmd\@tabularcr@LaTeX\ for reference,
2994 % and provide a new definition that works like \cmd\@eqncr: it sets \cmd\@tbpen\ to \cmd\@M\ if the star was given.
2995 %
2996 % We also provide new versions of \cmd\@xtabularcr, \cmd\@xargarraycr, and \cmd\@yargarraycr, all of which invoke \cmd\@tbpen.
2997 %
2998 % The \cmd\switch@tabular\ procedure switches in the new definitions.
2999 % \begin{macrocode}
3000 \newcount\intertabularlinepenalty
3001 \intertabularlinepenalty=100
3002 \newcount\@tbpen
3003 \appdef\samepage{\intertabularlinepenalty\@M}%
3004 \def\@tabularcr@LaTeX{{\ifnum 0=`}\fi \@ifstar \@xtabularcr \@xtabularcr}%
3005 \def\@tabularcr@ltx{{\ifnum 0=`}\fi \@ifstar {\global \@tbpen \@M \@xtabularcr }{\global \@tbpen \intertabularlinepenalty \@xtabularcr }}%
3006 \def\@xtabularcr@LaTeX{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr }}%
3007 \def\@xtabularcr@ltx{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr \noalign {\penalty \@tbpen }}}%
3008 \def\@xargarraycr@LaTeX#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr}%
3009 \def\@xargarraycr@ltx#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr \noalign {\penalty \@tbpen }}%
3010 \def\@yargarraycr@LaTeX#1{\cr \noalign {\vskip #1}}%
3011 \def\@yargarraycr@ltx#1{\cr \noalign {\penalty \@tbpen \vskip #1}}%
3012 % \end{macrocode}
3013 %
3014 % If the \classname{array} package has been loaded, we must alter the meanings of
3015 % \cmd\@arraycr, \cmd\@xarraycr, \cmd\@xargarraycr, and \cmd\@yargarraycr.
3016 % In this case, it is \cmd\switch@array\ that switches in the new definitions.
3017 % \begin{macrocode}
3018 \def\@arraycr@array{%
3019 \relax
3020 \iffalse{\fi\ifnum 0=`}\fi
3021 \@ifstar \@xarraycr \@xarraycr
3022 }%
3023 \def\@arraycr@new{%
3024 \relax
3025 \iffalse{\fi\ifnum 0=`}\fi
3026 \@ifstar {\global \@tbpen \@M \@xarraycr }{\global \@tbpen \intertabularlinepenalty \@xarraycr }%
3027 }%
3028 \def\@xarraycr@array{%
3029 \@ifnextchar [%]
3030 \@argarraycr {\ifnum 0=`{}\fi\cr}%
3031 }%
3032 \def\@xarraycr@new{%
3033 \@ifnextchar [%]
3034 \@argarraycr {\ifnum 0=`{}\fi\cr \noalign {\penalty \@tbpen }}%
3035 }%
3036 \def\@xargarraycr@array#1{%
3037 \unskip
3038 \@tempdima #1\advance\@tempdima \dp\@arstrutbox
3039 \vrule \@depth\@tempdima \@width\z@
3040 \cr
3041 }%
3042 \def\@xargarraycr@new#1{%
3043 \unskip
3044 \@tempdima #1\advance\@tempdima \dp\@arstrutbox
3045 \vrule \@depth\@tempdima \@width\z@
3046 \cr
3047 \noalign {\penalty \@tbpen }%
3048 }%
3049 \def\@yargarraycr@array#1{%
3050 \cr
3051 \noalign{\vskip #1}%
3052 }%
3053 \def\@yargarraycr@new#1{%
3054 \cr
3055 \noalign{\penalty \@tbpen \vskip #1}%
3056 }%
3057 % \end{macrocode}
3058 % \end{macro}
3059 % \end{macro}
3060 % \end{macro}
3061 % \end{macro}
3062 % \end{macro}
3063 % \end{macro}
3064 % \end{macro}
3065 % \end{macro}
3066 %
3067 % \begin{macro}{\array}
3068 % We provide old and new versions of the \cmd\array\ procedure for both \LaTeX\ and the \classname{array} package.
3069 % The change here is to accomodate the new procedures that will be called for the array boundaries, even
3070 % though at present they are not special.
3071 % A thought: here is where matrices can be readily accomodated.
3072 % \begin{macrocode}
3073 \def\array@LaTeX{%
3074 \let\@acol\@arrayacol
3075 \let\@classz\@arrayclassz
3076 \let\@classiv\@arrayclassiv
3077 \let\\\@arraycr
3078 \let\@halignto\@empty
3079 \@tabarray
3080 }%
3081 \def\array@ltx{%
3082 \@ifmmode{}{\@badmath$}%
3083 \let\@acoll\@arrayacol
3084 \let\@acolr\@arrayacol
3085 \let\@acol\@arrayacol
3086 \let\@classz\@arrayclassz
3087 \let\@classiv\@arrayclassiv
3088 \let\\\@arraycr
3089 \let\@halignto\@empty
3090 \@tabarray
3091 }%
3092 \def\array@array{%
3093 \col@sep\arraycolsep
3094 \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\gdef\@halignto{}%
3095 \@tabarray
3096 }
3097 \def\array@array@new{%
3098 \@ifmmode{}{\@badmath$}%
3099 \let\@acoll\@arrayacol
3100 \let\@acolr\@arrayacol
3101 \let\@acol\@arrayacol
3102 % \end{macrocode}
3103 % \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
3104 % Removed: \verb+\let\col@sep\@undefined+
3105 % \begin{macrocode}
3106 \def\d@llarbegin{$}%
3107 \let\d@llarend\d@llarbegin
3108 \gdef\@halignto{}%
3109 \@tabarray
3110 }%
3111 % \end{macrocode}
3112 % \end{macro}
3113 %
3114 % \begin{macro}{\@array}
3115 % Here we provide old and new versions of \cmd\@array.
3116 % The change here is to provide a convenient, flexible, and extensible
3117 % mechanism for new vertical alignment options.
3118 %
3119 % Instead of testing the optional argument with \cmd\if, we
3120 % use a dispatcher based on \cmd\csname.
3121 %
3122 % We also refrain from using \cmd\ialign, which would set
3123 % the \cmd\tabskip\ to the wrong value.
3124 %
3125 % Finally, the procedure to set the \cmd\@arstrutbox\
3126 % is broken out so that it can be patched.
3127 % \begin{macrocode}
3128 \def\@array@LaTeX[#1]#2{%
3129 \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
3130 \bgroup
3131 \setbox\@arstrutbox\hbox{%
3132 \vrule \@height\arraystretch\ht\strutbox
3133 \@depth\arraystretch \dp\strutbox
3134 \@width\z@}%
3135 \@mkpream{#2}%
3136 \edef\@preamble{%
3137 \ialign \noexpand\@halignto
3138 \bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
3139 \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
3140 \let\tabularnewline\\%
3141 \let\par\@empty
3142 \let\@sharp##%
3143 \set@typeset@protect
3144 \lineskip\z@skip\baselineskip\z@skip
3145 \ifhmode \@preamerr\z@ \@@par\fi
3146 \@preamble
3147 }%
3148 \def\@array@ltx[#1]#2{%
3149 \@nameuse{@array@align@#1}%
3150 \set@arstrutbox
3151 \@mkpream{#2}%
3152 \prepdef\@preamble{%
3153 \tabskip\tabmid@skip
3154 \@arstrut
3155 }%
3156 \appdef\@preamble{%
3157 \tabskip\tabright@skip
3158 \cr
3159 \array@row@pre
3160 }%
3161 % \let\@startpbox\@@startpbox
3162 % \let\@endpbox\@@endpbox
3163 \let\tabularnewline\\%
3164 \let\par\@empty
3165 \let\@sharp##%
3166 \set@typeset@protect
3167 \lineskip\z@skip\baselineskip\z@skip
3168 \tabskip\tableft@skip\relax
3169 \ifhmode \@preamerr\z@ \@@par\fi
3170 \everycr{}%
3171 \expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
3172 }%
3173 %
3174 \def\set@arstrutbox{%
3175 \setbox\@arstrutbox\hbox{%
3176 \vrule \@height\arraystretch\ht\strutbox
3177 \@depth\arraystretch \dp\strutbox
3178 \@width\z@
3179 }%
3180 }%
3181 % \end{macrocode}
3182 % \end{macro}
3183 %
3184 % \begin{macro}{\@array@array}
3185 %
3186 % \begin{macrocode}
3187 \def\@array@array[#1]#2{%
3188 \@tempdima \ht \strutbox
3189 \advance \@tempdima by\extrarowheight
3190 \setbox \@arstrutbox \hbox{\vrule
3191 \@height \arraystretch \@tempdima
3192 \@depth \arraystretch \dp \strutbox
3193 \@width \z@}%
3194 \begingroup
3195 \@mkpream{#2}%
3196 \xdef\@preamble{\noexpand \ialign \@halignto
3197 \bgroup \@arstrut \@preamble
3198 \tabskip \z@ \cr}%
3199 \endgroup
3200 \@arrayleft
3201 \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
3202 \bgroup
3203 \let \@sharp ##\let \protect \relax
3204 \lineskip \z@
3205 \baselineskip \z@
3206 \m@th
3207 \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble
3208 }%
3209 \def\@array@array@new[#1]#2{%
3210 \@tempdima\ht\strutbox
3211 \advance\@tempdima by\extrarowheight
3212 \setbox\@arstrutbox\hbox{%
3213 \vrule \@height\arraystretch\@tempdima
3214 \@depth \arraystretch\dp\strutbox
3215 \@width \z@
3216 }%
3217 \begingroup
3218 \@mkpream{#2}%
3219 \xdef\@preamble{\@preamble}%
3220 \endgroup
3221 \prepdef\@preamble{%
3222 \tabskip\tabmid@skip
3223 \@arstrut
3224 }%
3225 \appdef\@preamble{%
3226 \tabskip\tabright@skip
3227 \cr
3228 \array@row@pre
3229 }%
3230 \@arrayleft
3231 \@nameuse{@array@align@#1}%
3232 \m@th
3233 \let\\\@arraycr
3234 \let\tabularnewline\\%
3235 \let\par\@empty
3236 \let\@sharp##%
3237 \set@typeset@protect
3238 \lineskip\z@\baselineskip\z@
3239 \tabskip\tableft@skip
3240 \everycr{}%
3241 \expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
3242 }%
3243 % \end{macrocode}
3244 % \end{macro}
3245 %
3246 % \begin{macro}{\endarray}
3247 % Here we provide old and new versions of \cmd\endarray.
3248 % The change here is to use a single procedure to close
3249 % out any array-like structure, namely \cmd\endarray@ltx.
3250 % It merely closes out the \cmd\halign.
3251 % \begin{macrocode}
3252 \def\endarray@LaTeX{%
3253 \crcr\egroup\egroup
3254 }%
3255 \def\endarray@ltx{%
3256 \crcr\array@row@pst\egroup\egroup
3257 }%
3258 \def\endarray@array{%
3259 \crcr \egroup \egroup \@arrayright \gdef\@preamble{}%
3260 }%
3261 \def\endarray@array@new{%
3262 \crcr\array@row@pst\egroup\egroup % Same as \endarray@ltx
3263 \@arrayright
3264 \global\let\@preamble\@empty
3265 }%
3266 % \end{macrocode}
3267 % \end{macro}
3268 %
3269 % \begin{macro}{\endtabular}
3270 %
3271 % \begin{macrocode}
3272 \def\endtabular@LaTeX{%
3273 \crcr\egroup\egroup $\egroup
3274 }%
3275 \def\endtabular@ltx{%
3276 \endarray
3277 }%
3278 \def\endtabular@array{%
3279 \endarray $\egroup
3280 }%
3281 \def\endtabular@array@new{%
3282 \endarray
3283 }%
3284 % \end{macrocode}
3285 % \end{macro}
3286 %
3287 % \begin{macro}{endtabular*}
3288 % Here we provide a proper definition for the star-form of \enve{endtabular}.
3289 % It is one of the enduring curiosities that the \LaTeX\ kernel continues to use
3290 % dangerously and inappropriately ``optimized'' definitions for such commands.
3291 % \begin{macrocode}
3292 \@namedef{endtabular*}{\endtabular}%
3293 % \end{macrocode}
3294 % \end{macro}
3295 %
3296 % \begin{macro}{\multicolumn}
3297 %
3298 % \begin{macrocode}
3299 \long\def\multicolumn@LaTeX#1#2#3{%
3300 \multispan{#1}\begingroup
3301 \@mkpream{#2}%
3302 \def\@sharp{#3}\set@typeset@protect
3303 \let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
3304 \@arstrut \@preamble\hbox{}\endgroup\ignorespaces
3305 }%
3306 \long\def\multicolumn@ltx#1#2#3{%
3307 \multispan{#1}%
3308 \begingroup
3309 \@mkpream{#2}%
3310 \def\@sharp{#3}%
3311 \set@typeset@protect
3312 %\let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
3313 \@arstrut
3314 \@preamble
3315 \hbox{}%
3316 \endgroup
3317 \ignorespaces
3318 }%
3319 % \end{macrocode}
3320 % \end{macro}
3321 %
3322 % \begin{macro}{\@array@align@}
3323 % \begin{macro}{\array@default}
3324 % Here are the various procedures for the vertical alignment options.
3325 % The change from standard \LaTeX\ is that we do not go into math mode
3326 % in every case: only when required by \cmd\vcenter.
3327 % Also, we use \cmd\aftergroup\ to close out the boxes and modes we have started.
3328 % It requires only that each procedure issue exactly one unmatched \cmd\bgroup.
3329 %
3330 % We establish here the default vertical alignment.
3331 % \begin{macrocode}
3332 \def\@array@align@t{\leavevmode\vtop\bgroup}%
3333 \def\@array@align@b{\leavevmode\vbox\bgroup}%
3334 \def\@array@align@c{\leavevmode\@ifmmode{\vcenter\bgroup}{$\vcenter\bgroup\aftergroup$\aftergroup\relax}}%
3335 \def\@array@align@v{%
3336 \@ifmmode{%
3337 \@badmath
3338 \vcenter\bgroup
3339 }{%
3340 \@ifinner{%
3341 $\vcenter\bgroup\aftergroup$
3342 }{%
3343 \@@par\bgroup
3344 }%
3345 }%
3346 }%
3347 \def\array@default{c}%
3348 % \end{macrocode}
3349 % \end{macro}
3350 % \end{macro}
3351 %
3352 % \begin{macro}{\array@row@pre}
3353 % \begin{macro}{\array@row@pst}
3354 % \begin{macro}{\array@row@rst}
3355 % The procedure \cmd\array@row@rst\ reestablishes a default context for
3356 % an alignment, so that they can be nested.
3357 % Any environment or procedure that alters the way alignments are formatted
3358 % must patch this procedure to restore from that alteration.
3359 % To start things off, we equate \cmd\@array@align@v\ to \cmd\@array@align@c,
3360 % because it does not make sense to do the former in any context other
3361 % than the MVL or in a list that will be unboxed onto the MVL.
3362 % \begin{macrocode}
3363 \def\array@row@rst{%
3364 \let\@array@align@v\@array@align@c
3365 }%
3366 \def\array@row@pre{}%
3367 \def\array@row@pst{}%
3368 % \end{macrocode}
3369 % \end{macro}
3370 % \end{macro}
3371 % \end{macro}
3372 %
3373 % \begin{macro}{\toprule}
3374 % \begin{macro}{\colrule}
3375 % \begin{macro}{\botrule}
3376 % Default definitions for \cmd\toprule, \cmd\colrule, \cmd\botrule
3377 % \begin{macrocode}
3378 \newcommand\toprule{\tab@rule{\column@font}{\column@fil}{\frstrut}}%
3379 \newcommand\colrule{\unskip\lrstrut\\\tab@rule{\body@font}{}{\frstrut}}%
3380 \newcommand\botrule{\unskip\lrstrut\\\noalign{\hline@rule}{}}%
3381 % \end{macrocode}
3382 % \end{macro}
3383 % \end{macro}
3384 % \end{macro}
3385 %
3386 % \begin{macro}{\hline}
3387 % \begin{macrocode}
3388 \def\hline@LaTeX{%
3389 \noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
3390 \reserved@a\@xhline
3391 }%
3392 \def\hline@ltx{%
3393 \noalign{%
3394 \ifnum0=`}\fi
3395 \hline@rule
3396 \futurelet\reserved@a\@xhline
3397 % \noalign ended in \@xhline
3398 }%
3399 \def\@xhline@unneeded{%
3400 \say\reserved@a
3401 \ifx\reserved@a\hline
3402 \vskip\doublerulesep
3403 \vskip-\arrayrulewidth
3404 \fi
3405 \ifnum0=`{\fi}%
3406 }%
3407 \def\tab@rule#1#2#3{%
3408 \crcr
3409 \noalign{%
3410 \hline@rule
3411 \gdef\@arstrut@hook{%
3412 \global\let\@arstrut@hook\@empty
3413 #3%
3414 }%
3415 \gdef\cell@font{#1}%
3416 \gdef\cell@fil{#2}%
3417 }%
3418 }%
3419 \def\column@font{}%
3420 \def\column@fil{}%
3421 \def\body@font{}%
3422 \def\cell@font{}%
3423 \def\frstrut{}%
3424 \def\lrstrut{}%
3425 % \end{macrocode}
3426 % \end{macro}
3427 %
3428 % \begin{macro}{\@arstrut@hline}
3429 % \begin{macro}{\@arstrut@org}
3430 % \begin{macro}{\@arstrut@hook}
3431 % \begin{macro}{\@arstrutbox@hline}
3432 % \begin{macro}{\set@arstrutbox}
3433 % \begin{macro}{\hline@rule}
3434 % The procedure \cmd\@arstrut@hline\ is substantially the same as
3435 % \cmd\@arstrut, except the strut copied in is \cmd\@arstrutbox@hline
3436 % instead of \cmd\@arstrutbox.
3437 %
3438 % The procedure \cmd\@arstrut@hook\ is redefined in \cmd\tab@rule!
3439 %
3440 % The register \cmd\@arstrutbox@hline.
3441 %
3442 % We append to \cmd\set@arstrutbox\ the code necessary to set a strut following an \cmd\hline.
3443 %
3444 % The procedure \cmd\hline@rule\ lays down a rule, and changes the meaning of \cmd\@arstrut\
3445 % so that the next line will be correctly strutted.
3446 %
3447 % The \cmd\@arstrut@hline@clnc\ is a klootch, a magic number.
3448 % \begin{macrocode}
3449 \def\@arstrut@hline{%
3450 \relax
3451 \@ifmmode{\copy}{\unhcopy}\@arstrutbox@hline
3452 \@arstrut@hook
3453 }%
3454 %
3455 \let\@arstrut@org\@arstrut
3456 \def\@arstrut@hook{%
3457 \global\let\@arstrut\@arstrut@org
3458 }%
3459 %
3460 \newbox\@arstrutbox@hline
3461 \appdef\set@arstrutbox{%
3462 \setbox\@arstrutbox@hline\hbox{%
3463 \setbox\z@\hbox{$0^{0}_{}$}%
3464 \dimen@\ht\z@\advance\dimen@\@arstrut@hline@clnc
3465 \@ifdim{\dimen@<\arraystretch\ht\strutbox}{\dimen@=\arraystretch\ht\strutbox}{}%
3466 \vrule \@height\dimen@
3467 \@depth\arraystretch \dp\strutbox
3468 \@width\z@
3469 }%
3470 }%
3471 %
3472 \def\hline@rule{%
3473 \hrule \@height \arrayrulewidth
3474 \global\let\@arstrut\@arstrut@hline
3475 }%
3476 \def\@arstrut@hline@clnc{2\p@}% % Klootch: magic number
3477 % \end{macrocode}
3478 % \end{macro}
3479 % \end{macro}
3480 % \end{macro}
3481 % \end{macro}
3482 % \end{macro}
3483 % \end{macro}
3484 %
3485 % \begin{macro}{\tableft@skip}
3486 % \begin{macrocode}
3487 \def\tableft@skip{\z@skip}%
3488 \def\tabmid@skip{\z@skip}%\@flushglue
3489 \def\tabright@skip{\z@skip}%
3490 \def\tableftsep{\tabcolsep}%
3491 \def\tabmidsep{\tabcolsep}%
3492 \def\tabrightsep{\tabcolsep}%
3493 \def\cell@fil{}%
3494 \def\pbox@hook{}%
3495 % \end{macrocode}
3496 % \end{macro}
3497 %
3498 % \begin{macro}{\@arstrut}
3499 % \begin{macrocode}
3500 \appdef\@arstrut{\@arstrut@hook}%
3501 \let\@arstrut@hook\@empty
3502 \def\@addtopreamble{\appdef\@preamble}%
3503 % \end{macrocode}
3504 % \end{macro}
3505 %
3506 % \begin{macro}{\@mkpream}
3507 % \begin{macrocode}
3508 \def\@mkpream@LaTeX#1{%
3509 \@firstamptrue\@lastchclass6
3510 \let\@preamble\@empty
3511 \let\protect\@unexpandable@protect
3512 \let\@sharp\relax
3513 \let\@startpbox\relax\let\@endpbox\relax
3514 \@expast{#1}%
3515 \expandafter\@tfor \expandafter
3516 \@nextchar \expandafter:\expandafter=\reserved@a\do
3517 {\@testpach\@nextchar
3518 \ifcase \@chclass \@classz \or \@classi \or \@classii \or \@classiii
3519 \or \@classiv \or\@classv \fi\@lastchclass\@chclass}%
3520 \ifcase \@lastchclass \@acol
3521 \or \or \@preamerr \@ne\or \@preamerr \tw@\or \or \@acol \fi
3522 }%
3523 \def\@mkpream@ltx#1{%
3524 \@firstamptrue
3525 \@lastchclass6
3526 \let\@preamble\@empty
3527 \let\protect\@unexpandable@protect
3528 \let\@sharp\relax
3529 %\let\@startpbox\relax\let\@endpbox\relax
3530 \@expast{#1}%
3531 \expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\reserved@a
3532 \do{%
3533 \expandafter\@testpach\expandafter{\@nextchar}%
3534 \ifcase\@chclass
3535 \@classz
3536 \or
3537 \@classi
3538 \or
3539 \@classii
3540 \or
3541 \@classiii
3542 \or
3543 \@classiv
3544 \or
3545 \@classv
3546 \fi
3547 \@lastchclass\@chclass
3548 }%
3549 \ifcase\@lastchclass
3550 \@acolr % right-hand column
3551 \or
3552 \or
3553 \@preamerr\@ne
3554 \or
3555 \@preamerr\tw@
3556 \or
3557 \or
3558 \@acolr % right-hand column
3559 \fi
3560 }%
3561 % \end{macrocode}
3562 % \end{macro}
3563 %
3564 % \begin{macro}{\insert@column}
3565 % \begin{macrocode}
3566 \def\insert@column@array{%
3567 \the@toks \the \@tempcnta
3568 \ignorespaces \@sharp \unskip
3569 \the@toks \the \count@ \relax
3570 }%
3571 \def\insert@column@array@new{%
3572 \the@toks\the\@tempcnta
3573 \array@row@rst\cell@font
3574 \ignorespaces\@sharp\unskip
3575 \the@toks\the\count@
3576 \relax
3577 }%
3578 % \end{macrocode}
3579 % \end{macro}
3580 %
3581 % \begin{macro}{\@mkpream@relax}
3582 % The procedure \cmd\@mkpream@relax\ participates in a strange and wonderful
3583 % method of binding the alignment procedure---but only certain parts thereof.
3584 %
3585 % Here is how it works: in \LaTeX, the \classname{array} package, and in the
3586 % \classname{longtable} package alike, there is a need to create an alignment
3587 % preamble (using \cmd\@mkpream) for use by the upcoming \cmd\halign.
3588 % Then, in both \classname{array} and \classname{longtable}, \TeX's \cmd\edef\
3589 % is used to `compile in place' that alignment preamble.
3590 %
3591 % In the case of \classname{array},
3592 % the operation is done in order to pre-expand the use of \texttt{*};
3593 % in \classname{longtable}, it is to set the widths of the columns.
3594 %
3595 % Now, during this \cmd\edef, certain control sequence names must \emph{not}
3596 % be expanded, and those are robustified by \cmd\@mkpream@relax.
3597 %
3598 % \begin{macrocode}
3599 \def\@mkpream@relax{%
3600 \let\tableftsep \relax
3601 \let\tabmidsep \relax
3602 \let\tabrightsep \relax
3603 \let\array@row@rst\relax
3604 \let\cell@font \relax
3605 \let\@startpbox \relax
3606 }%
3607 % \end{macrocode}
3608 % \end{macro}
3609 %
3610 % \begin{macro}{\@mkpream}
3611 % We insert \cmd\@mkpream@relax\ at the head of the procedure.
3612 % The robustifying of \cmd\@startpbox\ and \cmd\@endpbox\ is taken over by this mechanism.
3613 % We also invoke \cmd\@acolr\ instead of \cmd\@acol\ when a right-hand column is at hand.
3614 %
3615 % \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
3616 % Note on \classname{colortbl}: this package head-patches \cmd\@mkpream\ to robustify
3617 % a number of its commands during the construction of the alignment preamble.
3618 % The best we can do is to supplement the \cmd\@mkpream@relax\ procedure to perform this action.
3619 % \begin{macrocode}
3620 \def\@mkpream@array#1{%
3621 \gdef\@preamble{}\@lastchclass 4 \@firstamptrue
3622 \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
3623 \@temptokena{#1}\@tempswatrue
3624 \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
3625 \count@\m@ne
3626 \let\the@toks\relax
3627 \prepnext@tok
3628 \expandafter \@tfor \expandafter \@nextchar
3629 \expandafter :\expandafter =\the\@temptokena \do
3630 {\@testpach
3631 \ifcase \@chclass \@classz \or \@classi \or \@classii
3632 \or \save@decl \or \or \@classv \or \@classvi
3633 \or \@classvii \or \@classviii
3634 \or \@classx
3635 \or \@classx \fi
3636 \@lastchclass\@chclass}%
3637 \ifcase\@lastchclass
3638 \@acol \or
3639 \or
3640 \@acol \or
3641 \@preamerr \thr@@ \or
3642 \@preamerr \tw@ \@addtopreamble\@sharp \or
3643 \or
3644 \else \@preamerr \@ne \fi
3645 \def\the@toks{\the\toks}%
3646 }%
3647 \def\@mkpream@array@new#1{%
3648 \gdef\@preamble{}%
3649 \@lastchclass\f@ur
3650 \@firstamptrue
3651 \let\@sharp\relax
3652 \@mkpream@relax
3653 %\let\@startpbox\relax\let\@endpbox\relax
3654 \@temptokena{#1}\@tempswatrue
3655 \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
3656 \count@\m@ne
3657 \let\the@toks\relax
3658 \prepnext@tok
3659 \expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\the\@temptokena
3660 \do{%
3661 \@testpach
3662 \ifcase\@chclass
3663 \@classz
3664 \or
3665 \@classi
3666 \or
3667 \@classii
3668 \or
3669 \save@decl
3670 \or
3671 \or
3672 \@classv
3673 \or
3674 \@classvi
3675 \or
3676 \@classvii
3677 \or
3678 \@classviii
3679 \or
3680 \@classx
3681 \or
3682 \@classx
3683 \fi
3684 \@lastchclass\@chclass
3685 }%
3686 \ifcase\@lastchclass
3687 \@acolr % right-hand column
3688 \or
3689 \or
3690 \@acolr % right-hand column
3691 \or
3692 \@preamerr\thr@@
3693 \or
3694 \@preamerr\tw@\@addtopreamble\@sharp
3695 \or
3696 \or
3697 \else
3698 \@preamerr\@ne
3699 \fi
3700 \def\the@toks{\the\toks}%
3701 }%
3702 % \end{macrocode}
3703 % \end{macro}
3704 %
3705 % \begin{macro}{\@mkpream@relax}
3706 % \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
3707 % David P. Carlisle's \classname{colortbl} package headpatches \cmd\@mkpream\ in place
3708 % during package loading, so it does not know whom it is working on.
3709 % Let us try to accomodate this package by doing what it would have liked to have done.
3710 %
3711 % Note: it would be far better to break out this mechanism in the \classname{array} package.
3712 % \begin{macrocode}
3713 \appdef\@mkpream@relax{%
3714 \let\CT@setup \relax
3715 \let\CT@color \relax
3716 \let\CT@do@color \relax
3717 \let\color \relax
3718 \let\CT@column@color\relax
3719 \let\CT@row@color \relax
3720 \let\CT@cell@color \relax
3721 }%
3722 % \end{macrocode}
3723 % \end{macro}
3724 %
3725 % \begin{macro}{\@addamp}
3726 % \begin{macrocode}
3727 \def\@addamp@LaTeX{%
3728 \if@firstamp\@firstampfalse\else\edef\@preamble{\@preamble &}\fi
3729 }%
3730 \def\@addamp@ltx{%
3731 \if@firstamp\@firstampfalse\else\@addtopreamble{&}\fi
3732 }%
3733 % \end{macrocode}
3734 % \end{macro}
3735 %
3736 % \begin{macro}{\@arrayacol}
3737 % \begin{macrocode}
3738 \def\@arrayacol@LaTeX{%
3739 \edef\@preamble{\@preamble \hskip \arraycolsep}%
3740 }%
3741 \def\@arrayacol@ltx{%
3742 \@addtopreamble{\hskip\arraycolsep}%
3743 }%
3744 % \end{macrocode}
3745 % \end{macro}
3746 %
3747 % \begin{macro}{\@tabacol}
3748 % \begin{macrocode}
3749 \def\@tabacoll{%
3750 \@addtopreamble{\hskip\tableftsep\relax}%
3751 }%
3752 \def\@tabacol@LaTeX{%
3753 \edef\@preamble{\@preamble \hskip \tabcolsep}%
3754 }%
3755 \def\@tabacol@ltx{%
3756 \@addtopreamble{\hskip\tabmidsep\relax}%
3757 }%
3758 \def\@tabacolr{%
3759 \@addtopreamble{\hskip\tabrightsep\relax}%
3760 }%
3761 % \end{macrocode}
3762 % \end{macro}
3763 %
3764 % \begin{macro}{\@arrayclassz}
3765 % \begin{macrocode}
3766 \def\@arrayclassz@LaTeX{%
3767 \ifcase \@lastchclass \@acolampacol \or \@ampacol \or
3768 \or \or \@addamp \or
3769 \@acolampacol \or \@firstampfalse \@acol \fi
3770 \edef\@preamble{\@preamble
3771 \ifcase \@chnum
3772 \hfil$\relax\@sharp$\hfil \or $\relax\@sharp$\hfil
3773 \or \hfil$\relax\@sharp$\fi}%
3774 }%
3775 \def\@arrayclassz@ltx{%
3776 \ifcase\@lastchclass
3777 \@acolampacol
3778 \or
3779 \@ampacol
3780 \or
3781 \or
3782 \or
3783 \@addamp
3784 \or
3785 \@acolampacol
3786 \or
3787 \@firstampfalse\@acoll
3788 \fi
3789 \ifcase\@chnum
3790 \@addtopreamble{%
3791 \hfil\array@row@rst$\relax\@sharp$\hfil
3792 }%
3793 \or
3794 \@addtopreamble{%
3795 \array@row@rst$\relax\@sharp$\hfil
3796 }%
3797 \or
3798 \@addtopreamble{%
3799 \hfil\array@row@rst$\relax\@sharp$%
3800 }%
3801 \fi
3802 }%
3803 % \end{macrocode}
3804 % \end{macro}
3805 %
3806 % \begin{macro}{\@tabclassz}
3807 % \begin{macrocode}
3808 \def\@tabclassz@LaTeX{%
3809 \ifcase\@lastchclass
3810 \@acolampacol
3811 \or
3812 \@ampacol
3813 \or
3814 \or
3815 \or
3816 \@addamp
3817 \or
3818 \@acolampacol
3819 \or
3820 \@firstampfalse\@acol
3821 \fi
3822 \edef\@preamble{%
3823 \@preamble{%
3824 \ifcase\@chnum
3825 \hfil\ignorespaces\@sharp\unskip\hfil
3826 \or
3827 \hskip1sp\ignorespaces\@sharp\unskip\hfil
3828 \or
3829 \hfil\hskip1sp\ignorespaces\@sharp\unskip
3830 \fi}}%
3831 }%
3832 \def\@tabclassz@ltx{%
3833 \ifcase\@lastchclass
3834 \@acolampacol
3835 \or
3836 \@ampacol
3837 \or
3838 \or
3839 \or
3840 \@addamp
3841 \or
3842 \@acolampacol
3843 \or
3844 \@firstampfalse\@acoll
3845 \fi
3846 \ifcase\@chnum
3847 \@addtopreamble{%
3848 {\hfil\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
3849 }%
3850 \or
3851 \@addtopreamble{%
3852 {\cell@fil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
3853 }%
3854 \or
3855 \@addtopreamble{%
3856 {\hfil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\cell@fil}%
3857 }%
3858 \fi
3859 }%
3860 % \end{macrocode}
3861 % \end{macro}
3862 %
3863 % \begin{macro}{\@tabclassiv}
3864 % \begin{macrocode}
3865 \def\@tabclassiv@LaTeX{%
3866 \@addtopreamble\@nextchar
3867 }%
3868 \def\@tabclassiv@ltx{%
3869 \expandafter\@addtopreamble\expandafter{\@nextchar}%
3870 }%
3871 % \end{macrocode}
3872 % \end{macro}
3873 %
3874 % \begin{macro}{\@arrayclassiv}
3875 % \begin{macrocode}
3876 \def\@arrayclassiv@LaTeX{%
3877 \@addtopreamble{$\@nextchar$}%
3878 }%
3879 \def\@arrayclassiv@ltx{%
3880 \expandafter\@addtopreamble\expandafter{\expandafter$\@nextchar$}%
3881 }%
3882 % \end{macrocode}
3883 % \end{macro}
3884 %
3885 % \begin{macro}{\@classv}
3886 % \begin{macrocode}
3887 \def\@classv@LaTeX{%
3888 \@addtopreamble{\@startpbox{\@nextchar}\ignorespaces
3889 \@sharp\@endpbox}%
3890 }%
3891 \def\@classv@ltx{%
3892 \expandafter\@addtopreamble
3893 \expandafter{%
3894 \expandafter \@startpbox
3895 \expandafter {\@nextchar}%
3896 \pbox@hook\array@row@rst\cell@font\ignorespaces\@sharp\@endpbox
3897 }%
3898 }%
3899 % \end{macrocode}
3900 % \end{macro}
3901 %
3902 % \begin{macro}{\@classx}
3903 % \begin{macrocode}
3904 \def\@classx@array{%
3905 \ifcase \@lastchclass
3906 \@acolampacol \or
3907 \@addamp \@acol \or
3908 \@acolampacol \or
3909 \or
3910 \@acol \@firstampfalse \or
3911 \@addamp
3912 \fi
3913 }%
3914 \def\@classx@array@new{%
3915 \ifcase \@lastchclass
3916 \@acolampacol
3917 \or
3918 \@addamp \@acol
3919 \or
3920 \@acolampacol
3921 \or
3922 \or
3923 \@firstampfalse\@acoll
3924 \or
3925 \@addamp
3926 \fi
3927 }%
3928 % \end{macrocode}
3929 % \end{macro}
3930 %
3931 %
3932 % \subsection{Repair other broken parts of \LaTeX}
3933 %
3934 % \begin{macro}{\@xbitor}
3935 % Expansion part has extraneous space token. Removed.
3936 % \begin{macrocode}
3937 \def\@xbitor@LaTeX #1{\@tempcntb \count#1
3938 \ifnum \@tempcnta =\z@
3939 \else
3940 \divide\@tempcntb\@tempcnta
3941 \ifodd\@tempcntb \@testtrue\fi
3942 \fi}%
3943 \def\@xbitor@ltx#1{%
3944 \@tempcntb\count#1\relax
3945 \@ifnum{\@tempcnta=\z@}{}{%
3946 \divide\@tempcntb\@tempcnta
3947 \@ifodd\@tempcntb{\@testtrue}{}%
3948 }%
3949 }%
3950 \@ifx{\@xbitor\@xbitor@LaTeX}{%
3951 \class@info{Repairing broken LaTeX \string\@xbitor}%
3952 }{%
3953 \class@info{Unrecognized LaTeX \string\@xbitor. Please update this document class! (Proceeding with fingers crossed.)}%
3954 }%
3955 \let\@xbitor\@xbitor@ltx
3956 % \end{macrocode}
3957 % \end{macro}
3958 %
3959 %
3960 % \subsection{Syntax}
3961 % \begin{macro}{\@gobble@opt@one}
3962 % The \cmd\@gobble@opt@one\ command eats up an optional argument
3963 % and one required argument.
3964 % \begin{macrocode}
3965 \newcommand*\@gobble@opt@one[2][]{}%
3966 % \end{macrocode}
3967 % \end{macro}
3968 %
3969 % \subsection{Auto-indented Contents}
3970 % Facility to automatically determine the proper indentation of
3971 % the TOC entries.
3972 %
3973 % Note on \classname{hyperref} compatibility:
3974 % We must respect that
3975 % \cmd\contentsline\ now has a fourth argument.
3976 % So, instead of trying to override the meaning of \cmd\contentsline,
3977 % we use the aux file to remember max values from one run to the next.
3978 %
3979 % In this respect, this package retains compatibility with
3980 % \classname{hyperref}.
3981 %
3982 % \begin{macro}{\@starttoc}
3983 % Install hooks at beginning and end of the TOC processing.
3984 % \begin{macrocode}
3985 \def\@starttoc#1{%
3986 \begingroup
3987 \toc@pre
3988 \makeatletter
3989 \@input{\jobname.#1}%
3990 \if@filesw
3991 \expandafter\newwrite\csname tf@#1\endcsname
3992 \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
3993 \fi
3994 \@nobreakfalse
3995 \toc@post
3996 \endgroup
3997 }%
3998 \def\toc@pre{}%
3999 \def\toc@post{}%
4000 % \end{macrocode}
4001 % \end{macro}
4002 %
4003 % \begin{macro}{\toc@@font}
4004 % Interface for setting the formatting characteristics of this part
4005 % of the TOC.
4006 %
4007 % Note: \cmd\toc@@font\ is the common font for all auto-sizing toc commands,
4008 % although this, too, could become a dispatcher.
4009 % \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.)}%
4010 % \begin{macrocode}
4011 \def\toc@@font{}%
4012 \def\ltxu@dotsep{\z@}%
4013 % \end{macrocode}
4014 % \end{macro}
4015 %
4016 % \begin{macro}{\l@section}
4017 % Interface for determining which TOC elements are automatically indented.
4018 %
4019 % All of the \cmd\l@\dots\ commands simply go through the
4020 % utility procedure \cmd\l@@sections. The calling convention is
4021 % to pass the name of self and the name of parent.
4022 % If you want to exclude any of these from the indentation
4023 % scheme, simply leave the \cmd\l@\dots\ command undefined.
4024 %
4025 % Note that the parent of ``section'' is nil, so we have to define a stub.
4026 % \begin{verbatim}\def\l@section{\l@@sections{}{section}}% Implicit #3#4\end{verbatim}
4027 % \begin{verbatim}\def\tocleft@{\z@}%\end{verbatim}
4028 % \begin{verbatim}\def\l@subsection{\l@@sections{section}{subsection}}% Implicit #3#4\end{verbatim}
4029 % \begin{verbatim}\def\l@subsubsection{\l@@sections{subsection}{subsubsection}}% Implicit #3#4\end{verbatim}
4030 % \begin{verbatim}\def\l@paragraph{\l@@sections{subsubsection}{paragraph}}% Implicit #3#4\end{verbatim}
4031 % \begin{verbatim}\def\l@subparagraph#1#2{\l@@sections{paragraph}{subparagraph}}% Implicit #3#4\end{verbatim}
4032 % \end{macro}
4033 %
4034 % Glom some \cmd\dimen\ registers.
4035 % \begin{macrocode}
4036 \let\tocdim@section \leftmargini
4037 \let\tocdim@subsection \leftmarginii
4038 \let\tocdim@subsubsection \leftmarginiii
4039 \let\tocdim@paragraph \leftmarginiv
4040 \let\tocdim@appendix \leftmarginv
4041 \let\tocdim@pagenum \leftmarginvi
4042 % \end{macrocode}
4043 %
4044 % \begin{macro}{\toc@pre@auto}
4045 % \begin{macro}{\toc@post@auto}
4046 % We patch \cmd\@starttoc\ to:
4047 % 1) before TOC processing,
4048 % initialize the max registers and
4049 % set the needed dimensions from
4050 % the values stored in the auxiliary file, and
4051 % 2) after TOC processing,
4052 % store out those max register values into the auxiliary file.
4053 %
4054 % Note that the font is set here: all other TOC entries must
4055 % override these font settings.
4056 %
4057 % To activate this override of the standard \LaTeX\ processing,
4058 % the substyle does: \cmd\let\cmd\toc@pre\cmd\toc@pre@auto\
4059 % and \cmd\let\cmd\toc@post\cmd\toc@post@auto.
4060 % \begin{macrocode}
4061 \def\toc@pre@auto{%
4062 \toc@@font
4063 \@tempdima\z@
4064 \toc@setindent\@tempdima{section}%
4065 \toc@setindent\@tempdima{subsection}%
4066 \toc@setindent\@tempdima{subsubsection}%
4067 \toc@setindent\@tempdima{paragraph}%
4068 \toc@letdimen{appendix}%
4069 \toc@letdimen{pagenum}%
4070 }%
4071 \def\toc@post@auto{%
4072 \if@filesw
4073 \begingroup
4074 \toc@writedimen{section}%
4075 \toc@writedimen{subsection}%
4076 \toc@writedimen{subsubsection}%
4077 \toc@writedimen{paragraph}%
4078 \toc@writedimen{appendix}%
4079 \toc@writedimen{pagenum}%
4080 \endgroup
4081 \fi
4082 }%
4083 % \end{macrocode}
4084 % \end{macro}
4085 % \end{macro}
4086 %
4087 % \begin{macro}{\toc@setindent}
4088 % \begin{macrocode}
4089 \def\toc@setindent#1#2{%
4090 \csname tocdim@#2\endcsname\tocdim@min\relax
4091 \@ifundefined{tocmax@#2}{\@namedef{tocmax@#2}{\z@}}{}%
4092 \advance#1\@nameuse{tocmax@#2}\relax
4093 \expandafter\edef\csname tocleft@#2\endcsname{\the#1}%
4094 }%
4095 % \end{macrocode}
4096 % \end{macro}
4097 %
4098 % \begin{macro}{\toc@letdimen}
4099 % \begin{macrocode}
4100 \def\toc@letdimen#1{%
4101 \csname tocdim@#1\endcsname\tocdim@min\relax
4102 \@ifundefined{tocmax@#1}{\@namedef{tocmax@#1}{\z@}}{}%
4103 \expandafter\let\csname tocleft@#1\expandafter\endcsname\csname tocmax@#1\endcsname
4104 }%
4105 % \end{macrocode}
4106 % \end{macro}
4107 %
4108 % \begin{macro}{\toc@writedimen}
4109 % \begin{macrocode}
4110 \def\toc@writedimen#1{%
4111 \immediate\write\@auxout{%
4112 \gdef\expandafter\string\csname tocmax@#1\endcsname{%
4113 \expandafter\the\csname tocdim@#1\endcsname
4114 }%
4115 }%
4116 }%
4117 % \end{macrocode}
4118 % \end{macro}
4119 %
4120 % \begin{macro}{\l@@sections}
4121 % The procedure for formatting the indented TOC entries.
4122 % We use control sequence names such as \cmd\tocmax@section\ and
4123 % \cmd\tocleft@section, the former being written to the auxiliary file
4124 % and the latter only defined for the duration of the TOC processing.
4125 %
4126 % Note that the assignment of \cmd\box\cmd\@tempboxa\ by \cmd\set@tocdim@pagenum\
4127 % must endure over the invocation of |#3|: it contains the
4128 % page number which will be set just before the \cmd\par.
4129 %
4130 % The arguments:\begin{enumerate}
4131 % \item[\#1] superior section
4132 % \item[\#2] this section
4133 % \item[\#3] content, including possible \cmd\numberline
4134 % \item[\#4] page number\end{enumerate}
4135 % \begin{macrocode}
4136 \def\l@@sections#1#2#3#4{%
4137 \begingroup
4138 \everypar{}%
4139 \set@tocdim@pagenum\@tempboxa{#4}%
4140 \global\@tempdima\csname tocdim@#2\endcsname
4141 \leftskip\csname tocleft@#2\endcsname\relax
4142 \dimen@\csname tocleft@#1\endcsname\relax
4143 \parindent-\leftskip\advance\parindent\dimen@
4144 \rightskip\tocleft@pagenum plus 1fil\relax
4145 \skip@\parfillskip\parfillskip\z@
4146 \let\numberline\numberline@@sections
4147 \@nameuse{l@f@#2}%
4148 \ignorespaces#3\unskip\nobreak\hskip\skip@
4149 \hb@xt@\rightskip{\hfil\unhbox\@tempboxa}\hskip-\rightskip\hskip\z@skip
4150 % \end{macrocode}
4151 % \changes{4.1n}{2009/12/13}{(AO, 574) protect against \classname{lineno.sty}, which forces a visit to the output routine, which appears to destroy the value of \cs{@tempdima}}%
4152 %
4153 % By side effect, set the value of, e.g., \cmd\tocdim@section.
4154 %
4155 % Note that the \cmd\par\ must not be executed before the value of \cmd\@tempdima\ is expanded (outside the current group).
4156 % Otherwise, the \classname{lineno.sty} package may interfere (it unfortunately does a global assignment of \cmd\@tempdima).
4157 % \begin{macrocode}
4158 \expandafter\par
4159 \expandafter\aftergroup\csname tocdim@#2%
4160 \expandafter\endcsname
4161 \expandafter\endgroup
4162 \the\@tempdima\relax
4163 }%
4164 % \end{macrocode}
4165 % \changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}%
4166 % In the call to \cmd\set@tocdim@pagenum, I am now exposing the use of the particular box register.
4167 % \begin{macrocode}
4168 \def\set@tocdim@pagenum#1#2{%
4169 \setbox#1\hbox{\ignorespaces#2}%
4170 \@ifdim{\tocdim@pagenum<\wd#1}{\global\tocdim@pagenum\wd#1}{}%
4171 }%
4172 % \end{macrocode}
4173 % \end{macro}
4174 %
4175 % \begin{macro}{\numberline@@sections}
4176 % \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.)}%
4177 % The utility procedure for all \cmd\numberline\ processing in indented TOC entries.
4178 % The first argument is self.
4179 %
4180 % We use \cmd\@tempdima\ to pass a value around (via global assignment) because
4181 % \cmd\numberline\ executes inside a group if the
4182 % \classname{hyperref} package is loaded.
4183 % Would that it were not so!
4184 % \begin{macrocode}
4185 \def\numberline@@sections#1{%
4186 \leavevmode\hb@xt@-\parindent{%
4187 \hfil
4188 \@if@empty{#1}{}{%
4189 \setbox\z@\hbox{#1.\kern\ltxu@dotsep}%
4190 \@ifdim{\@tempdima<\wd\z@}{\global\@tempdima\wd\z@}{}%
4191 \unhbox\z@
4192 }%
4193 }%
4194 \ignorespaces
4195 }%
4196 \def\tocdim@min{\z@}%
4197 % \end{macrocode}
4198 % \end{macro}
4199 %
4200 %
4201 % \subsection{Lists}
4202 % \begin{macro}{\list}
4203 % Using \cmd\parshape\ to implement lists was always suspect
4204 % (can you get behind \cmd\parshape\cmd\@ne?) and we now see that
4205 % it was a mistake all along. Why? Because \cmd\parshape, like
4206 % \cmd\hangindent, achieves its effect via ``shifting'' the \cmd\hbox es
4207 % in a paragraph
4208 % instead of using \cmd\leftskip\ and \cmd\parindent, which is
4209 % robust during column balancing.
4210 %
4211 % We introduce the alternative method with a hook into
4212 % the \LaTeX\ kernel procedure \cmd\list, which is
4213 % the implementation of all lists.
4214 %
4215 % \begin{macrocode}
4216 \def\list#1#2{%
4217 \ifnum \@listdepth >5\relax
4218 \@toodeep
4219 \else
4220 \global\advance\@listdepth\@ne
4221 \fi
4222 \rightmargin\z@
4223 \listparindent\z@
4224 \itemindent\z@
4225 \csname @list\romannumeral\the\@listdepth\endcsname
4226 \def\@itemlabel{#1}%
4227 \let\makelabel\@mklab
4228 \@nmbrlistfalse
4229 #2\relax
4230 \@trivlist
4231 \parskip\parsep
4232 \set@listindent
4233 \ignorespaces
4234 }%
4235 \def\set@listindent@parshape{%
4236 \parindent\listparindent
4237 \advance\@totalleftmargin\leftmargin
4238 \advance\linewidth-\rightmargin
4239 \advance\linewidth-\leftmargin
4240 \parshape\@ne\@totalleftmargin\linewidth
4241 }%
4242 \def\set@listindent@{%
4243 \parindent\listparindent
4244 \advance\@totalleftmargin\leftmargin
4245 \advance\rightskip\rightmargin
4246 \advance\leftskip\@totalleftmargin
4247 }%
4248 \let\set@listindent\set@listindent@parshape
4249 % \end{macrocode}
4250 % \end{macro}
4251 %
4252 %
4253 % \subsection{Hypertext capabilities}
4254 %
4255 % \begin{macro}{\href}
4256 % \begin{macro}{\url}
4257 % \begin{macro}{\URL@prefix}
4258 % \begin{macro}{\doi}
4259 % \begin{macro}{\doibase}
4260 % \changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}%
4261 % We provide support for the \cmd\href, \cmd\url, and \cmd\doi\ commands.
4262 % Packages, like \classname{hyperref}, may override these definitions
4263 % and provide better semantics.
4264 % \changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}%
4265 % \changes{4.1j}{2009/10/24}{(AO, 545) Provide definition for \cs{doi} that does hypertext}%
4266 % \begin{macrocode}
4267 \providecommand\href[0]{\begingroup\@sanitize@url\@href}%
4268 \def\@href#1{\@@startlink{#1}\endgroup\@@href}%
4269 \def\@@href#1{#1\@@endlink}%
4270 \providecommand \url [0]{\begingroup\@sanitize@url \@url }%
4271 \def \@url #1{\endgroup\@href {#1}{\URL@prefix#1}}%
4272 \providecommand \URL@prefix [0]{URL }%
4273 \providecommand\doi[0]{\begingroup\@sanitize@url\@doi}%
4274 \def\@doi#1{\endgroup\@@startlink{\doibase#1}doi:\discretionary {}{}{}#1\@@endlink }%
4275 %changes{4.2a}{2017/11/21}{(MD) Use updated best practice to use https and doi.org}%
4276 \providecommand \doibase [0]{https://doi.org/}%
4277 \providecommand \@sanitize@url[0]{\chardef\cat@space\the\catcode`\ \@sanitize\catcode`\ \cat@space}%
4278 % \end{macrocode}
4279 % \end{macro}
4280 % \end{macro}
4281 % \end{macro}
4282 % \end{macro}
4283 % \end{macro}
4284 %
4285 % \begin{macro}{\@@startlink}
4286 % \begin{macro}{\@@endlink}
4287 % \begin{macro}{\pdfstartlink@attr}
4288 % \begin{macro}{\hypertext@enable@ltx}
4289 % How we define \cmd\@@startlink\ and \cmd\@@endlink\ will depend on
4290 % whether we are running under \textsc{pdflatex}.
4291 % If so, and if PDF output is requested, then we use its primitives
4292 % to implement hypertext,
4293 % breaking out the link attributes in \cmd\pdfstartlink@attr\
4294 % and using the \classname{hyperref} defaults;
4295 % \cmd\pdfstartlink@attr\ can be redefined by a client package.
4296 % Otherwise we fall back the Hyper\TeX\ standard and leave things to the DVI translator.
4297 % \changes{4.1j}{2009/10/25}{(AO, 545) hypertext capabilities off by default; enable with \classoption{hypertext}}
4298 %
4299 % A class or package that wishes to employ hypertext capabilities should
4300 % execute the \cmd\hypertext@enable@ltx\ procedure.
4301 % \begin{macrocode}
4302 \def\@@startlink#1{}%
4303 \def\@@endlink{}%
4304 \@ifxundefined \pdfoutput {\true@sw}{\@ifnum{\z@=\pdfoutput}{\true@sw}{\false@sw}}%
4305 {%
4306 \def\@@startlink@hypertext#1{\leavevmode\special{html:<a href="#1">}}%
4307 \def\@@endlink@hypertext{\special{html:</a>}}%
4308 }{%
4309 \def\@@startlink@hypertext#1{%
4310 \leavevmode
4311 \pdfstartlink\pdfstartlink@attr
4312 user{/Subtype/Link/A<</Type/Action/S/URI/URI(#1)>>}%
4313 \relax
4314 }%
4315 \def\@@endlink@hypertext{\pdfendlink}%
4316 \def\pdfstartlink@attr{attr{/Border[0 0 1 ]/H/I/C[0 1 1]}}%
4317 }%
4318 \def\hypertext@enable@ltx{%
4319 \let\@@startlink\@@startlink@hypertext
4320 \let\@@endlink\@@endlink@hypertext
4321 }%
4322 % \end{macrocode}
4323 % \end{macro}
4324 % \end{macro}
4325 % \end{macro}
4326 % \end{macro}
4327 %
4328 % \begin{macro}{\href}
4329 % \changes{4.1p}{2010/02/24}{(AO, 582) A patch of \classname{hyperref.sty} to provide backward compatibility to \TeX Live 2007's version 6.75r}%
4330 % The \cmd\href\ command of \classname{hyperref} was extend somewhere
4331 % between versions 6.75r and 6.80e. We apply a repair to the earlier
4332 % version (if present) so that it works like the later version.
4333 %
4334 % The issue is the presence of whitespace, either following the \cmd\href\ token
4335 % or following the first argument's closing brace character.
4336 %
4337 % \begin{macrocode}
4338 \def\href@Hy{\hyper@normalise \href@ }%
4339 \def\href@Hy@ltx{\@ifnextchar\bgroup\Hy@href{\hyper@normalise\href@}}%
4340 \def\Hy@href#{\hyper@normalise\href@}%
4341 \begingroup
4342 \endlinechar=-1 %
4343 \catcode`\^^A=14 %
4344 \catcode`\^^M\active
4345 \catcode`\%\active
4346 \catcode`\#\active
4347 \catcode`\_\active
4348 \catcode`\$\active
4349 \catcode`\&\active
4350 \gdef\hyper@normalise@ltx{^^A
4351 \begingroup
4352 \catcode`\^^M\active
4353 \def^^M{ }^^A
4354 \catcode`\%\active
4355 \let%\@percentchar
4356 \let\%\@percentchar
4357 \catcode`\#\active
4358 \def#{\hyper@hash}^^A
4359 \def\#{\hyper@hash}^^A
4360 \@makeother\&^^A
4361 \edef&{\string&}^^A
4362 \edef\&{\string&}^^A
4363 \edef\textunderscore{\string_}^^A
4364 \let\_\textunderscore
4365 \catcode`\_\active
4366 \let_\textunderscore
4367 \let~\hyper@tilde
4368 \let\~\hyper@tilde
4369 \let\textasciitilde\hyper@tilde
4370 \let\\\@backslashchar
4371 \edef${\string$}^^A
4372 \Hy@safe@activestrue
4373 \hyper@n@rmalise
4374 }^^A
4375 \catcode`\#=6 ^^A
4376 \gdef\Hy@ActiveCarriageReturn@ltx{^^M}^^A
4377 \gdef\hyper@n@rmalise@ltx#1#2{^^A
4378 \def\Hy@tempa{#2}^^A
4379 \ifx\Hy@tempa\Hy@ActiveCarriageReturn
4380 \Hy@ReturnAfterElseFi{^^A
4381 \hyper@@normalise{#1}^^A
4382 }^^A
4383 \else
4384 \Hy@ReturnAfterFi{^^A
4385 \hyper@@normalise{#1}{#2}^^A
4386 }^^A
4387 \fi
4388 }^^A
4389 \gdef\hyper@@normalise@ltx#1#2{^^A
4390 \edef\Hy@tempa{^^A
4391 \endgroup
4392 \noexpand#1{\Hy@RemovePercentCr#2%^^M\@nil}^^A
4393 }^^A
4394 \Hy@tempa
4395 }^^A
4396 \gdef\Hy@RemovePercentCr@ltx#1%^^M#2\@nil{^^A
4397 #1^^A
4398 \ifx\limits#2\limits
4399 \else
4400 \Hy@ReturnAfterFi{^^A
4401 \Hy@RemovePercentCr #2\@nil
4402 }^^A
4403 \fi
4404 }^^A
4405 \endgroup
4406 \def\switch@hyperref@href{%
4407 \expandafter\@ifx\expandafter{\csname href \endcsname\href@Hy}{
4408 \class@info{Repairing hyperref 6.75r \string\href}%
4409 \let\hyper@normalise\hyper@normalise@ltx
4410 \let\hyper@@normalise\hyper@@normalise@ltx
4411 \let\hyper@n@rmalise\hyper@n@rmalise@ltx
4412 \let\Hy@ActiveCarriageReturn\Hy@ActiveCarriageReturn@ltx
4413 \let\Hy@RemovePercentCr\Hy@RemovePercentCr@ltx
4414 \let\href\href@Hy@ltx
4415 }{}%
4416 }%
4417 \appdef\document@inithook{\switch@hyperref@href}%
4418 % \end{macrocode}
4419 % \end{macro}
4420 %
4421 %
4422 % \begin{macro}{\typeout}
4423 % We make the \cmd\typeout\ procedure of \LaTeX\ be \cmd\long,
4424 % because sometimes we are talking about \cmd\par.
4425 % \begin{macrocode}
4426 \def\typeout@org#1{%
4427 \begingroup
4428 \set@display@protect
4429 \immediate\write\@unused{#1}%
4430 \endgroup
4431 }%
4432 \long\def\typeout@ltx#1{%
4433 \begingroup
4434 \set@display@protect
4435 \immediate\write\@unused{#1}%
4436 \endgroup
4437 }%
4438 \@ifx{\typeout\typeout@org}{%
4439 \let\typeout\typeout@ltx
4440 \true@sw
4441 }{%
4442 \rvtx@ifformat@geq{2020/10/01}%
4443 {\true@sw}{\false@sw}%
4444 }%
4445 {\class@info{Making \string\typeout\space \string\long}}%
4446 {}%
4447 % \end{macrocode}
4448 % \end{macro}
4449 %
4450 % \subsection{End of the \file{kernel} {\sc docstrip} module}
4451 % Here ends the module.
4452 % \begin{macrocode}
4453 %</kernel>
4454 % \end{macrocode}
4455 %
4456 % \Finale
4457 % \iffalse Here ends the programmer's documentation.\fi
4458 % \endinput
4459 %
4460 \endinput
4461 %%EOF