Debian Codegraph @

texmf-dist/source/latex/memoir/memoir.dtx

raw
1 % \iffalse meta-comment
2 %
3 % memoir.dtx
4 % Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
5 % Maintainer: Lars Madsen (daleif at math dot au dot dk)
6 % Copyright 2001--2010 Peter R. Wilson
7 % Copyright 2011-- Lars Madsen
8 %
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either
11 % version 1.3c of this license or (at your option) any
12 % later version.
13 % The latest version of the license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of
16 % LaTeX version 2008/05/04 or later.
17 %
18 % This work has the LPPL maintenance status "maintained".
19 %
20 % This work consists of the files listed in the README file.
21 %
22 % \fi
23 % ^^A\CheckSum{28340}
24 %
25 % \changes{v0.1}{2001/05/20}{First public alpha release}
26 % \changes{v0.2}{2001/06/03}{First beta release}
27 % \changes{v0.3}{2001/07/09}{Bug fixing}
28 % \changes{v0.31}{2001/07/09}{Bug fixing}
29 % \changes{v0.32}{2001/08/03}{Fix for old versions of amsmath package}
30 % \changes{v0.33}{2001/08/03}{Added controllable chapter/LoF spacing}
31 % \changes{v0.33}{2001/08/03}{Fixed bug in \cs{appendixpage}}
32 % \changes{v1.0}{2001/10/30}{First production release}
33 % \changes{v1.0a}{2001/12/07}{Feature fixes} ^^A never released
34 % \changes{v1.1}{2002/03/10}{More fixups}
35 % \changes{v1.1}{2002/03/10}{Replaced all the subfigure code}
36 % \changes{v1.1}{2002/03/28}{Added sidebars}
37 % \changes{v1.1}{2002/03/28}{Upgraded verse typesetting}
38 % \changes{v1.2}{2002/07/07}{Added 17pt option}
39 % \changes{v1.2}{2002/07/07}{Added extra \cs{provide} commands}
40 % \changes{v1.2}{2002/07/27}{Major verbatim, box and file additions}
41 % \changes{v1.2}{2002/07/27}{Removed extraneous space from change marks}
42 % \changes{v1.2}{2002/07/27}{Extra optarg in \cs{chapter} and \cs{chapter*}}
43 % \changes{v1.2}{2002/07/27}{Twiddled font sizes a little}
44 % \changes{v1.2}{2002/08/27}{Fixed 12pt bug}
45 % \changes{v1.3}{2002/09/27}{Minor tweaks wrt v1.2}
46 % \changes{v1.3}{2002/10/10}{Extra trimming styles}
47 % \changes{v1.3}{2002/10/10}{Major extensions for indexing}
48 % \changes{v1.3}{2002/11/14}{Automatically call a patch file}
49 % \changes{v1.3a}{2002/11/22}{Fixed nasty figure/table bug}
50 % \changes{v1.4}{2003/02/27}{Added patches v1.1}
51 % \changes{v1.4}{2003/02/27}{Added patches v1.3}
52 % \changes{v1.4}{2003/11/16}{Including current patches}
53 % \changes{v1.4}{2003/11/16}{Added patches v1.2}
54 % \changes{v1.4}{2003/11/22}{Added patches v1.4}
55 % \changes{v1.4}{2003/11/22}{Added patches v1.5}
56 % \changes{v1.4}{2003/11/22}{Added patches v1.6}
57 % \changes{v1.4}{2003/11/22}{Added patches v1.7}
58 % \changes{v1.4}{2003/11/30}{Added patches v1.8}
59 % \changes{v1.4}{2003/11/30}{Added patches v1.9}
60 % \changes{v1.6}{2004/01/31}{Decided to issue v1.4 as v1.6 on the way to
61 % the golden section 1.6180339887...}
62 % \changes{v1.61}{2004/03/14}{Changes to clo files, and footnotes}
63 % \changes{v1.61}{2004/03/21}{Removed a potential problem with the
64 % hangul package}
65 % \changes{v1.618}{2005/09/02}{Folded in all v1.61 patches}
66 % \changes{v1.618}{2005/09/15}{Some minor extensions}
67 % \changes{v1.618}{2005/09/25}{Support for glossaries}
68 % \changes{v1.6180}{2006/06/12}{Footnote font fix}
69 % \changes{v1.61803}{2008/05/26}{Folded in all mempatch v4.9a patches}
70 % \changes{v1.618033}{2008/06/02}{Fixed(?) page layout algorithms}
71 % \changes{v1.6180339}{2008/07/23}{Unemulated if... packages}
72 % \changes{v1.6180339}{2008/07/23}{Folded in all mempatch v5.1 patches}
73 % \changes{v1.6180339a}{2008/08/07}{Removed extra space in footnotes}
74 % \changes{v1.6180339c}{2009/01/21}{Minor bug fixes and extensions}
75 % \changes{v1.6180339c}{2009/01/25}{A few more}
76 % \changes{v1.6180339d}{2009/02/04}{Fixed a bug in the running
77 % head/foot widths}
78 % \changes{v1.6180339f}{2009/03/16}{Start of `f' version.}
79 % \changes{v1.6180339f}{2009/03/16}{Fixed problem with companion pagestyle
80 % and added 2 col Toc}
81 % \changes{v1.6180339f}{2009/04/25}{Extended description lists}
82 % \changes{v1.6180339f}{2009/07/12}{Added three \cs{memlet...} macros}
83 % \changes{v1.6180339g}{2009/07/13}{Fixed a bug regading extre enties
84 % in the page note list}
85 % \changes{v1.61803398}{2009/07/17}{Added bidi (RTL) support}
86 % \changes{v1.61803398}{2009/07/27}{Fixed bug in \cs{@setclcnt}, added simple pagestyle}
87 % \changes{v1.61803398}{2009/08/08}{changed the code that defined the
88 % main function out of \cs{newlistof}}
89 % \changes{v1.61803398}{2009/09/10}{fixed bug with upquote}
90 % \changes{v1.61803398b}{2009/09/21}{fixed typo}
91 % \changes{v1.61803398c}{2009/11/13}{fixed typo}
92 % \changes{v1.61803398d}{2009/11/13}{fixed infelicity with \cs{@starttoc}}
93 % \changes{v1.61803398d}{2009/12/01}{fixed bug in ifxetex, ifpdf,...}
94 % \changes{v1.61803398d}{2009/12/18}{made \cs{subcaptionref} robust}
95 % \changes{v1.61803398d}{2010/xx/xx}{several changes}
96 % \changes{v1.618033988}{2010/02/16}{bumped version to v1.618033988}
97 % \changes{v1.618033988b}{2010/02/17}{fixed typo that broke \cs{feetbelowfloat}}
98 % \changes{v1.618033988c}{2010/02/20}{fixed sporadic space in \cs{@footnotetext}}
99 % \changes{v1.618033988d}{2010/02/26}{fixed bug in
100 % \cs{marginparmargin}\{left\} in twoside mode}
101 %
102 % \changes{v3.6}{2010/04/19}{Reversioned memoir to a more suitable scheme}
103 % \changes{v3.6d}{2010/07/01}{Various bug fixes}
104 % \changes{v3.6e}{2010/08/20}{Maintenance}
105 % \changes{v3.6f}{2010/08/22}{Bad typo}
106 % \changes{v3.6g}{2010/09/19}{Maintenance}
107 % \changes{v3.6h}{2011/02/13}{Various things}
108 % \changes{v3.6i}{2011/02/18}{Two bug fixes}
109 % \changes{v3.6j}{2011/03/06}{Bug fixes}
110 % \changes{v3.6k}{2013/05/17}{Various fixes and long overdue maintenance}
111 % \changes{v3.7}{2013/05/22}{Bumped version}
112 % \changes{v3.7b}{2013/05/30}{Bugfix, sidecaption}
113 % \changes{v3.7c}{2015/03/05}{Bugfix}
114 % \changes{v3.7d}{2015/04/23}{Misc. bugfixes}
115 % \changes{v3.7e}{2015/07/08}{Per request from LaTeX Team, etex is not
116 % autoloaded on newer kernels}
117 % \changes{v3.7f}{2016/05/16}{Maintenance, luatex85 and booktabs update}
118 %
119 % \changes{v3.7h}{2018/12/12}{Maintenance, removing some emulated packages}
120 % \changes{v3.7i}{2019/11/15}{Maintenance, various edits}
121 % \changes{v3.7j}{2019/11/21}{Typo in embeded textcase, now that it is
122 % inside \cs{IfFileExists} \# needs to be doubled}
123 % \changes{v3.7k}{2020/03/25}{Maintenance}
124 % \changes{v3.7l}{2020/06/02}{Small preparation for october kernel update}
125 % \changes{v3.7m}{2020/09/10}{More preparations for october kernel update}
126 % \changes{v3.7n}{2020/10/04}{Foced # doubling in AtBegin/EndX macros
127 % to ensure backwards compatability}
128 % \changes{v3.7o}{2021/03/23}{Maintenance and a provide for the kernel}
129 % \changes{v3.7p}{2021/06/16}{Small adjustments of memoir vs memhfixc}
130 % \changes{v3.7q}{2022/02/20}{Maintenance}
131 % \changes{v3.7r}{2022/07/29}{Maintenance}
132 % \changes{v3.7.19}{2022/11/17}{Maintenance}
133 % \changes{v3.8}{2023/08/08}{Maintenance, see the README for details}
134 % \changes{v3.8a}{2023/08/14}{Forgot to enable stopping if the LaTeX
135 % format is too old}
136 % \changes{v3.8.1}{2023/08/21}{Moved AddToHook from \@xfloat to
137 % \@floatboxreset as the float package causes issues}
138 % \changes{v3.8.3}{2025/03/06}{Various updates}
139 % \changes{v3.8.3b}{2025/03/10}{Bug fix}
140 % \changes{v3.8.4}{2025/10/02}{Maintenance}
141 % \changes{v3.8.4b}{2025/11/04}{Problem in manual}
142 %
143 % \def\dtxfile{memoir.dtx}
144 %
145 % \def\fileversion{v0.1} \def\filedate{2001/05/20}
146 % \def\fileversion{v0.2} \def\filedate{2001/06/03}
147 % \def\fileversion{v0.3} \def\filedate{2001/07/14}
148 % \def\fileversion{v0.31} \def\filedate{2001/07/24}
149 % \def\fileversion{v0.32} \def\filedate{2001/08/03}
150 % \def\fileversion{v0.33} \def\filedate{2001/08/31}
151 % \def\fileversion{v1.0} \def\filedate{2001/11/17}
152 % \def\fileversion{v1.0a} \def\filedate{2001/12/07}
153 % \def\fileversion{v1.1} \def\filedate{2002/03/28}
154 % \def\fileversion{v1.1a} \def\filedate{2002/04/28}
155 % \def\fileversion{v1.2} \def\filedate{2002/08/10}
156 % \def\fileversion{v1.2} \def\filedate{2002/08/27}
157 % \def\fileversion{v1.3} \def\filedate{2002/11/14}
158 % \def\fileversion{v1.3a} \def\filedate{2002/11/22}
159 % \def\fileversion{v1.4} \def\filedate{2003/12/18}
160 % \def\fileversion{v1.6} \def\filedate{2004/01/31}
161 % \def\fileversion{v1.61} \def\filedate{2004/04/04}
162 % \def\fileversion{v1.618} \def\filedate{2005/09/27}
163 % \def\fileversion{v1.6180} \def\filedate{2006/06/12}
164 % \def\fileversion{v1.61803} \def\filedate{2008/05/26}
165 % \def\fileversion{v1.618033} \def\filedate{2008/06/02}
166 % \def\fileversion{v1.6180339} \def\filedate{2008/07/23}
167 % \def\fileversion{v1.6180339a} \def\filedate{2008/08/07}
168 % \def\fileversion{v1.6180339c} \def\filedate{2009/01/21}
169 % \def\fileversion{v1.6180339c} \def\filedate{2009/01/25}
170 % \def\fileversion{v1.6180339d} \def\filedate{2009/02/04}
171 % \def\fileversion{v1.6180339e} \def\filedate{2009/02/06}
172 % \def\fileversion{v1.6180339f} \def\filedate{2009/07/12}
173 % \def\fileversion{v1.6180339g} \def\filedate{2009/07/13}
174 % \def\fileversion{v1.61803398} \def\filedate{2009/09/10}
175 % \def\fileversion{v1.61803398b} \def\filedate{2009/09/21}
176 % \def\fileversion{v1.61803398c} \def\filedate{2009/11/17}
177 % \def\fileversion{v1.61803398d} \def\filedate{2009/11/23}
178 % \def\fileversion{v1.618033988} \def\filedate{2010/02/16}
179 % \def\fileversion{v1.618033988b} \def\filedate{2010/02/17}
180 % \def\fileversion{v1.618033988c} \def\filedate{2010/02/20}
181 % \def\fileversion{v3.6} \def\filedate{2010/04/19}
182 % \def\fileversion{v3.6d} \def\filedate{2010/07/01}
183 % \def\fileversion{v3.6e} \def\filedate{2010/08/20}
184 % \def\fileversion{v3.6f} \def\filedate{2010/08/22}
185 % \def\fileversion{v3.6g} \def\filedate{2010/09/19}
186 % \def\fileversion{v3.6h} \def\filedate{2011/02/13}
187 % \def\fileversion{v3.6i} \def\filedate{2011/02/18}
188 % \def\fileversion{v3.6j} \def\filedate{2011/03/06}
189 % \def\fileversion{v3.6k} \def\filedate{2013/05/17}
190 % \def\fileversion{v3.7} \def\filedate{2013/05/22}
191 % \def\fileversion{v3.7b} \def\filedate{2013/05/30}
192 % \def\fileversion{v3.7c} \def\filedate{2015/03/05}
193 % \def\fileversion{v3.7d} \def\filedate{2015/04/23}
194 % \def\fileversion{v3.7e} \def\filedate{2015/07/08}
195 % \def\fileversion{v3.7f} \def\filedate{2016/05/16}
196 % \def\fileversion{v3.7g} \def\filedate{2018/04/04}
197 % \def\fileversion{v3.7h} \def\filedate{2018/12/12}
198 % \def\fileversion{v3.7i} \def\filedate{2019/11/15}
199 % \def\fileversion{v3.7j} \def\filedate{2019/11/21}
200 % \def\fileversion{v3.7k} \def\filedate{2020/03/25}
201 % \def\fileversion{v3.7l} \def\filedate{2020/06/02}
202 % \def\fileversion{v3.7m} \def\filedate{2020/09/10}
203 % \def\fileversion{v3.7n} \def\filedate{2020/10/04}
204 % \def\fileversion{v3.7o} \def\filedate{2021/03/23}
205 % \def\fileversion{v3.7p} \def\filedate{2021/06/16}
206 % \def\fileversion{v3.7q} \def\filedate{2022/02/20}
207 % \def\fileversion{v3.7r} \def\filedate{2022/07/29}
208 % \def\fileversion{v3.7.19} \def\filedate{2022/11/17}
209 % \def\fileversion{v3.8} \def\filedate{2023/08/08}
210 % \def\fileversion{v3.8.1} \def\filedate{2023/08/21}
211 % \def\fileversion{v3.8.2} \def\filedate{2024/01/26}
212 % \def\fileversion{v3.8.3} \def\filedate{2025/03/06}
213 % \def\fileversion{v3.8.3b} \def\filedate{2025/03/10}
214 % \def\fileversion{v3.8.4} \def\filedate{2025/10/02}
215 % \def\fileversion{v3.8.4b} \def\filedate{2025/11/04}
216 % \title{The LaTeX \Lpack{memoir} class for configurable book
217 % typesetting: Source code\thanks{This
218 % file (\texttt{\dtxfile}) has version number \fileversion, last revised
219 % \filedate.}}
220 %
221 % \author{%
222 % Peter Wilson\\ ^^A\thanks{\texttt{herries dot press at earthlink dot net}}\\
223 % Herries Press \\
224 % (maintained by Lars Madsen\thanks{\texttt{daleif at math dot au dot dk}}\ )}
225 % \date{\filedate}
226 % \maketitle
227 %
228 % \begin{abstract}
229 % The \Lpack{memoir} class is designed for typesetting
230 % general books such as novels, biographies, histories,
231 % and so on, although as it supports all the functionality of the
232 % standard \Lpack{book} class it can also be used for technical writing.
233 % It provides more functions than the standard class as well as
234 % presenting a more friendly interface for the book designer.
235 % It can also simulate the typesetting style of the standard \Lpack{article}
236 % class.
237 %
238 % The class was first released in mid 2001 and has been well used ever
239 % since.
240 % \end{abstract}
241 %
242 % \tableofcontents
243 % \listoftables
244 %
245 % \StopEventually{}
246 %
247 %
248 %
249 % \section{Introduction}
250 %
251 % This document provides the commented source
252 % for the LaTeX \Lpack{memoir} class, which is designed for typesetting
253 % general books such as novels, biographies, histories,
254 % and so on. It has all the functionality of the standard \Lpack{book}
255 % class and, as well as providing some extra functions, also provides
256 % a more friendly interface for the document designer. As it can encompass
257 % everything that the \Lpack{book} class provides it may also be used
258 % for technical writing.
259 %
260 % The default appearance of a document typeset with this class is
261 % the same as if it had been typeset with the \Lpack{book} class and
262 % it can be made to simulate the \Lpack{article} class..
263 % The class, though, includes extra facilities that make it easy to
264 % change the appearance of such things as the page headers and footers,
265 % the style of chapter and other sectional headings, and the style of
266 % captions. It also makes it easy to both change the style of the
267 % Table of Contents, List of Figures, etc., as well as creating new
268 % kinds of `List of\ldots'. New types of floats, if needed, can be
269 % created very simply. Epigraphs can be put into the document in a
270 % variety of styles.
271 %
272 % The class provides a variety of page, chapter and captioning
273 % styles that you can choose from if you don't want to create your own.
274 %
275 % Documents can be typeset in 9pt, 10pt, 11pt, 12pt, 14pt or 17pt font
276 % sizes, and if you have scaleable fonts available they can be set at any size.
277 % There is a reasonably intuitive means of setting the margins
278 % and placement of the text on a page. There is an option to put
279 % trim marks on the printed pages if the stock sheets need to be trimmed
280 % down to the final page size. For those whose publishers like a
281 % manuscript to look as though it was typewritten, there is an option
282 % to do this (double spacing, ragged right, no hyphenation,
283 % fixed width font). There is also an unsophisticated means of flagging any
284 % revisions to the text.
285 %
286 % As this is a new class, by default it does not support the old
287 % LaTeX v2.09
288 % font commands, namely the \cs{bf}, \cs{sl}, \cs{it} and \cs{sc} commands;
289 % it warns about using the \cs{em} command but does support it.
290 %
291 %
292 % I hope that apart from the font commands the class
293 % is compatible with
294 % `standard' LaTeX.
295 %
296 % Development of this class would never have been started without
297 % the wonderful work done by Leslie Lamport and others~\cite{CLASSES}
298 % from whom I have learned a great deal and borrowed much code.
299 %
300 % Sections~\ref{sec:docstrip} through~\ref{sec:ic} describe some
301 % administrative elements and code for general use later in the
302 % specification.
303 % The macros forming the class file are defined in sections~\ref{sec:opt}
304 % through~\ref{sec:init}.
305 %
306 % This manual is typeset according to the conventions of the
307 % \LaTeX{} \textsc{docstrip} utility which enables the automatic
308 % extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
309 %
310 %
311 % \section{A driver for this document} \label{sec:docstrip}
312 %
313 % The next series of code contains the documentation driver file for
314 % \LaTeX, i.e., the file that will produce the documentation you are
315 % currently reading. This will be extracted from this file by the
316 % \textsc{docstrip} program.
317 %
318 % \begin{macrocode}
319 %<*driver>
320 \documentclass[twoside]{ltxdoc}
321 \usepackage[T1]{fontenc}
322 \usepackage{url,array}
323 %%\usepackage[draft=false,
324 %% plainpages=false,
325 %% pdfpagelabels,
326 %% bookmarksnumbered,
327 %% hyperindex=true
328 %% ]{hyperref} % Doesn't work with indexing of \DescribeMacro
329 \providecommand{\phantomsection}{} % just in case hyperref not used
330 % \end{macrocode}
331 %
332 % We do want an index, using linenumbers, but not update information.
333 % \begin{macrocode}
334 \EnableCrossrefs
335 \CodelineIndex
336 %% \RecordChanges
337 % \end{macrocode}
338 % We had better have page headings to aid navigation, but I don't
339 % like Uppercased titles.
340 % \begin{macrocode}
341 \makeatletter
342 \@mparswitchfalse
343 \makeatother
344 \renewcommand{\MakeUppercase}[1]{#1}
345 \pagestyle{headings}
346 % \end{macrocode}
347 % We may use so many \file{docstrip} modules that we set the
348 % \texttt{StandardModuleDepth} counter to 1.
349 % \begin{macrocode}
350 \setcounter{StandardModuleDepth}{1}
351 % \end{macrocode}
352 % Some commonly used abbreviations
353 % \begin{macrocode}
354 \newcommand*{\Lopt}[1]{\textsf {#1}} % typeset an option
355 \newcommand*{\file}[1]{\texttt {#1}} % typeset a file
356 \newcommand*{\Lcount}[1]{\textsl {\small#1}} % typeset a counter
357 \newcommand*{\pstyle}[1]{\textsl {#1}} % typeset a pagestyle
358 \newcommand*{\Lenv}[1]{\texttt {#1}} % typeset an environment
359 \newcommand*{\Lpack}[1]{\textsf {#1}} % typeset a package
360 \newcommand*{\ctt}{\textsc{ctt}} % comp.text.tex
361 \newcommand*{\Lhook}[1]{\meta{#1}} % name of a hook
362 \newenvironment{PW}{\em}{}
363 \newenvironment{dlf}{\em}{}
364 \newcommand*\MarkedForDeprecation[1]{\par\noindent%
365 \textcolor{red}{#1 is marked for deprecation}\par}
366 \newcommand*{\theTeXbook}{\textit{The \TeX book}}
367 \let\oldllap\llap
368 \def\llap#1{\oldllap{#1\quad}} % might be evil
369 % \end{macrocode}
370 % We want the full details printed.
371 % \begin{macrocode}
372 \begin{document}
373 \DeleteShortVerb{\|}
374 \raggedbottom
375 %\raggedright
376 \DocInput{\jobname.dtx}
377 \PrintIndex
378 %% \PrintChanges
379 \end{document}
380 %</driver>
381 % \end{macrocode}
382 %
383 %
384 % ^^A There are some elements we do not want to appear in the index.
385 % \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
386 % \DoNotIndex{\@centercr,\@cite}
387 % \DoNotIndex{\@dotsep,\@empty,\@gobble,\@gobbletwo,\@ignoretrue}
388 % \DoNotIndex{\@input,\@ixpt,\@m}
389 % \DoNotIndex{\@minus,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
390 % \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
391 % \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
392 % \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
393 % \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
394 % \DoNotIndex{\advance,\Alph,\alph}
395 % \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
396 % \DoNotIndex{\bullet}
397 % \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
398 % \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
399 % \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
400 % \DoNotIndex{\EnableCrossrefs,\end,\endgroup}
401 % \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
402 % \DoNotIndex{\fbox}
403 % \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
404 % \DoNotIndex{\global,\halign,\hbox,\hfil,\hfill,\hrule}
405 % \DoNotIndex{\hsize,\hskip,\hspace,\hss}
406 % ^^A \DoNotIndex{\if@tempswa,\fi}
407 % \DoNotIndex{\ifcase,\or,\fi}
408 % \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
409 % \DoNotIndex{\input}
410 % \DoNotIndex{\jobname,\kern,\leavevmode,\let}
411 % \DoNotIndex{\list,\llap,\long,\m@ne,\m@th}
412 % \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
413 % \DoNotIndex{\NeedsTeXFormat,\newdimen}
414 % \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
415 % \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
416 % \DoNotIndex{\par,\paragraph,\paragraphmark,\parfillskip}
417 % \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
418 % \DoNotIndex{\protect,\ProvidesClass}
419 % \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
420 % \DoNotIndex{\rightskip,\rlap,\rmfamily,\roman}
421 % \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
422 % \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
423 % \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
424 % \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
425 % \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
426 % \DoNotIndex{\wd,\xiipt,\year,\z@}
427 % \DoNotIndex{\@namedef,\@nameuse,\csname,\endcsname}
428 %
429 %
430 %
431 % \section{Identification} \label{sec:id}
432 %
433 % The \Lpack{memoir} document class can only be used with LaTeX2e, so
434 % we make sure that an appropriate message is displayed when another
435 % \TeX{} format is used.
436 % \changes{v3.8}{2023/08/02}{Added requirement on the kernel}
437 % \changes{v3.8.4}{2025/08/08}{Bumped required kernel by a year}
438 % \begin{macrocode}
439 %<class>\def\mem@atleast@kernel{2023/06/01}
440 %<class>\NeedsTeXFormat{LaTeX2e}[\mem@atleast@kernel]
441 % \end{macrocode}
442 %
443 % ^^A Use the Golden Section as the version number (1.6180339887 4989484820 4586834365)
444 % \changes{v3.6}{2010/04/19}{Not any more, apparently people does not
445 % know the numeric value of the golden ration very well}
446 %
447 %
448 % Announce the name, option files and version for LaTeX2e files:
449 % \begin{macrocode}
450 %<class>\ProvidesClass{memoir}%
451 %<class> [2025/11/04 v3.8.4b configurable book, report, article document class]
452 %<class>\newcommand\memversion{v3.8.4b, 2025/11/04}
453 % \end{macrocode}
454 %
455 % \changes{v3.7m}{2020/08/05}{Added \cs{IfFormatAtLeastTF}}
456 % \changes{v3.8}{2023/08/02}{Moved up earlier so we can use it to
457 % issue an error if the kernel is too old.}
458 % \begin{macro}{\IfFormatAtLeastTF}
459 % Credit to Frank Mittelbach. Using
460 % \cs{IfFormatAtLeastTF}\marg{date}\marg{true}\marg{false} we can
461 % execute \meta{true} if the format is dated after the given
462 % \meta{date} (in {\scriptsize\ttfamily YYYY/MM/DD} format) and
463 % \meta{false} otherwise. The main use is for when we get info that
464 % certain features are being added to the \LaTeX\ format, features
465 % that we want to base class features on. Then this is an easy method
466 % for providing the code only avaiable on newer formats and code left
467 % over for those still using the older \LaTeX\ formats.\footnote{The \dots TF is a
468 % nice \LaTeX3 convention.}
469 % \begin{macrocode}
470 %<class>\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
471 % \end{macrocode}
472 % \end{macro}
473 %
474 % Stop the loading if the kernel is too old (as \cs{NeedsTeXFormat}
475 % only issues a warning). Though we cannot do much about nonstopmode.
476 % \changes{v3.8a}{2023/08/14}{Forgot to enable the stop mode}
477 % \begin{macrocode}
478 %<class>\IfFormatAtLeastTF{\mem@atleast@kernel}{}{
479 %<class> \ClassError{memoir}{%
480 %<class> Your LaTeX release is too old.\MessageBreak
481 %<class> The memoir class requires at LaTeX format\MessageBreak
482 %<class> from at least \mem@atleast@kernel\space onwards.
483 %<class> Please update your\MessageBreak
484 %<class> entire LaTeX installation instead of manually updating\MessageBreak
485 %<class> just memoir}{}
486 %<class> \batchmode\read-1to\@tempa% evil mode engaged
487 %<class>}
488 % \end{macrocode}
489 %
490 % \begin{macrocode}
491 %<9pt> \ProvidesFile{mem9.clo}%
492 %<9pt> [2022/07/29 v0.5 memoir class 9pt size option]
493 %<10pt>\ProvidesFile{mem10.clo}%
494 %<10pt> [2022/07/29 v0.5 memoir class 10pt size option]
495 %<11pt>\ProvidesFile{mem11.clo}%
496 %<11pt> [2022/07/29 v0.5 memoir class 11pt size option]
497 %<12pt>\ProvidesFile{mem12.clo}%
498 %<12pt> [2022/07/29 v0.5 memoir class 12pt size option]
499 %<14pt>\ProvidesFile{mem14.clo}%
500 %<14pt> [2022/07/29 v0.5 memoir class 14pt size option]
501 %<17pt>\ProvidesFile{mem17.clo}%
502 %<17pt> [2022/07/29 v0.5 memoir class 17pt size option]
503 %<20pt>\ProvidesFile{mem20.clo}%
504 %<20pt> [2022/07/29 v0.5 memoir class 20pt size option]
505 %<25pt>\ProvidesFile{mem25.clo}%
506 %<25pt> [2022/07/29 v0.5 memoir class 25pt size option]
507 %<30pt>\ProvidesFile{mem30.clo}%
508 %<30pt> [2022/07/29 v0.5 memoir class 30pt size option]
509 %<36pt>\ProvidesFile{mem36.clo}%
510 %<36pt> [2022/07/29 v0.5 memoir class 36pt size option]
511 %<48pt>\ProvidesFile{mem48.clo}%
512 %<48pt> [2022/07/29 v0.5 memoir class 48pt size option]
513 %<60pt>\ProvidesFile{mem60.clo}%
514 %<60pt> [2022/07/29 v0.5 memoir class 60pt size option]
515 % \end{macrocode}
516 %
517 %
518 % \section{Initial Code} \label{sec:ic}
519 %
520 % \begin{macrocode}
521 %<*class>
522 % \end{macrocode}
523 %
524 % (2022/02/20): In order to be able to use a patching approach instead
525 % of overwriting kernel macros, we will now require the
526 % \Lpack{etoolbox} package. (2023/07/28) changed to \Lpack{xpatch} as
527 % it supports a little more.
528 % \changes{v3.8}{2023/07/28}{replaced etoolbox by xpatch}
529 % \begin{macrocode}
530 \RequirePackage{xpatch}
531 % \end{macrocode}
532 %
533 % (2024/01/31): There are a lot of excessive code in the class that
534 % probably does not have much use anymore. We will start deprecating
535 % stuff set for removal. In order to provide a transition period we
536 % provide a few macros to mark such that they give a warning (we only
537 % give one per macro).
538 %
539 % \begin{macro}{\MarkDeprecated}
540 % \changes{v3.8.3}{2024/01/31}{Added this deprecation macro}
541 % \cs{MarkDeprecated(*)}\marg{env or macro}\marg{when comment}, can
542 % be used to add a deprecation warning to macros or envs. We
543 % automatically remove \cs{} from macro names when needed. Normally
544 % er add a marker macro to note that we have shown the warning
545 % once. The starred version shows the warning at all uses. ^^A It
546 % can be
547 % ^^A added to a command either manually or via a hook:
548 % ^^A \begin{verbatim}
549 % ^^A \AddToHook{cmd/foo/before}{\MarkDeprecated{\foo}{start 2025}}
550 % ^^A \AddToHook{env/foo/before}{\MarkDeprecated{foo}{start 2025}}
551 % ^^A \end{verbatim}
552 % ^^A Note that the hooks are added at the start of the document, so we
553 % ^^A cannot use it to add to our own macros and reveil where they are
554 % ^^A used. The starred version will warn every time the macro is used.
555 % \begin{macrocode}
556 \ExplSyntaxOn
557 % note that this is not technically correct expl3 code
558 \NewDocumentCommand\MarkDeprecated{smm}{
559 % see if macro exists, if so don't give warning
560 \cs_if_exist:cTF {__memoir_deprecated_\cs_to_str:N #2:}{}{% already showed one warning
561 % marker macro did not exist, globally define it and give warning
562 \IfBooleanF{#1}{\cs_gset:cn {__memoir_deprecated_\cs_to_str:N #2:}{}}
563 \@memwarn{
564 \string#2~is~marked~deprecated~and~will~be\MessageBreak
565 removed~#3
566 }
567 }
568 }
569 \ExplSyntaxOff
570
571 % \end{macrocode}
572 % \end{macro}
573 %
574 %
575 % Note (2001/08/03): Old versions of the \Lpack{amsmath} package did odd
576 % things with \cs{@tempa}, \cs{@tempb} and \cs{@tempc}. I have now replaced
577 % any use of these with \cs{@memtempa}, etc.
578 %
579 % \medskip\noindent
580 % In this part we define a few commands that are used later on.
581 %
582 % \begin{macro}{\@ptsize}
583 % \begin{macro}{\@memptsize}
584 % The \cs{@ptsize} control sequence is normally used to store the
585 % second digit of the
586 % pointsize we are typesetting in. So, normally, it's value is one
587 % of 0, 1 or 2.
588 %
589 % \cs{@memptsize} stores the full pointsize.
590 % \changes{v1.61803}{2008/01/30}{Added \cs{@memptsize}}
591 % \begin{macrocode}
592 \newcommand*{\@ptsize}{}
593 \newcommand*{\@memptsize}{}
594 % \end{macrocode}
595 % \end{macro}
596 % \end{macro}
597 %
598 % Any new lengths that depend on the point size option must be declared
599 % before the options are executed.
600 % \begin{macro}{\onelineskip}
601 % \begin{macro}{\lxvchars}
602 % \begin{macro}{\xlvchars}
603 % The length \cs{onelineskip} is the vertical space taken
604 % by a normal line of text. The lengths \cs{lxvchars} and \cs{xlvchars} are
605 % the approximate lengths required for typesetting lines with either 65 or 45
606 % characters.
607 % \begin{macrocode}
608 \newlength{\onelineskip}
609 \newlength{\lxvchars}
610 \newlength{\xlvchars}
611 % \end{macrocode}
612 % \end{macro}
613 % \end{macro}
614 % \end{macro}
615 %
616 % \begin{macro}{\@memcnta}
617 % \begin{macro}{\c@memmarkcntra}
618 % We need a scratch count register and a scratch counter.
619 % \changes{v1.61803}{2008/10/30}{Added @memmarkcntra scratch counter}
620 % \begin{macrocode}
621 \newcount\@memcnta
622 \newcounter{@memmarkcntra}
623 % \end{macrocode}
624 % \end{macro}
625 % \end{macro}
626 %
627 % \changes{v1.0a}{2001/11/28}{Deleted count register \cs{@memtempa}}
628 %
629 % \begin{macro}{\if@restonecol}
630 % When the document has to be printed in two columns, we sometimes
631 % have to temporarily switch to one column. This switch is used to
632 % remember to switch back.
633 % \begin{macrocode}
634 \newif\if@restonecol
635 % \end{macrocode}
636 % \end{macro}
637 %
638 % \begin{macro}{\if@openright}
639 % This is TRUE if chapters are to start on righthand (recto) pages;
640 % this is the default. FALSE means chapters can start on any page.
641 % \begin{macrocode}
642 \newif\if@openright
643 \@openrighttrue
644
645 % \end{macrocode}
646 % \end{macro}
647 %
648 % \begin{macro}{\if@openleft}
649 % This is TRUE if chapters are to start on lefthand (verso) pages.
650 % \begin{macrocode}
651 \newif\if@openleft
652 \@openleftfalse
653
654 % \end{macrocode}
655 % \end{macro}
656 %
657 % \begin{macro}{\if@mainmatter}
658 % This is TRUE if the main part of the document is being currently procesed;
659 % this is the default.
660 % \begin{macrocode}
661 \newif\if@mainmatter
662 \@mainmattertrue
663
664 % \end{macrocode}
665 % \end{macro}
666 %
667 % \begin{macro}{\if@memoldfont}
668 % This is TRUE if the \Lopt{oldfontcommands} option is used.
669 % \changes{v1.0a}{2002/01/29}{Added \cs{if@memoldfont}}
670 % \begin{macrocode}
671 \newif\if@memoldfont
672 \@memoldfontfalse
673
674 % \end{macrocode}
675 % \end{macro}
676 %
677 % \begin{macro}{\ifextrafontsizes}
678 % This is TRUE if the \Lopt{extrafontsizes} option is used.
679 % \changes{v1.61803}{2008/01/30}{Added \cs{ifextrafontsizes}}
680 % \begin{macrocode}
681 \newif\ifextrafontsizes
682 \extrafontsizesfalse
683
684 % \end{macrocode}
685 % \end{macro}
686 %
687 % \begin{macro}{\@memerror}
688 % \begin{macro}{\@memwarn}
689 % Two macros to save some space when reporting errors or warnings.
690 % The macros take the same arguments, ignoring the first in each case,
691 % as \cs{ClassError} and \cs{ClassWarning}, e.g., \\
692 % \verb?\@memwarn{Message}? \\
693 % instead of \\
694 % \verb?\ClassWarning{memoir}{Message}?.
695 % \changes{v1.4}{2003/02/27}{Added \cs{@memerror} and \cs{@memwarn}}
696 % \begin{macrocode}
697 \newcommand*{\@memerror}{\ClassError{memoir}}
698 \newcommand*{\@memwarn}{\ClassWarning{memoir}}
699
700 % \end{macrocode}
701 % \end{macro}
702 % \end{macro}
703 %
704 % \begin{macro}{\ifsamename}
705 % \begin{macro}{\nametest}
706 % The macro \cs{nametest}\marg{name1}\marg{name2} tests whether the
707 % characters forming the two arguments are the same or not. If they are the
708 % same then \cs{ifsamename} is set TRUE, otherwise it is set FALSE. \meta{name1}
709 % and \meta{name2} must both be either macro names (including the backslash)
710 % or must both not be macro names. That is, you cannot do
711 % \verb?\nametest{\cs}{cs}?.
712 % \changes{v1.61803398d}{2010/02/13}{added some \% because the macro
713 % was leaking spaces}
714 % \begin{macrocode}
715 \newif\ifsamename
716 \newcommand{\nametest}[2]{%
717 \samenamefalse%
718 \begingroup%
719 \def\@memtempa{#1}\def\@memtempb{#2}%
720 \ifx \@memtempa\@memtempb%
721 \endgroup%
722 \samenametrue%
723 \else%
724 \endgroup%
725 \fi}
726
727 % \end{macrocode}
728 % \end{macro}
729 % \end{macro}
730 %
731 % \begin{macro}{\ifm@m@And}
732 % \begin{macro}{\m@m@Andtrue}
733 % \begin{macro}{\m@m@Andfalse}
734 % \begin{macro}{\ifm@m@Or}
735 % \begin{macro}{\m@m@Ortrue}
736 % \begin{macro}{\m@m@Orfalse}
737 % \begin{macro}{\ifm@m@Xor}
738 % \begin{macro}{\m@m@Xortrue}
739 % \begin{macro}{\m@m@Xorfalse}
740 % These are for `if A and B', `if A or B' and `if A xor B'.
741 %
742 % For A and B:
743 % \begin{verbatim}
744 % \m@m@Andfalse
745 % \ifA
746 % \ifB
747 % \m@mAndtrue
748 % \fi
749 % \fi
750 % \end{verbatim}
751 % For A or B:
752 % \begin{verbatim}
753 % \m@m@Ortrue
754 % \ifA
755 % \else
756 % \ifB
757 % \else
758 % \m@m@Orfalse
759 % \fi
760 % \fi
761 % \end{verbatim}
762 % For A xor B:
763 % \begin{verbatim}
764 % \m@m@Xortrue
765 % \ifA
766 % \ifB
767 % \m@m@Xfalse
768 % \fi
769 % \else
770 % \ifB
771 % \else
772 % \m@m@Xorfalse
773 % \fi
774 % \fi
775 % \end{verbatim}
776 % \changes{v1.618}{2005/09/09}{Added \cs{ifm@m@And}, \cs{ifm@m@Or} and \cs{ifm@m@Xor}}
777 % \begin{macrocode}
778 \newif\ifm@m@And
779 \newif\ifm@m@Or
780 \newif\ifm@m@Xor
781
782 % \end{macrocode}
783 % \end{macro}
784 % \end{macro}
785 % \end{macro}
786 % \end{macro}
787 % \end{macro}
788 % \end{macro}
789 % \end{macro}
790 % \end{macro}
791 % \end{macro}
792 %
793 % \changes{v0.3}{2001/07/09}{Deleted \cs{fillline} and \cs{makecommand} as
794 % they were not used}
795 %
796 %
797 % \changes{v3.8.3}{2024/02/02}{Deleted \cs{kill@lastcounter} as it is not used}
798 %
799 %
800 % \begin{macro}{\@name@p@xdf}
801 % \begin{macro}{\@name@unresp@xdef}
802 % \begin{macro}{\@namelet}
803 % \begin{macro}{\@namelongdef}
804 % Utility definition macros, along the lines of the kernel's \cs{@namedef}.
805 % \changes{v1.4}{2003/11/22}{Added \cs{@namelet} and friends (from patch v1.8)}
806 % \begin{macrocode}
807 \newcommand{\@name@p@xdef}[1]{%
808 \expandafter\protected@xdef\csname #1\endcsname}
809 \newcommand{\@name@unresp@xdef}[1]{%
810 \expandafter\unrestored@protected@xdef\csname #1\endcsname}
811 \newcommand{\@namelet}[1]{%
812 \expandafter\let\csname #1\endcsname}
813 \newcommand{\@namelongdef}[1]{%
814 \long\expandafter\def\csname #1\endcsname}
815 % \end{macrocode}
816 % \end{macro}
817 % \end{macro}
818 % \end{macro}
819 % \end{macro}
820 %
821 % \begin{macro}{\memletcmdtxt}
822 % \begin{macro}{\memlettxttxt}
823 % \begin{macro}{\memlettxtcmd}
824 % More utility macros (for the user but perhaps better not to tell them about
825 % it in the manual) \\
826 % \verb?\memletcmdtxt{\cmd}{txt} -> \let\cmd\txt? \\
827 % \verb?\memlettxttxt{txta}{txtb} -> \let\txta\txtb? \\
828 % \verb?\memlettxtcmd{txt}{\cmd} -> \let\txt\cmd? \\
829 % \changes{v1.6180339f}{2009/06/25}{Added \cs{memletcmdtxt}, \cs{memlettxttxt}
830 % and \cs{memlettxtcmd}}
831 % \begin{macrocode}
832 \newcommand*{\memletcmdtxt}[2]{\expandafter\let\expandafter#1\csname#2\endcsname}
833 \newcommand*{\memlettxttxt}[1]{\expandafter\memletcmdtxt\csname#1\endcsname}
834 \newcommand*{\memlettxtcmd}[2]{\expandafter\let\csname#1\endcsname#2}
835 % \end{macrocode}
836 % \end{macro}
837 % \end{macro}
838 % \end{macro}
839 %
840 % \begin{macro}{\@nameedef}
841 % A shorthand for using \cs{protected@edef}.
842 % \begin{macrocode}
843 \newcommand{\@nameedef}[1]{%
844 \expandafter\protected@edef\csname #1\endcsname}
845
846 % \end{macrocode}
847 % \end{macro}
848 %
849 %
850 % \begin{macro}{\memjustarg}
851 % \begin{macro}{\memgobble}
852 % Utility macros \emph{that are not to be changed by any user!}
853 % \changes{v1.618}{2005/09/25}{Added \cs{memjustarg} and \cs{memgobble}}
854 % \begin{macrocode}
855 \newcommand{\memjustarg}[1]{#1}
856 \newcommand{\memgobble}[1]{}
857
858 % \end{macrocode}
859 % \end{macro}
860 % \end{macro}
861 % \changes{v3.6k}{2013/05/14}{Added macro used macros}
862 % \begin{macro}{\memsetmacroused}
863 % \begin{macro}{\memsetmacrounused}
864 % \begin{macro}{\memifmacroused}
865 % We may want to make auto adjustment to the layout unless the user
866 % has used certain macros (in which case the user is responsible for
867 % their own actions). To make this macro test easier, we provide a
868 % few utility macros. Their use should be self explanatory. Though
869 % note that the macro being marked as used, is given in full, i.e.,
870 % \begin{verbatim}
871 % \memsetmacroused\setlrmargins
872 % \end{verbatim}
873 % \begin{macrocode}
874 \newcommand\memsetmacroused[1]{%
875 \@namedef{mem@macro@used@\expandafter\@gobble\string#1}{00}}
876 \newcommand\memsetmacrounused[1]{%
877 \@namedef{mem@macro@used@\expandafter\@gobble\string#1}{01}}
878 \newcommand\memifmacroused[1]{%
879 \if\@nameuse{mem@macro@used@\expandafter\@gobble\string#1}%
880 \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
881
882 % \end{macrocode}
883 %
884 % \end{macro}
885 % \end{macro}
886 % \end{macro}
887 %
888 % \begin{macro}{\memsetlengthmin}
889 % \begin{macro}{\memsetlengthmax}
890 % Returns the min or max of two lengths. Note we may alter this in
891 % the future to use \cs{dimexpr}.
892 % \begin{macrocode}
893 \newcommand\memsetlengthmin[3]{\ifdim#2<#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
894 \newcommand\memsetlengthmax[3]{\ifdim#2>#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
895
896 % \end{macrocode}
897 %
898 % \end{macro}
899 % \end{macro}
900 %
901 % \subsection{Hooks and provided kernel commands}
902 %
903 % \changes{v3.8}{2023/07/28}{Section added}
904 %
905 %
906 % \changes{v3.8.4}{2025/09/24}{Polyfils for \cs{ExpandArgs} and hooks with arguments no longer needed}
907 % As the current requirement for the class is kernel of 2023/06/01, we
908 % currently have no need to add polyfils other than we provide
909 % \cs{IfFormatAtLeastTF} at the very start in order to short circuit
910 % of the kernel is too old.
911 %
912 %
913 % As we now require a kernel that have support for the new kernel
914 % hooks, we'll use this area to define the hooks and provide commands
915 % that are useful in even newer kernels, but might not be in the
916 % kernels we'd like to support.
917 %
918 % The \Lhook{memoir/subcaption} hook is executed after
919 % \cs{refstepcounter} in \cs{subcaption}, \cs{subbottom}, \cs{subtop}
920 % and similar.
921 % \begin{macrocode}
922 \NewHook{memoir/subcaption/aftercounter}
923
924 % \end{macrocode}
925 %
926 %
927 % \subsection{Classes, Packages and Files}
928 %
929 % \begin{macro}{\@memfakeusepackage}
930 % \cs{@memfakeusepackage}\marg{pack} fools \LaTeX{} into thinking
931 % that the \meta{pack.sty} package has been loaded.
932 % \changes{v1.4}{2003/11/22}{Added \cs{@memfakeusepackage} (from patch v1.9)}
933 % \begin{macrocode}
934 \newcommand*{\@memfakeusepackage}[1]{%
935 \@namelet{ver@#1.sty}\@empty}
936
937 % \end{macrocode}
938 % \end{macro}
939 %
940 % \begin{macro}{\EmulatedPackage}
941 % \begin{macro}{\EmulatedPackageWithOptions}
942 % There was some discussion on CTT\footnote{\textit{Re: breakurl + pdfetex
943 % for generating .dvi}, March 2005.} about how to prevent loading of
944 % a package. My response was to use \cs{@memfakusepackage}. Donald Arseneau
945 % came up with this comprehensive solution (there was a little discussion
946 % about naming with my final suggestion as here). \\
947 % \cs{EmulatedPackage}\marg{package}\oarg{date} \\
948 % \cs{EmulatedPackageWithOptions}\marg{option-list}\marg{package}\oarg{date} \\
949 %
950 % \changes{v1.618}{2005/09/04}{Added \cs{EmulatedPackage} and
951 % \cs{EmulatedPackageWithOptions}}
952 % \changes{v1.6180339}{2008/07/23}{Extended \cs{EmulatedPackage}}
953 % \begin{macrocode}
954 \providecommand*{\EmulatedPackage}{}
955 \renewcommand*{\EmulatedPackage}[1]{%
956 \@ifnextchar[{\@emulated@package{#1}}%
957 {\@emulated@package{#1}[\@empty]}%]
958 }
959 \providecommand*{\EmulatedPackageWithOptions}{}
960 \renewcommand*{\EmulatedPackageWithOptions}[2]{%
961 \PassOptionsToPackage{#1}{#2}%
962 \EmulatedPackage{#2}%
963 }
964 % \end{macrocode}
965 % \end{macro}
966 % \end{macro}
967 %
968 % \begin{macro}{\@emulated@package}
969 % The workhorse for the user commands. At some point we might want
970 % to do this differently as many users does not realise that a
971 % package is being blocked by memoir.
972 % \begin{macrocode}
973 \def\@emulated@package#1[#2]{%
974 \expandafter\xdef\csname ver@#1.\@pkgextension\endcsname{#2}%
975 \@ifundefined{opt@#1.\@pkgextension}%
976 {\@namedef{opt@#1.\@pkgextension}{}}{}%
977 \wlog{Package #1 \ifx\@empty#2\else[#2] \fi
978 \if,\csname opt@#1.\@pkgextension\endcsname,\else
979 (with options \csname opt@#1.\@pkgextension\endcsname) \fi
980 emulated by \@currname.}%
981 }
982 \@onlypreamble\EmulatedPackage
983 \@onlypreamble\EmulatedPackageWithOptions
984 \@onlypreamble\@emulated@package
985
986 % \end{macrocode}
987 % \end{macro}
988 %
989 % \begin{macro}{\DisemulatePackage}
990 % \cs{DisemulatePackage}\marg{package} undoes a previous
991 % \cs{EmulatedPackage...}
992 % \changes{v1.61803}{2008/01/30}{Added \cs{DisemulatePackage} from memptach v4.5}
993 % \changes{v1.6180339}{2008/07/23}{Fixed \cs{DisemulatePackage} from mempatch v5.1}
994 % \begin{macrocode}
995 \newcommand*{\DisemulatePackage}[1]{%
996 \@namelet{ver@#1.\@pkgextension}\relax
997 }
998 \@onlypreamble\DisemulatePackage
999
1000 % \end{macrocode}
1001 % \end{macro}
1002 %
1003 % \noindent
1004 % From 2020/10/01 format onwards we will implement file hooks via the
1005 % features provided by the \LaTeX\ kernel. This makes our code easier
1006 % to do (actually, users really ought to use these hook macros instead
1007 % of the ones the class provides) and it eliminates the need for us to
1008 % redefine \cmd{\InputIfFileExists}.
1009 % \changes{v3.7m}{2020/08/06}{Reimplemented file/package/class hooks}
1010 % \changes{v3.8.4}{2025/09/24}{removed format check}
1011 %
1012 % As mentioned in \cite{LTHOOKS,LTFILEHOOK} the kernel provides hooks
1013 % at the start of files, packages and classes. The class you implement
1014 % the latter via our definition of the file hook. We will now instead
1015 % use the separate hooks. Note that we will \emph{not} be adding any
1016 % extra labels to these hooks and will provide no interface to do
1017 % so. If more control is needed, please use the kerel interface directly.
1018 % \begin{macro}{\AtBeginFile}
1019 % \begin{macro}{\AtEndFile}
1020 % \cs{AtBeginFile}\marg{file}\marg{code} inserts \meta{code}
1021 % just before \meta{file} is input. Similarly \cs{AtEndFile} inserts
1022 % just after input.
1023 %
1024 % \medskip\noindent
1025 % \textbf{Breaking change:} In the old implemenation
1026 % \verb!\AtEndFile{file}! worked for \texttt{file.tex} even if one
1027 % did not speficy the extension. Now you will need to use
1028 % \verb!\AtEndFile{file.tex}! explicitly.
1029 % \changes{v3.7n}{2020/10/04}{The old AtXFile code required \#\
1030 % doubling. The new does not, and this is not backwards compatible. By
1031 % suggestion from David Carlisle we change the code a little such that
1032 % \#\ is needed}
1033 % We add a \cs{temp} trick suggested by David Carlisle as the old code
1034 % required \texttt{\#} doubling and the new does not. To be backwards
1035 % compatible we force required \texttt{\#} doubling.
1036 % \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
1037 % hook name}
1038 % \begin{macrocode}
1039 \newcommand\AtBeginFile[2]{\def\temp{\AddToHook{file/#1/before}{#2}}\temp}
1040 \newcommand\AtEndFile[2]{\def\temp{\AddToHook{file/#1/after}{#2}}\temp}
1041
1042 % \end{macrocode}
1043 % \end{macro}
1044 % \end{macro}
1045 % \begin{macro}{\AtBeginPackage}
1046 % \begin{macro}{\AtEndPackage}
1047 % \begin{macro}{\RequireAtEndPackage}
1048 % \cs{AtBeginPackage}\marg{pack}\marg{code} inserts \meta{code}
1049 % just before the \meta{pack} package is input, and \cs{AtEndPackage}
1050 % is the equivalent for after input. \cs{RequireAtEndPackage} inserts
1051 % \meta{code} either at the end of \meta{pack}, or immediately if
1052 % \meta{pack} has already been input.
1053 % \changes{v3.7n}{2020/10/04}{The old AtXPackage code required \#\
1054 % doubling. The new does not, and this is not backwards compatible. By
1055 % suggestion from David Carlisle we change the code a little such that
1056 % \#\ is needed}
1057 % We add a \cs{temp} trick suggested by David Carlisle as the old code
1058 % required \#\ doubling and the new does not. To be backwards
1059 % compatible we force required \#\ doubling.
1060 % \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
1061 % hook name}
1062 % \begin{macrocode}
1063 \newcommand\AtBeginPackage[2]{\def\temp{\AddToHook{package/#1/before}{#2}}\temp}
1064 \newcommand\AtEndPackage[2]{\def\temp{\AddToHook{package/#1/after}{#2}}\temp}
1065 \newcommand{\RequireAtEndPackage}[2]{%
1066 \@ifpackageloaded{#1}{#2}{\AtEndPackage{#1}{#2}}}
1067
1068 % \end{macrocode}
1069 % \end{macro}
1070 % \end{macro}
1071 % \end{macro}
1072 % \begin{macro}{\AtBeginClass}
1073 % \begin{macro}{\AtEndClass}
1074 % \begin{macro}{\RequireAtEndClass}
1075 % \cs{AtBeginClass}\marg{class}\marg{code} and friends are the class
1076 % equivalents of \cs{AtBeginPackage} and friends.
1077 % \changes{v3.7n}{2020/10/04}{The old AtXPackage code required \#\
1078 % doubling. The new does not, and this is not backwards compatible. By
1079 % suggestion from David Carlisle we change the code a little such that
1080 % \#\ is needed}
1081 % We add a \cs{temp} trick suggested by David Carlisle as the old code
1082 % required \#\ doubling and the new does not. To be backwards
1083 % compatible we force required \#\ doubling.
1084 % \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
1085 % hook name}
1086 % \begin{macrocode}
1087 \newcommand\AtBeginClass[2]{\def\temp{\AddToHook{class/#1/before}{#2}}\temp}
1088 \newcommand\AtEndClass[2]{\def\temp{\AddToHook{class/#1/after}{#2}}\temp}
1089 \newcommand{\RequireAtEndClass}[2]{%
1090 \@ifclassloaded{#1}{#2}{\AtEndClass{#1}{#2}}}
1091
1092 % \end{macrocode}
1093 % \end{macro}
1094 % \end{macro}
1095 % \end{macro}
1096 % ^^A % \noindent
1097 % ^^A % Here follows the old code, which will still be used on older formats:
1098 % ^^A %
1099 % ^^A % Code, based on a hint from Morten H{\o}gholm\footnote{CTT posting
1100 % ^^A % 2005/11/08, \textit{Re: Checking for packages froma class...
1101 % ^^A % revisited}} that the \Lpack{scrlfile} package from
1102 % ^^A % \Lpack{koma-script} includes commands such as \\
1103 % ^^A % \cs{AfterFile}\marg{file}\marg{code} \\
1104 % ^^A % plus before and after classes and packages.
1105 % ^^A % \changes{v1.16803}{2008/01/30}{Added various \cs{AtBegin...} and
1106 % ^^A % \cs{AtEnd...} macros (mempatch v4.2)}
1107 % ^^A %
1108 % ^^A % Extend the \cs{InputIfFileExists} macro to call hooks before and
1109 % ^^A % the actual inputting. The kernel version (as of 2005/11/21) is:
1110 % ^^A % \begin{verbatim}
1111 % ^^A % \newcommand{\InputIfFileExists}[2]{%
1112 % ^^A % \IfFileExists{#1}%
1113 % ^^A % {\#2\@addtofilelist{#1}\@@input \@filef@und}}
1114 % ^^A % \end{verbatim}
1115 % ^^A % and as of 2019/10/01:
1116 % ^^A % \begin{verbatim}
1117 % ^^A % \DeclareRobustCommand \InputIfFileExists[2]{%
1118 % ^^A % \IfFileExists{#1}%
1119 % ^^A % {\expandafter\@swaptwoargs\expandafter
1120 % ^^A % {\@filef@und}{#2\@addtofilelist{#1}\@@input}}}
1121 % ^^A % \end{verbatim}
1122 % ^^A % Just to make sure we still work on formats prior and after
1123 % ^^A % 2019/10/01 we `redefine' both
1124 % ^^A %
1125 % ^^A % \begin{macro}{\InputIfFileExists}
1126 % ^^A % Effectively all file input is handled by this macro. Extend it
1127 % ^^A % by adding pre- and post- input hooks.
1128 % ^^A %
1129 % ^^A % \changes{3.7i}{2019/10/22}{Added latest kernel changes, special
1130 % ^^A % thanks to Phelype Oleinik}
1131 % ^^A % \begin{macrocode}
1132 % ^^A \ifcsname InputIfFileExists \endcsname% looking for an explicit space
1133 % ^^A % here aka the robust version
1134 % ^^A \DeclareRobustCommand \InputIfFileExists[2]{%
1135 % ^^A \IfFileExists{#1}%
1136 % ^^A {%
1137 % ^^A \expandafter\@swaptwoargs\expandafter
1138 % ^^A {\@filef@und\m@matendf{#1}\killm@matf{#1}}{%
1139 % ^^A #2\@addtofilelist{#1}\m@matbeginf{#1}\@@input%
1140 % ^^A }%
1141 % ^^A }%
1142 % ^^A }
1143 % ^^A \else
1144 % ^^A % Old definition
1145 % ^^A \renewcommand{\InputIfFileExists}[2]{%
1146 % ^^A \IfFileExists{#1}%
1147 % ^^A {#2\@addtofilelist{#1}\m@matbeginf{#1}%
1148 % ^^A \@@input \@filef@und
1149 % ^^A \m@matendf{#1}%
1150 % ^^A \killm@matf{#1}}}
1151 % ^^A \fi
1152 % ^^A
1153 % ^^A % \end{macrocode}
1154 % ^^A % \end{macro}
1155 % ^^A %
1156 % ^^A % \begin{macro}{\m@matbeginf}
1157 % ^^A % \begin{macro}{\m@matendf}
1158 % ^^A % \cs{m@matbeginf}\marg{file} calls macro \cs{file-m@mfb} if it
1159 % ^^A % is defined. Similarly \cs{m@matendf}\marg{file} calls
1160 % ^^A % \cs{file-m@mfe} if it is defined.
1161 % ^^A % \begin{macrocode}
1162 % ^^A \newcommand{\m@matbeginf}[1]{\@ifundefined{#1-m@mfb}{}%
1163 % ^^A {\@nameuse{#1-m@mfb}}}
1164 % ^^A \newcommand{\m@matendf}[1]{\@ifundefined{#1-m@mfe}{}%
1165 % ^^A {\@nameuse{#1-m@mfe}}}
1166 % ^^A
1167 % ^^A % \end{macrocode}
1168 % ^^A % \end{macro}
1169 % ^^A % \end{macro}
1170 % ^^A %
1171 % ^^A % \begin{macro}{\killm@matf}
1172 % ^^A % \cs{killm@matf}\marg{file} undefines the \cs{file-m@mfb} and
1173 % ^^A % \cs{file-m@mfe} macros.
1174 % ^^A % ^^A \begin{macrocode}
1175 % ^^A % ^^A we use the better defintion below
1176 % ^^A % ^^A % \newcommand*{\killm@matf}[1]{%
1177 % ^^A % ^^A % \@namelet{#1-m@mfb}\relax
1178 % ^^A % ^^A % \@namelet{#1-m@mfe}\relax}
1179 % ^^A % ^^A
1180 % ^^A % ^^A \end{macrocode}
1181 % ^^A %
1182 % ^^A % ^^A \subsection{Input files into tabulars, and etex}
1183 % ^^A %
1184 % ^^A % M.J. Williams (CTT \textit{\cs{noalign} problem with \cs{input} and
1185 % ^^A % tabular in memoir class}, 28 Aug 2007) reported that using \cs{input} in a
1186 % ^^A % tabular resulted in errors. His example was:
1187 % ^^A % \begin{verbatim}
1188 % ^^A % ...
1189 % ^^A % \begin{tabular}{c|c} \hline
1190 % ^^A % 1 & 2 \\ \hline
1191 % ^^A % \input{data} \hline
1192 % ^^A % 5 & 6 \\ \hline
1193 % ^^A % \end{tabular}
1194 % ^^A % \end{verbatim}
1195 % ^^A % where \texttt{data.tex} contains the single line (and no newline) \\
1196 % ^^A % \verb?3 & 4 \\?
1197 % ^^A %
1198 % ^^A % Morten H{\o}gholm noted that the problem
1199 % ^^A % was caused by \Lpack{memoir}'s extension to \cs{input}
1200 % ^^A % and gave a solution that depends on processing via
1201 % ^^A % \texttt{etex} rather than \texttt{tex}.
1202 % ^^A %
1203 % ^^A % Here's Morten's fix. Quoting, in part:
1204 % ^^A % \begin{quotation}
1205 % ^^A % \Lpack{memoir} extends the file loading mechanism by providing
1206 % ^^A % \cs{AtBeginFile} and \cs{AtEndFile} whose arguments are executed as
1207 % ^^A % the names indicate. \ldots after inputting a file the storage bins are
1208 % ^^A % emptied. The problem [in your case] is that this emptying is an
1209 % ^^A % assignment and so starts a new tabular cell and \cs{hline} is only
1210 % ^^A % allowed after \verb?\\? or other \cs{hline}s.
1211 % ^^A %
1212 % ^^A % \ldots the tabular environment wraps each tabular cell in additional
1213 % ^^A % groups so one can do an explicit test for which type of group we are in.
1214 % ^^A % If tested to be in an align group \emph{and} in vertical mode it means
1215 % ^^A % TeX hasn't found something to start a new cell and
1216 % ^^A % then \cs{noalign} can be used.
1217 % ^^A % \end{quotation}
1218 % ^^A %
1219 % ^^A % \begin{macrocode}
1220 % ^^A %% \ifetex
1221 % ^^A \newcommand*{\killm@matf}[1]{%
1222 % ^^A \ifnum 6=\currentgrouptype
1223 % ^^A \ifvmode
1224 % ^^A \expandafter\expandafter\expandafter\@firstoftwo
1225 % ^^A \expandafter\expandafter\expandafter\noalign
1226 % ^^A \fi
1227 % ^^A \fi
1228 % ^^A \@firstofone
1229 % ^^A {\@namelet{#1-m@mfb}\relax
1230 % ^^A \@namelet{#1-m@mfe}\relax
1231 % ^^A }%
1232 % ^^A }
1233 % ^^A %% \fi
1234 % ^^A
1235 % ^^A % \end{macrocode}
1236 % ^^A % \end{macro}
1237 % ^^A %
1238 % ^^A % \begin{macro}{\AtBeginFile}
1239 % ^^A % \begin{macro}{\AtEndFile}
1240 % ^^A % \cs{AtBeginFile}\marg{file}\marg{code} inserts \meta{code}
1241 % ^^A % just before \meta{file} is input. Similarly \cs{AtEndFile} inserts
1242 % ^^A % just after input.
1243 % ^^A % \begin{macrocode}
1244 % ^^A \newcommand{\AtBeginFile}[2]{\@ifundefined{#1-m@mfb}%
1245 % ^^A {\@namedef{#1-m@mfb}{#2}}%
1246 % ^^A {\expandafter\addtodef\csname #1-m@mfb\endcsname{}{#2}}}
1247 % ^^A \newcommand{\AtEndFile}[2]{\@ifundefined{#1-m@mfe}%
1248 % ^^A {\@namedef{#1-m@mfe}{#2}}%
1249 % ^^A {\expandafter\addtodef\csname #1-m@mfe\endcsname{}{#2}}}
1250 % ^^A
1251 % ^^A % \end{macrocode}
1252 % ^^A % \end{macro}
1253 % ^^A % \end{macro}
1254 % ^^A %
1255 % ^^A % \begin{macro}{\AtBeginPackage}
1256 % ^^A % \begin{macro}{\AtEndPackage}
1257 % ^^A % \begin{macro}{\RequireAtEndPackage}
1258 % ^^A % \cs{AtBeginPackage}\marg{pack}\marg{code} inserts \meta{code}
1259 % ^^A % just before the \meta{pack} package is input, and \cs{AtEndPackage}
1260 % ^^A % is the equivalent for after input. \cs{RequireAtEndPackage} inserts
1261 % ^^A % \meta{code} either at the end of \meta{pack}, or immediately if
1262 % ^^A % \meta{pack} has already been input.
1263 % ^^A % \begin{macrocode}
1264 % ^^A \newcommand{\AtBeginPackage}[2]{%
1265 % ^^A \AtBeginFile{#1.\@pkgextension}{#2}}
1266 % ^^A \newcommand{\AtEndPackage}[2]{%
1267 % ^^A \AtEndFile{#1.\@pkgextension}{#2}}
1268 % ^^A \newcommand{\RequireAtEndPackage}[2]{%
1269 % ^^A \@ifpackageloaded{#1}{#2}%
1270 % ^^A {\AtEndFile{#1.\@pkgextension}{#2}}}
1271 % ^^A
1272 % ^^A % \end{macrocode}
1273 % ^^A % \end{macro}
1274 % ^^A % \end{macro}
1275 % ^^A % \end{macro}
1276 % ^^A %
1277 % ^^A % \begin{macro}{\AtBeginClass}
1278 % ^^A % \begin{macro}{\AtEndClass}
1279 % ^^A % \begin{macro}{\RequireAtEndClass}
1280 % ^^A % \cs{AtBeginClass}\marg{class}\marg{code} and friends are the class
1281 % ^^A % equivalents of \cs{AtBeginPackage} and friends.
1282 % ^^A % \begin{macrocode}
1283 % ^^A \newcommand{\AtBeginClass}[2]{%
1284 % ^^A \AtBeginFile{#1.\@clsextension}{#2}}
1285 % ^^A \newcommand{\AtEndClass}[2]{%
1286 % ^^A \AtEndFile{#1.\@clsextension}{#2}}
1287 % ^^A \newcommand{\RequireAtEndClass}[2]{%
1288 % ^^A \@ifclassloaded{#1}{#2}%
1289 % ^^A {\AtEndFile{#1.\@clsextension}{#2}}}
1290 % ^^A
1291 % ^^A % \end{macrocode}
1292 % ^^A % \end{macro}
1293 % ^^A % \end{macro}
1294 % ^^A % \end{macro}
1295 % ^^A %
1296 % ^^A % \begin{macrocode}
1297 % ^^A
1298 % ^^A % end of else part of format check
1299 % ^^A }
1300 % ^^A
1301 % ^^A % \end{macrocode}
1302 % ^^A %
1303 %
1304 %
1305 % \begin{macro}{\phantomsection}
1306 % Whenever \Lpack{hyperref} is used and one uses fx
1307 % \cs{addcontentsline} at a place that has to hypertarget (e.g. a
1308 % counter being stepped) one adds \cs{phantomsection}.
1309 % \begin{macrocode}
1310 \newcommand{\phantomsection}{}
1311
1312 % \end{macrocode}
1313 % \end{macro}
1314 %
1315 % ^^A dlf note: kernal macro redefinition
1316 % \begin{macro}{\nofiles}
1317 % The kernel's \cs{nofiles}, which surprisingly may be called \emph{before}
1318 % the class is loaded, lets \cs{makeindex} to \cs{relax}. This could
1319 % cause problems\footnote{As reported by Heiko Oberdiek on 2005/07/09.}
1320 % with my initial version of \cs{makeindex}.
1321 % Here's the kernel \cs{nofiles} definition:
1322 % \begin{verbatim}
1323 % \def\nofiles{%
1324 % \@fileswfalse% flag for suppressing \immediate \writes
1325 % \typeout{No auxiliary output files.^^J}%
1326 % \long\def\protected@write##1##2##3%
1327 % {\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
1328 % \let\makeindex\relax
1329 % \let\makeglossary\relax}
1330 % \end{verbatim}
1331 % To get it to work for when \cs{makeindex}es optional argument is
1332 % used I let \cs{makeindex} itself deal with \cs{nofiles} (and
1333 % also \cs{makeglossary}).
1334 % \changes{v1.618}{2005/09/25}{Modified the kernel's \cs{nofiles}}
1335 % \begin{macrocode}
1336 \renewcommand*{\nofiles}{%
1337 \@fileswfalse% flag for suppressing \immediate \writes
1338 \typeout{No auxiliary output files.^^J}%
1339 \long\def\protected@write##1##2##3%
1340 {\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
1341 }
1342
1343 % \end{macrocode}
1344 % \end{macro}
1345 %
1346 % \begin{macro}{\memsetcounter}
1347 % A wrapper round \cs{setcounter}. I want to use this in the \texttt{aux} file.
1348 % \changes{v1.61803}{2008/01/30}{Added \cs{memsetcounter}}
1349 % \begin{macrocode}
1350 \newcommand*{\memsetcounter}[2]{\setcounter{#1}{#2}}
1351 \AtBeginDocument{\immediate\write\@mainaux{%
1352 \string\providecommand*{\string\memsetcounter}[2]{}}}
1353
1354 % \end{macrocode}
1355 % \end{macro}
1356 %
1357 % \subsection{For package documentation}
1358 %
1359 % Some macros that may be useful for documenting LaTeX code. These
1360 % have principally come from \texttt{doc.dtx}.
1361 %
1362 % \begin{macro}{\bs}
1363 % Prints \verb?\?
1364 % \begin{macrocode}
1365 \def\bs{\texttt{\char`\\}}
1366 % \end{macrocode}
1367 % \end{macro}
1368 %
1369 % \begin{macro}{\l@nohyphenation}
1370 % \begin{macro}{\meta}
1371 % \begin{macro}{\meta@font@select}
1372 % From \texttt{doc.dtx} \\
1373 % \cs{meta}\marg{arg} prints \meta{arg}.
1374 % \begin{macrocode}
1375 \ifx\l@nohyphenation\undefined
1376 \newlanguage\l@nohyphenation
1377 \fi
1378 \DeclareRobustCommand{\meta}[1]{%
1379 \ensuremath\langle
1380 \ifmmode \expandafter \nfss@text \fi
1381 {%
1382 \meta@font@select
1383 \edef\meta@hyphen@restore
1384 {\hyphenchar\the\font\the\hyphenchar\font}%
1385 \hyphenchar\font\m@ne
1386 \language\l@nohyphenation
1387 #1\/%
1388 \meta@hyphen@restore
1389 }\ensuremath\rangle
1390 }
1391 \def\meta@font@select{\itshape}
1392
1393 % \end{macrocode}
1394 % \end{macro}
1395 % \end{macro}
1396 % \end{macro}
1397 %
1398 % \begin{macro}{\marg}
1399 % \begin{macro}{\oarg}
1400 % \begin{macro}{\parg}
1401 % Robust versions of the \texttt{doc.dtx} macros. \\
1402 % \cs{marg}\marg{arg} prints \marg{arg} \\
1403 % \cs{oarg}\marg{arg} prints \oarg{arg} \\
1404 % \cs{parg}\marg{arg} prints \parg{arg} \\
1405 % \begin{macrocode}
1406 \DeclareRobustCommand{\marg}[1]{%
1407 {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
1408 \DeclareRobustCommand{\oarg}[1]{%
1409 {\ttfamily\char`\[}\meta{#1}{\ttfamily\char`\]}}
1410 \DeclareRobustCommand{\parg}[1]{%
1411 {\ttfamily\char`\(}\meta{#1}{\ttfamily\char`\)}}
1412 % \end{macrocode}
1413 % \end{macro}
1414 % \end{macro}
1415 % \end{macro}
1416 %
1417 % \begin{macro}{\cs}
1418 % \verb?\cs{arg}? prints \cs{arg}.
1419 % \begin{macrocode}
1420 \DeclareRobustCommand{\cs}[1]{\texttt{\char`\\#1}}
1421 % \end{macrocode}
1422 % \end{macro}
1423 %
1424 %
1425 % \begin{macro}{\cmdprint}
1426 % \begin{macro}{\cmd}
1427 % From Heiko Oberdiek CTT 2001/05/26 (print and index a command) \\
1428 % \verb?\cmdprint{\fred}? prints \verb?\fred? \\
1429 % \verb?\cmd{\fred}? prints and indexes \verb?\fred?. NOTE It assumes that
1430 % \verb!?! is the `actual' character for MakeIndex (it is normally \verb!@!
1431 % but that is not much use if a command includes \verb!@! as part of its name).
1432 % \begin{macrocode}
1433 \newcommand{\cmdprint}[1]{\texttt{\string#1}}
1434 \newcommand{\cmd}[1]{\cmdprint{#1}%
1435 \index{\expandafter\@gobble\string#1?\string\cmdprint{\string#1}}}
1436
1437 % \end{macrocode}
1438 % \end{macro}
1439 % \end{macro}
1440 %
1441 %
1442 %
1443 %
1444 % \subsection{Checking the processor}
1445 %
1446 % As of November 2019, we load the \Lpack{iftex} package in order to
1447 % the the various processor tests. The package was updated in 2019 to
1448 % cover the functionality of the \Lpack{ifpdf}, \Lpack{ifetex},
1449 % \Lpack{ifxetex} and \Lpack{ifluatex} packages. You can find details
1450 % about its use in \cite{IFTEX}.
1451 % \changes{v3.7i}{2019/11/11}{Changed
1452 % ifX package loading to just loading the new \Lpack{iftex}
1453 % package. At the request of the LaTeX Project Team.}
1454 % \begin{macrocode}
1455 \RequirePackage{iftex}[2019/11/07]
1456 % \end{macrocode}
1457 % The \Lpack{iftex} provides the following tests
1458 % (and several more):
1459 % \begin{macro}{\ifpdf}
1460 % True if the output mode is PDF. Useful if for example you are
1461 % working in an environment where you need to provide explicit code
1462 % for the LaTeX+dvips route.
1463 % \end{macro}
1464 % \begin{macro}{\ifxetex}
1465 % True if the XeTeX engine is being used.
1466 % \end{macro}
1467 % \begin{macro}{\ifluatex}
1468 % True if the LuaTeX engine is being used. Useful if you want to add
1469 % code that only apply under the LuaTeX based engines.
1470 % \end{macro}
1471 %
1472 %
1473 %
1474 % ^^A % Prior to 2008/07/22 the \Lpack{hyperref} package was modified in such a
1475 % ^^A % way as to produce warnings about versions of the \Lpack{ifpdf} and
1476 % ^^A % \Lpack{ifxetex} packages when \Lpack{hyperref} was used with versions
1477 % ^^A % v1.618033,
1478 % ^^A % v1.61803, or v1.618 mempatch v4.9 of the class.
1479 % ^^A % \Lpack{hyperref}'s author refused to
1480 % ^^A % make any changes to his package, insisting that emulating a package was
1481 % ^^A % `ugly hacking'. He did, though, provide an example code that could be
1482 % ^^A % added to memoir
1483 % ^^A % to use a package if it was available. I have used it for the emulations
1484 % ^^A % in this section. There will be no further changes to the class to accomodate
1485 % ^^A % any further changes to \Lpack{hyperref} --- it's easy for a package to
1486 % ^^A % determine what class is being used and make arrangements accordingly,
1487 % ^^A % especially as there are not all that many classes. There are hundreds
1488 % ^^A % of packages that might be used with a particular class and it would be
1489 % ^^A % senseless for a class to attempt to take account of everything that might
1490 % ^^A % be used with it.
1491 % ^^A %
1492 % ^^A % Note (2016/05/16): Due to recent changes in Luatex, most notably the
1493 % ^^A % removal of several \cs{pdf...} macro, several PDF tests fail with
1494 % ^^A % LuaLaTeX. As a temporary measure the following is used to restore
1495 % ^^A % the old functionality when a newer LuaLaTeX is used. Code courtesy
1496 % ^^A % of David Carlisle. At some point we will include some of this into
1497 % ^^A % the class.
1498 % ^^A % \changes{v3.7f}{2016/05/16}{Temp measure to make the class work with
1499 % ^^A % updated luatex}
1500 % ^^A % \changes{v3.7g}{2018/03/09}{\Lpack{luatex85} removed again, now
1501 % ^^A % relying on external \cs{if<engine>} packages and have rewritten the
1502 % ^^A % macros that use \cs{pdf...}}
1503 % ^^A % ^^A % \begin{macrocode}
1504 % ^^A % ^^A \ifx\pdfextension\@undefined\else
1505 % ^^A % ^^A \RequirePackage{luatex85}
1506 % ^^A % ^^A \fi
1507 % ^^A % ^^A
1508 % ^^A % ^^A % \end{macrocode}
1509 % ^^A %
1510 % ^^A %
1511 % ^^A % \begin{macro}{\ifpdf}
1512 % ^^A % This can be used to check whether or not a document is being processed
1513 % ^^A % by \LaTeX{} or pdf\LaTeX. We will simply require the \Lpack{ifpdf} package.
1514 % ^^A % \changes{v1.0}{2001/09/21}{Made checking of \cs{pdfouput} more robust}
1515 % ^^A % \changes{v1.618}{2005/09/03}{Prohibit loading the ifpdf package (mempatch v3.9)}
1516 % ^^A % \changes{v1.618033}{2008/06/02}{Further improved pdf checking}
1517 % ^^A % \changes{v1.6180339}{2008/07/23}{Use ifpdf package if available}
1518 % ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifpdf} is already
1519 % ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
1520 % ^^A % then using \cs{newif}\cs{ifpdf} will cause TeX to eat up a lot of
1521 % ^^A % code. We fix this using a hint by Will Robertson.}
1522 % ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
1523 % ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
1524 % ^^A % do not have them}
1525 % ^^A % \begin{macrocode}
1526 % ^^A % \RequirePackage{ifpdf}[2017/03/15]
1527 % ^^A % \end{macrocode}
1528 % ^^A % \end{macro}
1529 % ^^A %
1530 % ^^A % \begin{macro}{\ifetex}
1531 % ^^A % Check if \texttt{etex} is being used. We will simply require the \Lpack{ifetex} package.
1532 % ^^A % \changes{v1.61803}{2008/01/30}{Added check for etex (mempatch v4.9)}
1533 % ^^A % \changes{v1.618033}{2008/06/02}{Improved check for etex}
1534 % ^^A % \changes{v1.6180339}{2008/07/23}{Use an ifetex package if available}
1535 % ^^A % \changes{v1.6180339c}{2008/12/27}{Changed ifetex message from Warning to Info}
1536 % ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
1537 % ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
1538 % ^^A % do not have them}
1539 % ^^A % \begin{macrocode}
1540 % ^^A % \RequirePackage{ifetex}
1541 % ^^A % \end{macrocode}
1542 % ^^A % \end{macro}
1543 % ^^A % Having supplied an \cs{ifpdf} to check if pdfLaTeX is being used,
1544 % ^^A % here's one for XeTeX.
1545 % ^^A %
1546 % ^^A % \begin{macro}{\ifxetex}
1547 % ^^A % Checks if XeTeX is being used. We will simply require the \Lpack{ifxetex} package.
1548 % ^^A % \changes{v1.61803}{2008/01/30}{Added checks for XeTeX (mempatch v4.9)}
1549 % ^^A % \changes{v1.6180339}{2008/07/23}{Use ifxetex package if available}
1550 % ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifxetex} is already
1551 % ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
1552 % ^^A % then using \cs{newif}\cs{ifxetex} will cause TeX to eat up a lot of
1553 % ^^A % code. We fix this using a hint by Will Robertson.}
1554 % ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
1555 % ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
1556 % ^^A % do not have them}
1557 % ^^A % \begin{macrocode}
1558 % ^^A % \RequirePackage{ifxetex}[2010/09/12]
1559 % ^^A % \end{macrocode}
1560 % ^^A % \end{macro}
1561 % ^^A %
1562 % ^^A % \begin{macro}{\ifluatex}
1563 % ^^A % Check if \texttt{luatex} is being used. We will simply require the \Lpack{ifluatex} package.
1564 % ^^A % \changes{v1.61803}{2008/01/30}{Added check for luatex}
1565 % ^^A % \changes{v1.6180339}{2008/07/23}{Use an ifluatex package if available}
1566 % ^^A % \changes{v1.6180339c}{2008/12/31}{It seems that Heiko Oberdiek has created an
1567 % ^^A % ifluatex package.}
1568 % ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifluatex} is already
1569 % ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
1570 % ^^A % then using \cs{newif}\cs{ifluatex} will cause TeX to eat up a lot of
1571 % ^^A % code. We fix this using a hint by Will Robertson.}
1572 % ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
1573 % ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
1574 % ^^A % do not have them}
1575 % ^^A % \begin{macrocode}
1576 % ^^A % \RequirePackage{ifluatex}[2016/05/16]
1577 % ^^A %
1578 % ^^A % \end{macrocode}
1579 % ^^A % \end{macro}
1580 % ^^A %
1581 %
1582 %
1583 %
1584 % \subsection{Extending an existing macro}
1585 %
1586 %
1587 % My usual technique for modifying the code of an existing macro was
1588 % to use \cs{renewcommand}. However it slowly became apparent that
1589 % many of such modifications merely consisted of adding some code at
1590 % either the start or end of the existing definition. In June 2000 I
1591 % posed a question on the \texttt{comp.text.tex} newsgroup about this,
1592 % and Michael Downes and Heiko Oberdiek were kind enough to respond.
1593 % The responses arrived almost simultaneously, both supplying methods
1594 % for adding code at the end of a macro defined to take one
1595 % argument. Michael Downes' response included a remark about it
1596 % probably being too much effort to formulate a general way of doing
1597 % this. Heiko Oberdiek almost immediately replied with such a
1598 % generalisation.
1599 %
1600 % The following code, which I have extracted from a package that I
1601 % wrote but which I did not submit to CTAN, incorporates the work of both
1602 % Michael and Heiko. I have added a bit. All errors are my responsibility.
1603 % Michael went on the write the \Lpack{patchcmd} package which is
1604 % a generalisation of the facilities below and so there was no need for
1605 % my more restricted package.
1606 % \changes{v0.33}{2001/08/31}{Replaced \cs{appendiarg} with \cs{addtodef}
1607 % and friends}
1608 %
1609 % \begin{macro}{\wo@dmacro}
1610 % Heiko Oberdiek suggested\footnote{Via email on 2000/07/12.} that
1611 % \meta{macro} should be tested for being the name of a macro, rather than
1612 % using the normal \LaTeX{} test against it being undefined. He supplied
1613 % the code for performing the macro name test.
1614 %
1615 % \cs{wo@dmacro} is a helper for handling the string `macro:'.
1616 % \begin{macrocode}
1617 \edef\wo@dmacro{%
1618 \string m\string a\string c\string r\string o\string :%
1619 }
1620
1621 % \end{macrocode}
1622 % \end{macro}
1623 %
1624 % \begin{macro}{\wo@difmacro@begingroup}
1625 % This seems to take two arguments:
1626 % \cs{wo@difmacro@begingroup}\marg{macro}\marg{code}, where
1627 % \meta{macro} should be the name of a defined macro and \meta{code}
1628 % is code to be executed if and only if \meta{macro} \emph{is} a
1629 % defined macro.
1630 % \begin{macrocode}
1631 \def\wo@difmacro@begingroup#1{%
1632 % \end{macrocode}
1633 % Start a group.
1634 % \begin{macrocode}
1635 \begingroup
1636 % \end{macrocode}
1637 % Test if \verb?#1? is a defined macro; \cs{wo@dparsemacro} does most of the work.
1638 % \begin{macrocode}
1639 \edef\x{%
1640 \noexpand\wo@dparsemacro\meaning#1\wo@dmacro\string -%
1641 }%
1642 \x\@nil{#1}%
1643 }
1644
1645 % \end{macrocode}
1646 % \end{macro}
1647 %
1648 % \begin{macro}{\wo@dparsemacro}
1649 % This is called by \cs{wo@difmacro@begingroup}. If \meta{macro} is not
1650 % a defined macro it prints a warning and closes the group begun by
1651 % \cs{wo@difmacro@begingroup}. Otherwise it process the \meta{code} which
1652 % \emph{must} close the group.
1653 % \begin{macrocode}
1654 \begingroup
1655 \edef\x{\endgroup
1656 \def\noexpand\wo@dparsemacro##1\wo@dmacro##2\string -}%
1657 \x#3\@nil#4{%
1658 \ifx\\#3\\%
1659 \endgroup
1660 \@memwarn{\string `\string #4\string ' is not a macro}%
1661 \expandafter\@gobble
1662 \else
1663 \expandafter\@firstofone
1664 \fi
1665 }
1666
1667 % \end{macrocode}
1668 % \end{macro}
1669 %
1670 % \begin{macro}{\addtodef}
1671 % \begin{macro}{\addtodef*}
1672 % \begin{macro}{\wo@daddtodef}
1673 % The command \cs{addtodef}\marg{macro}\marg{start-stuff}\marg{end-stuff}
1674 % adds stuff at the start and/or end of an argumentless macro.
1675 % Initially the code for appending was a reimplementation of the
1676 % kernel \cs{g@addto@macro} command (from \file{ltclass.dtx}).
1677 % Later, at Michael Downes' suggestion, I combined
1678 % appending and prepending stuff into a single command.
1679 % Actually, there is no real need to have both
1680 % \cs{addtodef} and \cs{addtodef*} as the body of the command
1681 % being amended has no argument,
1682 % but both versions are provided for consistency.
1683 %
1684 % The kernel \cs{@star@or@long} and \cs{l@ngrel@x} commands
1685 % (in \file{ltdefns.dtx}) are used to handle
1686 % the potential \verb?*? after the command name.
1687 % \changes{v3.8.3}{2024/02/01}{Marked \cs{addtodef(*)} as deprecated}
1688 % \MarkedForDeprecation{\cs{addtodef(*)}}
1689 % \begin{macrocode}
1690 \def\addtodef{%
1691 \MarkDeprecated{\addtodef}{in 2026, use instead \string\patchcmd,\MessageBreak%
1692 \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
1693 (which is autoloaded by the class)}
1694 \@star@or@long\wo@daddtodef}
1695 % \end{macrocode}
1696 % The \cs{@star@or@long} command dealt with a possible \verb?*? and now
1697 % \cs{wo@daddtodef} does the work. It picks up the three arguments
1698 % that the user thinks belong to \cs{addtodef}, namely \meta{macro},
1699 % \meta{start-stuff} and \meta{end-stuff}.
1700 % \begin{macrocode}
1701 \long\def\wo@daddtodef#1#2#3{%
1702 % \end{macrocode}
1703 % Check if \meta{macro} has been defined.
1704 % \begin{macrocode}
1705 \wo@difmacro@begingroup{#1}{%
1706 % \end{macrocode}
1707 % If \meta{macro} is defined then store the tokens corresponding to the
1708 % body of \meta{macro} and the extra \meta{-stuff} in token registers.
1709 % \begin{macrocode}
1710 \@temptokena{#2}%
1711 \toks@\expandafter{#1#3}%
1712 % \end{macrocode}
1713 % Do an expanded definition for \cs{x}, so that calling \cs{x}
1714 % will \cs{def} a new version of \meta{macro}, whose body consists of the
1715 % saved tokens (i.e., the orginal body plus the extra stuff).
1716 % As Michael Downes noted, single letter control sequences do not take any of
1717 % \TeX's hash table space.
1718 % \cs{l@ngrel@x}
1719 % has been previously set to either \cs{long} or \cs{relax} by \cs{@star@or@long},
1720 % and so may make the new definition of \meta{macro} to be \cs{long}.
1721 % \begin{macrocode}
1722 \edef\x{\endgroup
1723 \l@ngrel@x\def\noexpand#1{\the\@temptokena \the\toks@}}%
1724 % \end{macrocode}
1725 % Finally, call \cs{x} to perform the new definition.
1726 % \begin{macrocode}
1727 \x
1728 }%
1729 }
1730
1731 % \end{macrocode}
1732 % \end{macro}
1733 % \end{macro}
1734 % \end{macro}
1735 %
1736 % \begin{macro}{\addtoiargdef}
1737 % \begin{macro}{\addtoiargdef*}
1738 % \begin{macro}{\wo@daddtoiargdef}
1739 % This adds stuff at the start and/or end of a macro that takes one argument.
1740 % It is a modification of Michael Downes' appending
1741 % code\footnote{Posted to \ctt{} on 15~June 2000,\\
1742 % URL: \url{http://www.dejanews.com/getdoc.xp?AN=635057844}.}
1743 % which was:
1744 % \begin{small}\begin{verbatim}
1745 % \def\appendef#1#2{%
1746 % \begingroup
1747 % \toks@\expandafter{#1{##1}#2}%
1748 % \edef\x{\endgroup \def\noexpand#1####1{\the\toks@}}%
1749 % \x}
1750 % \end{verbatim}
1751 % \par\end{small}
1752 %
1753 % \changes{v3.8.3}{2024/02/01}{Marked \cs{addtoiargdef(*)} as deprecated}
1754 % \MarkedForDeprecation{\cs{addtoiargdef(*)}}
1755 % \begin{macrocode}
1756 \def\addtoiargdef{%
1757 \MarkDeprecated{\addtoiargdef}{in 2026, use instead \string\patchcmd,\MessageBreak%
1758 \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
1759 (which is autoloaded by the class)}
1760 \@star@or@long\wo@daddtoiargdef}
1761 \long\def\wo@daddtoiargdef#1#2#3{%
1762 \wo@difmacro@begingroup{#1}{%
1763 \@temptokena{#2}%
1764 \toks@\expandafter{#1{##1}#3}%
1765 \edef\x{\endgroup
1766 \l@ngrel@x\def\noexpand#1####1{\the\@temptokena \the\toks@}}%
1767 \x
1768 }%
1769 }
1770
1771 % \end{macrocode}
1772 % For the record, Heiko Oberdiek produced the following
1773 % version\footnote{Posted to \ctt{} on 16~June 2000,\\
1774 % URL: \url{http://www.dejanews.com/getdoc.xp?AN=635095381}.}
1775 % which avoids the use of a token register.
1776 % \begin{small}\begin{verbatim}
1777 % \newcommand{\appendiargdef}[2]{%
1778 % \long\expandafter\def\expandafter#1\expandafter
1779 % ##\expandafter1\expandafter{#1{##1}#2}}
1780 % \end{verbatim}
1781 % \par\end{small}
1782 %
1783 % \end{macro}
1784 % \end{macro}
1785 % \end{macro}
1786 %
1787 % Continuing the saga, Michael came up with a pretty general solution for
1788 % modifying a macro with any number (up to 9) of arguments which he
1789 % sent to me on 2000/07/13; this became
1790 % the \Lpack{patchcmd} package which is on CTAN. I'm sure that Michael
1791 % would have given me permission to include it here if he had not tragically
1792 % passed away in 2003. I miss his encouragement, advice, and skills.
1793 %
1794 % \begin{macro}{\patchcommand}
1795 % \cs{patchcommand}\marg{macro}\marg{start-stuff}\marg{end-stuff} inserts
1796 % \meta{start-stuff} at the beginning of the definition of \meta{macro}
1797 % and \meta{end-stuff} at the end of the definition. \meta{macro}
1798 % can have 0--9 arguments and be defined by \cs{newcommand} (and associates)
1799 % or with \cs{DeclareRobustCommand}. For macros that use \cs{futurelet}
1800 % (e.g., those with starred forms or optional arguments) only prepending
1801 % works --- any non-empty \meta{end-stuff} will mess things up. \cs{patchcommand}
1802 % does not work with macros that have delimited arguments.
1803 % \changes{v1.618}{2005/09/05}{Added \cs{patchcmd}}
1804 % \changes{v3.8.3}{2024/02/01}{Marked \cs{patchcommand} as deprecated}
1805 % \MarkedForDeprecation{\cs{patchcommand}}
1806 % \begin{macrocode}
1807 %%%%%%%%%%%%%%%% Michael Downes' patchcmd 2000/07/31 v1.03 %%%%%%%%
1808 \newcommand{\patchcommand}[1]{%
1809 \MarkDeprecated{\patchcommand}{in 2026, use instead \string\patchcmd,\MessageBreak%
1810 \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
1811 (which is autoloaded by the class)}
1812 \expandafter\patchcmd@a\meaning#1??->@\@nil#1%
1813 }
1814 % \end{macrocode}
1815 % \end{macro}
1816 %
1817 % \begin{macro}{\patchcmd@a}
1818 % \begin{macrocode}
1819 \long\def\patchcmd@a#1#2#3->#4#5\@nil#6{%
1820 \ifx @#4\relax \patchcmdError#6#1%
1821 \expandafter\@gobbletwo % discard the other two arguments
1822 \else
1823 \if l#2\toks@{\patchcmd@e{}#6}% l in this position means \long
1824 \else \toks@{\patchcmd@e*#6}% not \long
1825 \fi
1826 \patchcmd@b #3@#4#5 ? ? ? \@nil#6%
1827 \expandafter\the\expandafter\toks@
1828 \fi}
1829 % \end{macrocode}
1830 % \end{macro}
1831 %
1832 % \begin{macro}{\patchcmd@b}
1833 % \begin{macrocode}
1834 \def\patchcmd@b#1:#2@#3#4 #5#6 #7 #8\@nil#9{%
1835 \if \ifx @#7@\expandafter
1836 \ifx\csname #6\endcsname#9T\else F\fi\else F\fi T%
1837 \toks@\expandafter{\expandafter\patchcommand\csname #6 \endcsname}%
1838 \else
1839 \ifx @#2@% No arguments
1840 \toks@\expandafter{\the\toks@ 0}%
1841 \else
1842 \patchcmd@c 0#2{\string##}0%
1843 \fi
1844 \fi}
1845 % \end{macrocode}
1846 % \end{macro}
1847 %
1848 % \begin{macro}{\patchcmd@c}
1849 % \begin{macrocode}
1850 \def\patchcmd@c#1#2#3{%
1851 \if\string###2% % yes it's a # token
1852 \ifodd 0#31 % and it's followed by a number
1853 \if 0#3\patchcmd@d#1\fi % number=0? then we're done
1854 \else \patchcmd@d D% # not a number: must be a delimited arg
1855 \fi
1856 \else \patchcmd@d D% not a # token: must be a delmited arg
1857 \fi
1858 \patchcmd@c#3}
1859 % \end{macrocode}
1860 % \end{macro}
1861 %
1862 % \begin{macro}{\patchcmd@d}
1863 % \begin{macrocode}
1864 \def\patchcmd@d#1{%
1865 \if D#1%
1866 %%% \PackageError{patchcmd}{Cannot change a macro that has
1867 %%% delimited arguments}\@ehd
1868 \@memerror{%
1869 Cannot change a macro that has delimited arguments}{\@ehd}
1870 \else
1871 \toks@\expandafter{\the\toks@ #1}%
1872 \fi
1873 \begingroup
1874 \aftergroup\@gobble
1875 \let\patchcmd@c\endgroup}
1876 % \end{macrocode}
1877 % \end{macro}
1878 %
1879 % \begin{macro}{\patchcmd@e}
1880 % \begin{macrocode}
1881 \def\patchcmd@e#1#2#3#4#5{%
1882 \begingroup
1883 \edef\@##1{%
1884 \@temptokena\noexpand\expandafter{%
1885 \noexpand#2%
1886 \ifnum#3>0 {####1}\ifnum#3>1 {####2}\ifnum#3>2 {####3}%
1887 \ifnum#3>3 {####4}\ifnum#3>4 {####5}\ifnum#3>5 {####6}%
1888 \ifnum#3>6 {####7}\ifnum#3>7 {####8}\ifnum#3>8 {####9}%
1889 \fi\fi\fi\fi\fi\fi\fi\fi\fi
1890 ##1%
1891 }%
1892 }
1893 \@{#5}%
1894 \edef\@##1{\endgroup
1895 \noexpand\renewcommand#1\noexpand#2\ifcase#3 \else [#3]\fi
1896 {##1\the\@temptokena}}%
1897 \@{#4}%
1898 }
1899 % \end{macrocode}
1900 % \end{macro}
1901 %
1902 % \begin{macro}{\patchcmdError}
1903 % \begin{macrocode}
1904 \long\def\patchcmdError#1#2{%
1905 \begingroup
1906 \toks@{Not redefinable}%
1907 \ifcat\relax\noexpand#1% Is it a control sequence?
1908 \begingroup
1909 \let#1=?\ifx ?\relax % Is it "\relax"?
1910 \endgroup % accept current value of \toks@
1911 \else \endgroup
1912 \if\ifx\relax#1u\else #2\fi u%
1913 \toks@{Not defined}%
1914 \fi
1915 \fi
1916 \fi
1917 \edef\@{\endgroup
1918 %%% \noexpand\PackageError{patchcmd}{%
1919 %%% \the\toks@: \string#1}\noexpand\@ehd}%
1920 \noexpand\@memerror{%
1921 \the\toks@: \string#1}\noexpand\@ehd}%
1922 \@}
1923
1924 %%%%%%%%%%%%%%%%%%%%% end of patchcmd code %%%%%%%%%%%%%%%%%%%%%%%%%%%
1925
1926 % \end{macrocode}
1927 % \end{macro}
1928 %
1929 % Prevent later loading of the original \Lpack{patchcmd} package.
1930 % \begin{macrocode}
1931 %%\@memfakeusepackage{patchcmd}
1932
1933 % \end{macrocode}
1934 %
1935 % \changes{v1.61803398}{2009/07/18}{Added support for bidi}
1936 % \subsection{Support for the bidi package (RTL typesetting)}
1937 %
1938 % The \Lpack{bidi} package (system) enables bidirectional typesetting.
1939 % As part of
1940 % being able to accomplish this it often needs to exchange, for example,
1941 % \cs{leftskip} and \cs{rightskip} depending on whether it is setting
1942 % left-to-right (LTR) or right-to-left (RTL). In the case of \Lpack{memoir}
1943 % the initial \Lpack{bidi} system implementation used a \Lpack{bidimemoir}
1944 % class developed by Vafa Khalighi. Now, with Vafa's help, the necessary
1945 % changes have been incorporated in \Lpack{memoir}; the \Lpack{bidimemoir}
1946 % class is no longer needed.
1947 %
1948 % \begin{macro}{\memRTLleftskip}
1949 % \begin{macro}{\memRTLrightskip}
1950 % \begin{macro}{\memRTLvleftskip}
1951 % \begin{macro}{\memRTLvrightskip}
1952 % \begin{macro}{\memRTLraggedright}
1953 % \begin{macro}{\memRTLraggedleft}
1954 % \begin{macro}{\memRTLmainraggedright}
1955 % \begin{macro}{\memRTLmainraggedleft}
1956 % These are the hooks required to support the \Lpack{bidi} package,
1957 % plus some we added that \Lpack{bidi} can use. The idea behind the
1958 % \cs{XmainraggedX} macros are documents fully in RTL mode, then it
1959 % makes sense to have the raggedness of the header and footer
1960 % reversed. By default they do what the normally do, but in main RTL
1961 % mode, \Lpack{bidi} can redefine them to reverse the order of the
1962 % headers, i.e. the `left' part of the header is typeset as the
1963 % `right' part.
1964 % \changes{v3.6h}{2010/10/22}{Added \cs{mem@RTLmainraggedX} macros}
1965 % \changes{v3.6k}{2011/06/24}{the \cs{mem@RTLvX} macros should point
1966 % at \cs{vX} not \cs{X}}
1967 % \begin{macrocode}
1968 \newcommand*{\memRTLleftskip}{\leftskip}
1969 \newcommand*{\memRTLrightskip}{\rightskip}
1970 \newcommand*{\memRTLvleftskip}{\vleftskip}
1971 \newcommand*{\memRTLvrightskip}{\vrightskip}
1972 \newcommand*{\memRTLraggedright}{\raggedright}
1973 \newcommand*{\memRTLraggedleft}{\raggedleft}
1974 \newcommand*{\memRTLmainraggedright}{\raggedright}
1975 \newcommand*{\memRTLmainraggedleft}{\raggedleft}
1976
1977 % \end{macrocode}
1978 % \end{macro}
1979 % \end{macro}
1980 % \end{macro}
1981 % \end{macro}
1982 % \end{macro}
1983 % \end{macro}
1984 % \end{macro}
1985 % \end{macro}
1986 %
1987 % It is expected that the \Lpack{bidi} package will redefine these as:
1988 % \begin{verbatim}
1989 % \renewcommand*{\memRTLleftskip}{\if@RTL\rightskip\else\leftskip\fi}
1990 % \renewcommand*{\memRTLrightskip}{\if@RTL\leftskip\else\rightskip\fi}
1991 % \renewcommand*{\memRTLvleftskip}{\if@RTL\vrightskip\else\vleftskip\fi}
1992 % \renewcommand*{\memRTLvrightskip}{\if@RTL\vleftskip\else\vrightskip\fi}
1993 % \renewcommand*{\memRTLraggedright}{\if@RTL\raggedleft\else\raggedright\fi}
1994 % \renewcommand*{\memRTLraggedleft}{\if@RTL\raggedright\else\raggedleft\fi}
1995 % \renewcommand*{\memRTLmainraggedright}{\if@RTLmain\raggedleft\else\raggedright\fi}
1996 % \renewcommand*{\memRTLmainraggedleft}{\if@RTLmain\raggedright\else\raggedleft\fi}
1997 % \end{verbatim}
1998 %
1999 % \section{Declaration of Options} \label{sec:opt}
2000 %
2001 % \changes{v3.8}{2023/08/03}{Added secret option}
2002 % \begin{macrocode}
2003 % secret extra option for testing stuff in the wild
2004 % caution 1: patching inside \ifmem@devmode ... \fi requires that all
2005 % if statements in the patch are blanced
2006 % caution 2: pathing inside \mem@devmode@run{ ... }{} does not work
2007 % if the search pattern contains #<num>
2008 % thus added both variants
2009 \newif\ifmem@devmode
2010 \let\mem@devmode@run\@secondoftwo
2011 \DeclareOption{dev-mode}{\let\mem@devmode@run\@firstoftwo\mem@devmodetrue}
2012
2013 % \end{macrocode}
2014 %
2015 % \subsection{Setting Paper Sizes}
2016 %
2017 % The variables \cs{paperheight} and \cs{paperwidth} should reflect the
2018 % physical paper size after trimming.
2019 %
2020 % Option \Lopt{letterpaper} will be the default.
2021 %
2022 % \begin{macro}{\stockheight}
2023 % \begin{macro}{\stockwidth}
2024 % \begin{macro}{\trimtop}
2025 % \begin{macro}{\trimedge}
2026 % The lengths \cs{stockheight} and \cs{stockwidth} should be the height and
2027 % width of the stock sheet before trimming. For example, this is the
2028 % physical size
2029 % of a single sheet that might be laser-printed. The lengths \cs{trimtop}
2030 % and \cs{trimedge} are the amount that will be trimmed off the top and fore
2031 % edge of the physical sheet.
2032 % For desk printer output the size of the trimmed sheet is often the
2033 % same as the physical sheet. In other words the \cs{paper...} and \cs{stock...}
2034 % sizes are the same and the trims are zero. This class assumes that this
2035 % is the normal case.
2036 % \changes{v3.7.19}{2022/10/28}{\cs{stockheight} and \cs{stockwidth}
2037 % may now be defined in the kernel, so we test for that}
2038 % \begin{macrocode}
2039 \@ifundefined{stockwidth}{\newdimen{\stockheight}}{}
2040 \@ifundefined{stockwidth}{\newdimen{\stockwidth}}{}
2041 \newlength{\trimtop}
2042 \newlength{\trimedge}
2043
2044 % \end{macrocode}
2045 % \end{macro}
2046 % \end{macro}
2047 % \end{macro}
2048 % \end{macro}
2049 %
2050 % The class provides an extended range of stock sizes. It may be useful at some
2051 % point to have macros for these.
2052 %
2053 % \begin{macro}{\stockdbill}
2054 % \begin{macro}{\stockstatement}
2055 % \begin{macro}{\stockexecutive}
2056 % \begin{macro}{\stockletter}
2057 % \begin{macro}{\stockold}
2058 % \begin{macro}{\stocklegal}
2059 % \begin{macro}{\stockledger}
2060 % \begin{macro}{\stockbroadsheet}
2061 % US stock sizes.
2062 % \changes{v1.61803}{2008/01/30}{Major expansion of stock size options}
2063 % \begin{macrocode}
2064 \newcommand*{\stockdbill} {\stockheight=7in \stockwidth=3in}
2065 \newcommand*{\stockstatement} {\stockheight=8.5in \stockwidth=5.5in}
2066 \newcommand*{\stockexecutive} {\stockheight=10.5in \stockwidth=7.25in}
2067 \newcommand*{\stockletter} {\stockheight=11in \stockwidth=8.5in}
2068 \newcommand*{\stockold} {\stockheight=12in \stockwidth=9in}
2069 \newcommand*{\stocklegal} {\stockheight=14in \stockwidth=8.5in}
2070 \newcommand*{\stockledger} {\stockheight=17in \stockwidth=11in}
2071 \newcommand*{\stockbroadsheet}{\stockheight=22in \stockwidth=17in}
2072
2073 % \end{macrocode}
2074 % \end{macro}
2075 % \end{macro}
2076 % \end{macro}
2077 % \end{macro}
2078 % \end{macro}
2079 % \end{macro}
2080 % \end{macro}
2081 % \end{macro}
2082 %
2083 % \begin{macro}{\stockpottvo}
2084 % \begin{macro}{\stockfoolscapvo}
2085 % \begin{macro}{\stockcrownvo}
2086 % \begin{macro}{\stockpostvo}
2087 % \begin{macro}{\stocklargecrownvo}
2088 % \begin{macro}{\stocklargepostvo}
2089 % \begin{macro}{\stocksmalldemyvo}
2090 % Traditional British octavo sizes.
2091 % \begin{macrocode}
2092 \newcommand*{\stockpottvo} {\stockheight=6.25in \stockwidth=4in}
2093 \newcommand*{\stockfoolscapvo} {\stockheight=6.75in \stockwidth=4.25in}
2094 \newcommand*{\stockcrownvo} {\stockheight=7.5in \stockwidth=5in}
2095 \newcommand*{\stockpostvo} {\stockheight=8in \stockwidth=5in}
2096 \newcommand*{\stocklargecrownvo}{\stockheight=8in \stockwidth=5.25in}
2097 \newcommand*{\stocklargepostvo} {\stockheight=8.25in \stockwidth=5.25in}
2098 \newcommand*{\stocksmalldemyvo} {\stockheight=8.5in \stockwidth=5.675in}
2099 % \end{macrocode}
2100 % \end{macro}
2101 % \end{macro}
2102 % \end{macro}
2103 % \end{macro}
2104 % \end{macro}
2105 % \end{macro}
2106 % \end{macro}
2107 %
2108 % \begin{macro}{\stockdemyvo}
2109 % \begin{macro}{\stockmediumvo}
2110 % \begin{macro}{\stocksmallroyalvo}
2111 % \begin{macro}{\stockroyalvo}
2112 % \begin{macro}{\stocksuperroyalvo}
2113 % \begin{macro}{\stockimperialvo}
2114 % \begin{macrocode}
2115 \newcommand*{\stockdemyvo} {\stockheight=8.75in \stockwidth=5.675in}
2116 \newcommand*{\stockmediumvo} {\stockheight=9in \stockwidth=5.75in}
2117 \newcommand*{\stocksmallroyalvo}{\stockheight=9.25in \stockwidth=6.175in}
2118 \newcommand*{\stockroyalvo} {\stockheight=10in \stockwidth=6.25in}
2119 \newcommand*{\stocksuperroyalvo}{\stockheight=10.25in \stockwidth=6.75in}
2120 \newcommand*{\stockimperialvo} {\stockheight=11in \stockwidth=7.5in}
2121
2122 % \end{macrocode}
2123 % \end{macro}
2124 % \end{macro}
2125 % \end{macro}
2126 % \end{macro}
2127 % \end{macro}
2128 % \end{macro}
2129 %
2130 % \begin{macro}{\stockmcrownvo}
2131 % \begin{macro}{\stockmlargecrownvo}
2132 % \begin{macro}{\stockmdemyvo}
2133 % \begin{macro}{\stockmsmallroyalvo}
2134 % Metric stock sizes.
2135 % \begin{macrocode}
2136 \newcommand*{\stockmcrownvo} {\stockheight=186mm \stockwidth=123mm}
2137 \newcommand*{\stockmlargecrownvo} {\stockheight=198mm \stockwidth=129mm}
2138 \newcommand*{\stockmdemyvo} {\stockheight=216mm \stockwidth=138mm}
2139 \newcommand*{\stockmsmallroyalvo} {\stockheight=234mm \stockwidth=156mm}
2140
2141 % \end{macrocode}
2142 % \end{macro}
2143 % \end{macro}
2144 % \end{macro}
2145 % \end{macro}
2146 %
2147 % \begin{macro}{\stockao}
2148 % \begin{macro}{\stockai}
2149 % \begin{macro}{\stockaii}
2150 % \begin{macro}{\stockaiii}
2151 % \begin{macro}{\stockaiv}
2152 % \begin{macro}{\stockav}
2153 % \begin{macro}{\stockavi}
2154 % \begin{macro}{\stockavii}
2155 % The A series, A0 --- A7.
2156 % \changes{v1.6180339c}{2008/12/26}{Extended the A and B stock/paper size
2157 % seies with A/B0 through A/B6}
2158 % \changes{v3.7i}{2019/11/04}{Added A7 stock}
2159 % \begin{macrocode}
2160 \newcommand*{\stockao} {\stockheight=1189mm \stockwidth=841mm}
2161 \newcommand*{\stockai} {\stockheight=841mm \stockwidth=594mm}
2162 \newcommand*{\stockaii} {\stockheight=594mm \stockwidth=420mm}
2163 \newcommand*{\stockaiii}{\stockheight=420mm \stockwidth=297mm}
2164 \newcommand*{\stockaiv} {\stockheight=297mm \stockwidth=210mm}
2165 \newcommand*{\stockav} {\stockheight=210mm \stockwidth=148mm}
2166 \newcommand*{\stockavi} {\stockheight=148mm \stockwidth=105mm}
2167 \newcommand*{\stockavii}{\stockheight=105mm \stockwidth=74mm}
2168
2169 % \end{macrocode}
2170 % \end{macro}
2171 % \end{macro}
2172 % \end{macro}
2173 % \end{macro}
2174 % \end{macro}
2175 % \end{macro}
2176 % \end{macro}
2177 % \end{macro}
2178 %
2179 % \begin{macro}{\stockbo}
2180 % \begin{macro}{\stockbi}
2181 % \begin{macro}{\stockbii}
2182 % \begin{macro}{\stockbiii}
2183 % \begin{macro}{\stockbiv}
2184 % \begin{macro}{\stockbv}
2185 % \begin{macro}{\stockbvi}
2186 % \begin{macro}{\stockbvii}
2187 % The B series, B0 --- B7.
2188 % \changes{v3.7i}{2019/11/04}{added B7 stock}
2189 % \begin{macrocode}
2190 \newcommand*{\stockbo} {\stockheight=1414mm \stockwidth=1000mm}
2191 \newcommand*{\stockbi} {\stockheight=1000mm \stockwidth=707mm}
2192 \newcommand*{\stockbii} {\stockheight=707mm \stockwidth=500mm}
2193 \newcommand*{\stockbiii}{\stockheight=500mm \stockwidth=353mm}
2194 \newcommand*{\stockbiv} {\stockheight=353mm \stockwidth=250mm}
2195 \newcommand*{\stockbv} {\stockheight=250mm \stockwidth=176mm}
2196 \newcommand*{\stockbvi} {\stockheight=176mm \stockwidth=125mm}
2197 \newcommand*{\stockbvii}{\stockheight=125mm \stockwidth=88mm}
2198
2199 % \end{macrocode}
2200 % \end{macro}
2201 % \end{macro}
2202 % \end{macro}
2203 % \end{macro}
2204 % \end{macro}
2205 % \end{macro}
2206 % \end{macro}
2207 % \end{macro}
2208 %
2209 % It will be useful also to provide macros that set the page sizes.
2210 %
2211 % \begin{macro}{\pagedbill}
2212 % \begin{macro}{\pagestatement}
2213 % \begin{macro}{\pageexecutive}
2214 % \begin{macro}{\pageletter}
2215 % \begin{macro}{\pageold}
2216 % \begin{macro}{\pagelegal}
2217 % \begin{macro}{\pageledger}
2218 % \begin{macro}{\pagebroadsheet}
2219 % \changes{v1.6180339c}{\cs{pageheight} and \cs{pagewidth} should be
2220 % \cs{paperheight} and \cs{paperwidth}
2221 % (courtesy Wilhelm Muller)}
2222 % US page sizes.
2223 % \begin{macrocode}
2224 \newcommand*{\pagedbill} {\paperheight=7in \paperwidth=3in}
2225 \newcommand*{\pagestatement} {\paperheight=8.5in \paperwidth=5.5in}
2226 \newcommand*{\pageexecutive} {\paperheight=10.5in \paperwidth=7.25in}
2227 \newcommand*{\pageletter} {\paperheight=11in \paperwidth=8.5in}
2228 \newcommand*{\pageold} {\paperheight=12in \paperwidth=9in}
2229 \newcommand*{\pagelegal} {\paperheight=14in \paperwidth=8.5in}
2230 \newcommand*{\pageledger} {\paperheight=17in \paperwidth=11in}
2231 \newcommand*{\pagebroadsheet}{\paperheight=22in \paperwidth=17in}
2232
2233 % \end{macrocode}
2234 % \end{macro}
2235 % \end{macro}
2236 % \end{macro}
2237 % \end{macro}
2238 % \end{macro}
2239 % \end{macro}
2240 % \end{macro}
2241 % \end{macro}
2242 %
2243 % \begin{macro}{\pagepottvo}
2244 % \begin{macro}{\pagefoolscapvo}
2245 % \begin{macro}{\pagecrownvo}
2246 % \begin{macro}{\pagepostvo}
2247 % \begin{macro}{\pagelargecrownvo}
2248 % \begin{macro}{\pagelargepostvo}
2249 % \begin{macro}{\pagesmalldemyvo}
2250 % British traditional page sizes, octavo.
2251 % \begin{macrocode}
2252 \newcommand*{\pagepottvo} {\paperheight=6.25in \paperwidth=4in}
2253 \newcommand*{\pagefoolscapvo} {\paperheight=6.75in \paperwidth=4.25in}
2254 \newcommand*{\pagecrownvo} {\paperheight=7.5in \paperwidth=5in}
2255 \newcommand*{\pagepostvo} {\paperheight=8in \paperwidth=5in}
2256 \newcommand*{\pagelargecrownvo}{\paperheight=8in \paperwidth=5.25in}
2257 \newcommand*{\pagelargepostvo} {\paperheight=8.25in \paperwidth=5.25in}
2258 \newcommand*{\pagesmalldemyvo} {\paperheight=8.5in \paperwidth=5.675in}
2259 % \end{macrocode}
2260 % \end{macro}
2261 % \end{macro}
2262 % \end{macro}
2263 % \end{macro}
2264 % \end{macro}
2265 % \end{macro}
2266 % \end{macro}
2267 %
2268 % \begin{macro}{\pagedemyvo}
2269 % \begin{macro}{\pagemediumvo}
2270 % \begin{macro}{\pagesmallroyalvo}
2271 % \begin{macro}{\pageroyalvo}
2272 % \begin{macro}{\pagesuperroyalvo}
2273 % \begin{macro}{\pageimperialvo}
2274 % \begin{macrocode}
2275 \newcommand*{\pagedemyvo} {\paperheight=8.75in \paperwidth=5.675in}
2276 \newcommand*{\pagemediumvo} {\paperheight=9in \paperwidth=5.75in}
2277 \newcommand*{\pagesmallroyalvo}{\paperheight=9.25in \paperwidth=6.175in}
2278 \newcommand*{\pageroyalvo} {\paperheight=10in \paperwidth=6.25in}
2279 \newcommand*{\pagesuperroyalvo}{\paperheight=10.25in \paperwidth=6.75in}
2280 \newcommand*{\pageimperialvo} {\paperheight=11in \paperwidth=7.5in}
2281
2282 % \end{macrocode}
2283 % \end{macro}
2284 % \end{macro}
2285 % \end{macro}
2286 % \end{macro}
2287 % \end{macro}
2288 % \end{macro}
2289 %
2290 %
2291 % \begin{macro}{\pagemcrownvo}
2292 % \begin{macro}{\pagemlargecrownvo}
2293 % \begin{macro}{\pagemdemyvo}
2294 % \begin{macro}{\pagemsmallroyalvo}
2295 % Metric sizes.
2296 % \begin{macrocode}
2297 \newcommand*{\pagemcrownvo} {\paperheight=186mm \paperwidth=123mm}
2298 \newcommand*{\pagemlargecrownvo} {\paperheight=198mm \paperwidth=129mm}
2299 \newcommand*{\pagemdemyvo} {\paperheight=216mm \paperwidth=138mm}
2300 \newcommand*{\pagemsmallroyalvo} {\paperheight=234mm \paperwidth=156mm}
2301
2302 % \end{macrocode}
2303 % \end{macro}
2304 % \end{macro}
2305 % \end{macro}
2306 % \end{macro}
2307 %
2308 % \begin{macro}{\pageao}
2309 % \begin{macro}{\pageai}
2310 % \begin{macro}{\pageaii}
2311 % \begin{macro}{\pageaiii}
2312 % \begin{macro}{\pageaiv}
2313 % \begin{macro}{\pageav}
2314 % \begin{macro}{\pageavi}
2315 % \begin{macro}{\pageavii}
2316 % The A series, A0 --- A7.
2317 % \changes{v3.7i}{2019/11/04}{added A7 paper}
2318 % \begin{macrocode}
2319 \newcommand*{\pageao} {\paperheight=1189mm \paperwidth=841mm}
2320 \newcommand*{\pageai} {\paperheight=841mm \paperwidth=594mm}
2321 \newcommand*{\pageaii} {\paperheight=594mm \paperwidth=420mm}
2322 \newcommand*{\pageaiii}{\paperheight=420mm \paperwidth=297mm}
2323 \newcommand*{\pageaiv} {\paperheight=297mm \paperwidth=210mm}
2324 \newcommand*{\pageav} {\paperheight=210mm \paperwidth=148mm}
2325 \newcommand*{\pageavi} {\paperheight=148mm \paperwidth=105mm}
2326 \newcommand*{\pageavii}{\paperheight=105mm \paperwidth=74mm}
2327
2328 % \end{macrocode}
2329 % \end{macro}
2330 % \end{macro}
2331 % \end{macro}
2332 % \end{macro}
2333 % \end{macro}
2334 % \end{macro}
2335 % \end{macro}
2336 % \end{macro}
2337 %
2338 % \begin{macro}{\pagebo}
2339 % \begin{macro}{\pagebi}
2340 % \begin{macro}{\pagebii}
2341 % \begin{macro}{\pagebiii}
2342 % \begin{macro}{\pagebiv}
2343 % \begin{macro}{\pagebv}
2344 % \begin{macro}{\pagebvi}
2345 % \begin{macro}{\pagebvii}
2346 % The B series, B0 --- B7.
2347 % \changes{v3.7i}{2019/11/04}{Added B7 paper}
2348 % \begin{macrocode}
2349 \newcommand*{\pagebo} {\paperheight=1414mm \paperwidth=1000mm}
2350 \newcommand*{\pagebi} {\paperheight=1000mm \paperwidth=707mm}
2351 \newcommand*{\pagebii} {\paperheight=707mm \paperwidth=500mm}
2352 \newcommand*{\pagebiii}{\paperheight=500mm \paperwidth=353mm}
2353 \newcommand*{\pagebiv} {\paperheight=353mm \paperwidth=250mm}
2354 \newcommand*{\pagebv} {\paperheight=250mm \paperwidth=176mm}
2355 \newcommand*{\pagebvi} {\paperheight=176mm \paperwidth=125mm}
2356 \newcommand*{\pagebvii}{\paperheight=125mm \paperwidth=88mm}
2357
2358 % \end{macrocode}
2359 % \end{macro}
2360 % \end{macro}
2361 % \end{macro}
2362 % \end{macro}
2363 % \end{macro}
2364 % \end{macro}
2365 % \end{macro}
2366 % \end{macro}
2367 %
2368 % Declare the stock size options.
2369 %
2370 % Metric paper stock sizes.
2371 % \changes{v1.6180339c}{2008/12/26}{Extended class options to include stock
2372 % sizes A0, A1, A2, B0, B1 and B2}
2373 % \changes{v3.7i}{2019/11/04}{Added a7paper and b7paper options}
2374 % \begin{macrocode}
2375 \DeclareOption{a0paper}{\stockao}
2376 \DeclareOption{a1paper}{\stockai}
2377 \DeclareOption{a2paper}{\stockaii}
2378 \DeclareOption{a3paper}{\stockaiii}
2379 \DeclareOption{a4paper}{\stockaiv}
2380 \DeclareOption{a5paper}{\stockav}
2381 \DeclareOption{a6paper}{\stockavi}
2382 \DeclareOption{a7paper}{\stockavii}
2383 \DeclareOption{b0paper}{\stockbo}
2384 \DeclareOption{b1paper}{\stockbi}
2385 \DeclareOption{b2paper}{\stockbii}
2386 \DeclareOption{b3paper}{\stockbiii}
2387 \DeclareOption{b4paper}{\stockbiv}
2388 \DeclareOption{b5paper}{\stockbv}
2389 \DeclareOption{b6paper}{\stockbvi}
2390 \DeclareOption{b7paper}{\stockbvii}
2391 \DeclareOption{mcrownvopaper}{\stockmcrownvo}
2392 \DeclareOption{mlargecrownvopaper}{\stockmlargecrownvo}
2393 \DeclareOption{mdemyvopaper}{\stockmdemyvo}
2394 \DeclareOption{msmallroyalvopaper}{\stockmsmallroyalvo}
2395
2396 % \end{macrocode}
2397 % US paper stock sizes.
2398 % \begin{macrocode}
2399 \DeclareOption{dbillpaper}{\stockdbill}
2400 \DeclareOption{statementpaper}{\stockstatement}
2401 \DeclareOption{executivepaper}{\stockexecutive}
2402 \DeclareOption{letterpaper}{\stockletter}
2403 \DeclareOption{oldpaper}{\stockold}
2404 \DeclareOption{legalpaper}{\stocklegal}
2405 \DeclareOption{ledgerpaper}{\stockledger}
2406 \DeclareOption{broadsheetpaper}{\stockbroadsheet}
2407
2408 % \end{macrocode}
2409 % British octavo stock paper sizes.
2410 % \begin{macrocode}
2411 \DeclareOption{pottvopaper}{\stockpottvo}
2412 \DeclareOption{foolscapvopaper}{\stockfoolscapvo}
2413 \DeclareOption{crownvopaper}{\stockcrownvo}
2414 \DeclareOption{postvopaper}{\stockpostvo}
2415 \DeclareOption{largecrownvopaper}{\stocklargecrownvo}
2416 \DeclareOption{largepostvopaper}{\stocklargepostvo}
2417 \DeclareOption{smalldemyvopaper}{\stocksmalldemyvo}
2418 \DeclareOption{demyvopaper}{\stockdemyvo}
2419 \DeclareOption{mediumvopaper}{\stockmediumvo}
2420 \DeclareOption{smallroyalvopaper}{\stocksmallroyalvo}
2421 \DeclareOption{royalvopaper}{\stockroyalvo}
2422 \DeclareOption{superroyalvopaper}{\stocksuperroyalvo}
2423 \DeclareOption{imperialvopaper}{\stockimperialvo}
2424
2425 % \end{macrocode}
2426 % Ebook.
2427 % \begin{macrocode}
2428 \DeclareOption{ebook}
2429 {\setlength\stockheight {9in}%
2430 \setlength\stockwidth {6in}}
2431
2432 % \end{macrocode}
2433 %
2434 % The \Lopt{landscape} option switches the values of the height and width,
2435 % assuming that the dimensions were originally given for portrait
2436 % orientation. (At the suggestion of Wilhelm M\"{u}ller made this independent
2437 % of the option sequence).
2438 % \changes{v1.6180339c}{2008/12/26}{`Stabilised' the landscape option and
2439 % added a portrait option}.
2440 % \begin{macro}{\ifmemlandscape}
2441 % \begin{macro}{\memlandscapetrue}
2442 % \begin{macro}{\memlandscapefalse}
2443 % \begin{macrocode}
2444 \newif\ifmemlandscape
2445 \memlandscapefalse
2446 % \end{macrocode}
2447 % \end{macro}
2448 % \end{macro}
2449 % \end{macro}
2450 %
2451 % \begin{macrocode}
2452 \DeclareOption{landscape}{\memlandscapetrue}
2453 \DeclareOption{portrait}{\memlandscapefalse}
2454
2455 % \end{macrocode}
2456 %
2457 %
2458 % \subsection{Choosing the type size}
2459 %
2460 % The type size options are handled by defining \cs{@ptsize} to contain
2461 % the last digit of the size in question and branching on \cs{ifcase}
2462 % statements. This is done for historical reasons to stay compatible
2463 % with other packages that use the \cs{@ptsize} variable to select
2464 % special actions. It makes the declarations of size options less
2465 % than 10pt or more than 20pt difficult. In this class \texttt{9} is used
2466 % for the \Lopt{9pt} option, assuming that the class will never define a
2467 % \Lopt{19pt} option. For larger options the full complement of digits
2468 % are used.
2469 %
2470 % In any event, \cs{@memptsize} holds the complete size.
2471 %
2472 % Option \Lopt{10pt} will be the default.
2473 % \changes{v1.2}{2002/07/07}{Added 17pt option}
2474 % \changes{v1.61803}{2008/01/30}{Added pt options 20 to 60.}
2475 % \changes{v1.61803}{2008/01/30}{Used \cs{@memptsize}}
2476 % \begin{macrocode}
2477 \renewcommand*{\@ptsize}{0}
2478 \renewcommand*{\@memptsize}{10}
2479 \DeclareOption{9pt}{\renewcommand*{\@ptsize}{9}\renewcommand*{\@memptsize}{9}}
2480 \DeclareOption{10pt}{\renewcommand*{\@ptsize}{0}\renewcommand*{\@memptsize}{10}}
2481 \DeclareOption{11pt}{\renewcommand*{\@ptsize}{1}\renewcommand*{\@memptsize}{11}}
2482 \DeclareOption{12pt}{\renewcommand*{\@ptsize}{2}\renewcommand*{\@memptsize}{12}}
2483 \DeclareOption{14pt}{\renewcommand*{\@ptsize}{4}\renewcommand*{\@memptsize}{14}}
2484 \DeclareOption{17pt}{\renewcommand*{\@ptsize}{7}\renewcommand*{\@memptsize}{17}}
2485 \DeclareOption{20pt}{\renewcommand*{\@ptsize}{20}\renewcommand*{\@memptsize}{20}}
2486 \DeclareOption{25pt}{\renewcommand*{\@ptsize}{25}\renewcommand*{\@memptsize}{25}}
2487 \DeclareOption{30pt}{\renewcommand*{\@ptsize}{30}\renewcommand*{\@memptsize}{30}}
2488 \DeclareOption{36pt}{\renewcommand*{\@ptsize}{36}\renewcommand*{\@memptsize}{36}}
2489 \DeclareOption{48pt}{\renewcommand*{\@ptsize}{48}\renewcommand*{\@memptsize}{48}}
2490 \DeclareOption{60pt}{\renewcommand*{\@ptsize}{60}\renewcommand*{\@memptsize}{60}}
2491
2492 % \end{macrocode}
2493 %
2494 % \begin{macro}{\if@nyptsizeopt}
2495 % \begin{macro}{\@nyptsizeopttrue}
2496 % \begin{macro}{\@nyptsizeoptfalse}
2497 % \begin{macro}{\anyptfilebase}
2498 % \begin{macro}{\anyptsize}
2499 % For any point size:
2500 % \changes{v1.61803}{2008/02/29}{Added *pt option}
2501 % \begin{macrocode}
2502 \newif\if@nyptsizeopt
2503 \@nyptsizeoptfalse
2504 \providecommand*{\anyptfilebase}{mem}
2505 \providecommand*{\anyptsize}{10}
2506 \DeclareOption{*pt}{\@nyptsizeopttrue}
2507
2508 % \end{macrocode}
2509 % \end{macro}
2510 % \end{macro}
2511 % \end{macro}
2512 % \end{macro}
2513 % \end{macro}
2514 %
2515 %
2516 % \subsection{Two-side or one-side printing}
2517 %
2518 % For two-sided printing we use the switch \cs{if@twoside}. In
2519 % addition we have to set the \cs{if@mparswitch} to get any margin
2520 % paragraphs into the outside margin. The default is \Lopt{twoside}.
2521 % \begin{macro}{\if@twoside}
2522 % \begin{macro}{\if@mparswitch}
2523 % \begin{macrocode}
2524 \DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
2525 \DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
2526 % \end{macrocode}
2527 % \end{macro}
2528 % \end{macro}
2529 %
2530 %
2531 % \subsection{Two column printing}
2532 %
2533 % Two-column and one-column printing is again realized via a switch
2534 % which is defined in the kernel. The default is single column printing.
2535 %
2536 % \begin{macro}{\if@twocolumn}
2537 % \begin{macrocode}
2538 \DeclareOption{onecolumn}{\@twocolumnfalse}
2539 \DeclareOption{twocolumn}{\@twocolumntrue}
2540 % \end{macrocode}
2541 % \end{macro}
2542 %
2543 %
2544 % \subsection{The \Lopt{draft} option}
2545 %
2546 % If the user requests \Lopt{draft} we show any overfull boxes,
2547 % marginal notes are allowed, and any copyright notices are not
2548 % printed. For symmetry, we also define a \Lopt{final} option
2549 % which is the default.
2550 %
2551 % The user can use the \cs{ifdraftdoc} flag to add additional effects: \\
2552 % \verb?\ifdraftdoc <additional code> \fi?
2553 % \begin{macro}{\ifdraftdoc}
2554 % \begin{macrocode}
2555 \newif\ifdraftdoc\draftdocfalse
2556 \setlength{\overfullrule}{\z@}
2557 \DeclareOption{final}{\setlength{\overfullrule}{\z@}
2558 \draftdocfalse
2559 \msdocfalse}
2560 \DeclareOption{draft}{\setlength\overfullrule{5pt}%
2561 \draftdoctrue
2562 \msdocfalse}
2563 % \end{macrocode}
2564 % \end{macro}
2565 %
2566 % \subsection{The \Lopt{ms} option}
2567 %
2568 % \begin{macro}{\ifmsdoc}
2569 % The \Lopt{ms} option makes the document look as though it was produced
2570 % on a typewriter. We use a flag for remembering this. The user may also
2571 % use the flag for specifying \Lopt{ms} effects.
2572 % \begin{macrocode}
2573 \newif\ifmsdoc
2574 \msdocfalse
2575 \DeclareOption{ms}{%
2576 \msdoctrue
2577 \draftdocfalse
2578 \setlength\overfullrule{\z@}
2579 }
2580
2581 % \end{macrocode}
2582 % \end{macro}
2583 %
2584 % \subsection{The \Lopt{showtrims} option}
2585 %
2586 % The \Lopt{showtrims} option will display crosses at the corners
2587 % of the logical pages showing where the stock should be trimmed.
2588 %
2589 % \begin{macro}{\ifshowtrims}
2590 % \begin{macrocode}
2591 \newif\ifshowtrims
2592 \showtrimsfalse
2593 \DeclareOption{showtrims}{\showtrimstrue}
2594
2595 % \end{macrocode}
2596 % \end{macro}
2597 %
2598 % \subsection{The \Lopt{article} option}
2599 %
2600 % The \Lopt{article} option typesets as a simulation of the
2601 % \Lpack{article} class.
2602 % \changes{v0.3}{2001/07/09}{Added article option}
2603 % \begin{macro}{\ifartopt}
2604 % \cs{ifartopt} is a flag (TRUE) if the \Lopt{article} option is called.
2605 % \begin{macrocode}
2606 \newif\ifartopt
2607 \artoptfalse
2608 \DeclareOption{article}{\artopttrue}
2609
2610 % \end{macrocode}
2611 % \end{macro}
2612 %
2613 % \subsection{The \Lopt{subfigure} option}
2614 %
2615 % The \Lopt{subfigure} option has been made a no-op since version 1.1
2616 % and finally removed in version 1.61803. It was:
2617 % \changes{v0.3}{2001/07/09}{Added subfigure option}
2618 % \changes{v1.1}{2002/03/10}{Effectively removed subfigure option}
2619 % \changes{v1.61803}{2008/01/30}{Removed subfigure option}
2620 % \begin{verbatim}
2621 % \DeclareOption{subfigure}{%
2622 % \ClassWarningNoLine{memoir}{The subfigure option is not required}}
2623 % \end{verbatim}
2624 %
2625 % \subsection{The openright, openleft and openany options}
2626 %
2627 % The \Lopt{openright} option specifies that Chapters must begin on
2628 % recto pages. The \Lopt{openleft} option specifies that Chapters
2629 % must begin on verso pages and the \Lopt{openany} option lets Chapters
2630 % start on any page.
2631 % \changes{v1.0}{2001/10/24}{Added the openleft option}
2632 % \begin{macrocode}
2633 \DeclareOption{openright}{\@openrighttrue}
2634 \DeclareOption{openany}{\@openrightfalse}
2635 \DeclareOption{openleft}{\@openlefttrue}
2636 % \end{macrocode}
2637 %
2638 % \begin{macro}{\openright}
2639 % \begin{macro}{\openany}
2640 % \begin{macro}{\openleft}
2641 % Commands that can be used to change the option in the middle of the
2642 % document\footnote{Openleft provided to meet a request by
2643 % Vladimir G.~Ivanovic in September 2001.}.
2644 % \begin{macrocode}
2645 \newcommand{\openright}{\@openrighttrue\@openleftfalse%
2646 \gdef\clearforchapter{\cleartorecto}}
2647 \newcommand{\openany}{\@openrightfalse\@openleftfalse%
2648 \gdef\clearforchapter{\clearpage}}
2649 \newcommand{\openleft}{\@openlefttrue
2650 \gdef\clearforchapter{\cleartoverso}}
2651
2652 % \end{macrocode}
2653 % \end{macro}
2654 % \end{macro}
2655 % \end{macro}
2656 %
2657 %
2658 % \subsection{Equation numbering on the left}
2659 %
2660 % The \Lopt{leqno} option prints equation numbers on the left. This
2661 % is implemented via an external class option file.
2662 % \begin{macrocode}
2663 \DeclareOption{leqno}{\input{leqno.clo}}
2664 % \end{macrocode}
2665 %
2666 % \subsection{Flush left math displays}
2667 %
2668 % The \Lopt{fleqn} option redefines the displayed math environments
2669 % so that they are left adjusted with an indent of \cs{mathindent}
2670 % from the current left margin. This
2671 % is implemented via an external class option file.
2672 % \begin{macrocode}
2673 \DeclareOption{fleqn}{\input{fleqn.clo}}
2674 % \end{macrocode}
2675 %
2676 % \subsection{Open bibliography}
2677 %
2678 % The \Lopt{openbib} option redefines the \verb?thebibliography? so that each
2679 % block starts on a new line, and succeeding lines in a block are
2680 % indented by \cs{bibindent}.
2681 % \changes{v1.0a}{2001/11/28}{Replaced \cs{AtEndOfPackage} with \cs{AtEndOfClass}}
2682 % \begin{macrocode}
2683 \DeclareOption{openbib}{%
2684 \AtEndOfClass{%
2685 \renewcommand\@openbib@code{%
2686 \advance\leftmargin\bibindent
2687 \itemindent -\bibindent
2688 \listparindent \itemindent
2689 \parsep \z@
2690 }%
2691 \renewcommand\newblock{\par}}}
2692
2693 % \end{macrocode}
2694 %
2695 % \subsection{Old font commands}
2696 %
2697 % The \Lopt{oldfontcommands} option enables commands like \cs{bf} and friends.
2698 % \changes{v1.0a}{2002/01/29}{Added the oldfontcommands option}
2699 % \begin{macrocode}
2700 \DeclareOption{oldfontcommands}{\@memoldfonttrue}
2701 % \end{macrocode}
2702 %
2703 % \subsection{Extra font sizes}
2704 %
2705 % The \Lopt{extrafontsizes} options indicates that extended font sizes (above 25pt)
2706 % are available.
2707 % \changes{v1.61803}{2008/01/30}{Added extrafontsizes option.}
2708 % \begin{macrocode}
2709 \DeclareOption{extrafontsizes}{\extrafontsizestrue}
2710
2711 % \end{macrocode}
2712 %
2713 % \subsection{The \Lopt{fullptlayout} option}
2714 % \changes{v3.7g}{2018/03/09}{Added the \Lopt{fullptlayout} option}
2715 % \begin{macro}{\mem@settopoint}
2716 % By default the class will truncate some layout lengths to a whole
2717 % number of points.\footnote{Presumably because it looks better when
2718 % the layout is written to the log.} This might not be desirable, so the
2719 % \Lopt{fullptlayout} class option disables this truncation.
2720 % \begin{macrocode}
2721 \newcommand\mem@settopoint[1]{\@settopoint{#1}}
2722 \DeclareOption{fullptlayout}{\renewcommand\mem@settopoint{\@gobble}}
2723
2724 % \end{macrocode}
2725 % \end{macro}
2726 %
2727 %
2728 %
2729 % \section{Executing Options} \label{sec:xopt}
2730 %
2731 % Here we execute the default options to initialize certain
2732 % variables.
2733 % \begin{macrocode}
2734 \ExecuteOptions{final,letterpaper,10pt,onecolumn,openright,twoside,
2735 portrait}
2736 % \end{macrocode}
2737 %
2738 % The \cs{ProcessOptions} command causes the execution of the code
2739 % for every option \Lopt{foo}
2740 % which is declared and for which the user typed
2741 % the \Lopt{foo} option in his
2742 % \cs{documentclass} command. For every option \Lopt{bar} he typed,
2743 % which is not declared, the option is assumed to be a global option.
2744 % All options will be passed as document options to any
2745 % \cs{usepackage} command in the document preamble.
2746 %
2747 % \cs{ProcessOptions*} processes the options in the order they are given
2748 % in the \cs{documentclass} command, instead of the definition order.
2749 % \changes{v1.6180339c}{2008/12/26}{Change \cs{ProcessOptions} to
2750 % \cs{ProcessOptions*} and handle landscape/portrait
2751 % option after \cs{ProcessOptions*}}
2752 % \begin{macrocode}
2753 \ProcessOptions*
2754
2755 % \end{macrocode}
2756 % Execute the delayed landscape switch if given
2757 % \begin{macrocode}
2758 \ifmemlandscape
2759 \setlength\@tempdima {\stockheight}
2760 \setlength\stockheight{\stockwidth}
2761 \setlength\stockwidth {\@tempdima}
2762 \fi
2763
2764 % \end{macrocode}
2765
2766 % \begin{macro}{\memoirpostopthook}
2767 % A user could define this \emph{before} the \cs{documentclass} command
2768 % to do something at this point. For example, to set up a new stock size: \\
2769 % \verb?\def\memoirpostopthook{\stockheight=44in \stockwidth=34in}?
2770 % \changes{v1.618033}{2008/06/02}{Added \cs{memoirpostopthook}}
2771 % \begin{macrocode}
2772 \providecommand*{\memoirpostopthook}{}
2773 \memoirpostopthook
2774
2775 % \end{macrocode}
2776 % \end{macro}
2777 %
2778 % \begin{macro}{\cleartorecto}
2779 % A repeat of \cs{cleardoublepage}; clears to a recto (odd-numbered) page.
2780 % \begin{macrocode}
2781 \def\cleartorecto{\clearpage\if@twoside \ifodd\c@page\else
2782 \hbox{}\thispagestyle{cleared}%
2783 \newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
2784
2785 % \end{macrocode}
2786 % \end{macro}
2787 %
2788 % \begin{macro}{\cleartoverso}
2789 % Clears to a verso (even-numbered) page.
2790 % \begin{macrocode}
2791 \def\cleartoverso{\clearpage\if@twoside
2792 \ifodd\c@page\hbox{}\thispagestyle{cleared}%
2793 \newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
2794
2795 % \end{macrocode}
2796 % \end{macro}
2797 %
2798
2799 % Set the macro \cs{clearforchapter} according to the options (via
2800 % \cs{openleft}, \cs{openright} or \cs{openany} defined
2801 % earlier)
2802 % \begin{macrocode}
2803 \if@openleft
2804 \openleft
2805 \else
2806 \if@openright
2807 \openright
2808 \else
2809 \openany
2810 \fi
2811 \fi
2812
2813 % \end{macrocode}
2814 %
2815 % \begin{macro}{\@ivpt}
2816 % \begin{macro}{\@xxxpt}
2817 % \begin{macro}{\@xxxvipt}
2818 % \begin{macro}{\@xlviiipt}
2819 % \begin{macro}{\@lxpt}
2820 % \begin{macro}{\@lxxiipt}
2821 % \begin{macro}{\@lxxxivpt}
2822 % \begin{macro}{\@xcvipt}
2823 % \begin{macro}{\@cviiipt}
2824 % \begin{macro}{\@cxxpt}
2825 % \begin{macro}{\@cxxxiipt}
2826 % \changes{v1.61803}{2008/01/30}{Added a bunch of \cs{@...pt} macros}
2827 % \begin{macrocode}
2828 \newcommand*{\@ivpt}{4}
2829 \newcommand*{\@xxxpt}{30}
2830 \newcommand*{\@xxxvipt}{36}
2831 \newcommand*{\@xlviiipt}{48}
2832 \newcommand*{\@lxpt}{60}
2833 \newcommand*{\@lxxiipt}{72}
2834 \newcommand*{\@lxxxivpt}{84}
2835 \newcommand*{\@xcvipt}{96}
2836 \newcommand*{\@cviiipt}{108}
2837 \newcommand*{\@cxxpt}{120}
2838 \newcommand*{\@cxxxiipt}{132}
2839
2840 % \end{macrocode}
2841 % \end{macro}
2842 % \end{macro}
2843 % \end{macro}
2844 % \end{macro}
2845 % \end{macro}
2846 % \end{macro}
2847 % \end{macro}
2848 % \end{macro}
2849 % \end{macro}
2850 % \end{macro}
2851 % \end{macro}
2852 %
2853 % Now that all the options have been executed we can load the
2854 % chosen class option file that contains all size dependent code. The
2855 % larger sizes are only made available for the \Lopt{extrafontsizes} option.
2856 %
2857 % \begin{macro}{\memfontfamily}
2858 % \begin{macro}{\memfontenc}
2859 % \begin{macro}{\memfontpack}
2860 % The default font and coding as set by the kernel is \texttt{cmr} and
2861 % \texttt{OT1} respectively, giving Knuth's original Computer Modern Roman
2862 % font at a set of fixed sizes (maximum of 24.88pt). If we are to have
2863 % any size font we have to go to a scaleable font. As the Latin Modern font
2864 % is a scaleable version of Computer Modern, and all modern LaTeX distributions
2865 % include it, I am using this by default.
2866 %
2867 % By defining these three macros \emph{before}
2868 % the \cs{documentclass} any other font and package can be used.
2869 % \begin{macrocode}
2870 \providecommand*{\memfontfamily}{lmr}
2871 \providecommand*{\memfontenc}{T1}
2872 \providecommand*{\memfontpack}{lmodern}
2873
2874 % \end{macrocode}
2875 % \end{macro}
2876 % \end{macro}
2877 % \end{macro}
2878 %
2879 % Deal with the `anyptsize' (\Lopt{*pt}) option first. In this case the macros
2880 % \cs{anyptfilebase} and \cs{anyptsize} should have been defined by the
2881 % author \emph{before} the \cs{documentclass} command, and a file \\
2882 % \verb?\anyptfilebase\anyptsize.clo? should exist (if not the file will
2883 % default to \verb?mem10.clo?).
2884 % \changes{v1.61803}{2008/01/30}{Extended the loading of \texttt{.clo} files.}
2885 % \begin{macrocode}
2886 \if@nyptsizeopt
2887 \newcommand*{\@nyptclofile}{\anyptfilebase\anyptsize.clo}
2888 \IfFileExists{\@nyptclofile}{\def\@memptsize{\anyptsize}}{%
2889 \@memerror{You have used the `*pt' option but \MessageBreak
2890 file \@nyptclofile\space can't be found}%
2891 {I'll use mem10.clo instead}
2892 \renewcommand*{\@nyptclofile}{mem10.clo}%
2893 \def\@memptsize{10}%
2894 }
2895 \renewcommand*{\@ptsize}{\@memptsize}
2896 \usefont{\memfontenc}{\memfontfamily}{m}{n}
2897 \input{\@nyptclofile}
2898 % \end{macrocode}
2899 % Packages in a class should be loaded via \cs{RequirePackage}. Also
2900 % don't load \Lpack{fontenc} under Xe- or LuaLaTeX.
2901 % \changes{v3.8.3}{2024/08/30}{Changed}
2902 % \begin{macrocode}
2903 \RequirePackage{\memfontpack}
2904 \iftutex\else
2905 \RequirePackage[\memfontenc]{fontenc}
2906 \fi
2907 \else
2908 % \end{macrocode}
2909 % Now for the fixed pt size options.
2910 % \begin{macrocode}
2911 \ifextrafontsizes
2912 \usefont{\memfontenc}{\memfontfamily}{m}{n}
2913 \input{mem\@memptsize.clo}
2914 % \end{macrocode}
2915 % Packages in a class should be loaded via \cs{RequirePackage}. Also
2916 % don't load \Lpack{fontenc} under Xe- or LuaLaTeX.
2917 % \changes{v3.8.3}{2024/08/30}{Changed}
2918 % \begin{macrocode}
2919 \RequirePackage{\memfontpack}
2920 \iftutex\else
2921 \RequirePackage[\memfontenc]{fontenc}
2922 \fi
2923 \else
2924 \ifnum\@memptsize > 17\relax
2925 \@memerror{The `extrafontsizes' option is required to use \MessageBreak
2926 the `\@memptsize pt' option}%
2927 {The 17pt option will be used instead}
2928 \input{mem17.clo}
2929 \else
2930 \ifnum\@ptsize = 9\relax
2931 \input{mem\@ptsize.clo}
2932 \else
2933 \input{mem1\@ptsize.clo}
2934 \fi
2935 \fi
2936 \fi
2937 \fi
2938
2939 %</class>
2940 % \end{macrocode}
2941 %
2942 %
2943 % \section{Fonts and spaces} \label{sec:docl}
2944 % \label{sec:maincode}
2945 %
2946 % In this section we deal with most of the aspects that are related
2947 % to font sizes, and spacing that is related to the size of the body font.
2948 %
2949 % \subsection{Fonts}
2950 %
2951 % \LaTeX\ offers the user commands to change the size of the font,
2952 % relative to the `main' size. Each relative size changing command
2953 % \cs{size} executes the command
2954 % \verb?\@setfontsize\size? \meta{font-size} \meta{baselineskip} where:
2955 %
2956 % \begin{description}
2957 % \item[\meta{font-size}] The absolute size of the font to use from
2958 % now on.
2959 %
2960 % \item[\meta{baselineskip}] The normal value of \cs{baselineskip}
2961 % for the size of the font selected. (The actual value will be
2962 % \cs{baselinestretch} * \meta{baselineskip}.)
2963 % \end{description}
2964 %
2965 % A number of commands, defined in the \LaTeX\ kernel, shorten the
2966 % following definitions and are used throughout. They are listed in
2967 % the first part of Table~\ref{tab:sh}. Those in the second part are introduced
2968 % by the class.
2969 %
2970 % \begin{table}
2971 % \centering
2972 % \caption{Shorthand font point size commands}\label{tab:sh}
2973 % \begin{tabular}{ll@{\qquad}ll@{\qquad}ll} \hline
2974 % & & & & \cs{@ivpt} & 4 \\
2975 % \cs{@vpt} & 5 & \cs{@vipt} & 6 & \cs{@viipt} & 7 \\
2976 % \cs{@viiipt} & 8 & \cs{@ixpt} & 9 & \cs{@xpt} & 10 \\
2977 % \cs{@xipt} & 10.95 & \cs{@xiipt} & 12 & \cs{@xivpt} & 14.4\\
2978 % \cs{@xviipt} & 17.28 & \cs{@xxpt} & 20.74 & \cs{@xxvpt} & 24.88\\ \hline
2979 % \cs{@xxxpt} & 30 & \cs{@xxxvipt} & 36 & \cs{@xlviiipt} & 48 \\
2980 % \cs{@lxpt} & 60 & \cs{@lxxiipt} & 72 & \cs{@lxxxivpt} & 84 \\
2981 % \cs{@xcvipt} & 96 & \cs{@cviiipt} & 108 & \cs{@cxxpt} & 120 \\
2982 % \cs{@cxxxiipt} & 132 \\ \hline
2983 % \end{tabular}
2984 % \end{table}
2985 %
2986 % \begin{macro}{\normalsize}
2987 % \begin{macro}{\@normalsize}
2988 %
2989 % The user level command for the main size is \cs{normalsize}.
2990 % Internally \LaTeX\ uses \cs{@normalsize} when it refers to the
2991 % main size. \cs{@normalsize} will be defined to work like
2992 % \cs{normalsize} if the latter is redefined from its default
2993 % definition (that just issues an error message). Otherwise, in the standard
2994 % classes \cs{@normalsize} simply selects a 10pt/12pt size, but here
2995 % it selects among the wider range.
2996 %
2997 % The \cs{normalsize} macro also sets new values for\\
2998 % \cs{abovedisplayskip}, \cs{abovedisplayshortskip} and
2999 % \cs{belowdisplayshortskip}.
3000 %
3001 % For the larger sizes I have set \cs{abovedisplayskip} to the font size
3002 % and \cs{belowdisplayshortskip} to 0.5\cs{onelineskip}.
3003 %
3004 % \begin{macrocode}
3005 %<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3006 % \end{macrocode}
3007 % \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed baseline skip from 17.28pt to 17.5pt}
3008 % \changes{v1.61803}{2008/01/30}{Added files mem20.clo through mem60.clo}
3009 % \changes{v1.61803}{2008/01/30}{Changed .clo files to accomodate \cs{extrafontsizes}}
3010 % \begin{macrocode}
3011 \renewcommand{\normalsize}{%
3012 %<*9pt>
3013 \@setfontsize\normalsize\@ixpt\@xpt
3014 \abovedisplayskip 9\p@ \@plus 2\p@ \@minus 4.5\p@
3015 \abovedisplayshortskip \z@ \@plus 3\p@
3016 \belowdisplayshortskip 5.5\p@ \@plus 2.5\p@ \@minus 3\p@
3017 %</9pt>
3018 %<*10pt>
3019 \@setfontsize\normalsize\@xpt\@xiipt
3020 \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
3021 \abovedisplayshortskip \z@ \@plus3\p@
3022 \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
3023 %</10pt>
3024 %<*11pt>
3025 \@setfontsize\normalsize\@xipt{13.6}%
3026 \abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
3027 \abovedisplayshortskip \z@ \@plus3\p@
3028 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3029 %</11pt>
3030 %<*12pt>
3031 \@setfontsize\normalsize\@xiipt{14.5}%
3032 \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
3033 \abovedisplayshortskip \z@ \@plus3\p@
3034 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3035 %</12pt>
3036 %<*14pt>
3037 \@setfontsize\normalsize\@xivpt{17.5}%
3038 \abovedisplayskip 14\p@ \@plus3\p@ \@minus8\p@
3039 \abovedisplayshortskip \z@ \@plus3\p@
3040 \belowdisplayshortskip 7\p@ \@plus3.5\p@ \@minus3\p@
3041 %</14pt>
3042 %<*17pt>
3043 \@setfontsize\normalsize\@xviipt{22}%
3044 \abovedisplayskip 15\p@ \@plus4\p@ \@minus8\p@
3045 \abovedisplayshortskip \z@ \@plus4\p@
3046 \belowdisplayshortskip 8\p@ \@plus4\p@ \@minus3\p@
3047 %</17pt>
3048 %<*20pt>
3049 \@setfontsize\normalsize\@xxpt{25}%
3050 \abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
3051 \abovedisplayshortskip \z@ \@plus5\p@
3052 \belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
3053 %</20pt>
3054 %<*25pt>
3055 \@setfontsize\normalsize\@xxvpt{30}%
3056 \abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
3057 \abovedisplayshortskip \z@ \@plus6\p@
3058 \belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
3059 %</25pt>
3060 %<*30pt>
3061 \@setfontsize\normalsize\@xxxpt{37}%
3062 \abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
3063 \abovedisplayshortskip \z@ \@plus7\p@
3064 \belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
3065 %</30pt>
3066 %<*36pt>
3067 \@setfontsize\normalsize\@xxxvipt{45}%
3068 \abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
3069 \abovedisplayshortskip \z@ \@plus8\p@
3070 \belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
3071 %</36pt>
3072 %<*48pt>
3073 \@setfontsize\normalsize\@xlviiipt{60}%
3074 \abovedisplayskip 48\p@ \@plus9\p@ \@minus13\p@
3075 \abovedisplayshortskip \z@ \@plus9\p@
3076 \belowdisplayshortskip 30\p@ \@plus15\p@ \@minus7\p@
3077 %</48pt>
3078 %<*60pt>
3079 \@setfontsize\normalsize\@lxpt{72}%
3080 \abovedisplayskip 60\p@ \@plus10\p@ \@minus14\p@
3081 \abovedisplayshortskip \z@ \@plus10\p@
3082 \belowdisplayshortskip 36\p@ \@plus18\p@ \@minus9\p@
3083 %</60pt>
3084 % \end{macrocode}
3085 % The \cs{belowdisplayskip} is always equal to the
3086 % \cs{abovedisplayskip}. The parameters of the first level list are
3087 % always given by \cs{@listI}.
3088 % \begin{macrocode}
3089 \belowdisplayskip \abovedisplayskip
3090 \let\@listi\@listI}
3091 % \end{macrocode}
3092 %
3093 % We initially choose the normalsize font.
3094 % \begin{macrocode}
3095 \normalsize
3096 % \end{macrocode}
3097 % \changes{v3.7r}{2022/07/26}{Make \cs{normalsize} robust in the same
3098 % manner as in \file{size10.clo}}
3099 % \begin{macrocode}
3100 \ifx\MakeRobust\@undefined \else
3101 \MakeRobust\normalsize
3102 \fi
3103 % \end{macrocode}
3104 % \end{macro}
3105 % \end{macro}
3106 %
3107 % \begin{macro}{\small}
3108 % This code is similar to that for \cs{normalsize}.
3109 % (Robert Schlicht via email on 2004/03/11
3110 % noted that in some cases \% signs were missing after \verb?\@setfontsize?).
3111 %
3112 % For the larger sizes I have set \cs{topsep} to 2/3\cs{onelineskip}
3113 % and \cs{parsep} to 1/2\cs{topsep}.
3114 % \changes{v1.61}{2004/03/12}{Added missing percent signs to some uses of
3115 % \cs{@setfontsize}}
3116 % \changes{v3.7r}{2022/07/26}{Make robust}
3117 % \begin{macrocode}
3118 \DeclareRobustCommand{\small}{%
3119 %<*9pt>
3120 \@setfontsize\small\@viiipt{9.5}%
3121 \abovedisplayskip 6\p@ \@plus 2\p@ \@minus 4\p@
3122 \abovedisplayshortskip \z@ \@plus 2\p@
3123 \belowdisplayshortskip 4\p@ \@plus 2\p@ \@minus 2\p@
3124 \def\@listi{\leftmargin\leftmargini
3125 \topsep 2\p@ \@plus 2\p@ \@minus 2\p@
3126 \parsep 1\p@ \@plus\p@ \@minus\p@
3127 \itemsep \parsep
3128 %% \itemindent\z@
3129 }%
3130 %</9pt>
3131 %<*10pt>
3132 \@setfontsize\small\@ixpt{11}%
3133 \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
3134 \abovedisplayshortskip \z@ \@plus2\p@
3135 \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
3136 \def\@listi{\leftmargin\leftmargini
3137 \topsep 4\p@ \@plus2\p@ \@minus2\p@
3138 \parsep 2\p@ \@plus\p@ \@minus\p@
3139 \itemsep \parsep
3140 %% \itemindent\z@
3141 }%
3142 %</10pt>
3143 %<*11pt>
3144 \@setfontsize\small\@xpt\@xiipt
3145 \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
3146 \abovedisplayshortskip \z@ \@plus3\p@
3147 \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
3148 \def\@listi{\leftmargin\leftmargini
3149 \topsep 6\p@ \@plus2\p@ \@minus2\p@
3150 \parsep 3\p@ \@plus2\p@ \@minus\p@
3151 \itemsep \parsep
3152 %% \itemindent\z@
3153 }%
3154 %</11pt>
3155 %<*12pt>
3156 \@setfontsize\small\@xipt{13.6}%
3157 \abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
3158 \abovedisplayshortskip \z@ \@plus3\p@
3159 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3160 \def\@listi{\leftmargin\leftmargini
3161 \topsep 9\p@ \@plus3\p@ \@minus5\p@
3162 \parsep 4.5\p@ \@plus2\p@ \@minus\p@
3163 \itemsep \parsep
3164 %% \itemindent\z@
3165 }%
3166 %</12pt>
3167 %<*14pt>
3168 \@setfontsize\small\@xiipt{14.5}%
3169 \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
3170 \abovedisplayshortskip \z@ \@plus3\p@
3171 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3172 \def\@listi{\leftmargin\leftmargini
3173 \topsep 11\p@ \@plus4\p@ \@minus6\p@
3174 \parsep 6\p@ \@plus3\p@ \@minus\p@
3175 \itemsep \parsep
3176 %% \itemindent\z@
3177 }%
3178 %</14pt>
3179 %<*17pt>
3180 \@setfontsize\small\@xivpt{17}%
3181 \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
3182 \abovedisplayshortskip \z@ \@plus3\p@
3183 \belowdisplayshortskip 7\p@ \@plus4\p@ \@minus3\p@
3184 \def\@listi{\leftmargin\leftmargini
3185 \topsep 11\p@ \@plus4\p@ \@minus6\p@
3186 \parsep 6\p@ \@plus3\p@ \@minus\p@
3187 \itemsep \parsep
3188 %% \itemindent\z@
3189 }%
3190 %</17pt>
3191 %<*20pt>
3192 \@setfontsize\small\@xviipt{22}%
3193 \abovedisplayskip 17\p@ \@plus4\p@ \@minus8\p@
3194 \abovedisplayshortskip \z@ \@plus4\p@
3195 \belowdisplayshortskip 11\p@ \@plus4\p@ \@minus3\p@
3196 \def\@listi{\leftmargin\leftmargini
3197 \topsep 14\p@ \@plus5\p@ \@minus7\p@
3198 \parsep 7\p@ \@plus2\p@ \@minus3\p@
3199 \itemsep \parsep}%
3200 %</20pt>
3201 %<*25pt>
3202 \@setfontsize\small\@xxpt{25}%
3203 \abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
3204 \abovedisplayshortskip \z@ \@plus5\p@
3205 \belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
3206 \def\@listi{\leftmargin\leftmargini
3207 \topsep 16\p@ \@plus5\p@ \@minus8\p@
3208 \parsep 8\p@ \@plus3\p@ \@minus4\p@
3209 \itemsep \parsep}%
3210 %</25pt>
3211 %<*30pt>
3212 \@setfontsize\small\@xxvpt{30}%
3213 \abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
3214 \abovedisplayshortskip \z@ \@plus6\p@
3215 \belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
3216 \def\@listi{\leftmargin\leftmargini
3217 \topsep 20\p@ \@plus7\p@ \@minus10\p@
3218 \parsep 10\p@ \@plus4\p@ \@minus5\p@
3219 \itemsep \parsep}%
3220 %</30pt>
3221 %<*36pt>
3222 \@setfontsize\small\@xxxpt{37}%
3223 \abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
3224 \abovedisplayshortskip \z@ \@plus7\p@
3225 \belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
3226 \def\@listi{\leftmargin\leftmargini
3227 \topsep 24\p@ \@plus8\p@ \@minus12\p@
3228 \parsep 12\p@ \@plus4\p@ \@minus6\p@
3229 \itemsep \parsep}%
3230 %</36pt>
3231 %<*48pt>
3232 \@setfontsize\small\@xxxvipt{45}%
3233 \abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
3234 \abovedisplayshortskip \z@ \@plus8\p@
3235 \belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
3236 \def\@listi{\leftmargin\leftmargini
3237 \topsep 30\p@ \@plus10\p@ \@minus15\p@
3238 \parsep 15\p@ \@plus5\p@ \@minus7\p@
3239 \itemsep \parsep}%
3240 %</48pt>
3241 %<*60pt>
3242 \@setfontsize\small\@xlviiipt{60}%
3243 \abovedisplayskip 48\p@ \@plus9\p@ \@minus13\p@
3244 \abovedisplayshortskip \z@ \@plus9\p@
3245 \belowdisplayshortskip 30\p@ \@plus15\p@ \@minus7\p@
3246 \def\@listi{\leftmargin\leftmargini
3247 \topsep 40\p@ \@plus13\p@ \@minus20\p@
3248 \parsep 20\p@ \@plus6\p@ \@minus10\p@
3249 \itemsep \parsep}%
3250 %</60pt>
3251 \belowdisplayskip \abovedisplayskip
3252 }
3253 % \end{macrocode}
3254 % \end{macro}
3255 %
3256 % \begin{macro}{\footnotesize}
3257 % This code is similar to that for \cs{small}.
3258 % \changes{v3.7r}{2022/07/26}{Make robust}
3259 % \begin{macrocode}
3260 \DeclareRobustCommand{\footnotesize}{%
3261 %<*9pt>
3262 \@setfontsize\footnotesize\@viipt{8}%
3263 \abovedisplayskip 6\p@ \@plus 2\p@ \@minus 4\p@
3264 \abovedisplayshortskip \z@ \@plus 2\p@
3265 \belowdisplayshortskip 4\p@ \@plus 2\p@ \@minus 2\p@
3266 \def\@listi{\leftmargin\leftmargini
3267 \topsep 2\p@ \@plus 2\p@ \@minus 2\p@
3268 \parsep 1\p@ \@plus\p@ \@minus\p@
3269 \itemsep \parsep
3270 %% \itemindent\z@
3271 }%
3272 %</9pt>
3273 %<*10pt>
3274 \@setfontsize\footnotesize\@viiipt{9.5}%
3275 \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
3276 \abovedisplayshortskip \z@ \@plus\p@
3277 \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
3278 \def\@listi{\leftmargin\leftmargini
3279 \topsep 3\p@ \@plus\p@ \@minus\p@
3280 \parsep 2\p@ \@plus\p@ \@minus\p@
3281 \itemsep \parsep
3282 %% \itemindent\z@
3283 }%
3284 %</10pt>
3285 %<*11pt>
3286 \@setfontsize\footnotesize\@ixpt{11}%
3287 \abovedisplayskip 8\p@ \@plus2\p@ \@minus4\p@
3288 \abovedisplayshortskip \z@ \@plus\p@
3289 \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
3290 \def\@listi{\leftmargin\leftmargini
3291 \topsep 4\p@ \@plus2\p@ \@minus2\p@
3292 \parsep 2\p@ \@plus\p@ \@minus\p@
3293 \itemsep \parsep
3294 %% \itemindent\z@
3295 }%
3296 %</11pt>
3297 %<*12pt>
3298 \@setfontsize\footnotesize\@xpt\@xiipt
3299 \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
3300 \abovedisplayshortskip \z@ \@plus3\p@
3301 \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
3302 \def\@listi{\leftmargin\leftmargini
3303 \topsep 6\p@ \@plus2\p@ \@minus2\p@
3304 \parsep 3\p@ \@plus2\p@ \@minus\p@
3305 \itemsep \parsep
3306 %% \itemindent\z@
3307 }%
3308 %</12pt>
3309 %<*14pt>
3310 \@setfontsize\footnotesize\@xipt{13.6}%
3311 \abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
3312 \abovedisplayshortskip \z@ \@plus3\p@
3313 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3314 \def\@listi{\leftmargin\leftmargini
3315 \topsep 6.5\p@ \@plus3.5\p@ \@minus3\p@
3316 \parsep 4\p@ \@plus3\p@ \@minus\p@
3317 \itemsep \parsep
3318 %% \itemindent\z@
3319 }%
3320 %</14pt>
3321 %<*17pt>
3322 \@setfontsize\footnotesize\@xiipt{14}%
3323 \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
3324 \abovedisplayshortskip \z@ \@plus3\p@
3325 \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
3326 \def\@listi{\leftmargin\leftmargini
3327 \topsep 6.5\p@ \@plus3.5\p@ \@minus3\p@
3328 \parsep 4\p@ \@plus3\p@ \@minus\p@
3329 \itemsep \parsep
3330 %% \itemindent\z@
3331 }%
3332 %</17pt>
3333 %<*20pt>
3334 \@setfontsize\footnotesize\@xivpt{17.5}%
3335 \abovedisplayskip 14\p@ \@plus3\p@ \@minus8\p@
3336 \abovedisplayshortskip \z@ \@plus3\p@
3337 \belowdisplayshortskip 7\p@ \@plus3.5\p@ \@minus3\p@
3338 \def\@listi{\leftmargin\leftmargini
3339 \topsep 12\p@ \@plus4\p@ \@minus6\p@
3340 \parsep 6\p@ \@plus2\p@ \@minus3\p@
3341 \itemsep \parsep}%
3342 %</20pt>
3343 %<*25pt>
3344 \@setfontsize\footnotesize\@xviipt{22}%
3345 \abovedisplayskip 17\p@ \@plus4\p@ \@minus8\p@
3346 \abovedisplayshortskip \z@ \@plus4\p@
3347 \belowdisplayshortskip 11\p@ \@plus4\p@ \@minus3\p@
3348 \def\@listi{\leftmargin\leftmargini
3349 \topsep 14\p@ \@plus5\p@ \@minus7\p@
3350 \parsep 7\p@ \@plus2\p@ \@minus3\p@
3351 \itemsep \parsep}%
3352 %</25pt>
3353 %<*30pt>
3354 \@setfontsize\footnotesize\@xxpt{25}%
3355 \abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
3356 \abovedisplayshortskip \z@ \@plus5\p@
3357 \belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
3358 \def\@listi{\leftmargin\leftmargini
3359 \topsep 16\p@ \@plus5\p@ \@minus8\p@
3360 \parsep 8\p@ \@plus3\p@ \@minus4\p@
3361 \itemsep \parsep}%
3362 %</30pt>
3363 %<*36pt>
3364 \@setfontsize\footnotesize\@xxvpt{30}%
3365 \abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
3366 \abovedisplayshortskip \z@ \@plus6\p@
3367 \belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
3368 \def\@listi{\leftmargin\leftmargini
3369 \topsep 20\p@ \@plus7\p@ \@minus10\p@
3370 \parsep 10\p@ \@plus4\p@ \@minus5\p@
3371 \itemsep \parsep}%
3372 %</36pt>
3373 %<*48pt>
3374 \@setfontsize\footnotesize\@xxxpt{37}%
3375 \abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
3376 \abovedisplayshortskip \z@ \@plus7\p@
3377 \belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
3378 \def\@listi{\leftmargin\leftmargini
3379 \topsep 24\p@ \@plus8\p@ \@minus12\p@
3380 \parsep 12\p@ \@plus4\p@ \@minus6\p@
3381 \itemsep \parsep}%
3382 %</48pt>
3383 %<*60pt>
3384 \@setfontsize\footnotesize\@xxxvipt{45}%
3385 \abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
3386 \abovedisplayshortskip \z@ \@plus8\p@
3387 \belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
3388 \def\@listi{\leftmargin\leftmargini
3389 \topsep 30\p@ \@plus10\p@ \@minus15\p@
3390 \parsep 15\p@ \@plus5\p@ \@minus7\p@
3391 \itemsep \parsep}%
3392 %</60pt>
3393 \belowdisplayskip \abovedisplayskip
3394 }
3395 % \end{macrocode}
3396 % \end{macro}
3397 %
3398 % \begin{macro}{\miniscule}
3399 % \begin{macro}{\scriptsize}
3400 % \begin{macro}{\tiny}
3401 % \begin{macro}{\large}
3402 % \begin{macro}{\Large}
3403 % \begin{macro}{\LARGE}
3404 % \begin{macro}{\huge}
3405 % \begin{macro}{\Huge}
3406 % \begin{macro}{\HUGE}
3407 % These are all much simpler than the previous macros, they just
3408 % select a new fontsize, but leave the parameters for displays and
3409 % lists alone. The class provides two additional sizes, \cs{miniscule}
3410 % and \cs{HUGE}, with respect to the usual set. For the larger sizes (e.g.,
3411 % 72pt and above) I have
3412 % made the \cs{baselineskip} approximately 20 precent larger than the pt size.
3413 % \changes{v1.2}{2002/07/27}{Added \cs{miniscule} and \cs{HUGE} font sizes}
3414 % \changes{v1.2}{2002/07/27}{Twiddled some font sizes to get regular steps}
3415 % \changes{v1.2a}{2002/08/27}{Fixed 12pt scriptsize bug}
3416 % \changes{v3.7r}{2022/07/26}{Make robust}
3417 % \begin{macrocode}
3418 %<*9pt>
3419 \ifextrafontsizes
3420 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@ivpt{5}}
3421 \else
3422 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vpt{6}}
3423 \fi
3424 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@vpt{6}}
3425 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@vipt{7}}
3426 \DeclareRobustCommand{\large}{\@setfontsize\large\@xpt{12}}
3427 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xipt{13.6}}
3428 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xiipt{14.5}}
3429 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xivpt{18}}
3430 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xviipt{22}}
3431 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxpt{25}}
3432 %</9pt>
3433 %<*10pt>
3434 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vpt{6}}
3435 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@vipt{7}}
3436 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@viipt{8}}
3437 \DeclareRobustCommand{\large}{\@setfontsize\large\@xipt{13.6}}
3438 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xiipt{14.5}}
3439 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xivpt{18}}
3440 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xviipt{22}}
3441 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxpt{25}}
3442 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxvpt{30}}
3443 %</10pt>
3444 %<*11pt>
3445 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vipt{7}}
3446 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@viipt{8}}
3447 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@viiipt{9.5}}
3448 \DeclareRobustCommand{\large}{\@setfontsize\large\@xiipt{14.5}}
3449 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xivpt{18}}
3450 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xviipt{22}}
3451 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxpt{25}}
3452 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxvpt{30}}
3453 \ifextrafontsizes
3454 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxxpt{37}}
3455 \else
3456 \let\HUGE=\Huge
3457 \fi
3458 %</11pt>
3459 %<*12pt>
3460 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@viipt{8}}
3461 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@viiipt{9.5}}
3462 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@ixpt\@xpt}
3463 \DeclareRobustCommand{\large}{\@setfontsize\large\@xivpt{18}}
3464 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xviipt{22}}
3465 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxpt{25}}
3466 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxvpt{30}}
3467 \ifextrafontsizes
3468 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxxpt{37}}
3469 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxxvipt{45}}
3470 \else
3471 \let\Huge=\huge
3472 \let\HUGE=\huge
3473 \fi
3474 %</12pt>
3475 %<*14pt>
3476 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@viiipt{9.5}}
3477 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@ixpt{10}}
3478 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xpt{12}}
3479 \DeclareRobustCommand{\large}{\@setfontsize\large\@xviipt{22}}
3480 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxpt{25}}
3481 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxvpt{30}}
3482 \ifextrafontsizes
3483 \DeclareRobustCommand{\huge}{\@setfontsize\Huge\@xxxpt{37}}
3484 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxxvipt{45}}
3485 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xlviiipt{60}}
3486 \else
3487 \let\huge=\LARGE
3488 \let\Huge=\LARGE
3489 \let\HUGE=\LARGE
3490 \fi
3491 %</14pt>
3492 %<*17pt>
3493 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@ixpt{10}}
3494 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xpt{12}}
3495 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xipt{13.6}}
3496 \DeclareRobustCommand{\large}{\@setfontsize\large\@xxpt{25}}
3497 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxvpt{30}}
3498 \ifextrafontsizes
3499 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxxpt{37}}
3500 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxxvipt{45}}
3501 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xlviiipt{60}}
3502 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxpt{72}}
3503 \else
3504 \let\LARGE=\Large
3505 \let\huge=\Large
3506 \let\Huge=\Large
3507 \let\HUGE=\Large
3508 \fi
3509 %</17pt>
3510 %<*20pt>
3511 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xpt{12}}
3512 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xipt{13.6}}
3513 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xiipt{14.5}}
3514 \DeclareRobustCommand{\large}{\@setfontsize\large\@xxvpt{30}}
3515 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxxpt{37}}
3516 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxxvipt{45}}
3517 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xlviiipt{60}}
3518 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxpt{72}}
3519 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxxiipt{86}}
3520 %</20pt>
3521 %<*25pt>
3522 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xipt{13.6}}
3523 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xiipt{14.5}}
3524 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xivpt{17.5}}
3525 \DeclareRobustCommand{\large}{\@setfontsize\large\@xxxpt{37}}
3526 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxxvipt{45}}
3527 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xlviiipt{60}}
3528 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxpt{72}}
3529 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxxiipt{86}}
3530 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxxxivpt{100}}
3531 %</25pt>
3532 %<*30pt>
3533 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xiipt{14.5}}
3534 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xivpt{17.5}}
3535 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xviipt{22}}
3536 \DeclareRobustCommand{\large}{\@setfontsize\large\@xxxvipt{45}}
3537 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@xlviiipt{60}}
3538 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxpt{72}}
3539 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxxiipt{86}}
3540 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxxxivpt{100}}
3541 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xcvipt{116}}
3542 %</30pt>
3543 %<*36pt>
3544 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xivpt{17.5}}
3545 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xviipt{22}}
3546 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxpt{25}}
3547 \DeclareRobustCommand{\large}{\@setfontsize\large\@xlviiipt{60}}
3548 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxpt{72}}
3549 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxxiipt{86}}
3550 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxxxivpt{100}}
3551 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xcvipt{116}}
3552 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cviiipt{132}}
3553 %</36pt>
3554 %<*48pt>
3555 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xviipt{22}}
3556 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xxpt{25}}
3557 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxvpt{30}}
3558 \DeclareRobustCommand{\large}{\@setfontsize\large\@lxpt{72}}
3559 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxxiipt{86}}
3560 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxxxivpt{100}}
3561 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@xcvipt{116}}
3562 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@cviiipt{132}}
3563 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cxxpt{144}}
3564 %</48pt>
3565 %<*60pt>
3566 \DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xxpt{25}}
3567 \DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xxvpt{30}}
3568 \DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxxpt{37}}
3569 \DeclareRobustCommand{\large}{\@setfontsize\large\@lxxiipt{86}}
3570 \DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxxxivpt{100}}
3571 \DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xcvipt{116}}
3572 \DeclareRobustCommand{\huge}{\@setfontsize\huge\@cviiipt{132}}
3573 \DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@cxxpt{144}}
3574 \DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cxxxiipt{162}}
3575 %</60pt>
3576 % \end{macrocode}
3577 % \end{macro}
3578 % \end{macro}
3579 % \end{macro}
3580 % \end{macro}
3581 % \end{macro}
3582 % \end{macro}
3583 % \end{macro}
3584 % \end{macro}
3585 % \end{macro}
3586 %
3587 %
3588 % \begin{macrocode}
3589 %</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3590 %<*class>
3591 % \end{macrocode}
3592 %
3593 % \begin{macro}{\captionsize}
3594 % This internal command holds the font size for captions.
3595 % \begin{macrocode}
3596 \newcommand{\captionsize}{\normalsize}
3597 % \end{macrocode}
3598 % \end{macro}
3599 %
3600 % \subsection{Paragraphing}
3601 %
3602 % \begin{macro}{\lineskip}
3603 % \begin{macro}{\normallineskip}
3604 % These parameters control \TeX's behaviour when two lines tend to
3605 % come too close together.
3606 % \begin{macrocode}
3607 \setlength\lineskip{1\p@}
3608 \setlength\normallineskip{1\p@}
3609 % \end{macrocode}
3610 % \end{macro}
3611 % \end{macro}
3612 %
3613 % \begin{macro}{\baselinestretch}
3614 % This is used as a multiplier for \cs{baselineskip}. The default is
3615 % to \emph{not} stretch the baselines.
3616 % \begin{macrocode}
3617 \renewcommand{\baselinestretch}{}
3618 % \end{macrocode}
3619 % \end{macro}
3620 %
3621 %
3622 % \begin{macro}{\parskip}
3623 % \begin{macro}{\onelineskip}
3624 %
3625 % \cs{parskip} is additional vertical space between paragraphs; default
3626 % is zero.
3627 %
3628 %
3629 % \cs{onelineskip} is the default space between baselines.
3630 % \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed \cs{onelineskip} from 17.28pt to 17.5pt}
3631 % \begin{macrocode}
3632 \setlength\parskip{0\p@ \@plus \p@}
3633 %</class>
3634 %<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3635 %<9pt>\setlength{\onelineskip}{\@xpt\p@}
3636 %<10pt>\setlength{\onelineskip}{\@xiipt\p@}
3637 %<11pt>\setlength{\onelineskip}{13.6\p@}
3638 %<12pt>\setlength{\onelineskip}{14.5\p@}
3639 %<14pt>\setlength{\onelineskip}{17.5\p@}
3640 %<17pt>\setlength{\onelineskip}{22\p@}
3641 %<20pt>\setlength{\onelineskip}{25\p@}
3642 %<25pt>\setlength{\onelineskip}{30\p@}
3643 %<30pt>\setlength{\onelineskip}{37\p@}
3644 %<36pt>\setlength{\onelineskip}{45\p@}
3645 %<48pt>\setlength{\onelineskip}{60\p@}
3646 %<60pt>\setlength{\onelineskip}{72\p@}
3647 % \end{macrocode}
3648 % \end{macro}
3649 % \end{macro}
3650 %
3651 % \begin{macro}{\parindent}
3652 % \cs{parskip} gives extra vertical space between paragraphs and
3653 % \cs{parindent} is the width of the paragraph indentation.
3654 % \begin{macrocode}
3655 \if@twocolumn
3656 \setlength\parindent{1em}
3657 \else
3658 %<9pt> \setlength\parindent{12\p@}
3659 %<10pt> \setlength\parindent{15\p@}
3660 %<11pt> \setlength\parindent{17\p@}
3661 %<12pt> \setlength\parindent{1.5em}
3662 %<14pt> \setlength\parindent{1.5em}
3663 %<17pt> \setlength\parindent{1.5em}
3664 %<20pt> \setlength\parindent{1.5em}
3665 %<25pt> \setlength\parindent{1.5em}
3666 %<30pt> \setlength\parindent{1.5em}
3667 %<36pt> \setlength\parindent{1.5em}
3668 %<48pt> \setlength\parindent{1.5em}
3669 %<60pt> \setlength\parindent{1.5em}
3670 \fi
3671 %</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3672 % \end{macrocode}
3673 % \end{macro}
3674 %
3675 % \begin{macro}{\smallskipamount}
3676 % \begin{macro}{\medskipamount}
3677 % \begin{macro}{\bigskipamount}
3678 % The values for these three parameters are set in the LaTeX kernel.
3679 % Historically they have been size invariant, but I have changed them for
3680 % the larger sizes (\cs{smallskipamount} is 1/4 the fontsize, and the others
3681 % each double up on the next lower).
3682 % \changes{v1.61803}{2008/01/30}{(small/med/big)skips not invraiant for larger font sizes.}
3683 % \changes{v1.61803}{2008/01/30}{Changed (small/med/big)skips for 17pt}
3684 % \begin{macrocode}
3685 %<*9pt|10pt|11pt|12pt|14pt>
3686 \setlength\smallskipamount{3\p@ \@plus 1\p@ \@minus 1\p@}
3687 \setlength\medskipamount{6\p@ \@plus 2\p@ \@minus 2\p@}
3688 \setlength\bigskipamount{12\p@ \@plus 4\p@ \@minus 4\p@}
3689 %</9pt|10pt|11pt|12pt|14pt>
3690 %<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3691 %<*17pt>
3692 \setlength\smallskipamount{4\p@ \@plus1\p@ \@minus1\p@}
3693 \setlength\medskipamount{8\p@ \@plus2\p@ \@minus2\p@}
3694 \setlength\bigskipamount{17\p@ \@plus4\p@ \@minus4\p@}
3695 %</17pt>
3696 %<*20pt>
3697 \setlength\smallskipamount{5\p@ \@plus1\p@ \@minus1\p@}
3698 \setlength\medskipamount{10\p@ \@plus2\p@ \@minus2\p@}
3699 \setlength\bigskipamount{20\p@ \@plus4\p@ \@minus4\p@}
3700 %</20pt>
3701 %<*25pt>
3702 \setlength\smallskipamount{6\p@ \@plus1\p@ \@minus1\p@}
3703 \setlength\medskipamount{12\p@ \@plus2\p@ \@minus2\p@}
3704 \setlength\bigskipamount{24\p@ \@plus4\p@ \@minus4\p@}
3705 %</25pt>
3706 %<*30pt>
3707 \setlength\smallskipamount{5\p@ \@plus1\p@ \@minus1\p@}
3708 \setlength\medskipamount{10\p@ \@plus2\p@ \@minus2\p@}
3709 \setlength\bigskipamount{20\p@ \@plus4\p@ \@minus4\p@}
3710 %</30pt>
3711 %<*36pt>
3712 \setlength\smallskipamount{9\p@ \@plus2\p@ \@minus2\p@}
3713 \setlength\medskipamount{18\p@ \@plus4\p@ \@minus4\p@}
3714 \setlength\bigskipamount{36\p@ \@plus8\p@ \@minus8\p@}
3715 %</36pt>
3716 %<*48pt>
3717 \setlength\smallskipamount{12\p@ \@plus3\p@ \@minus3\p@}
3718 \setlength\medskipamount{24\p@ \@plus6\p@ \@minus6\p@}
3719 \setlength\bigskipamount{48\p@ \@plus12\p@ \@minus12\p@}
3720 %</48pt>
3721 %<*60pt>
3722 \setlength\smallskipamount{15\p@ \@plus4\p@ \@minus4\p@}
3723 \setlength\medskipamount{30\p@ \@plus8\p@ \@minus8\p@}
3724 \setlength\bigskipamount{60\p@ \@plus16\p@ \@minus16\p@}
3725 %</60pt>
3726 %</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3727 % \end{macrocode}
3728 % \end{macro}
3729 % \end{macro}
3730 % \end{macro}
3731 %
3732 %
3733 % \begin{macro}{\@lowpenalty}
3734 % \begin{macro}{\@medpenalty}
3735 % \begin{macro}{\@highpenalty}%
3736 % The commands \cs{nopagebreak} and \cs{nolinebreak} put in penalties
3737 % to discourage these breaks at the point they are put in.
3738 % They use \cs{@lowpenalty}, \cs{@medpenalty} or \cs{@highpenalty},
3739 % dependent on their argument.
3740 % \begin{macrocode}
3741 %<*class>
3742 \@lowpenalty 51
3743 \@medpenalty 151
3744 \@highpenalty 301
3745 % \end{macrocode}
3746 % \end{macro}
3747 % \end{macro}
3748 % \end{macro}
3749 %
3750 % \begin{macro}{\clubpenalty}
3751 % \begin{macro}{\widowpenalty}
3752 % These penalties are used to discourage club and widow lines.
3753 % The default values are 150 each, but we want stronger discouragement.
3754 % \begin{macrocode}
3755 \clubpenalty 1000
3756 \widowpenalty 1000
3757 % \end{macrocode}
3758 % \end{macro}
3759 % \end{macro}
3760 %
3761 % \begin{macro}{\displaywidowpenalty}
3762 % \begin{macro}{\predisplaypenalty}
3763 % \begin{macro}{\postdisplaypenalty}
3764 % Discourage, but do not prevent, widows in front of a math display
3765 % and forbid breaking directly in front of a display. Allow break
3766 % after a display without a penalty. The default values are
3767 % used, therefore we only show them here.
3768 % \begin{macrocode}
3769 % \displaywidowpenalty 50
3770 % \predisplaypenalty 10000
3771 % \postdisplaypenalty 0
3772 % \end{macrocode}
3773 % \end{macro}
3774 % \end{macro}
3775 % \end{macro}
3776 %
3777 % \begin{macro}{\interlinepenalty}
3778 % Allow the breaking of a page in the middle of a paragraph. Using
3779 % the kernel default and here just showing it.
3780 % \begin{macrocode}
3781 % \interlinepenalty 0
3782 % \end{macrocode}
3783 % \end{macro}
3784 %
3785 %
3786 % \begin{macro}{\brokenpenalty}
3787 % We allow the breaking of a page after a hyphenated line. Using
3788 % the kernel default and here just showing it.
3789 % \begin{macrocode}
3790 % \brokenpenalty 100
3791 % \end{macrocode}
3792 % \end{macro}
3793 %
3794 %
3795 %
3796 %
3797 % \subsection{Vertical spacing}
3798 %
3799 % \begin{macro}{\headheight}
3800 % \begin{macro}{\headsep}
3801 % \begin{macro}{\topskip}
3802 % \begin{macro}{\footskip}
3803 % The \cs{headheight} is the height of the box that will contain the
3804 % running head. In this class it is point size dependent ---
3805 % \cs{onelineskip} (normally it is a constant 12pt).
3806 %
3807 % The \cs{headsep} is the distance between the bottom of the running
3808 % head and the top of the text. For the larger sizes this is 1.8
3809 % times the fontsize.
3810 %
3811 % The \cs{topskip} is the \cs{baselineskip} for the first line on a
3812 % page; \LaTeX's output routine will not work properly if it has the
3813 % value 0pt, so do not do that! For the larger sizes this is the
3814 % font size.
3815 %
3816 % The distance from the baseline of the box which contains the
3817 % running footer to the baseline of last line of text is controlled
3818 % by the \cs{footskip}. For the larger sizes this is 2.5 times the
3819 % font size.
3820 % \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed \cs{headheight} from 16pt to 17.5pt}
3821 % \changes{v0.11 (mem11.clo)}{2002/03/10}{Changed \cs{headheight} from 13pt to 13.6pt}
3822 % \changes{v0.4b (mem12.clo)}{2010/10/19}{Changed \cs{headheight} from 14pt to 14.5pt}
3823 % \begin{macrocode}
3824 %</class>
3825 %<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
3826 %<*9pt>
3827 \setlength\headheight{11\p@}
3828 \setlength\headsep{.225in}
3829 \setlength\topskip{9\p@}
3830 \setlength\footskip{.33in}
3831 %</9pt>
3832 %<*10pt>
3833 \setlength\headheight{12\p@}
3834 \setlength\headsep{.25in}
3835 \setlength\topskip{10\p@}
3836 \setlength\footskip{.35in}
3837 %</10pt>
3838 %<*11pt>
3839 \setlength\headheight{13.6\p@}
3840 \setlength\headsep{.275in}
3841 \setlength\topskip{11\p@}
3842 \setlength\footskip{.38in}
3843 %</11pt>
3844 %<*12pt>
3845 \setlength\headheight{14.5\p@}
3846 \setlength\headsep{.275in}
3847 \setlength\topskip{12\p@}
3848 \setlength\footskip{30\p@}
3849 %</12pt>
3850 %<*14pt>
3851 \setlength\headheight{17.5\p@}
3852 \setlength\headsep{.30in}
3853 \setlength\topskip{14.4\p@}
3854 \setlength\footskip{.4in}
3855 %</14pt>
3856 %<*17pt>
3857 \setlength\headheight{22\p@}
3858 \setlength\headsep{.30in}
3859 \setlength\topskip{14.4\p@}
3860 \setlength\footskip{.4in}
3861 %</17pt>
3862 %<*20pt>
3863 \setlength\headheight{25\p@}
3864 \setlength\headsep{36\p@}
3865 \setlength\topskip{20\p@}
3866 \setlength\footskip{50\p@}
3867 %</20pt>
3868 %<*25pt>
3869 \setlength\headheight{30\p@}
3870 \setlength\headsep{45\p@}
3871 \setlength\topskip{25\p@}
3872 \setlength\footskip{62\p@}
3873 %</25pt>
3874 %<*30pt>
3875 \setlength\headheight{37\p@}
3876 \setlength\headsep{54\p@}
3877 \setlength\topskip{30\p@}
3878 \setlength\footskip{75\p@}
3879 %</30pt>
3880 %<*36pt>
3881 \setlength\headheight{45\p@}
3882 \setlength\headsep{65\p@}
3883 \setlength\topskip{36\p@}
3884 \setlength\footskip{90\p@}
3885 %</36pt>
3886 %<*48pt>
3887 \setlength\headheight{60\p@}
3888 \setlength\headsep{86\p@}
3889 \setlength\topskip{48\p@}
3890 \setlength\footskip{120\p@}
3891 %</48pt>
3892 %<*60pt>
3893 \setlength\headheight{72\p@}
3894 \setlength\headsep{108\p@}
3895 \setlength\topskip{60\p@}
3896 \setlength\footskip{150\p@}
3897 %</60pt>
3898 % \end{macrocode}
3899 % \end{macro}
3900 % \end{macro}
3901 % \end{macro}
3902 % \end{macro}
3903 %
3904 % \begin{macro}{\maxdepth}
3905 % \begin{macro}{\@maxdepth}
3906 % The \TeX\ primitive register \cs{maxdepth} has a function that is
3907 % similar to that of \cs{topskip}. The register \cs{@maxdepth} should
3908 % always contain a copy of \cs{maxdepth}. In both plain \TeX\ and
3909 % \LaTeX~2.09 \cs{maxdepth} had a fixed value of \texttt{4pt}; in
3910 % native \LaTeX 2e mode we let the value depend on the typesize. We
3911 % set it so that \cs{maxdepth} $+$ \cs{topskip} $=$ typesize $\times
3912 % 1.5$. As it happens, in these classes \cs{topskip} is equal to the
3913 % typesize, therefor we set \cs{maxdepth} to half the value of
3914 % \cs{topskip}.
3915 % \begin{macrocode}
3916 \setlength\maxdepth{.5\topskip}
3917 \setlength\@maxdepth\maxdepth
3918 % \end{macrocode}
3919 % \end{macro}
3920 % \end{macro}
3921 %
3922 %
3923 %
3924 % \subsection{Footnotes}
3925 %
3926 % \begin{macro}{\footnotesep}
3927 % \cs{footnotesep} is the height of the strut placed at the beginning
3928 % of every footnote. It equals the height of a normal \cs{footnotesize}
3929 % strut, so no extra space appears between footnotes.
3930 % \changes{v1.61803}{2007/01/30}{Changed nearly all \cs{footnotesep}}
3931 % \begin{macrocode}
3932 %<9pt>\setlength\footnotesep{5.6\p@}
3933 %<10pt>\setlength\footnotesep{6.65\p@}
3934 %<11pt>\setlength\footnotesep{7.7\p@}
3935 %<12pt>\setlength\footnotesep{8.4\p@}
3936 %<14pt>\setlength\footnotesep{9.5\p@}
3937 %<17pt>\setlength\footnotesep{10.15\p@}
3938 %<20pt>\setlength\footnotesep{12.6\p@}
3939 %<25pt>\setlength\footnotesep{15.4\p@}
3940 %<30pt>\setlength\footnotesep{17.5\p@}
3941 %<36pt>\setlength\footnotesep{21\p@}
3942 %<48pt>\setlength\footnotesep{25.9\p@}
3943 %<60pt>\setlength\footnotesep{31.5\p@}
3944 % \end{macrocode}
3945 % \end{macro}
3946 %
3947 % \begin{macro}{\footins}
3948 % \verb?\skip\footins? is the space between the last line of the main
3949 % text and the top of the first footnote.
3950 % \begin{macrocode}
3951 %<9pt>\setlength{\skip\footins}{8\p@ \@plus 2\p@ \@minus 2\p@}
3952 %<10pt>\setlength{\skip\footins}{9\p@ \@plus 4\p@ \@minus 2\p@}
3953 %<11pt>\setlength{\skip\footins}{10\p@ \@plus 4\p@ \@minus 2\p@}
3954 %<12pt>\setlength{\skip\footins}{10.8\p@ \@plus 4\p@ \@minus 2\p@}
3955 %<14pt>\setlength{\skip\footins}{13\p@ \@plus 4\p@ \@minus 2\p@}
3956 %<17pt>\setlength{\skip\footins}{16\p@ \@plus 5\p@ \@minus 3\p@}
3957 %<20pt>\setlength{\skip\footins}{19\p@ \@plus 7\p@ \@minus 3\p@}
3958 %<25pt>\setlength{\skip\footins}{24\p@ \@plus 8\p@ \@minus 4\p@}
3959 %<30pt>\setlength{\skip\footins}{29\p@ \@plus 10\p@ \@minus 5\p@}
3960 %<36pt>\setlength{\skip\footins}{35\p@ \@plus 12\p@ \@minus 6\p@}
3961 %<48pt>\setlength{\skip\footins}{47\p@ \@plus 16\p@ \@minus 8\p@}
3962 %<60pt>\setlength{\skip\footins}{59\p@ \@plus 20\p@ \@minus 10\p@}
3963 % \end{macrocode}
3964 % \end{macro}
3965 %
3966 % \subsection{Floats}
3967 %
3968 % \paragraph{Floats on a text page}
3969 %
3970 % \begin{macro}{\floatsep}
3971 % \begin{macro}{\textfloatsep}
3972 % \begin{macro}{\intextsep}
3973 % When a floating object is placed on a page with text, these
3974 % parameters control the separation between the float and the other
3975 % objects on the page. These parameters are used for both
3976 % one-column mode and single-column floats in two-column mode.
3977 %
3978 % \cs{floatsep} is the space between adjacent floats that are moved
3979 % to the top or bottom of the text page. For the larger sizes this is
3980 % \cs{bigskip}.
3981 %
3982 % \cs{textfloatsep} is the space between the main text and floats
3983 % at the top or bottom of the page. For the larger sizes this is
3984 % 1.45\cs{onelineskip}.
3985 %
3986 % \cs{intextsep} is the space between in-text floats and the text.
3987 % \begin{macrocode}
3988 %<*9pt>
3989 \setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
3990 \setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
3991 \setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
3992 %</9pt>
3993 %<*10pt>
3994 \setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
3995 \setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
3996 \setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
3997 %</10pt>
3998 %<*11pt>
3999 \setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4000 \setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4001 \setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4002 %</11pt>
4003 %<*12pt>
4004 \setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4005 \setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4006 \setlength\intextsep {14\p@ \@plus 4\p@ \@minus 4\p@}
4007 %</12pt>
4008 %<*14pt>
4009 \setlength\floatsep {14\p@ \@plus 4\p@ \@minus 4\p@}
4010 \setlength\textfloatsep{20\p@ \@plus 4\p@ \@minus 4\p@}
4011 \setlength\intextsep {14\p@ \@plus 4\p@ \@minus 4\p@}
4012 %</14pt>
4013 %<*17pt>
4014 \setlength\floatsep {15\p@ \@plus 4\p@ \@minus 4\p@}
4015 \setlength\textfloatsep{25\p@ \@plus 4\p@ \@minus 5\p@}
4016 \intextsep \floatsep
4017 %</17pt>
4018 %<*20pt>
4019 \setlength\floatsep {20\p@ \@plus 4\p@ \@minus 4\p@}
4020 \setlength\textfloatsep{36\p@ \@plus 4\p@ \@minus 8\p@}
4021 \intextsep \floatsep
4022 %</20pt>
4023 %<*25pt>
4024 \setlength\floatsep {24\p@ \@plus 4\p@ \@minus 4\p@}
4025 \setlength\textfloatsep{43\p@ \@plus 4\p@ \@minus 8\p@}
4026 \intextsep \floatsep
4027 %</25pt>
4028 %<*30pt>
4029 \setlength\floatsep {30\p@ \@plus 6\p@ \@minus 6\p@}
4030 \setlength\textfloatsep{54\p@ \@plus 6\p@ \@minus 12\p@}
4031 \intextsep \floatsep
4032 %</30pt>
4033 %<*36pt>
4034 \setlength\floatsep {36\p@ \@plus 8\p@ \@minus 8\p@}
4035 \setlength\textfloatsep{65\p@ \@plus 8\p@ \@minus 16\p@}
4036 \intextsep \floatsep
4037 %</36pt>
4038 %<*48pt>
4039 \setlength\floatsep {48\p@ \@plus 12\p@ \@minus 12\p@}
4040 \setlength\textfloatsep{87\p@ \@plus 12\p@ \@minus 24\p@}
4041 \intextsep \floatsep
4042 %</48pt>
4043 %<*60pt>
4044 \setlength\floatsep {60\p@ \@plus 16\p@ \@minus 16\p@}
4045 \setlength\textfloatsep{104\p@ \@plus 16\p@ \@minus 32\p@}
4046 \intextsep \floatsep
4047 %</60pt>
4048 % \end{macrocode}
4049 % \end{macro}
4050 % \end{macro}
4051 % \end{macro}
4052 %
4053 % \begin{macro}{\dblfloatsep}
4054 % \begin{macro}{\dbltextfloatsep}
4055 % When floating objects that span the whole \cs{textwidth} are placed
4056 % on a text page and \LaTeX{} is in twocolumn mode the separation
4057 % between the float and the text is controlled by \cs{dblfloatsep}
4058 % and \cs{dbltextfloatsep}.
4059 %
4060 % \cs{dblfloatsep} is the space between adjacent floats that are moved
4061 % to the top or bottom of the text page.
4062 %
4063 % \cs{dbltextfloatsep} is the space between the main text and floats
4064 % at the top or bottom of the page.
4065 %
4066 % \begin{macrocode}
4067 %<*9pt>
4068 \setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4069 \setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4070 %</9pt>
4071 %<*10pt>
4072 \setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4073 \setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4074 %</10pt>
4075 %<*11pt>
4076 \setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
4077 \setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4078 %</11pt>
4079 %<*12pt>
4080 \setlength\dblfloatsep {14\p@ \@plus 2\p@ \@minus 4\p@}
4081 \setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4082 %</12pt>
4083 %<*14pt>
4084 \setlength\dblfloatsep {14\p@ \@plus 2\p@ \@minus 4\p@}
4085 \setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
4086 %</14pt>
4087 %<*17pt>
4088 \setlength\dblfloatsep {15\p@ \@plus 4\p@ \@minus 4\p@}
4089 \setlength\dbltextfloatsep{25\p@ \@plus 5\p@ \@minus 5\p@}
4090 %</17pt>
4091 %<*20pt>
4092 \dblfloatsep \floatsep
4093 \dbltextfloatsep \textfloatsep
4094 %</20pt>
4095 %<*25pt>
4096 \dblfloatsep \floatsep
4097 \dbltextfloatsep \textfloatsep
4098 %</25pt>
4099 %<*30pt>
4100 \dblfloatsep \floatsep
4101 \dbltextfloatsep \textfloatsep
4102 %</30pt>
4103 %<*36pt>
4104 \dblfloatsep \floatsep
4105 \dbltextfloatsep \textfloatsep
4106 %</36pt>
4107 %<*48pt>
4108 \dblfloatsep \floatsep
4109 \dbltextfloatsep \textfloatsep
4110 %</48pt>
4111 %<*60pt>
4112 \dblfloatsep \floatsep
4113 \dbltextfloatsep \textfloatsep
4114 %</60pt>
4115 % \end{macrocode}
4116 % \end{macro}
4117 % \end{macro}
4118 %
4119 % \paragraph{Floats on their own page or column}
4120 %
4121 % \begin{macro}{\@fptop}
4122 % \begin{macro}{\@fpsep}
4123 % \begin{macro}{\@fpbot}
4124 % When floating objects are placed on separate pages the layout of
4125 % such pages is controlled by these parameters. At the top of the
4126 % page \cs{@fptop} amount of stretchable whitespace is inserted, at
4127 % the bottom of the page we get an \cs{@fpbot} amount of stretchable
4128 % whitespace. Between adjacent floats the \cs{@fpsep} is inserted.
4129 % For the larger sizes \cs{@fpsep} is .7\cs{onelineskip}.
4130 %
4131 % These parameters are used for the placement of floating objects
4132 % in one column mode, or in single column floats in two column
4133 % mode.
4134 %
4135 % Note that at least one of the two parameters \cs{@fptop} and
4136 % \cs{@fpbot} should contain a \verb?plus ...fil? to allow filling the
4137 % remaining empty space.
4138 % \begin{macrocode}
4139 %<*9pt>
4140 \setlength\@fptop{0\p@ \@plus 1fil}
4141 \setlength\@fpsep{9\p@ \@plus 2fil}
4142 \setlength\@fpbot{0\p@ \@plus 1fil}
4143 %</9pt>
4144 %<*10pt>
4145 \setlength\@fptop{0\p@ \@plus 1fil}
4146 \setlength\@fpsep{8\p@ \@plus 2fil}
4147 \setlength\@fpbot{0\p@ \@plus 1fil}
4148 %</10pt>
4149 %<*11pt>
4150 \setlength\@fptop{0\p@ \@plus 1fil}
4151 \setlength\@fpsep{8\p@ \@plus 2fil}
4152 \setlength\@fpbot{0\p@ \@plus 1fil}
4153 %</11pt>
4154 %<*12pt>
4155 \setlength\@fptop{0\p@ \@plus 1fil}
4156 \setlength\@fpsep{10\p@ \@plus 2fil}
4157 \setlength\@fpbot{0\p@ \@plus 1fil}
4158 %</12pt>
4159 %<*14pt>
4160 \setlength\@fptop{0\p@ \@plus 1fil}
4161 \setlength\@fpsep{10\p@ \@plus 2fil}
4162 \setlength\@fpbot{0\p@ \@plus 1fil}
4163 %</14pt>
4164 %<*17pt>
4165 \setlength\@fptop{0\p@ \@plus 1fil}
4166 \setlength\@fpsep{12\p@ \@plus 2fil}
4167 \setlength\@fpbot{0\p@ \@plus 1fil}
4168 %</17pt>
4169 %<*20pt>
4170 \setlength\@fptop{0\p@ \@plus 1fil}
4171 \setlength\@fpsep{17\p@ \@plus 2fil}
4172 \@fpbot \@fptop
4173 %</20pt>
4174 %<*25pt>
4175 \setlength\@fptop{0\p@ \@plus 1fil}
4176 \setlength\@fpsep{21\p@ \@plus 2fil}
4177 \@fpbot \@fptop
4178 %</25pt>
4179 %<*30pt>
4180 \setlength\@fptop{0\p@ \@plus 1fil}
4181 \setlength\@fpsep{26\p@ \@plus 2fil}
4182 \@fpbot \@fptop
4183 %</30pt>
4184 %<*36pt>
4185 \setlength\@fptop{0\p@ \@plus 1fil}
4186 \setlength\@fpsep{31\p@ \@plus 2fil}
4187 \@fpbot \@fptop
4188 %</36pt>
4189 %<*48pt>
4190 \setlength\@fptop{0\p@ \@plus 1fil}
4191 \setlength\@fpsep{42\p@ \@plus 2fil}
4192 \@fpbot \@fptop
4193 %</48pt>
4194 %<*60pt>
4195 \setlength\@fptop{0\p@ \@plus 1fil}
4196 \setlength\@fpsep{50\p@ \@plus 2fil}
4197 \@fpbot \@fptop
4198 %</60pt>
4199 % \end{macrocode}
4200 % \end{macro}
4201 % \end{macro}
4202 % \end{macro}
4203 %
4204 % \begin{macro}{\@dblfptop}
4205 % \begin{macro}{\@dblfpsep}
4206 % \begin{macro}{\@dblfpbot}
4207 % Double column floats in two column mode are handled with similar
4208 % parameters.
4209 % \begin{macrocode}
4210 %<*9pt>
4211 \setlength\@dblfptop{0\p@ \@plus 1fil}
4212 \setlength\@dblfpsep{7\p@ \@plus 2fil}
4213 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4214 %</9pt>
4215 %<*10pt>
4216 \setlength\@dblfptop{0\p@ \@plus 1fil}
4217 \setlength\@dblfpsep{8\p@ \@plus 2fil}
4218 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4219 %</10pt>
4220 %<*11pt>
4221 \setlength\@dblfptop{0\p@ \@plus 1fil}
4222 \setlength\@dblfpsep{8\p@ \@plus 2fil}
4223 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4224 %</11pt>
4225 %<*12pt>
4226 \setlength\@dblfptop{0\p@ \@plus 1fil}
4227 \setlength\@dblfpsep{10\p@ \@plus 2fil}
4228 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4229 %</12pt>
4230 %<*14pt>
4231 \setlength\@dblfptop{0\p@ \@plus 1fil}
4232 \setlength\@dblfpsep{12\p@ \@plus 2fil}
4233 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4234 %</14pt>
4235 %<*17pt>
4236 \setlength\@dblfptop{0\p@ \@plus 1fil}
4237 \setlength\@dblfpsep{12\p@ \@plus 2fil}
4238 \setlength\@dblfpbot{0\p@ \@plus 1fil}
4239 %</17pt>
4240 %<*20pt>
4241 \@dblfptop \@fptop
4242 \@dblfpsep \@fpsep
4243 \@dblfpbot \@dblfptop
4244 %</20pt>
4245 %<*25pt>
4246 \@dblfptop \@fptop
4247 \@dblfpsep \@fpsep
4248 \@dblfpbot \@dblfptop
4249 %</25pt>
4250 %<*30pt>
4251 \@dblfptop \@fptop
4252 \@dblfpsep \@fpsep
4253 \@dblfpbot \@dblfptop
4254 %</30pt>
4255 %<*36pt>
4256 \@dblfptop \@fptop
4257 \@dblfpsep \@fpsep
4258 \@dblfpbot \@dblfptop
4259 %</36pt>
4260 %<*48pt>
4261 \@dblfptop \@fptop
4262 \@dblfpsep \@fpsep
4263 \@dblfpbot \@dblfptop
4264 %</48pt>
4265 %<*60pt>
4266 \@dblfptop \@fptop
4267 \@dblfpsep \@fpsep
4268 \@dblfpbot \@dblfptop
4269 %</60pt>
4270 % \end{macrocode}
4271 % \end{macro}
4272 % \end{macro}
4273 % \end{macro}
4274 %
4275 % \subsection{The measure}
4276 %
4277 % The width of a line of text (and therefore the text block) is termed
4278 % the \emph{measure}.
4279 %
4280 % \begin{macro}{\lxvchars}
4281 % The length \cs{lxvchars} is the approximate length of a normal
4282 % text line containing 65 characters (a typesetters rule of thumb is
4283 % that there should be about 60--70 characters per line).
4284 % \begin{macrocode}
4285 %<9pt>\setlength\lxvchars{276\p@} %
4286 %<10pt>\setlength\lxvchars{300\p@} % standard 345pt
4287 %<11pt>\setlength\lxvchars{324\p@} % standard 360pt
4288 %<12pt>\setlength\lxvchars{336\p@} % standard 390pt
4289 %<14pt>\setlength\lxvchars{408\p@} %
4290 %<17pt>\setlength\lxvchars{444\p@} %
4291 %<20pt>\setlength\lxvchars{528\p@} %
4292 %<25pt>\setlength\lxvchars{626\p@} %
4293 %<30pt>\setlength\lxvchars{748\p@} %
4294 %<36pt>\setlength\lxvchars{891\p@} %
4295 %<48pt>\setlength\lxvchars{1177\p@} %
4296 %<60pt>\setlength\lxvchars{1463\p@} %
4297 % \end{macrocode}
4298 % \end{macro}
4299 %
4300 % \begin{macro}{\xlvchars}
4301 % The length \cs{xlvchars} is the approximate length of a normal
4302 % double column text line containing 45 characters
4303 % (a typesetters rule of thumb is
4304 % that there should be about 40--50 characters per column line).
4305 % \begin{macrocode}
4306 %<9pt>\setlength\xlvchars{192\p@} %
4307 %<10pt>\setlength\xlvchars{204\p@} %
4308 %<11pt>\setlength\xlvchars{216\p@} %
4309 %<12pt>\setlength\xlvchars{240\p@} %
4310 %<14pt>\setlength\xlvchars{288\p@} %
4311 %<17pt>\setlength\xlvchars{312\p@} %
4312 %<20pt>\setlength\xlvchars{365\p@} %
4313 %<25pt>\setlength\xlvchars{438\p@} %
4314 %<30pt>\setlength\xlvchars{518\p@} %
4315 %<36pt>\setlength\xlvchars{617\p@} %
4316 %<48pt>\setlength\xlvchars{815\p@} %
4317 %<60pt>\setlength\xlvchars{1014\p@} %
4318 % \end{macrocode}
4319 % \end{macro}
4320 %
4321 % \begin{macro}{\marginparsep}
4322 % \begin{macro}{\marginparpush}
4323 % \cs{marginparsep} is the horizontal space between the text block and
4324 % marginal notes, while \cs{marginparpush} is the minimum vertical
4325 % separation between the notes.
4326 % \begin{macrocode}
4327 \if@twocolumn
4328 %<*9pt|10pt|11pt|12pt|14pt>
4329 \setlength\marginparsep{10\p@}
4330 %</9pt|10pt|11pt|12pt|14pt>
4331 %<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4332 \setlength\marginparsep{1em}
4333 %</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4334 \else
4335 %<*9pt|10pt|11pt|12pt|14pt>
4336 \setlength\marginparsep{7\p@}
4337 %</9pt|10pt|11pt|12pt|14pt>
4338 %<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4339 \setlength\marginparsep{0.7em}
4340 %</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4341 \fi
4342 %<9pt|10pt|11pt>\setlength{\marginparpush}{5\p@}
4343 %<12pt|14pt>\setlength{\marginparpush}{7\p@}
4344 %<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4345 \setlength\marginparpush{0.5em}
4346 %</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4347 % \end{macrocode}
4348 % \end{macro}
4349 % \end{macro}
4350 %
4351 % \begin{macrocode}
4352 %</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
4353 %<*class>
4354 % \end{macrocode}
4355 %
4356 % \section{Page Layout}
4357 %
4358 %
4359 % \subsection{The typeblock and margins}
4360 %
4361 % All margin dimensions are measured from a point one inch from the
4362 % top and lefthand side of the page.
4363 %
4364 % \begin{macro}{\setlxvchars}
4365 % \begin{macro}{\setxlvchars}
4366 % These were suggested and supplied by Morten H{\o}gholm (18 May 2003).
4367 %
4368 % \cs{setlxvchars}\oarg{fontspec} sets \cs{lxvchars} to the length of a line
4369 % containing 65 characters in the \meta{fontspec}.
4370 %
4371 % Similarly
4372 % \cs{setxlvchars}\oarg{fontspec} sets \cs{xlvchars} for 45 characters.
4373 % \changes{v1.4}{2003/11/22}{Added \cs{setlxvchars} and \cs{setxlvchars}
4374 % (from patch v1.6)}
4375 % \begin{macrocode}
4376 \newcommand*{\setlxvchars}[1][\normalfont]{\begingroup
4377 #1
4378 \settowidth{\lxvchars}{abcdefghijklmnopqrstuvwxyz}%
4379 \setlength{\lxvchars}{2.042\lxvchars}%
4380 \addtolength{\lxvchars}{33.41pt}%
4381 \global\lxvchars=\lxvchars
4382 \endgroup}
4383 \newcommand*{\setxlvchars}[1][\normalfont]{\begingroup
4384 #1
4385 \settowidth{\xlvchars}{abcdefghijklmnopqrstuvwxyz}%
4386 \setlength{\xlvchars}{1.415\xlvchars}%
4387 \addtolength{\xlvchars}{23.03pt}%
4388 \global\xlvchars=\xlvchars
4389 \endgroup}
4390
4391 % \end{macrocode}
4392 % \end{macro}
4393 % \end{macro}
4394 %
4395 % \begin{macro}{\setrectanglesize}
4396 % The macro \cs{setrectanglesize}\marg{H}\marg{W}\marg{r}
4397 % calculates the height and width of a rectangle given any two out of
4398 % the three arguments. An unvalued argument is denoted by \verb?*?.
4399 %
4400 % Table~\ref{tab:setrect} shows the argument combinations and the result
4401 % for each combination.
4402 % \begin{table}
4403 % \centering
4404 % \caption{Arguments and results for \cs{setrectanglesize}}\label{tab:setrect}
4405 % \begin{tabular}{ccc|l} \hline
4406 % H & W & r & Result \\ \hline
4407 % * & W & r & $H = rW$ \\{}
4408 % * & W & * & $H = W$ \\{}
4409 % * & * & r & ambiguous \\{}
4410 % * & * & * & ambiguous \\{}
4411 % H & W & r & $H, W$ \\
4412 % H & W & * & $H, W$ \\
4413 % H & * & r & $W = rH$ \\
4414 % H & * & * & $W = H$ \\
4415 % \hline
4416 % \end{tabular}
4417 % \end{table}
4418 %
4419 % The
4420 % calculated height and width are stored in \cs{@tempdima} and \cs{@tempdimb}
4421 % respectively. Both lengths are set to zero if there is an error.
4422 % \changes{v1.61803}{2008/01/30}{Used \cs{setlength} instead of TeX syntax so that the calc package
4423 % can be used with page layout (Morten H{\o}gholm mempatch v4.5)}
4424 % \begin{macrocode}
4425 \newcommand*{\setrectanglesize}[3]{%
4426 \nametest{#1}{*}%
4427 \ifsamename % H = *
4428 \nametest{#2}{*}%
4429 \ifsamename % W = *
4430 \@memerror{%
4431 The combination of argument values is ambiguous.\MessageBreak
4432 The lengths will be set to zero}{\@ehd}%
4433 \setlength{\@tempdima}{0pt}%
4434 \setlength{\@tempdimb}{0pt}%
4435 \else % W
4436 \nametest{#3}{*}%
4437 \ifsamename % r = *
4438 \setlength{\@tempdimb}{#2}%
4439 \setlength{\@tempdima}{\@tempdimb}%
4440 \else % r
4441 \setlength{\@tempdimb}{#2}%
4442 \setlength{\@tempdima}{#3\@tempdimb}%
4443 \fi
4444 \fi
4445 \else % H
4446 \nametest{#2}{*}%
4447 \ifsamename % W = *
4448 \nametest{#3}{*}%
4449 \ifsamename % r = *
4450 \setlength{\@tempdima}{#1}%
4451 \setlength{\@tempdimb}{\@tempdima}%
4452 \else % r
4453 \setlength{\@tempdima}{#1}%
4454 \setlength{\@tempdimb}{#3\@tempdima}%
4455 \fi
4456 \else % W
4457 \setlength{\@tempdima}{#1}%
4458 \setlength{\@tempdimb}{#2}%
4459 \fi
4460 \fi}
4461
4462 % \end{macrocode}
4463 % \end{macro}
4464 %
4465 % \begin{macro}{\setfillsize}
4466 % Consider a set of 4 lengths, $T$, $L$, $C$, and $R$, such that
4467 % $T = L + C + R$, where $T$ is a fixed size and normally $C$ is also fixed.
4468 % Also $L$ and $R$ may be specified independently of each other or as a
4469 % ratio (i.e., $L = rR$ or $R = rL$).
4470 % The macro
4471 % \cs{setfillsize}\marg{T}\marg{C}\marg{L}\marg{R}\marg{r}
4472 % maintains these constraints among the variables, where an unvalued
4473 % argument is denoted by \verb?*?.
4474 %
4475 % Table~\ref{tab:setfill} shows the argument combinations and the result
4476 % for each combination.
4477 % \begin{table}
4478 % \centering
4479 % \caption{Arguments and results for \cs{setfillsize}}\label{tab:setfill}
4480 % \begin{tabular}{cccc|ll} \hline
4481 % C & L & R & r & Result & \\ \hline
4482 % * & * & R & r & $L = rR$, & $C = T - L - R$ \\{}
4483 % * & * & R & * & $L = R$, & $C = T - L - R$ \\{}
4484 % * & * & * & r & ambigous & \\{}
4485 % * & * & * & * & ambiguous & \\{}
4486 % * & L & R & r & $L$, $R$, & $C = T - L - R$ \\{}
4487 % * & L & R & * & $L$, $R$, & $C = T - L - R$ \\{}
4488 % * & L & * & r & $R = rL$, & $C = T - L - R$ \\{}
4489 % * & L & * & * & $R = L$, & $C = T - L - R$ \\{}
4490 % C & * & R & r & $L = T - C - R$ & $C$ \\
4491 % C & * & R & * & $L = T - C - R$, & $C$ \\
4492 % C & * & * & r & $L + R = T - C$, $R = rL$, & $C$ \\
4493 % C & * & * & * & $L + R = T - C$, $R = L$, & $C$ \\
4494 % C & L & R & r & ambiguous & $C$ \\
4495 % C & L & R & * & ambiguous & $C$ \\
4496 % C & L & * & r & $R = T - C - L$, & $C$ \\
4497 % C & L & * & * & $R = T - C - L$, & $C$ \\
4498 % \hline
4499 % \end{tabular}
4500 % ^^A \MakeShortVerb{\|}
4501 % \end{table}
4502 %
4503 %
4504 % The
4505 % calculated values of \texttt{C}, \texttt{L} and \texttt{R} are stored
4506 % \cs{@tempdimc},
4507 % \cs{@tempdima} and \cs{@tempdimb} respectively. If there is an error
4508 % the lengths are set to zero.
4509 % \begin{macrocode}
4510 \newcommand*{\setfillsize}[5]{%
4511 \nametest{#2}{*}%
4512 \ifsamename % C = *
4513 \nametest{#3}{*}%
4514 \ifsamename % L = *
4515 \nametest{#4}{*}%
4516 \ifsamename % R = *
4517 \@memerror{%
4518 The combination of argument values is ambiguous.\MessageBreak
4519 The lengths will be set to zero}{\@ehd}
4520 \setlength{\@tempdima}{0pt}%
4521 \setlength{\@tempdimb}{0pt}%
4522 \setlength{\@tempdimc}{0pt}%
4523 \else % R
4524 \nametest{#5}{*}%
4525 \ifsamename % r = *
4526 \setlength{\@tempdimb}{#4}%
4527 \setlength{\@tempdima}{\@tempdimb}%
4528 \setlength{\@tempdimc}{#1}%
4529 \advance\@tempdimc -\@tempdima
4530 \advance\@tempdimc -\@tempdimb
4531 \else % r
4532 \setlength{\@tempdimb}{#4}%
4533 \setlength{\@tempdima}{#5\@tempdimb}%
4534 \setlength{\@tempdimc}{#1}%
4535 \advance\@tempdimc -\@tempdima
4536 \advance\@tempdimc -\@tempdimb
4537 \fi
4538 \fi
4539 \else % L
4540 \nametest{#4}{*}%
4541 \ifsamename % R = *
4542 \nametest{#5}{*}%
4543 \ifsamename % r = *
4544 \setlength{\@tempdima}{#3}%
4545 \setlength{\@tempdimb}{\@tempdima}
4546 \setlength{\@tempdimc}{#1}%
4547 \advance\@tempdimc -\@tempdima
4548 \advance\@tempdimc -\@tempdimb
4549 \else % r
4550 \setlength{\@tempdima}{#3}%
4551 \setlength{\@tempdimb}{#5\@tempdima}
4552 \setlength{\@tempdimc}{#1}%
4553 \advance\@tempdimc -\@tempdima
4554 \advance\@tempdimc -\@tempdimb
4555 \fi
4556 \else % R
4557 \setlength{\@tempdima}{#3}%
4558 \setlength{\@tempdimb}{#4}%
4559 \setlength{\@tempdimc}{#1}%
4560 \advance\@tempdimc -\@tempdima
4561 \advance\@tempdimc -\@tempdimb
4562 \fi
4563 \fi
4564 \else % C is valued
4565 \nametest{#3}{*}%
4566 \ifsamename % L = *
4567 \nametest{#4}{*}%
4568 \ifsamename % R = *
4569 \nametest{#5}{*}%
4570 \ifsamename % r = *
4571 \setlength{\@tempdimc}{#2}%
4572 \setlength{\@tempdima}{#1}%
4573 \advance\@tempdima -\@tempdimc
4574 \@tempdima = 0.5\@tempdima
4575 \@tempdimb = \@tempdima
4576 \else % r (CODE PERHAPS FIXED)
4577 \setlength{\@tempdimc}{#2} % C
4578 \setlength{\@tempdimb}{#1} % T
4579 \advance\@tempdimb -\@tempdimc % T - C
4580 \@tempdima = 1000sp
4581 \setlength{\@tempdima}{#5\@tempdima} % 1000r sp
4582 \advance\@tempdima by 1000sp % 1000(1+r)sp
4583 \@tempcnta = \@tempdima % 1000(1+r)
4584 \@tempdima = \@tempdimb % T - C
4585 \divide\@tempdima by \@tempcnta % (T-C)/1000(1+r) pts
4586 \@tempdima = 1000\@tempdima % (T-C)/(1+r) pts = L
4587 \advance\@tempdimb by -\@tempdima % = R
4588 \fi
4589 \else % R
4590 \setlength{\@tempdimc}{#2}%
4591 \setlength{\@tempdimb}{#4}%
4592 \setlength{\@tempdima}{#1}%
4593 \advance\@tempdima -\@tempdimc
4594 \advance\@tempdima -\@tempdimb
4595 \fi
4596 \else % L
4597 \nametest{#4}{*}%
4598 \ifsamename % R = *
4599 \setlength{\@tempdimc}{#2}%
4600 \setlength{\@tempdima}{#3}%
4601 \setlength{\@tempdimb}{#1}%
4602 \advance\@tempdimb -\@tempdimc
4603 \advance\@tempdimb -\@tempdima
4604 \else % R
4605 \@memerror{%
4606 The combination of argument values is ambiguous.\MessageBreak
4607 The lengths will be set to zero}{\@ehd}%
4608 \setlength{\@tempdima}{0pt}%
4609 \setlength{\@tempdimb}{0pt}%
4610 \setlength{\@tempdimc}{#2}%
4611 \fi
4612 \fi
4613 \fi}
4614
4615 % \end{macrocode}
4616 % \end{macro}
4617 %
4618 % \begin{macro}{\setstocksize}
4619 % \begin{macro}{\settrims}
4620 % \begin{macro}{\settrimmedsize}
4621 % \cs{setstocksize}\marg{height}\marg{width} sets the height
4622 % and width of the stock material and
4623 % \cs{settrims}\marg{top}\marg{edge} sets the trim lengths
4624 % for the top and side (fore edge) of the stock.
4625 % The macro \cs{settrimmedsize}\marg{height}\marg{width}\marg{ratio}
4626 % sets the size for the trimmed page, based on \cs{setrectanglesize}.
4627 % \begin{macrocode}
4628 \newcommand{\setstocksize}[2]{%
4629 \setlength{\stockheight}{#1}%
4630 \setlength{\stockwidth}{#2}}
4631 \newcommand{\settrims}[2]{%
4632 \setlength{\trimtop}{#1}%
4633 \setlength{\trimedge}{#2}}
4634 \newcommand{\settrimmedsize}[3]{%
4635 \setrectanglesize{#1}{#2}{#3}%
4636 \setlength{\paperheight}{\@tempdima}%
4637 \setlength{\paperwidth}{\@tempdimb}}
4638
4639 % \end{macrocode}
4640 % \end{macro}
4641 % \end{macro}
4642 % \end{macro}
4643 %
4644 %
4645 % \begin{macro}{\settypeblocksize}
4646 % \cs{settypeblocksize}\marg{height}\marg{width}\marg{ratio}
4647 % calulates the \cs{textheight} and \cs{textwidth} from two out of the
4648 % three arguments.
4649 % \changes{v3.6k}{2013/05/14}{Marked \cs{settypeblocksize} as being used}
4650 % \begin{macrocode}
4651 \newcommand{\settypeblocksize}[3]{%
4652 \memsetmacroused\settypeblocksize%
4653 \setrectanglesize{#1}{#2}{#3}%
4654 \setlength{\textheight}{\@tempdima}%
4655 \setlength{\textwidth}{\@tempdimb}}
4656
4657 % \end{macrocode}
4658 % \end{macro}
4659 %
4660 % \begin{macro}{\binding}
4661 % \begin{macro}{\setbinding}
4662 % The length \cs{binding} is an allowance on the spine margin for
4663 % binding. \cs{setbinding}\marg{length} sets the \cs{binding}.
4664 % \changes{v1.6180339c}{2008/12/29}{Added binding offset code to the
4665 % layout functions}
4666 % \begin{macrocode}
4667 \newlength{\binding}
4668 \newcommand*{\setbinding}[1]{\setlength{\binding}{#1}}
4669 \setbinding{0pt}
4670
4671 % \end{macrocode}
4672 % \end{macro}
4673 % \end{macro}
4674 %
4675 % \begin{macro}{\spinemargin}
4676 % \begin{macro}{\foremargin}
4677 % \begin{macro}{\setlrmargins}
4678 % \cs{setlrmargins}\marg{L}\marg{R}\marg{r} sets the Left (spine)
4679 % and Right (fore edge) margins with constant typeblock.
4680 % \changes{v1.6180339c}{2008/12/29}{Added binding to \cs{setlrmargins}}
4681 % \changes{v3.6k}{2013/05/14}{Marked \cs{setlrmargins} as being used}
4682 % \begin{macrocode}
4683 \newlength{\spinemargin}
4684 \newlength{\foremargin}
4685 \newcommand{\setlrmargins}[3]{%
4686 \memsetmacroused\setlrmargins%
4687 \advance\paperwidth -\binding
4688 \setfillsize{\paperwidth}{\textwidth}{#1}{#2}{#3}%
4689 \setlength{\textwidth}{\@tempdimc}%
4690 \setlength{\spinemargin}{\@tempdima}%
4691 \setlength{\foremargin}{\@tempdimb}%
4692 \advance\paperwidth \binding
4693 \advance\spinemargin \binding}
4694
4695 % \end{macrocode}
4696 % \end{macro}
4697 % \end{macro}
4698 % \end{macro}
4699 %
4700 % \begin{macro}{\setlrmarginsandblock}
4701 % \cs{setlrmarginsandblock}\marg{L}\marg{R}\marg{r} sets the Left (spine)
4702 % and Right (fore edge) margins with variable typeblock.
4703 % \changes{v1.6180339c}{2008/12/29}{Added binding to \cs{setlrmarginsandblock}}
4704 % \begin{macrocode}
4705 \newcommand{\setlrmarginsandblock}[3]{%
4706 \advance\paperwidth -\binding
4707 \setfillsize{\paperwidth}{*}{#1}{#2}{#3}%
4708 \setlength{\textwidth}{\@tempdimc}%
4709 \setlength{\spinemargin}{\@tempdima}%
4710 \setlength{\foremargin}{\@tempdimb}%
4711 \advance\paperwidth \binding
4712 \advance\spinemargin \binding}
4713
4714 % \end{macrocode}
4715 % \end{macro}
4716 %
4717 % \begin{macro}{\uppermargin}
4718 % \begin{macro}{\lowermargin}
4719 % \begin{macro}{\setulmargins}
4720 % \cs{setulmargins}\marg{L}\marg{R}\marg{r} sets the Left (upper)
4721 % and Right (lower) margins with constant typeblock.
4722 % \changes{v3.6k}{2013/05/14}{Marked \cs{setulmargins} as being used}
4723 % \begin{macrocode}
4724 \newlength{\uppermargin}
4725 \newlength{\lowermargin}
4726 \newcommand{\setulmargins}[3]{%
4727 \memsetmacroused\setulmargins%
4728 \setfillsize{\paperheight}{\textheight}{#1}{#2}{#3}%
4729 \setlength{\textheight}{\@tempdimc}%
4730 \setlength{\uppermargin}{\@tempdima}%
4731 \setlength{\lowermargin}{\@tempdimb}}
4732
4733 % \end{macrocode}
4734 % \end{macro}
4735 % \end{macro}
4736 % \end{macro}
4737 %
4738 % \begin{macro}{\setulmarginsandblock}
4739 % \cs{setulmarginsandblock}\marg{L}\marg{R}\marg{r} sets the Left (upper)
4740 % and Right (lower) margins with variable typeblock.
4741 % \begin{macrocode}
4742 \newcommand{\setulmarginsandblock}[3]{%
4743 \setfillsize{\paperheight}{*}{#1}{#2}{#3}%
4744 \setlength{\textheight}{\@tempdimc}%
4745 \setlength{\uppermargin}{\@tempdima}%
4746 \setlength{\lowermargin}{\@tempdimb}}
4747
4748 % \end{macrocode}
4749 % \end{macro}
4750 %
4751 % \begin{macro}{\headdrop}
4752 % \begin{macro}{\setheaderspaces}
4753 % \cs{setheaderspaces}\marg{L}\marg{R}\marg{r} sets the Left (head margin)
4754 % and Right (headsep) spacing with constant headheight.
4755 % \begin{macrocode}
4756 \newlength{\headdrop}
4757 \newcommand{\setheaderspaces}[3]{%
4758 \setfillsize{\uppermargin}{\headheight}{#1}{#2}{#3}%
4759 \setlength{\headheight}{\@tempdimc}%
4760 \setlength{\headdrop}{\@tempdima}%
4761 \setlength{\headsep}{\@tempdimb}}
4762
4763 % \end{macrocode}
4764 % \end{macro}
4765 % \end{macro}
4766 %
4767 % \begin{macro}{\setheadfoot}
4768 % \cs{setheadfoot}\marg{headheight}\marg{footskip}
4769 % sets the headheight and the footskip.
4770 % \begin{macrocode}
4771 \newcommand{\setheadfoot}[2]{%
4772 \setlength{\headheight}{#1}%
4773 \setlength{\footskip}{#2}}
4774
4775 % \end{macrocode}
4776 % \end{macro}
4777 %
4778 % \begin{macro}{\setcolsepandrule}
4779 % \cs{setcolsepandrule}\marg{colsep}\marg{thickness}
4780 % sets the column separation and the rule thickness.
4781 % \changes{v1.0}{2001/09/20}{Changed \cs{setcolseprule} to
4782 % \cs{setcolsepandrule} to match the documentation.}
4783 % \begin{macrocode}
4784 \newcommand{\setcolsepandrule}[2]{%
4785 \setlength{\columnsep}{#1}%
4786 \setlength{\columnseprule}{#2}}
4787
4788 % \end{macrocode}
4789 % \end{macro}
4790 %
4791 % \begin{macro}{\setmarginnotes}
4792 % \cs{setmarginnotes}\marg{sep}\marg{width}\marg{push}
4793 % sets the marginpar parameters.
4794 % \changes{v3.6k}{2013/05/14}{Marked \cs{setmarginnotes} as being used}
4795 % \begin{macrocode}
4796 \newcommand{\setmarginnotes}[3]{%
4797 \memsetmacroused\setmarginnotes%
4798 \setlength{\marginparsep}{#1}%
4799 \setlength{\marginparwidth}{#2}%
4800 \setlength{\marginparpush}{#3}}
4801
4802 % \end{macrocode}
4803 % \end{macro}
4804 %
4805 % \begin{macro}{\setfootins}
4806 % \cs{setfootins}\marg{length}\marg{length} sets
4807 % \cs{skip}\cs{footins} and its minipage counterpart. It will also
4808 % set \cs{skip}\cs{footinsv@r} and similar for minipages to the same
4809 % values. These are used by for example \cs{twocolumnfootnotes}.
4810 % \begin{macrocode}
4811 \newcommand\setfootins[2]{
4812 \setlength{\skip\footins}{#1}
4813 \setlength{\skip\footinsv@r}{#1}
4814 \setlength{\skip\@mpfootins}{#2}
4815 % not explicitly used
4816 \setlength{\skip\@mpfootinsv@r}{#2}
4817 }
4818
4819 % \end{macrocode}
4820 %
4821 % \end{macro}
4822 %
4823 %
4824 % Initialise the paper size and trimming to their default values.
4825 % \begin{macrocode}
4826 \settrimmedsize{\stockheight}{\stockwidth}{*}
4827 \settrims{\z@}{\z@}
4828
4829 % \end{macrocode}
4830 %
4831 % What now follows is the standard class's method for setting up
4832 % the dimensions.
4833 %
4834 % Set \cs{@tempdimb} to size-dependent initial line length and
4835 % set \cs{@tempdima} to the maximum textwidth for the paper width,
4836 % an inch margin on either side. In the standard classes the initial
4837 % line length is about 14\% greater than \cs{lxvchars}.
4838 % \begin{macrocode}
4839 \setlength{\@tempdimb}{1.14\lxvchars}
4840 \setlength\@tempdima{\paperwidth}
4841 \addtolength\@tempdima{-2in}
4842 % \end{macrocode}
4843 %
4844 % \begin{macro}{\textwidth}
4845 % Now set the \cs{textwidth} depending on the number of columns. In twocolumn
4846 % mode each column should be no wider than \cs{@tempdimb}.
4847 % \begin{macrocode}
4848 \if@twocolumn
4849 \ifdim\@tempdima>2\@tempdimb\relax
4850 \setlength\textwidth{2\@tempdimb}
4851 \else
4852 \setlength\textwidth{\@tempdima}
4853 \fi
4854 % \end{macrocode}
4855 % In onecolumn
4856 % the text should not be wider than the minumum of the paperwidth (less
4857 % 2in for the margins) and the maximum length of the character line.
4858 % \begin{macrocode}
4859 \else
4860 \ifdim\@tempdima>\@tempdimb\relax
4861 \setlength\textwidth{\@tempdimb}
4862 \else
4863 \setlength\textwidth{\@tempdima}
4864 \fi
4865 \fi
4866 % \end{macrocode}
4867 % Adjust the width to be a whole number of points.
4868 % \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
4869 % can disable truncation via class option}
4870 % \begin{macrocode}
4871 \mem@settopoint\textwidth
4872
4873 % \end{macrocode}
4874 % \end{macro}
4875 %
4876 % \begin{macro}{\textheight}
4877 % The \cs{textheight} is the height of the text block, excluding
4878 % headers and footers. This is set according to the \cs{paperheight},
4879 % to an integral number of lines, and allowing a 1in margin at the
4880 % top and bottom and a further 1.5in for headers and footers.
4881 % \begin{macrocode}
4882 \setlength\@tempdima{\paperheight}
4883 \addtolength\@tempdima{-3.5in}
4884 % \end{macrocode}
4885 % Divide this height by the \cs{baselineskip} to get the number of lines.
4886 % Then (re)calculate the \cs{textheight} and finally add the \cs{topskip}.
4887 % \begin{macrocode}
4888 \divide\@tempdima\baselineskip
4889 \@tempcnta=\@tempdima
4890 \setlength\textheight{\@tempcnta\baselineskip}
4891 \addtolength\textheight{\topskip}
4892
4893 % \end{macrocode}
4894 % \end{macro}
4895 %
4896 % The margins are calculated.
4897 %
4898 % \begin{macro}{\oddsidemargin}
4899 % \begin{macro}{\marginparwidth}
4900 % \begin{macro}{\evensidemargin}
4901 % The margins depend on the paper size, also for two sided
4902 % printing the inner margin is made smaller than the outer.
4903 % \begin{macrocode}
4904 \if@twoside
4905 \setlength\@tempdima {\paperwidth}
4906 \addtolength\@tempdima {-\textwidth}
4907 \setlength\oddsidemargin {.4\@tempdima}
4908 \addtolength\oddsidemargin {-1in}
4909 \setlength\marginparwidth {.6\@tempdima}
4910 \addtolength\marginparwidth{-\marginparsep}
4911 \addtolength\marginparwidth{-0.4in}
4912 \else
4913 \setlength\@tempdima {\paperwidth}
4914 \addtolength\@tempdima {-\textwidth}
4915 \setlength\oddsidemargin {.5\@tempdima}
4916 \addtolength\oddsidemargin {-1in}
4917 \setlength\marginparwidth {.5\@tempdima}
4918 \addtolength\marginparwidth{-\marginparsep}
4919 \addtolength\marginparwidth{-0.8in} % don't know why this isn't .4
4920 \fi
4921 \ifdim\marginparwidth>2in
4922 \setlength\marginparwidth{2in}%
4923 \fi
4924 % \end{macrocode}
4925 % Set these values to integer numbers of points, and afterwards calculate the
4926 % \cs{evensidemargin}.
4927 % Jonathon Stickel on 2008/05/30 noted that
4928 % \cs{marginparwidth} had to be positive for the initial setting of the sidebar
4929 % geometry through \cs{setsidebars}.
4930 % \changes{v1.618033}{2008/06/02}{Ensured initial value of \cs{marginparwidth}
4931 % was positive}
4932 % \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
4933 % can disable truncation via class option}
4934 % \begin{macrocode}
4935 \mem@settopoint\oddsidemargin
4936 \mem@settopoint\marginparwidth
4937 \ifdim\marginparwidth<1pt \setlength\marginparwidth{1pt}\fi
4938
4939 \setlength\evensidemargin {\paperwidth}
4940 \addtolength\evensidemargin{-2in}
4941 \addtolength\evensidemargin{-\textwidth}
4942 \addtolength\evensidemargin{-\oddsidemargin}
4943 \mem@settopoint\evensidemargin
4944 % \end{macrocode}
4945 % \end{macro}
4946 % \end{macro}
4947 % \end{macro}
4948 %
4949 % \begin{macro}{\topmargin}
4950 % The \cs{topmargin} is the distance below the top of the printable
4951 % area (1in below the top of the paper) and the top of the box
4952 % containing the running head.
4953 % \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
4954 % can disable truncation via class option}
4955 % \begin{macrocode}
4956 \setlength\topmargin {\paperheight}
4957 \addtolength\topmargin{-2in}
4958 \addtolength\topmargin{-\headheight}
4959 \addtolength\topmargin{-\headsep}
4960 \addtolength\topmargin{-\textheight}
4961 \addtolength\topmargin{-\footskip}
4962 \addtolength\topmargin{-.5\topmargin}
4963 \mem@settopoint\topmargin
4964
4965 % \end{macrocode}
4966 % \end{macro}
4967 %
4968 % That is the end of the classical algorithm. Now calculate the
4969 % user-friendly dimensions. The calculations are simpler than in
4970 % the general case as the \cs{paperwidth} and \cs{paperheight} is the
4971 % same as the \cs{stockwidth} and \cs{stockheight}.
4972 %
4973 % We can get the spine
4974 % and edge margins from the \cs{oddsidemargin}.
4975 % \begin{macrocode}
4976 \setlength{\spinemargin}{\oddsidemargin}
4977 \addtolength{\spinemargin}{1in}
4978 \setlrmargins{\spinemargin}{*}{*}
4979
4980 % \end{macrocode}
4981 %
4982 % Similarly we can get the upper and lower margins from the
4983 % \cs{topmargin}, \cs{headheight} and \cs{headskip}.
4984 % \begin{macrocode}
4985 \setlength{\uppermargin}{\topmargin}
4986 \addtolength{\uppermargin}{1in}
4987 \addtolength{\uppermargin}{\headheight}
4988 \addtolength{\uppermargin}{\headsep}
4989 \setulmargins{\uppermargin}{*}{*}
4990
4991 % \end{macrocode}
4992 %
4993 % \begin{macro}{\@memznegtest}
4994 % DA suggested this in a private email (2003/002/13) to make error
4995 % checking and reporting a bit more (space) efficient. Use like \\
4996 % \verb?\@memznegtest{\marginparsep}? instead of \\
4997 % \begin{verbatim}
4998 % \ifdim\marginparsep>\z@\else
4999 % \@memerror{\protect\marginparsep\space is zero or negative}{\@ehd}%
5000 % \fi
5001 % \end{verbatim}
5002 % If its length variable argument is zero or less it reports an error.
5003 %
5004 % \changes{v1.4}{2003/02/27}{Added \cs{@memznegtest}}
5005 % \changes{v1.618033}{2008/06/02}{Changed \cs{@memznegtest} and
5006 % \cs{@memnegtest} to issue warnings instead of errors}
5007 %
5008 % \begin{macrocode}
5009 \newcommand*{\@memznegtest}[1]{%
5010 \ifdim#1>\z@\else
5011 \@memwarn{\protect#1\space is zero or negative}%
5012 \fi}
5013 % \end{macrocode}
5014 % \end{macro}
5015 %
5016 % \begin{macro}{\@memnegtest}
5017 % Reports an error if its length variable argument is negative.
5018 % \changes{v1.4}{2003/02/27}{Added \cs{@memnegtest}}
5019 % \begin{macrocode}
5020 \newcommand*{\@memnegtest}[1]{%
5021 \ifdim#1<\z@
5022 \@memwarn{\protect#1\space is negative}%
5023 \fi}
5024
5025 % \end{macrocode}
5026 % \end{macro}
5027 %
5028 % \begin{macro}{\m@mclassicht}
5029 % The classic adjustment of the \cs{textheight} to get an integral number
5030 % of lines (given an integral number of baselineskips returns a height
5031 % giving one more line in the block).
5032 % \changes{v1.61803}{2008/01/30}{Added \cs{m@mclassicht}, \cs{m@mlinesht}
5033 % and \cs{m@mnearestht} (mempatch v4.5)}
5034 % \begin{macrocode}
5035 \newcommand*{\m@mclassicht}{%
5036 \setlength{\@tempdima}{\textheight}%
5037 \divide\@tempdima \baselineskip
5038 \@tempcnta=\@tempdima
5039 \setlength{\textheight}{\@tempcnta\baselineskip}%
5040 \addtolength{\textheight}{\topskip}}
5041
5042 % \end{macrocode}
5043 % \end{macro}
5044 %
5045 % \begin{macro}{\m@mlinesht}
5046 % The adjustment of the \cs{textheight} to get an integral number
5047 % of lines (given an inegral number of baselineskips returns a height
5048 % giving that number of lines).
5049 % \begin{macrocode}
5050 \newcommand*{\m@mlinesht}{%
5051 \setlength{\@tempdima}{\textheight}%
5052 \advance\@tempdima -\baselineskip
5053 \divide\@tempdima \baselineskip
5054 \@tempcnta=\@tempdima
5055 \setlength{\textheight}{\@tempcnta\baselineskip}%
5056 \addtolength{\textheight}{\topskip}}
5057
5058 % \end{macrocode}
5059 % \end{macro}
5060 %
5061 % \begin{macro}{\m@mnearestht}
5062 % The adjustment of the \cs{textheight} to get an integral number
5063 % of lines with the calculated height being as the closest to the given
5064 % height. Algorithm supplied by Lars Madsen and Morten H{\o}gholm on
5065 % 2006/07/27.
5066 % \begin{macrocode}
5067 \newcommand*{\m@mnearestht}{%
5068 \setlength{\@tempdima}{\textheight}%
5069 \advance\@tempdima -\topskip
5070 \advance\@tempdima 0.5\baselineskip
5071 \divide\@tempdima \baselineskip
5072 \@tempcnta=\@tempdima
5073 \setlength{\textheight}{\@tempcnta\baselineskip}%
5074 \addtolength{\textheight}{\topskip}}
5075
5076 % \end{macrocode}
5077 % \end{macro}
5078 %
5079 % \begin{macro}{\mem@autoadjust@marginparwidth}
5080 % This macro implements an algorithm, to automatically adjust
5081 % \cs{marginparwidth} to the current values of \cs{spinemargin} and
5082 % \cs{foremargin} (i.e., the inner and outer margins). It may be used
5083 % within \cs{fixthelayout} in case the user has not changed
5084 % \cs{marginparwidth} using \cs{setmarginnotes}.
5085 % \begin{macrocode}
5086 \newcommand\mem@autoadjust@marginparwidth{%
5087 \if@twocolumn
5088 \memsetlengthmin\marginparwidth\spinemargin\foremargin
5089 \else
5090 \if@twoside
5091 \ifcase\m@mmpar@margin\relax% 0 - left
5092 \memsetlengthmin\marginparwidth\spinemargin\foremargin
5093 \or% 1 - right
5094 \memsetlengthmin\marginparwidth\spinemargin\foremargin
5095 \or% 2 - outer
5096 \setlength\marginparwidth{\foremargin}
5097 \or% 3 - inner
5098 \setlength\marginparwidth{\spinemargin}
5099 \fi
5100 \else % oneside
5101 \ifnum\m@mmpar@margin=0% left
5102 \setlength\marginparwidth{\spinemargin}
5103 \else% right
5104 \setlength\marginparwidth{\foremargin}
5105 \fi
5106 \fi
5107 \fi
5108 \addtolength\marginparwidth{-2\marginparsep}
5109 \ifdim\marginparwidth<1pt\setlength\marginparwidth{1pt}\fi%
5110 }
5111
5112 % \end{macrocode}
5113 % \end{macro}
5114 %
5115 % \begin{macro}{\mem@reset@used@macros}
5116 % This macro is used to unset used macros. It is a manually
5117 % maintained macro. A better version would have been to let
5118 % \cs{memsetmacroused} record its use in a list, and then loop over
5119 % this list. Maybe some other time.
5120 % \begin{macrocode}
5121 \newcommand\mem@reset@used@macros{%
5122 \memsetmacrounused\setmarginnotes
5123 \memsetmacrounused\settypeblocksize
5124 \memsetmacrounused\setulmargins
5125 \memsetmacrounused\setlrmargins
5126 }
5127
5128 % \end{macrocode}
5129 %
5130 % \end{macro}
5131 %
5132 % \begin{macro}{\checkthelayout}
5133 % \cs{checkthelayout}\oarg{text} is the user level macro for
5134 % checking the layout. The \meta{text} argument controls which
5135 % algorithm should be used to calculate the \cs{textheight}.
5136 % \changes{v1.61803}{2008/01/30}{Extended \cs{checkthelayout} to include a choice
5137 % of algorithms (mempatch v4.5)}
5138 % \changes{v1.61803}{2008/01/30}{Changed some page layout tests to negative from zero or negative
5139 % (mempatch v4.5)}
5140 % \begin{macrocode}
5141 \newcommand*{\checkthelayout}[1][classic]{%
5142 % \end{macrocode}
5143 % First check the dimensions are not (zero or) negative.
5144 % \begin{macrocode}
5145 \@memnegtest{\trimedge}
5146 \@memnegtest{\trimtop}
5147 \@memznegtest{\stockwidth}
5148 \@memznegtest{\paperwidth}
5149 \@memznegtest{\textwidth}
5150 \@memnegtest{\spinemargin}
5151 \@memnegtest{\foremargin}
5152 \@memznegtest{\marginparsep}
5153 \@memznegtest{\marginparwidth}
5154 \@memznegtest{\stockheight}
5155 \@memznegtest{\paperheight}
5156 \@memznegtest{\textheight}
5157 \@memnegtest{\uppermargin}
5158 \@memnegtest{\lowermargin}
5159 \@memnegtest{\headheight}
5160 \@memnegtest{\headsep}
5161 \@memnegtest{\footskip}
5162 % \end{macrocode}
5163 %
5164 % Carry on regardless. We may need to adjust the \cs{textheight}
5165 % to get an integral number of lines.
5166 % \begin{macrocode}
5167 \nametest{#1}{classic}%
5168 \ifsamename
5169 \m@mclassicht
5170 \else
5171 \nametest{#1}{lines}%
5172 \ifsamename
5173 \m@mlinesht
5174 \else
5175 \nametest{#1}{nearest}%
5176 \ifsamename
5177 \m@mnearestht
5178 \else
5179 \nametest{#1}{fixed}
5180 \ifsamename
5181 \else% not classic, lines, nearest, or fixed
5182 \@memerror{Optional argument is not one of:\MessageBreak
5183 classic, fixed, lines, or nearest. \MessageBreak
5184 I will assume the default}%
5185 {\@ehc}%
5186 \fi
5187 \fi
5188 \fi
5189 \fi
5190 \setulmargins{\uppermargin}{*}{*}
5191 % \end{macrocode}
5192 %
5193 % Check that all the sums add up correctly, or
5194 % at least to within a small (\cs{@tempdimb}) error.
5195 % \changes{v1.618033}{2008/06/02}{Added more information about problematic
5196 % layout values}
5197 % \begin{macrocode}
5198 \@tempdimb = -1pt
5199 \@tempdima=\stockwidth
5200 \advance\@tempdima -\trimedge
5201 \advance\@tempdima -\paperwidth
5202 \ifdim\@tempdima<\@tempdimb
5203 \@tempdima = -\@tempdima
5204 \@memerror{\protect\paperwidth\space (\the\paperwidth) and/or
5205 \protect\trimedge\space (\the\trimedge)
5206 are too large for \protect\stockwidth\space (\the\stockwidth)
5207 by \the\@tempdima}%
5208 {\@ehd}
5209 \fi
5210 \@tempdima = \paperwidth
5211 \advance\@tempdima -\foremargin
5212 \advance\@tempdima -\textwidth
5213 \advance\@tempdima -\spinemargin
5214 \ifdim\@tempdima<\@tempdimb
5215 \@tempdima = -\@tempdima
5216 \@memerror{\protect\spinemargin\space (\the\spinemargin) and/or
5217 \protect\textwidth\space (\the\textwidth) and/or
5218 \protect\foremargin\space (\the\foremargin)
5219 are too large for \protect\paperwidth\space (\the\paperwidth)
5220 by \the\@tempdima}%
5221 {\@ehd}
5222 \fi
5223 \@tempdima = \stockheight
5224 \advance\@tempdima -\trimtop
5225 \advance\@tempdima -\paperheight
5226 \ifdim\@tempdima<\@tempdimb
5227 \@tempdima = -\@tempdima
5228 \@memerror{\protect\paperheight\space (\the\paperheight) and/or
5229 \protect\trimtop\space (\the\trimtop)
5230 are too large for \protect\stockheight\space (\the\stockheight)
5231 by \the\@tempdima}%
5232 {\@ehd}
5233 \fi
5234 \@tempdima = \paperheight
5235 \advance\@tempdima -\uppermargin
5236 \advance\@tempdima -\textheight
5237 \advance\@tempdima -\lowermargin
5238 \ifdim\@tempdima<\@tempdimb
5239 \@tempdima = -\@tempdima
5240 \@memerror{\protect\uppermargin\space (\the\uppermargin) and/or
5241 \protect\textheight\space (\the\textheight) and/or
5242 \protect\lowermargin\space (\the\lowermargin)
5243 are too large for \protect\paperheight\space (\the\paperheight)
5244 by \the\@tempdima}%
5245 {\@ehd}
5246 \fi
5247 \@tempdima = \uppermargin
5248 \advance\@tempdima -\headheight
5249 \advance\@tempdima -\headsep
5250 \ifdim\@tempdima<\@tempdimb
5251 \@tempdima = -\@tempdima
5252 \@memerror{\protect\headheight\space (\the\headheight) and/or
5253 \protect\headsep\space (\the\headsep)
5254 are too large for \protect\uppermargin\space (\the\uppermargin)
5255 by \the\@tempdima}%
5256 {\@ehd}
5257 \fi
5258 \@tempdima = \lowermargin
5259 \advance\@tempdima -\footskip
5260 \ifdim\@tempdima<\z@
5261 \@tempdima = -\@tempdima
5262 \@memerror{\protect\footskip\space (\the\footskip)
5263 is too large for \protect\lowermargin\space (\the\lowermargin)
5264 by \the\@tempdima}%
5265 {\@ehd}
5266 \fi}
5267
5268 % \end{macrocode}
5269 % \end{macro}
5270 %
5271 %
5272 % \begin{macro}{\fixthelayout}
5273 % Calculate the normal
5274 % \LaTeX{} page layout parameter values. We'll do the heights first
5275 % as they are independent of the number of columns and the side printing.
5276 % \changes{v1.0a}{2002/01/18}{Added \cs{fixthelayout}}
5277 % \begin{macrocode}
5278 \newcommand*{\fixthelayout}{%
5279 \topmargin = \trimtop
5280 \advance\topmargin \uppermargin
5281 \advance\topmargin -\headsep
5282 \advance\topmargin -\headheight
5283 \advance\topmargin -1in\relax
5284 % \end{macrocode}
5285 %
5286 % Now the \cs{oddsidemargin}.
5287 % \begin{macrocode}
5288 \oddsidemargin = \stockwidth
5289 \advance\oddsidemargin -\trimedge
5290 \advance\oddsidemargin -\paperwidth
5291 \advance\oddsidemargin \spinemargin
5292 \advance\oddsidemargin -1in\relax
5293 % \end{macrocode}
5294 %
5295 % And the \cs{evensidemargin}.
5296 % \begin{macrocode}
5297 \evensidemargin = \trimedge
5298 \advance\evensidemargin \foremargin
5299 \advance\evensidemargin -1in\relax
5300 % \end{macrocode}
5301 %
5302 %
5303 % Set the values to the nearest whole point.
5304 % \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
5305 % can disable truncation via class option}
5306 % \begin{macrocode}
5307 \mem@settopoint\textwidth
5308 \mem@settopoint\oddsidemargin
5309 \mem@settopoint\evensidemargin
5310 % \end{macrocode}
5311 % Fix standard page layouts after possible change of \cs{textwidth}.
5312 % \changes{v1.6180339f}{2009/03/16}{Added \cs{fixheaderwidths} to \cs{fixthelayout}}
5313 % \begin{macrocode}
5314 \fixheaderwidths
5315 % \end{macrocode}
5316 % Autoadjust \cs{marginparwidth} unless the user have used
5317 % \cs{setmarginnotes}. Plus add a reset of the recordedmacros, just in
5318 % case \cs{fixthelayout} is being used several times.
5319 % \changes{v3.6k}{2013/05/15}{Added autoadjust}
5320 % \begin{macrocode}
5321 \memifmacroused\setmarginnotes{}{\mem@autoadjust@marginparwidth}
5322 \mem@reset@used@macros
5323 }
5324
5325 % \end{macrocode}
5326 % \end{macro}
5327 %
5328 % \begin{macro}{\typeoutlayout}
5329 % \begin{macro}{\settypeoutlayoutunit}
5330 % \begin{macro}{\mem@typeouttwolengths}
5331 % \begin{macro}{\mem@typeoutonelength}
5332 % Why not type out the calculated versions of the designed values?
5333 % \changes{v1.0a}{2002/01/18}{Added \cs{typeoutlayout}}
5334 % \changes{v1.0a}{2002/01/25}{Added column info to \cs{typeoutlayout}}
5335 % \changes{v1.61803}{2008/01/30}{Added sidecap and sidebar data to \cs{typeoutlayout}
5336 % (mempatch v4.6)}
5337 % \changes{v1.61803398d}{2010/02/04}{Added information about side feet}
5338 % \changes{v3.6g}{2010/09/17}{Added feature such that user can change
5339 % the unit used by \cs{typeoutlayout}, requested by Rasmus Villemoes}
5340 % Using the macro \cs{settypeoutlayoutunit}\marg{unit} before
5341 % \cs{typeoutlayout} (or more often \cs{checkandfixthelayout}), the
5342 % user can choose the unit in which the list is typeset. The code is
5343 % inspired by the \texttt{printlen} package.
5344 % \changes{v3.8.3}{2024/01/31}{A lot easier to implement \cs{settypeoutlayoutunit} via expl3}
5345 % \begin{macrocode}
5346 \ExplSyntaxOn
5347 \newcommand\settypeoutlayoutunit[1]{
5348 \def\mem@tl@unit{#1}
5349 \str_case_e:nnF{#1}{
5350 {pt}{ \def\mem@tl@unitperpt{1.0} }
5351 {pc}{ \def\mem@tl@unitperpt{0.083333} }
5352 {in}{ \def\mem@tl@unitperpt{0.013837} }
5353 {mm}{ \def\mem@tl@unitperpt{0.351459} }
5354 {cm}{ \def\mem@tl@unitperpt{0.0351459} }
5355 {bp}{ \def\mem@tl@unitperpt{0.996264} }
5356 {dd}{ \def\mem@tl@unitperpt{0.9345718} }
5357 {cc}{ \def\mem@tl@unitperpt{0.0778809} }
5358 }{ % or error
5359 \@memerror{Unknown~unit~'#1'~not~suitable~for~layout\MessageBreak listing}{}
5360 }
5361 }
5362 \ExplSyntaxOff
5363
5364 %\newcommand\settypeoutlayoutunit[1]{
5365 % \nametest{#1}{pt}
5366 % \ifsamename
5367 % \def\mem@tl@unit{#1}
5368 % \def\mem@tl@unitperpt{1.0}
5369 % \else
5370 % \nametest{#1}{pc}
5371 % \ifsamename
5372 % \def\mem@tl@unit{#1}
5373 % \def\mem@tl@unitperpt{0.083333}
5374 % \else
5375 % \nametest{#1}{in}
5376 % \ifsamename
5377 % \def\mem@tl@unit{#1}
5378 % \def\mem@tl@unitperpt{0.013837}
5379 % \else
5380 % \nametest{#1}{mm}
5381 % \ifsamename
5382 % \def\mem@tl@unit{#1}
5383 % \def\mem@tl@unitperpt{0.351459}
5384 % \else
5385 % \nametest{#1}{cm}
5386 % \ifsamename
5387 % \def\mem@tl@unit{#1}
5388 % \def\mem@tl@unitperpt{0.0351459}
5389 % \else
5390 % \nametest{#1}{bp}
5391 % \ifsamename
5392 % \def\mem@tl@unit{#1}
5393 % \def\mem@tl@unitperpt{0.996264}
5394 % \else
5395 % \nametest{#1}{dd}
5396 % \ifsamename
5397 % \def\mem@tl@unit{#1}
5398 % \def\mem@tl@unitperpt{0.9345718}
5399 % \else
5400 % \nametest{#1}{cc}
5401 % \ifsamename
5402 % \def\mem@tl@unit{#1}
5403 % \def\mem@tl@unitperpt{0.0778809}
5404 % \else
5405 % \@memerror{Unknown unit '#1' not suitable for layout listing}{}
5406 % \fi
5407 % \fi
5408 % \fi
5409 % \fi
5410 % \fi
5411 % \fi
5412 % \fi
5413 % \fi
5414 %}
5415 % \end{macrocode}
5416 % Default value is \texttt{pt}, other supported are \texttt{mm},
5417 % \texttt{cm}, \texttt{in}, \texttt{bp}, \texttt{dd} and \texttt{cc}.
5418 % \begin{macrocode}
5419 \settypeoutlayoutunit{pt}
5420 % \end{macrocode}
5421 % To help with the typesetting, we need to helper macros:
5422 % \begin{macrocode}
5423 \newcommand\mem@typeouttwolengths[4]{
5424 % #1 = text before
5425 % #2 = first length
5426 % #3 = text between
5427 % #4 = second length
5428 \setlength\@tempdimc{\mem@tl@unitperpt #2}
5429 \edef\l@first{\strip@pt\@tempdimc}%
5430 \setlength\@tempdimc{\mem@tl@unitperpt #4}
5431 \edef\l@second{\strip@pt\@tempdimc}%
5432 \typeout{#1: \l@first\mem@tl@unit\space#3\space\l@second\mem@tl@unit}
5433 }
5434 \newcommand\mem@typeoutonelength[2]{
5435 % #1 = text before
5436 % #2 = first length
5437 \setlength\@tempdimc{\mem@tl@unitperpt #2}
5438 \edef\l@first{\strip@pt\@tempdimc}%
5439 \typeout{#1: \l@first\mem@tl@unit}
5440 }
5441 % \end{macrocode}
5442 % Thirdly \cs{typeoutlayout} need to be rewritten to take care of the
5443 % extra convertions
5444 % \begin{macrocode}
5445 \newcommand*{\typeoutlayout}{%
5446 \typeout{}
5447 \typeout{******************************************************}
5448 % \typeout{Stock height and width:
5449 % \the\stockheight\space by \the\stockwidth}
5450 % \typeout{Top and edge trims:
5451 % \the\trimtop\space and \the\trimedge}
5452 % \typeout{Page height and width:
5453 % \the\paperheight\space by \the\paperwidth}
5454 % \typeout{Text height and width:
5455 % \the\textheight\space by \the\textwidth}
5456 % \typeout{Spine and edge margins:
5457 % \the\spinemargin\space and \the\foremargin}
5458 % \typeout{Upper and lower margins:
5459 % \the\uppermargin\space and \the\lowermargin}
5460 % \typeout{Headheight and headsep:
5461 % \the\headheight\space and \the\headsep}
5462 % \typeout{Footskip:
5463 % \the\footskip}
5464 % \typeout{Columnsep and columnseprule:
5465 % \the\columnsep\space and \the\columnseprule}
5466 % \typeout{Marginparsep and marginparwidth:
5467 % \the\marginparsep\space and \the\marginparwidth}
5468 % \typeout{Sidecapsep and sidecapwidth:
5469 % \the\sidecapsep\space and \the\sidecapwidth}
5470 % \typeout{Sidebarhsep and sidebarwidth:
5471 % \the\sidebarhsep\space and \the\sidebarwidth}
5472 % \typeout{Sidebarvsep and sidebartopsep:
5473 % \the\sidebarvsep\space and \the\sidebartopsep}
5474 % \typeout{Sidebarheight:
5475 % \the\dimen\sideins}
5476 % \typeout{Sidefoothsep and sidefootwidth:
5477 % \the\sidefoothsep\space and \the\sidefootwidth}
5478 % \typeout{Sidefootvsep and sidefootheight:
5479 % \the\sidefootvsep\space and \the\sidefootheight}
5480 \mem@typeouttwolengths{Stock height and width}{\stockheight}{by}{\stockwidth}
5481 \mem@typeouttwolengths{Top and edge trims}{\trimtop}{and}{\trimedge}
5482 \mem@typeouttwolengths{Page height and width}{\paperheight}{by}{\paperwidth}
5483 \mem@typeouttwolengths{Text height and width}{\textheight}{by}{\textwidth}
5484 \mem@typeouttwolengths{Spine and edge margins}{\spinemargin}{and}{\foremargin}
5485 \mem@typeouttwolengths{Upper and lower margins}{\uppermargin}{and}{\lowermargin}
5486 \mem@typeouttwolengths{Headheight and headsep}{\headheight}{and}{\headsep}
5487 \mem@typeoutonelength{Footskip}{\footskip}
5488 \mem@typeouttwolengths{Columnsep and columnseprule}{\columnsep}{and}{\columnseprule}
5489 \mem@typeouttwolengths{Marginparsep and marginparwidth}{\marginparsep}{and}{\marginparwidth}
5490 \mem@typeouttwolengths{Sidecapsep and sidecapwidth}{\sidecapsep}{and}{\sidecapwidth}
5491 \mem@typeouttwolengths{Sidebarhsep and sidebarwidth}{\sidebarhsep}{and}{\sidebarwidth}
5492 \mem@typeouttwolengths{Sidebarvsep and sidebartopsep}{\sidebarvsep}{and}{\sidebartopsep}
5493 \mem@typeoutonelength{Sidebarheight}{\dimen\sideins}
5494 \mem@typeouttwolengths{Sidefoothsep and sidefootwidth}{\sidefoothsep}{and}{\sidefootwidth}
5495 \mem@typeouttwolengths{Sidefootvsep and sidefootheight}{\sidefootvsep}{and}{\sidefootheight}
5496 \typeout{******************************************************}
5497 \typeout{}}
5498
5499 % \end{macrocode}
5500 % \end{macro}
5501 % \end{macro}
5502 % \end{macro}
5503 % \end{macro}
5504 %
5505 % \begin{macro}{\checkandfixthelayout}
5506 % This macro checks and fixes the layout, and reports the result. It takes the
5507 % same optional argument as \cs{checkthelayout}.
5508 % \changes{v0.2}{2001/06/03}{Replaced \cs{fixpagelayout} by \cs{checkandfixthelayout}}
5509 % \changes{v1.0a}{2002/01/18}{Partitioned \cs{checkandfixthelayout}}
5510 % \changes{v1.61803}{2008/01/30}{Changed \cs{checkandfixthelayout}
5511 % for the extended \cs{checkthelayout} (mempatch v4.5)}
5512 % \begin{macrocode}
5513 \newcommand*{\checkandfixthelayout}[1][classic]{%
5514 \checkthelayout[#1]%
5515 \fixthelayout
5516 \typeoutlayout}
5517
5518 % \end{macrocode}
5519 % \end{macro}
5520 %
5521 %
5522 % \begin{macro}{\mem@fixpagelayout}
5523 % \changes{v3.7g}{2018/03/09}{Changed to use this instead of
5524 % \cs{fixpdflayout} and \cs{fixdvipslayout}, then we no longer need \Lpack{luatex85}}
5525 % Outputting the size of the output document. This is a little tricky as
5526 % the various engines do not quite agree on which variables to use. As
5527 % of 2018 we will be using this: First of \cs{pdfpageheight/width} is
5528 % used by pdf(e)tex based enginges. We set them if they are
5529 % defined. Just in case someone need to be able to patch this, we make
5530 % it into a macro and just run it at the start of the cocument
5531 % \begin{macrocode}
5532 \newcommand\mem@fixpagelayout{%
5533 \@ifundefined{pdfpageheight}{}{\pdfpageheight=\the\stockheight}
5534 \@ifundefined{pdfpagewidth}{}{\pdfpagewidth=\the\stockwidth}
5535 % \end{macrocode}
5536 % Next comes the two macros that recent luaTeX versions use instead of
5537 % the \cs{pdf...} equivalents.
5538 % \begin{macrocode}
5539 \@ifundefined{pageheight}{}{\pageheight=\the\stockheight}
5540 \@ifundefined{pagewidth}{}{\pagewidth=\the\stockwidth}
5541 % \end{macrocode}
5542 % If is unclear why these were added to the class sources in the first
5543 % place, we'll just leave them.
5544 % \begin{macrocode}
5545 \@ifundefined{pdfvorigin}{}{\ifdim\pdfvorigin=0pt\pdfvorigin=1in\fi}
5546 \@ifundefined{pdfhorigin}{}{\ifdim\pdfhorigin=0pt\pdfhorigin=1in\fi}
5547 % \end{macrocode}
5548 % Lastly we need to output a special to the DVI, but other engines can
5549 % also understand specials, so to not end up getting those pesky
5550 % non-PDF special warnings, we need some engine tests before emiting
5551 % the data to the DVI.
5552 % \begin{macrocode}
5553 \ifluatex\else
5554 \ifxetex\else
5555 \ifpdf\else
5556 \AtBeginDvi{\special{papersize=\the\stockwidth,\the\stockheight}}
5557 \fi
5558 \fi
5559 \fi
5560 }
5561
5562 \AtBeginDocument{\mem@fixpagelayout}
5563 % \end{macrocode}
5564 %
5565 % \changes{v3.7k}{2020/03/25}{Added a link to \cs{mem@fixpagelayout}}
5566 % \begin{macrocode}
5567 \let\refixpagelayout\mem@fixpagelayout
5568
5569 % \end{macrocode}
5570 % \end{macro}
5571 %
5572 % \begin{macro}{\fixpdflayout}
5573 % \begin{macro}{\fixdvipslayout}
5574 % As of 2018 these are disabled
5575 % ^^A % Page layout with pdf\LaTeX{} seems a bit iffy.
5576 % ^^A % At the suggestion of Lars Madsen, help with
5577 % ^^A % setting viewer (e.g., ghostview)
5578 % ^^A % window sizes for dvi/ps. \cs{fixdvipslayout} does for \file{dvi} output
5579 % ^^A % as \cs{fixpdflayout} does for \file{pdf} output.
5580 % \changes{v1.4}{2003/11/22}{Added \cs{fixpdflayout} (from patch v1.6)}
5581 % \changes{v1.4}{2003/12/01}{Added \cs{fixdvipslayout} }
5582 % \changes{v1.61803398}{2009/08/17}{on ctt dynamotwain suggested a
5583 % change to \cs{fixpdflayout} and the following \cs{AtBeginDocument}
5584 % such that the \cs{special} is not outputtet when running xelatex}
5585 % \begin{macrocode}
5586 \newcommand*{\fixpdflayout}{%
5587 \ClassWarning{memoir}{As of 2018, \string\fixpdflayout\ is no longer used}
5588 % \pdfpageheight=\the\stockheight
5589 % \pdfpagewidth=\the\stockwidth
5590 % \ifxetex\else
5591 % \ifdim\pdfvorigin=0pt\pdfvorigin=1in\fi
5592 % \ifdim\pdfhorigin=0pt\pdfhorigin=1in\fi
5593 % \fi
5594 }
5595 \newcommand*{\fixdvipslayout}{%
5596 \ClassWarning{memoir}{As of 2018, \string\fixdvipslayout\ is no longer used}
5597 %\AtBeginDvi{\special{papersize=\the\stockwidth,\the\stockheight}}
5598 }
5599 % \end{macrocode}
5600
5601 % ^^A % \AtBeginDocument{%
5602 % ^^A % \ifxetex
5603 % ^^A % \fixpdflayout
5604 % ^^A % \else
5605 % ^^A % \ifpdf
5606 % ^^A % \ifnum\pdfoutput<\@ne
5607 % ^^A % \fixdvipslayout
5608 % ^^A % \else
5609 % ^^A % \fixpdflayout
5610 % ^^A % \fi
5611 % ^^A % \else
5612 % ^^A % \fixdvipslayout
5613 % ^^A % \fi
5614 % ^^A % \fi}
5615
5616 %
5617 % ^^A % With a landscape document when going \texttt{latex -> dvips} the
5618 % ^^A % resulting \file{.ps} file
5619 % ^^A % may apear upside down in \texttt{ghostview}. If this happens, try putting
5620 % ^^A % the following in the document preamble:
5621 % ^^A % \begin{verbatim}
5622 % ^^A % \addtodef{\fixdvipslayout}{}{%
5623 % ^^A % \special{!TeXDict begin /landplus90{true}store end }}
5624 % ^^A % \end{verbatim}
5625 % ^^A % See \texttt{http://www.radicaleye.com.dvips.html} (DVIPS Home Page) for
5626 % ^^A % an explanation.
5627 % ^^A %
5628 % ^^A % Some other potential specials for PostScript printing may be
5629 % ^^A % (at least for an HP 5SiMx LaserJet duplex printer):
5630 % ^^A % \begin{verbatim}
5631 % ^^A % \special{!TeXDict begin <</Duplex true>>
5632 % ^^A % setpagedevice end} % duplex
5633 % ^^A % \special{!TeXDict begin <</Tumble true>>
5634 % ^^A % setpagedevice end} % short side binding
5635 % ^^A % \end{verbatim}
5636 % \end{macro}
5637 % \end{macro}
5638 %
5639 %
5640 % \begin{macro}{\typeoutstandardlayout}
5641 % Types out the current values of the standard page layout parameters.
5642 % \changes{v1.0a}{2002/01/25}{Added \cs{typeoutstandardlayout}}
5643 % \changes{v3.6g}{2010/09/17}{changed such that the user can change
5644 % the unit being used}
5645 % \begin{macrocode}
5646 \newcommand{\typeoutstandardlayout}{%
5647 \typeout{}
5648 \typeout{******************************************************}
5649 % \typeout{Page height and width:
5650 % \the\paperheight\space by \the\paperwidth}
5651 \mem@typeouttwolengths{Page height and width}{\paperheight}{by}{\paperwidth}
5652 % \typeout{Text height and width:
5653 % \the\textheight\space by \the\textwidth}
5654 \mem@typeouttwolengths{Text height and width}{\textheight}{by}{\textwidth}
5655 % \typeout{Oddside and evenside margins:
5656 % \the\oddsidemargin\space and \the\evensidemargin}
5657 \mem@typeouttwolengths{Oddside and evenside margins}{\oddsidemargin}{and}{\evensidemargin}
5658 % \typeout{Topmargin and footskip:
5659 % \the\topmargin\space and \the\footskip}
5660 \mem@typeouttwolengths{Topmargin and footskip}{\topmargin}{and}{\footskip}
5661 % \typeout{Headheight and headsep:
5662 % \the\headheight\space and \the\headsep}
5663 \mem@typeouttwolengths{Headheight and headsep}{\headheight}{and}{\headsep}
5664 % \typeout{Columnsep and columnseprule:
5665 % \the\columnsep\space and \the\columnseprule}
5666 \mem@typeouttwolengths{Columnsep and columnseprule}{\columnsep}{and}{\columnseprule}
5667 % \typeout{Marginparsep and marginparwidth:
5668 % \the\marginparsep\space and \the\marginparwidth}
5669 \mem@typeouttwolengths{Marginparsep and marginparwidth}{\marginparsep}{and}{\marginparwidth}
5670 \typeout{******************************************************}
5671 \typeout{}
5672 }
5673
5674 % \end{macrocode}
5675 % \end{macro}
5676 %
5677 %
5678 % \subsection{Some predefined layouts}
5679 %
5680 % A few predefined layouts for the textblock are presented. The \cs{checkandfixthelayout}
5681 % macro \emph{must} be called afterwards.
5682 %
5683 % \begin{macro}{\medievalpage}
5684 % This implements Jan Tschichold's reconstruction of the page and textblock
5685 % layout used by medieval scribes and the early printers.
5686 % The spine, top, edge and bottom margins are in the ratios 2:3:4:6.
5687 %
5688 % \cs{medievalpage}\oarg{num} positions the typeblock on the page with the
5689 % margins in the above ratios. The spine margin is (page width)/\meta{num}
5690 % (default 9). This must be an integer.
5691 % \changes{v1.61803}{2008/01/30}{Added \cs{medievalpage}}
5692 % \begin{macrocode}
5693 %%%% s = w/#1, t = 1.5s, e = 2s, f = 3s
5694 \newcommand*{\medievalpage}[1][9]{%
5695 \spinemargin=\paperwidth
5696 \divide\spinemargin #1\relax
5697 \uppermargin = 1.5\spinemargin
5698 \setlrmarginsandblock{\spinemargin}{*}{2}
5699 \setulmarginsandblock{\uppermargin}{*}{2}}
5700
5701 % \end{macrocode}
5702 % \end{macro}
5703 %
5704 % \begin{macro}{\isopage}
5705 % An implementation of Bringhurst's layout for ISO proportioned pages.
5706 % It works for any page though. The edge margin is twice the spine,
5707 % and the bottom margin is twice the top.
5708 %
5709 % \cs{isopage}\oarg{num} positions and sizes the typeblock on the page
5710 % according to the above ratios. The spine is (page width)/\meta{num}
5711 % and the top margin id (page height)/\meta{num}. \meta{num} must be
5712 % an integer.
5713 % \changes{v1.61803}{2008/01/30}{Added \cs{isopage}}
5714 % \begin{macrocode}
5715 % s = w/#1, e = 2s, t = h/#1, f = 2h
5716 \newcommand*{\isopage}[1][9]{%
5717 \spinemargin=\paperwidth
5718 \divide\spinemargin #1\relax
5719 \uppermargin=\paperheight
5720 \divide\uppermargin #1\relax
5721 \setlrmarginsandblock{\spinemargin}{*}{2}
5722 \setulmarginsandblock{\uppermargin}{*}{2}}
5723
5724 % \end{macrocode}
5725 % \end{macro}
5726 %
5727 % \begin{macro}{\semiisopage}
5728 % An variation on Bringhurst's layout for ISO proportioned pages.
5729 % It works for any page though. The top margin is the same as the spine,
5730 % and the edge and bottom margins are twice the spine.
5731 %
5732 % \cs{semiisopage}\oarg{num} positions and sizes the typeblock on the page
5733 % according to the above ratios. The spine is (page width)/\meta{num}.
5734 % \meta{num} must be an integer.
5735 % \changes{v1.61803}{2008/01/30}{Added \cs{isopage}}
5736 % \begin{macrocode}
5737 %%% s = w/#1, t = s, e = 2s, f = e
5738 \newcommand*{\semiisopage}[1][9]{%
5739 \spinemargin=\paperwidth
5740 \divide\spinemargin #1\relax
5741 \uppermargin=\spinemargin
5742 \setlrmarginsandblock{\spinemargin}{*}{2}
5743 \setulmarginsandblock{\uppermargin}{*}{2}}
5744
5745 % \end{macrocode}
5746 % \end{macro}
5747 %
5748 % \begin{macro}{\setpagebl}
5749 % \begin{macro}{\setpageml}
5750 % \begin{macro}{\setpagetl}
5751 % \begin{macro}{\setpagetm}
5752 % \cs{setpagebl}\marg{height}\marg{width}\marg{ratio} sets a page smaller than
5753 % the stock size at the bottom left of the stock. The arguments are the
5754 % the same as for \cs{settrimmedsize};
5755 % \meta{height}, \meta{width} and \meta{ratio} of height and width
5756 % (choose any two) of the desired page size. The trims are adjusted to suit.
5757 % \cs{setpagetl} puts the page at the top left, \cs{setpageml} at the
5758 % middle left, and \cs{setpagetm} at the top middle.
5759 % \changes{v1.61803}{2008/01/30}{Added \cs{setpagebl}, \cs{setpageml}, and
5760 % \cs{setpagetl}}
5761 % \changes{v1.6180339c}{2008/12/26}{Added \cs{setpagetm}}
5762 % \begin{macrocode}
5763 \newcommand*{\setpagebl}[3]{%
5764 \settrimmedsize{#1}{#2}{#3}%
5765 \trimtop=\stockheight \advance\trimtop -\paperheight
5766 \trimedge=\stockwidth \advance\trimedge -\paperwidth}
5767 \newcommand*{\setpageml}[3]{%
5768 \settrimmedsize{#1}{#2}{#3}
5769 \trimtop=\stockheight \advance\trimtop -\paperheight
5770 \advance\trimtop -0.5\trimtop
5771 \trimedge=\stockwidth \advance\trimedge -\paperwidth}
5772 \newcommand*{\setpagetl}[3]{%
5773 \settrimmedsize{#1}{#2}{#3}
5774 \trimtop=0pt
5775 \trimedge=\stockwidth \advance\trimedge -\paperwidth}
5776 \newcommand*{\setpagetm}[3]{%
5777 \settrimmedsize{#1}{#2}{#3}%
5778 \trimtop=0pt
5779 \trimedge=\stockwidth \advance\trimedge -\paperwidth
5780 \advance\trimedge -0.5\trimedge}
5781
5782 % \end{macrocode}
5783 % \end{macro}
5784 % \end{macro}
5785 % \end{macro}
5786 % \end{macro}
5787 %
5788 % \begin{macro}{\setpagetr}
5789 % \begin{macro}{\setpagemr}
5790 % \begin{macro}{\setpagebr}
5791 % \begin{macro}{\setpagebm}
5792 % \begin{macro}{\setpagecc}
5793 % Similar to those above, these macros set the page on the stock
5794 % at the top right, middle right, bottom right, bottom middle, and centered.
5795 % \changes{v1.6180339c}{2008/12/26}{Added \cs{setpagetr}, \cs{setpagemr}, \cs{setpagebr},
5796 % \cs{setpagebm} and \cs{setpagecc}}
5797 % \changes{v3.7k}{2020/03/15}{Added \cs{setpagemm} as an alias to \cs{setpagecc}}
5798 % \begin{macrocode}
5799 \newcommand*{\setpagetr}[3]{%
5800 \settrimmedsize{#1}{#2}{#3}%
5801 \trimtop=0pt
5802 \trimedge=0pt}
5803 \newcommand*{\setpagemr}[3]{%
5804 \settrimmedsize{#1}{#2}{#3}%
5805 \trimtop=\stockheight \advance\trimtop -\paperheight
5806 \advance\trimtop -0.5\trimtop
5807 \trimedge=0pt}
5808 \newcommand*{\setpagebr}[3]{%
5809 \settrimmedsize{#1}{#2}{#3}%
5810 \trimtop=\stockheight \advance\trimtop -\paperheight
5811 \trimedge=0pt}
5812 \newcommand*{\setpagebm}[3]{%
5813 \settrimmedsize{#1}{#2}{#3}%
5814 \trimtop=\stockheight \advance\trimtop -\paperheight
5815 \trimedge=\stockwidth \advance\trimedge -\paperwidth
5816 \advance\trimedge -0.5\trimedge}
5817 \newcommand*{\setpagecc}[3]{%
5818 \settrimmedsize{#1}{#2}{#3}%
5819 \trimtop=\stockheight \advance\trimtop -\paperheight
5820 \advance\trimtop -0.5\trimtop
5821 \trimedge=\stockwidth \advance\trimedge -\paperwidth
5822 \advance\trimedge -0.5\trimedge}
5823 \let\setpagemm\setpagecc
5824
5825 % \end{macrocode}
5826 % \end{macro}
5827 % \end{macro}
5828 % \end{macro}
5829 % \end{macro}
5830 % \end{macro}
5831 %
5832 %
5833 %
5834 % \subsection{Float placement parameters}
5835 %
5836 %
5837 % All float parameters are given default values in the \LaTeX{}
5838 % kernel. For this reason counters only need to be set with
5839 % \cs{setcounter} and other parameters are set using \cs{renewcommand}.
5840 %
5841 % \paragraph{Limits for the placement of floating objects}
5842 %
5843 % The settings here make it easier to place floats than with the
5844 % standard classes.
5845 %
5846 % \begin{macro}{\c@topnumber}
5847 % The \Lcount{topnumber} counter holds the maximum number of
5848 % floats that can appear on the top of a text page (classically 2)
5849 % \begin{macrocode}
5850 \setcounter{topnumber}{3}
5851 % \end{macrocode}
5852 % \end{macro}
5853 %
5854 % \begin{macro}{\topfraction}
5855 % This indicates the maximum part of a text page that can be
5856 % occupied by floats at the top (classically 0.7).
5857 % \begin{macrocode}
5858 \renewcommand{\topfraction}{.85}
5859 % \end{macrocode}
5860 % \end{macro}
5861 %
5862 % \begin{macro}{\c@bottomnumber}
5863 % The \Lcount{bottomnumber} counter holds the maximum number of
5864 % floats that can appear on the bottom of a text page (classically 1).
5865 % \begin{macrocode}
5866 \setcounter{bottomnumber}{2}
5867 % \end{macrocode}
5868 % \end{macro}
5869 %
5870 % \begin{macro}{\bottomfraction}
5871 % This indicates the maximum part of a text page that can be
5872 % occupied by floats at the bottom (classically 0.3).
5873 % \begin{macrocode}
5874 \renewcommand{\bottomfraction}{.5}
5875 % \end{macrocode}
5876 % \end{macro}
5877 %
5878 % \begin{macro}{\c@totalnumber}
5879 % This indicates the maximum number of floats that can appear on
5880 % any text page (classically 3).
5881 % \begin{macrocode}
5882 \setcounter{totalnumber}{4}
5883 % \end{macrocode}
5884 % \end{macro}
5885 %
5886 % \begin{macro}{\textfraction}
5887 % This indicates the minimum part of a text page that has to be
5888 % occupied by text (classically 0.2).
5889 % \begin{macrocode}
5890 \renewcommand{\textfraction}{.1}
5891 % \end{macrocode}
5892 % \end{macro}
5893 %
5894 % \begin{macro}{\floatpagefraction}
5895 % This indicates the minimum part of a page that has to be
5896 % occupied by floating objects before a `float page' is
5897 % produced (classically 0.5).
5898 % \begin{macrocode}
5899 \renewcommand{\floatpagefraction}{.7}
5900 % \end{macrocode}
5901 % \end{macro}
5902 %
5903 % \begin{macro}{\c@dbltopnumber}
5904 % The \Lcount{dbltopnumber} counter holds the maximum number of
5905 % two column floats that can appear on the top of a two column text
5906 % page (classically 2).
5907 % \begin{macrocode}
5908 \setcounter{dbltopnumber}{3}
5909 % \end{macrocode}
5910 % \end{macro}
5911 %
5912 % \begin{macro}{\dbltopfraction}
5913 % This indicates the maximum part of a two column text page that
5914 % can be occupied by two column floats at the top (classically 0.7).
5915 % \begin{macrocode}
5916 \renewcommand{\dbltopfraction}{.85}
5917 % \end{macrocode}
5918 % \end{macro}
5919 %
5920 % \begin{macro}{\dblfloatpagefraction}
5921 % This indicates the minimum part of a page that has to be
5922 % occupied by two column wide floating objects before a `float
5923 % page' is produced (classically 0.5).
5924 % \begin{macrocode}
5925 \renewcommand{\dblfloatpagefraction}{.7}
5926 % \end{macrocode}
5927 % \end{macro}
5928 %
5929 %
5930 % \section{Page Styles}
5931 %
5932 % The page style \pstyle{foo} is defined by defining the command
5933 % \cs{ps@foo}. This command should make only local definitions.
5934 % There should be no stray spaces in the definition, since they
5935 % could lead to mysterious extra spaces in the output.
5936 %
5937 % \begin{macro}{\@evenhead}
5938 % \begin{macro}{\@oddhead}
5939 % \begin{macro}{\@evenfoot}
5940 % \begin{macro}{\@oddfoot}
5941 % The \cs{ps@...} command defines the macros \cs{@oddhead},
5942 % \cs{@oddfoot}, \cs{@evenhead}, and \cs{@evenfoot} to define the running
5943 % heads and feet---e.g., \cs{@oddhead} is the macro to produce the
5944 % contents of the heading box for odd-numbered pages. It is called
5945 % inside an \cs{hbox} of width \cs{textwidth}.
5946 % \end{macro}
5947 % \end{macro}
5948 % \end{macro}
5949 % \end{macro}
5950 %
5951 % \subsection{Marking conventions}
5952 %
5953 % To make headings determined by the sectioning commands, the page
5954 % style defines the commands \cs{chaptermark}, \cs{sectionmark},
5955 % \ldots,\\
5956 % where \cs{chaptermark}\marg{TEXT} is called by
5957 % \cs{chapter} to set a mark, and so on.
5958 %
5959 % The \cs{...mark} commands and the \cs{...head} macros are defined
5960 % with the help of the following macros. (All the \cs{...mark}
5961 % commands should be initialized to no-ops.)
5962 %
5963 % \LaTeX{} extends \TeX's \cs{mark} facility by producing two kinds
5964 % of marks, a `left' and a `right' mark, using the following
5965 % commands:
5966 % \begin{flushleft}
5967 % \cs{markboth}\marg{LEFT}\marg{RIGHT}: Adds both marks.
5968 %
5969 % \cs{markright}\marg{RIGHT}: Adds a `right' mark.
5970 %
5971 % \cs{leftmark}: Used in the \cs{@oddhead}, \cs{@oddfoot}, \cs{@evenhead}
5972 % or \cs{@evenfoot} macros, it gets the current `left'
5973 % mark. \cs{leftmark} works like \TeX's \cs{botmark}
5974 % command.
5975 %
5976 % \cs{rightmark}: Used in the \cs{@oddhead}, \cs{@oddfoot}, \cs{@evenhead}
5977 % or \cs{@evenfoot} macros, it gets the current
5978 % `right' mark. \cs{rightmark} works like \TeX's
5979 % \cs{firstmark} command.
5980 % \end{flushleft}
5981 %
5982 % The marking commands work reasonably well for right marks
5983 % `numbered within' left marks--e.g., the left mark is changed by a
5984 % \cs{chapter} command and the right mark is changed by a \cs{section}
5985 % command. However, it does produce somewhat anomalous results if
5986 % two \cs{markboth}'s occur on the same page.
5987 %
5988 %
5989 % Commands like \cs{tableofcontents} that should set the marks in some
5990 % page styles use a \cs{@mkboth} command, which is \cs{let} by the
5991 % pagestyle command (\cs{ps@...}) to \cs{markboth} for setting the
5992 % heading or to \cs{@gobbletwo} to do nothing.
5993 %
5994 %
5995 %
5996 % \subsection{Defining the page styles}
5997 %
5998 % This class provides a set of commands for the user to define new
5999 % pagestyles. Essentially defining a pagestyle consists of defining the
6000 % macros \cs{@evenhead}, \cs{@oddhead}, \cs{@evenfoot}, and \cs{@oddfoot}.
6001 % For this class, each header and footer is treated as three parts: a left,
6002 % center, and right part. In this case, defining a pagestyle consists of
6003 % specifying these 12 portions of the running headers and footers. The
6004 % width of the headers/footers may also be specified, rules may be drawn
6005 % below the headers and/or above the footers, and the complete header and/or
6006 % footer may be offset with respect to the textblock when the width is not
6007 % the same as the textwidth.
6008 %
6009 % In the following \meta{style} is the name of a pagestyle being defined
6010 % (e.g., \verb?ruled?).
6011 %
6012 % \changes{v1.61803398d}{2010/02/09}{Added the following three macros}
6013 % \begin{macro}{\mem@set@ps@xtra@info}
6014 % \begin{macro}{\mem@ps@find@real}
6015 % \begin{macro}{\mem@ps@safe@change}
6016 % The class supports an aliasing feature, where a page style name can
6017 % actually call the code from another. Quite handy. But There might be
6018 % problems if a use try to modify an alias page style. We care for
6019 % this by storing some information about each page style, and throwing
6020 % an error if the user atempts to alter a page style marked as an
6021 % alias.
6022 %
6023 % \verb?\mem@set@ps@xtra@info? store two things: the name of the style
6024 % we are an alias for (if we are not an alias it will be blank) and an
6025 % indicator whether we are an alias (00 if we are and 01 if we are not).
6026 % \begin{macrocode}
6027 \newcommand\mem@set@ps@xtra@info[3]{%
6028 \@namedef{ps@#1@aliasfor}{#2}%
6029 \@namedef{ps@#1@isalias}{#3}}
6030
6031 % \end{macrocode}
6032 % \verb?\mem@ps@find@real? starts at a given page style, if it is
6033 % marked as an alias, it will recursively go down the chain of aliases
6034 % and save the name of the first real page style in \verb?\@tempa?.
6035 % \begin{macrocode}
6036 \newcommand\mem@ps@find@real[1]{%
6037 \if\@nameuse{ps@#1@isalias}\relax
6038 \mem@ps@find@real{\@nameuse{ps@#1@aliasfor}}
6039 \else\def\@tempa{#1}\fi}
6040
6041 % \end{macrocode}
6042 % \verb?\mem@ps@safe@change? takes a page style name, checks to see if
6043 % it is defined, if it is, it checks to see if it is safe to change
6044 % it.
6045 % \changes{v3.7c}{2014/05/20}{Typo reported by Werner Grundlingh}
6046 % \begin{macrocode}
6047 \newcommand\mem@ps@safe@change[1]{%
6048 \@ifundefined{ps@#1}{%
6049 \@memerror{Undefined pagestyle '#1', so I cannot change it}{}}{}
6050 \if\@nameuse{ps@#1@isalias}\relax \mem@ps@find@real{#1}
6051 \@memerror{The pagestyle '#1' is marked as an alias page style.^^J
6052 Modifying an alias page style may give unexpected results.^^J The
6053 alias chain resolves to the real page style '\@tempa', so try
6054 issuing^^J \string\copypagestyle{#1}{\@tempa}^^J
6055 before modifying '#1'}{} \fi }
6056
6057 % \end{macrocode}
6058 %
6059 % \end{macro}
6060 % \end{macro}
6061 % \end{macro}
6062 %
6063 % \begin{macro}{\makeevenhead}
6064 % The command
6065 % \cs{makeevenhead}\marg{style}\marg{left}\marg{center}\marg{right}
6066 % specifies that the left, center and right portions of the even header for
6067 % pagestyle \meta{style} are defined as the other three arguments, respectiveley.
6068 % Internally it defines the commands \cs{styleeheadl}, \cs{styleeheadc} and
6069 % \cs{styleeheadr} to be \meta{left}, \meta{center} and \meta{right} respectively.
6070 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6071 % \begin{macrocode}
6072 \newcommand{\makeevenhead}[4]{%
6073 \mem@ps@safe@change{#1}
6074 \@namedef{#1eheadl}{#2}
6075 \@namedef{#1eheadc}{#3}
6076 \@namedef{#1eheadr}{#4}
6077 }
6078 % \end{macrocode}
6079 % \end{macro}
6080 %
6081 % \begin{macro}{\makeoddhead}
6082 % \begin{macro}{\makeevenfoot}
6083 % \begin{macro}{\makeoddfoot}
6084 % These three macros are similar to \cs{makeevenhead} except that they are
6085 % for the oddhead, evenfoot and oddfoot.
6086 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6087 % \begin{macrocode}
6088 \newcommand{\makeoddhead}[4]{%
6089 \mem@ps@safe@change{#1}
6090 \@namedef{#1oheadl}{#2}
6091 \@namedef{#1oheadc}{#3}
6092 \@namedef{#1oheadr}{#4}
6093 }
6094 \newcommand{\makeevenfoot}[4]{%
6095 \mem@ps@safe@change{#1}
6096 \@namedef{#1efootl}{#2}
6097 \@namedef{#1efootc}{#3}
6098 \@namedef{#1efootr}{#4}
6099 }
6100 \newcommand{\makeoddfoot}[4]{%
6101 \mem@ps@safe@change{#1}
6102 \@namedef{#1ofootl}{#2}
6103 \@namedef{#1ofootc}{#3}
6104 \@namedef{#1ofootr}{#4}
6105 }
6106
6107 % \end{macrocode}
6108 % \end{macro}
6109 % \end{macro}
6110 % \end{macro}
6111 %
6112 % \begin{macro}{\makerunningwidth}
6113 % \begin{macro}{\makerunningheadwidth}
6114 % \begin{macro}{\makerunningfootwidth}
6115 % \begin{macro}{\m@mhfstyle}
6116 % \begin{macro}{\m@mopthfwidth}
6117 % The macro \cs{makerunningwidth}\marg{style}\oarg{ftlength}\marg{length}
6118 % sets the
6119 % width of the headers and footers of pagestyle \meta{style} to
6120 % be \meta{length}, but if \meta{ftlength} is present the footer
6121 % width is set to \meta{ftlength}. The lengths are stored as the
6122 % macros \cs{styleheadrunwidth} and \cs{stylefootrunwidth}. The two
6123 % widths can be set individually using
6124 % \cs{makerunningheadwidth}\marg{style}\marg{length} and
6125 % \cs{makerunningfootwidth}\marg{style}\marg{length}.
6126 % \changes{v1.6180339c}{2008/12/26}{Enabled the width of headers and footers
6127 % to be different
6128 % (requested by Wilhelm M\"{u}ller).}
6129 % \changes{v1.6180339c}{2009/01/13}{Added \cs{makerunningheadwidth}
6130 % and \cs{makerunningfootwidth}}.
6131 % \changes{v1.6180339d}{2009/02/04}{Fixed a mental bug, /daleif}
6132 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6133 % \begin{macrocode}
6134 \newcommand*{\makerunningwidth}[1]{%
6135 \mem@ps@safe@change{#1}%
6136 \def\m@mhfstyle{#1}%
6137 \m@mopthfwidth}
6138 \newcommand*{\m@mopthfwidth}[2][\@mpty]{%
6139 % \setlength\@tempdima{#2}
6140 \@namedef{\m@mhfstyle headrunwidth}{#2}%
6141 % \expandafter\edef\csname \m@mhfstyle headrunwidth\endcsname{\the\@tempdima}
6142 \ifx\@mpty #1
6143 \@namedef{\m@mhfstyle footrunwidth}{#2}%
6144 % \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}
6145 \else
6146 \@namedef{\m@mhfstyle footrunwidth}{#1}%
6147 % \setlength\@tempdima{#1}
6148 % \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}
6149 \fi}
6150 \newcommand*{\makerunningheadwidth}[2]{%
6151 % \setlength\@tempdima{#2}%
6152 % \expandafter\edef\csname \m@mhfstyle headrunwidth\endcsname{\the\@tempdima}%
6153 \mem@ps@safe@change{#1}%
6154 \@namedef{#1headrunwidth}{#2}%
6155 }
6156 \newcommand*{\makerunningfootwidth}[2]{%
6157 % \setlength\@tempdima{#2}%
6158 \mem@ps@safe@change{#1}%
6159 \@namedef{#1footrunwidth}{#2}%
6160 % \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}%
6161 }
6162
6163 % \end{macrocode}
6164 % \end{macro}
6165 % \end{macro}
6166 % \end{macro}
6167 % \end{macro}
6168 % \end{macro}
6169 %
6170 % \begin{macro}{\normalrulethickness}
6171 % \begin{macro}{\footruleheight}
6172 % \begin{macro}{\footruleskip}
6173 % \begin{macro}{\makeheadrule}
6174 % \begin{macro}{\makefootrule}
6175 % \cs{normalrulethickness} is the thickness of a normal horizontal
6176 % or vertical rule.
6177 % \cs{footruleheight} is the height of a normal rule above a footer (actually zero).
6178 % \cs{footruleskip} is a distance sufficient to ensure that a foot rule
6179 % will appear between the bottom of the textblock and above any actual footer.
6180 %
6181 % (There was a \ctt{} thread \textit{ngerman, fancyhdr and \cs{footrulewidth} --- bug?}
6182 % in December 2002 that bears on the definitions below).
6183 % \changes{v1.4}{2003/02/27}{Make \cs{normalrulethickness} a length,
6184 % not a macro (patch 1.1)}
6185 % \changes{v1.4}{2003/02/27}{Initialise \cs{footruleheight} to 0pt, not
6186 % \cs{z@skip} (patch 1.1)}
6187 % \begin{macrocode}
6188 \newlength{\normalrulethickness}
6189 \setlength{\normalrulethickness}{0.4pt}
6190 \newcommand{\footruleheight}{0pt}
6191 \newcommand{\footruleskip}{0.3\normalbaselineskip}
6192 % \end{macrocode}
6193 % The macro \cs{makeheadrule}\marg{style}\marg{width}\marg{height}
6194 % specifies the width and height of the header rule for \meta{style}.
6195 %
6196 % Similarly
6197 % \cs{makefootrule}\marg{style}\marg{width}\marg{height}\marg{skip}
6198 % specifies the width, height and skip for the footrule.
6199 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6200 % \changes{v3.7d}{2015/04/22}{Moved \cs{...(head|foot)ruleprefix} out and
6201 % added them else where}
6202 % \begin{macrocode}
6203 \newcommand{\makeheadrule}[3]{%
6204 \mem@ps@safe@change{#1}%
6205 \@namedef{#1headrule}{%
6206 \hrule\@width #2\@height #3 \vskip-#3}}
6207 \newcommand{\makefootrule}[4]{%
6208 \mem@ps@safe@change{#1}%
6209 \@namedef{#1footrule}{%
6210 \vskip-#4\vskip-#3%
6211 \hrule\@width #2\@height #3 \vskip #4}}
6212
6213 % \end{macrocode}
6214 % \end{macro}
6215 % \end{macro}
6216 % \end{macro}
6217 % \end{macro}
6218 % \end{macro}
6219 %
6220 % \changes{v3.6h}{2011/01/25}{Added this macro}
6221 % \begin{macro}{\makeheadfootruleprefix}
6222 % We insert a maro at the start of the head and foot rule. By default
6223 % it does nothing, but it can be ised to specify a different color to
6224 % the head or foot rules.
6225 % \begin{macrocode}
6226 \newcommand\makeheadfootruleprefix[3]{%
6227 \@namedef{#1headruleprefix}{#2}%
6228 \@namedef{#1footruleprefix}{#3}%
6229 }
6230 % \end{macrocode}
6231 % \end{macro}
6232 %
6233 % \begin{macro}{\makeheadposition}
6234 % \cs{makeheadposition}\marg{style}\marg{eheadpos}\marg{oheadpos}\marg{efootpos}\marg{ofootpos}
6235 % specifies the horizontal positioning of the even and odd headers and footers,
6236 % respectively,
6237 % for the pagestyle \meta{style}. Each of the \meta{...pos} arguments may be
6238 % either \verb?flushleft?, \verb?center? or \verb?flushright?, with the obvious meanings.
6239 % An empty argument (or an unrecognised one) is equivalent to \verb?center?.
6240 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6241 % \begin{macrocode}
6242 \newcommand{\makeheadposition}[5]{%
6243 \mem@ps@safe@change{#1}%
6244 % \end{macrocode}
6245 % Do the even head position first.
6246 % \begin{macrocode}
6247 \nametest{flushleft}{#2}
6248 \ifsamename
6249 \@namedef{#1evenheadpl}{\relax} \@namedef{#1evenheadpr}{\hss}
6250 \else
6251 \nametest{flushright}{#2}
6252 \ifsamename
6253 \@namedef{#1evenheadpl}{\hss} \@namedef{#1evenheadpr}{\relax}
6254 \else
6255 \@namedef{#1evenheadpl}{\hss} \@namedef{#1evenheadpr}{\hss}
6256 \fi
6257 \fi
6258 % \end{macrocode}
6259 % And similarly for the odd head and even \& odd footers.
6260 % \begin{macrocode}
6261 \nametest{flushleft}{#3}
6262 \ifsamename
6263 \@namedef{#1oddheadpl}{\relax} \@namedef{#1oddheadpr}{\hss}
6264 \else
6265 \nametest{flushright}{#3}
6266 \ifsamename
6267 \@namedef{#1oddheadpl}{\hss} \@namedef{#1oddheadpr}{\relax}
6268 \else
6269 \@namedef{#1oddheadpl}{\hss} \@namedef{#1oddheadpr}{\hss}
6270 \fi
6271 \fi
6272 \nametest{flushleft}{#4}
6273 \ifsamename
6274 \@namedef{#1evenfootpl}{\relax} \@namedef{#1evenfootpr}{\hss}
6275 \else
6276 \nametest{flushright}{#4}
6277 \ifsamename
6278 \@namedef{#1evenfootpl}{\hss} \@namedef{#1evenfootpr}{\relax}
6279 \else
6280 \@namedef{#1evenfootpl}{\hss} \@namedef{#1evenfootpr}{\hss}
6281 \fi
6282 \fi
6283 \nametest{flushleft}{#5}
6284 \ifsamename
6285 \@namedef{#1oddfootpl}{\relax} \@namedef{#1oddfootpr}{\hss}
6286 \else
6287 \nametest{flushright}{#5}
6288 \ifsamename
6289 \@namedef{#1oddfootpl}{\hss} \@namedef{#1oddfootpr}{\relax}
6290 \else
6291 \@namedef{#1oddfootpl}{\hss} \@namedef{#1oddfootpr}{\hss}
6292 \fi
6293 \fi}
6294
6295 % \end{macrocode}
6296 % \end{macro}
6297 %
6298 % \begin{macro}{\makepsmarks}
6299 % \begin{macro}{\makepshook}
6300 % The macro \cs{makepsmarks}\marg{style}\marg{code} specifies that
6301 % \meta{code} is the definition of the hook for pagestyle \meta{style}.
6302 % \cs{makepshook} was a deprecated version of \cs{makepsmarks} and is
6303 % now deleted.
6304 % \changes{v1.0}{2001/11/15}{Added \cs{makepsmarks} and deprecated
6305 % \cs{makepshook}}
6306 % \changes{v1.4}{2003/12/14}{Deleted \cs{makepshook}}
6307 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6308 % \begin{macrocode}
6309 \newcommand{\makepsmarks}[2]{\mem@ps@safe@change{#1}\@namedef{#1pshook}{#2}}
6310
6311 % \end{macrocode}
6312 % \end{macro}
6313 % \end{macro}
6314 %
6315 % \begin{macro}{\m@mhe@dreset}
6316 % To cater for potential baselineskip changes, such as \verb?\linespread{2}?,
6317 % we have to ensure they don't percolate into the header/footer.
6318 % (See CTT thread \textit{memoir + linespread}, 2004/02/11)
6319 % \changes{v1.61}{2004/03/14}{Added \cs{m@mhe@dreset}}
6320 % \begin{macrocode}
6321 \newcommand*{\m@mhe@dreset}{\def\baselinestretch{1}\normalsize}
6322
6323 % \end{macrocode}
6324 % \end{macro}
6325 %
6326 % \begin{macro}{\makeheadfootvposition}
6327 % The headers and footers are typeset inside \cs{parbox}'es, using
6328 % \cs{makeheadfootvposition}\marg{style}\marg{headvpos}\marg{footvpost}
6329 % users can specify whether the alignment should be b,t or~c.The
6330 % default is~b.
6331 % \changes{v1.6180339c}{2009/01/13}{Added support for
6332 % controlling the alignment of the headers and footers}
6333 % \changes{v1.61803398d}{2010/02/09}{Added safe change test}
6334 % \begin{macrocode}
6335 \newcommand*\makeheadfootvposition[3]{%
6336 \mem@ps@safe@change{#1}%
6337 \@namedef{#1headvplacement}{#2}\@namedef{#1footvplacement}{#3}}
6338
6339 % \end{macrocode}
6340 % \end{macro}
6341 % \begin{macro}{\mem@maxheadheight}
6342 % \begin{macro}{\mem@maxfootheight}
6343 % \begin{macro}{\mem@sayonce@head}
6344 % \begin{macro}{\mem@sayonce@foot}
6345 % \begin{macro}{\mem@hf@measure@vbox}
6346 % \begin{macro}{\mem@toolarge@header@message}
6347 % \begin{macro}{\mem@toolarge@footer@message}
6348 % \changes{v3.6h}{2010/10/21}{Added the above seven macros to be able
6349 % to measure the headers and warn users if their design takes them outside.}
6350 % \verb?\mem@maxheadheight? and \verb?\mem@maxfootheight? globally
6351 % stores the max measured head and foot heights. Actually the footer
6352 % ought to be measuring the total height and depth. We may add this
6353 % later. The two XsayonceX macros are toggles used such that we can
6354 % add a warning at only the first bad head/foot. We repeat the message
6355 % at the end of the document.
6356 % \begin{macrocode}
6357 \newlength\mem@maxheadheight
6358 \newlength\mem@maxfootheight
6359 \newcommand\mem@sayonce@head{00}
6360 \newcommand\mem@sayonce@foot{00}
6361 % \end{macrocode}
6362 % This is the work horse of this construction. First argument is the
6363 % height to compare against, second should be \texttt{head} or
6364 % \texttt{foot}, third is the warning message, and the fourth is the
6365 % material to be measured. The idea to taken from \Lpack{fancyhdr}.
6366 % \begin{macrocode}
6367 \newcommand\mem@hf@measure@vbox[4]{%
6368 \setbox0\vbox{#4}%
6369 \ifdim\ht0>#1\relax%
6370 \setlength\@tempdima{\@nameuse{mem@max#2height}}%
6371 \ifdim\ht0>\@tempdima\relax%
6372 \expandafter\global\@nameuse{mem@max#2height}=\ht0%
6373 \expandafter\if\@nameuse{mem@sayonce@#2}\relax%
6374 \@memwarn{#3}%
6375 \global\@namedef{mem@sayonece@#2}{01}%
6376 \fi%
6377 \fi%
6378 \fi%
6379 \box0%
6380 }
6381 % \end{macrocode}
6382 % Warning messages
6383 % \begin{macrocode}
6384 \newcommand\mem@toolarge@header@message{%
6385 The material used in the headers is too large^^J%
6386 (\the\mem@maxheadheight) for the given head height
6387 (\the\headheight), it is recommended to^^J%
6388 either increase the head height or redesign the header^^J%
6389 (in both cases you will find help in the memoir manual).%
6390 }
6391 \newcommand\mem@toolarge@footer@message{%
6392 The material used in the footer is too large^^J%
6393 (\the\mem@maxfootheight) for the given foot skip
6394 (\the\footskip), it is recommended to^^J%
6395 either increase the foot skip or redesign the footer^^J%
6396 (in both cases you will find help in the memoir manual).%
6397 }
6398 % \end{macrocode}
6399 % To make things easier to read we make two short cut macros
6400 % \begin{macrocode}
6401 \newcommand\mem@hvboxm[1]{%
6402 \mem@hf@measure@vbox\headheight{head}\mem@toolarge@header@message{#1}}
6403 \newcommand\mem@fvboxm[1]{%
6404 \mem@hf@measure@vbox\footskip{foot}\mem@toolarge@footer@message{#1}}
6405 % \end{macrocode}
6406 % Make sure to repeat the message at the end of the document. This
6407 % will show the max value up until the point where the end of document
6408 % stuff is executed.
6409 % \begin{macrocode}
6410 \AtEndDocument{
6411 \ifdim\mem@maxheadheight>\headheight
6412 \@memwarn{\mem@toolarge@header@message}
6413 \fi
6414 \ifdim\mem@maxfootheight>\footskip
6415 \@memwarn{\mem@toolarge@footer@message}
6416 \fi
6417 }
6418 % \end{macrocode}
6419 % \end{macro}
6420 % \end{macro}
6421 % \end{macro}
6422 % \end{macro}
6423 % \end{macro}
6424 % \end{macro}
6425 % \end{macro}
6426 %
6427 % \begin{macro}{\mem@ps@entry@wrap}
6428 % \changes{v3.6h}{2010/10/06}{Added this to help bidi control the
6429 % typesetting direction of the header and footer}
6430 % This macro is wrapped around eash entry in the headers and
6431 % footers. By default it does nothing, but can be redefined by
6432 % packages such as \Lpack{bidi} to control the typesetting direction
6433 % in the header. Bidi for example has two modes such that headers
6434 % can be RTL locally while the header stay at LTR. If this macro is
6435 % changed, it will be a good idea to coordinate it with the bidi
6436 % maintainer.
6437 % \begin{macrocode}
6438 \newcommand\mem@ps@entry@wrap{}
6439 % \end{macrocode}
6440 %
6441 % \end{macro}
6442 % \begin{macro}{\mem@ps@HLH}
6443 % \changes{v3.6d}{2010/10/06/24}{Factored \cs{makepagestyle}}
6444 % The entries in the header used in \cs{makepagestyle} (below) are
6445 % more or less the same. It depends on \emph{head/foot},
6446 % \emph{odd/even} and a shorter \emph{o/e}. So to make the code more
6447 % maintainable we factor this out into a generator macro. The
6448 % explanation for the code being used is kept below (see
6449 % \cs{makepagestyle}).
6450 % \changes{v3.6k}{2012/05/31}{Forgot to separate head/foot position into the
6451 % factorization, propblem reported by Wybo Dekker on
6452 % http://tex.stackexchange.com/q/56141/3929}
6453 % \begin{macrocode}
6454 \newcommand\mem@ps@HLH[4]{%
6455 % #1 ps name
6456 % #2 type: head, foot
6457 % #3 odd/even
6458 % #4 odd/even short (o,e)
6459 \@namedef{#1@#3#2}{%
6460 \@nameuse{#1#3#2pl}\hb@xt@\@nameuse{#1#2runwidth}{\m@mhe@dreset%
6461 % \end{macrocode}
6462 % In footers the line goes before the text, so we test and add the
6463 % footline if \texttt{\#2} equals \texttt{foot}.
6464 % \changes{v3.6h}{2010/10/06}{added the entry wrapper}
6465 % \changes{v3.6h}{201010/10/21}{Added the header/footer measuring feature.}
6466 % For the header/footer measuring stuff we look at \#2 and make the
6467 % suiting macro from that value.
6468 % \changes{v3.6h}{2010/10/22}{Added \cs{memRTLmainraggedX} macros such
6469 % that \Lpack{bidi} can also change the order of the header if RTL is
6470 % the main direction of the document.}
6471 % \begin{macrocode}
6472 \nametest{#2}{head}\ifsamename\let\mem@hfboxer\mem@hvboxm\else\let\mem@hfboxer\mem@fvboxm\fi%
6473 % \end{macrocode}
6474 % \changes{v3.7d}{2015/04/22}{Moved \cs{...footruleprefix} outside
6475 % \cs{...footrule}. Otherwise copy does not work correctly. Reported
6476 % at http://tex.stackexchange.com/q/231454/3929}
6477 % \begin{macrocode}
6478 \mem@hfboxer{\nametest{#2}{foot}\ifsamename%
6479 \begingroup% to prevent colors from bleeding into the footer
6480 \@nameuse{#1#2ruleprefix}%
6481 \@nameuse{#1#2rule}%
6482 \endgroup%
6483 \fi%
6484 \hbox{%
6485 \rlap{%
6486 \parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
6487 \memRTLmainraggedright\@nameuse{#1ps#2strut}%
6488 \mem@ps@entry@wrap{\@nameuse{#1#4#2l}}%
6489 \@nameuse{#1ps#2strut}}}\hfill
6490 \parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
6491 \centering\@nameuse{#1ps#2strut}%
6492 \mem@ps@entry@wrap{\@nameuse{#1#4#2c}}%
6493 \@nameuse{#1ps#2strut}}\hfill
6494 \llap{%
6495 \parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
6496 \memRTLmainraggedleft\@nameuse{#1ps#2strut}%
6497 \mem@ps@entry@wrap{\@nameuse{#1#4#2r}}%
6498 \@nameuse{#1ps#2strut}}}%
6499 }%
6500 % \end{macrocode}
6501 % In the header the line goes under the text, so we test and add the
6502 % headline if \texttt{\#2} equals \texttt{head}.
6503 % \changes{v3.6k}{2012/05/31}{Forgot to separate head/foot position into the
6504 % factorization}
6505 % \changes{v3.7d}{2015/04/22}{Moved \cs{...headruleprefix} outside
6506 % \cs{...headrule}. Otherwise copy does not work correctly.}
6507 % \begin{macrocode}
6508 \nametest{#2}{head}\ifsamename%
6509 \@nameuse{#1#2ruleprefix}%
6510 \@nameuse{#1#2rule}%
6511 \fi%
6512 }}\@nameuse{#1#3#2pr}}%
6513 % \end{macrocode}
6514 % And end by letting the LaTeX head/foot use our version
6515 % \begin{macrocode}
6516 \@namedef{@#3#2}{\@nameuse{#1@#3#2}}%
6517 }
6518 % \end{macrocode}
6519 % \end{macro}
6520 %
6521 % \begin{macro}{\makepagestyle}
6522 % At last we can put everything together for defining a new pagestyle,
6523 % via the macro \cs{makepagestyle}\marg{style} which initially sets up
6524 % a new pagestyle \meta{style} corresponding the the \LaTeX{} \verb?empty?
6525 % pagestyle. The prior macros can then be used to make modifications
6526 % to the style.
6527 % \changes{v1.0}{2001/11/15}{Now 2 stage process for defining \cs{@evenhead}
6528 % and friends}
6529 % \changes{v1.61}{2004/03/14}{Added \cs{m@mhe@dreset} at several points in
6530 % \cs{makepagestyle} (from patch 2.1)}
6531 % \changes{v1.61803}{2008/01/30}{Removed extraneous spaces from pagestyle code
6532 % (mempatch v4.6)}
6533 % \changes{v1.61803398d}{2010/02/09}{Added storing extra information
6534 % about page styles}
6535 % We also make sure to specify that this is a `real' page style, and
6536 % thus sets the empty alias name and the alias test to 01.
6537 % \begin{macrocode}
6538 \newcommand{\makepagestyle}[1]{%
6539 \mem@set@ps@xtra@info{#1}{}{01}%
6540 % \end{macrocode}
6541 % First define the macro \cs{ps@style}, which in turn defines the macros
6542 % \cs{@evenhead}, \cs{@oddhead}, \cs{@evenfoot} and \cs{@oddfoot}.
6543 % \changes{v3.6d}{20101/06/24}{Factored \cs{makepagestyle}, such
6544 % that \cs{#1@evenhead} and friends are made using \emph{one} single
6545 % macro. We keep the original code just in case.}
6546 % \begin{macrocode}
6547 \@namedef{ps@#1}{%
6548 \mem@ps@HLH{#1}{head}{even}{e}%
6549 \mem@ps@HLH{#1}{head}{odd}{o}%
6550 \mem@ps@HLH{#1}{foot}{even}{e}%
6551 \mem@ps@HLH{#1}{foot}{odd}{o}%
6552 % \@namedef{#1@evenhead}{%
6553 % \end{macrocode}
6554 % The code for the definition of \cs{@evenhead} and friends is based on code
6555 % from Piet van Oostrum's \Lpack{fancyhdr} package~\cite{FANCYHDR}. The three
6556 % parts of the header are put into parboxes, with fills between them, and
6557 % the whole lot is put into a box the width of the header. Fillers are put
6558 % before and after the main box which control the header position.
6559 %
6560 % First the left filler which is either \cs{relax} or \cs{hss}, and then
6561 % start the main box.
6562 % \changes{v1.6180339c}{2008/12/26}{Replaced \cs{...runwidth} by \cs{...headrunwidth}
6563 % or \cs{...footrunwidth}, as appropriate for headers and footers.}
6564 % \changes{v1.6180339c}{2009/01/13}{Replaced \cs{parbox}\texttt[b]
6565 % with \cs{parbox}\texttt{[\cs{nameuse{#1headvplacement}}]} etc.}
6566 % \begin{macrocode}
6567 % \@nameuse{#1evenhpl}\hb@xt@\@nameuse{#1headrunwidth}{\m@mhe@dreset%
6568 % \vbox{\hbox{%
6569 % \end{macrocode}
6570 % The left part of the header.
6571 % \begin{macrocode}
6572 % \rlap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6573 % \raggedright\@nameuse{#1eheadl}\strut}}\hfill
6574 % \end{macrocode}
6575 % The center part of the header.
6576 % \begin{macrocode}
6577 % \parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6578 % \centering\@nameuse{#1eheadc}\strut}\hfill
6579 % \end{macrocode}
6580 % The right part of the header.
6581 % \begin{macrocode}
6582 % \llap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6583 % \raggedleft\@nameuse{#1eheadr}\strut}}}%
6584 % \end{macrocode}
6585 % Finally, the header rule and finish with the right filler, which
6586 % is either \cs{relax} or \cs{hss}.
6587 % \begin{macrocode}
6588 % \@nameuse{#1headrule}}}\@nameuse{#1evenhpr}}%
6589 % \end{macrocode}
6590 % The code for the \cs{@oddhead}, \cs{@evenfoot} and \cs{@oddfoot} follows
6591 % a similar pattern. Here is \cs{@oddhead}.
6592 % \begin{macrocode}
6593 % \@namedef{#1@oddhead}{%
6594 % \@nameuse{#1oddhpl}\hb@xt@\@nameuse{#1headrunwidth}{\m@mhe@dreset%
6595 % \vbox{\hbox{%
6596 % \rlap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6597 % \raggedright\@nameuse{#1oheadl}\strut}}\hfill
6598 % \parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6599 % \centering\@nameuse{#1oheadc}\strut}\hfill
6600 % \llap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
6601 % \raggedleft\@nameuse{#1oheadr}\strut}}}%
6602 % \@nameuse{#1headrule}}}\@nameuse{#1oddhpr}}%
6603 % \end{macrocode}
6604 % And \cs{@evenfoot}. For the footers the rules come \emph{before} any foot
6605 % entries.
6606 % \begin{macrocode}
6607 % \@namedef{#1@evenfoot}{%
6608 % \@nameuse{#1evenfpl}\hb@xt@\@nameuse{#1footrunwidth}{\m@mhe@dreset%
6609 % \vbox{\@nameuse{#1footrule}\hbox{%
6610 % \rlap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6611 % \raggedright\@nameuse{#1efootl}\strut}}\hfill
6612 % \parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6613 % \centering\@nameuse{#1efootc}\strut}\hfill
6614 % \llap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6615 % \raggedleft\@nameuse{#1efootr}\strut}}}%
6616 % }}\@nameuse{#1evenfpr}}%
6617 % \end{macrocode}
6618 % Lastly the \cs{@oddfoot}.
6619 % \begin{macrocode}
6620 % \@namedef{#1@oddfoot}{%
6621 % \@nameuse{#1oddfpl}\hb@xt@\@nameuse{#1footrunwidth}{\m@mhe@dreset%
6622 % \vbox{\@nameuse{#1footrule}\hbox{%
6623 % \rlap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6624 % \raggedright\@nameuse{#1ofootl}\strut}}\hfill
6625 % \parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6626 % \centering\@nameuse{#1ofootc}\strut}\hfill
6627 % \llap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
6628 % \raggedleft\@nameuse{#1ofootr}\strut}}}%
6629 % }}\@nameuse{#1oddfpr}}%
6630 % \end{macrocode}
6631 % Now we define \cs{@evenhead} etc., in terms of \verb?#1@evenhead?.
6632 % \begin{macrocode}
6633 % \def\@evenhead{\@nameuse{#1@evenhead}}%
6634 % \def\@oddhead{\@nameuse{#1@oddhead}}%
6635 % \def\@evenfoot{\@nameuse{#1@evenfoot}}%
6636 % \def\@oddfoot{\@nameuse{#1@oddfoot}}%
6637 % \end{macrocode}
6638 % To finish off the definition of \cs{ps@style}, add in a hook which can be
6639 % defined so that it adds additional code, if required.
6640 % \begin{macrocode}
6641 \@nameuse{#1pshook}}%
6642 % \end{macrocode}
6643 % \changes{v3.6d}{2010/06/24}{Added strut initialization} Next we
6644 % initialize the struts being used. Remember the for the
6645 % \pstyle{empty} style, the strut should be empty.
6646 % \begin{macrocode}
6647 \nametest{#1}{empty}%
6648 \ifsamename%
6649 \@namedef{#1psheadstrut}{}\@namedef{#1psfootstrut}{}%
6650 \else%
6651 \@namedef{#1psheadstrut}{\strut}\@namedef{#1psfootstrut}{\strut}%
6652 \fi%
6653 % \end{macrocode}
6654 %
6655 % The final part of setting up the new pagestyle
6656 % is defining all the macros called by \cs{ps@style}, and giving them
6657 % default values. Make the headers and footers empty.
6658 % \begin{macrocode}
6659 \makeevenhead{#1}{}{}{}%
6660 \makeoddhead{#1}{}{}{}%
6661 \makeevenfoot{#1}{}{}{}%
6662 \makeoddfoot{#1}{}{}{}%
6663 % \end{macrocode}
6664 % Make the headers/footers the same width as the \cs{textwidth},
6665 % center them, and ensure that the rules have zero height so that they
6666 % will be invisible. Also initialize the head/foot prefixes.
6667 % \changes{v3.6h}{2011/01/25}{Added the \cs{makeheadfootruleprefix}}
6668 % \begin{macrocode}
6669 \makerunningwidth{#1}{\textwidth}%
6670 \makeheadposition{#1}{}{}{}{}%
6671 \makeheadrule{#1}{\textwidth}{0pt}%
6672 \makefootrule{#1}{\textwidth}{\footruleheight}{\footruleskip}%
6673 \makeheadfootruleprefix{#1}{}{}
6674 % \end{macrocode}
6675 % Set the initial vertical header and footer positions.
6676 % \changes{v1.6180339c}{2009/01/13}{Added head/foot position initialisation}
6677 % \begin{macrocode}
6678 \makeheadfootvposition{#1}{b}{b}%
6679 % \end{macrocode}
6680 % Finally, there is no addtional code needed, so make the hook empty, and
6681 % we are done.
6682 % \begin{macrocode}
6683 \makepsmarks{#1}{}}
6684
6685 % \end{macrocode}
6686 % \end{macro}
6687 %
6688 % \begin{macro}{\aliaspagestyle}
6689 % The command \cs{aliaspagestyle}\marg{alias}\marg{original}
6690 % defines the \meta{alias} pagestyle to be an alias for the
6691 % \meta{original} pagestyle.
6692 % \changes{v1.61803398d}{2010/02/09}{Added page style storing info}
6693 % We remember to set the stored alias name, and sets the alias test to
6694 % true (00).
6695 % \begin{macrocode}
6696 \newcommand{\aliaspagestyle}[2]{%
6697 \mem@set@ps@xtra@info{#1}{#2}{00}%
6698 \@namedef{ps@#1}{\@nameuse{ps@#2}}}
6699
6700 % \end{macrocode}
6701 % \end{macro}
6702 %
6703 % \begin{macro}{\copypagestyle}
6704 % The command \cs{copypagestyle}\marg{new}\marg{original}
6705 % defines the \meta{new} pagestyle to be a copy of the
6706 % \meta{original} pagestyle.
6707 %
6708 % It first makes the \meta{new} (empty) pagestyle then defines the internals
6709 % in terms of the \meta{original} internals.
6710 % \changes{v1.2}{2002/08/10}{Added \cs{copypagestyle}}
6711 % \changes{v1.61803}{2008/01/30}{Added missing elements to \cs{copypagestyle}
6712 % (per Erik Quaeghebeur mempatch v4.9)}
6713 % \begin{macrocode}
6714 \newcommand{\copypagestyle}[2]{%
6715 \makepagestyle{#1}%
6716 % \end{macrocode}
6717 % Do the headers and footers.
6718 % \begin{macrocode}
6719 \makeevenhead{#1}{\@nameuse{#2eheadl}}%
6720 {\@nameuse{#2eheadc}}{\@nameuse{#2eheadr}}%
6721 \makeoddhead{#1}{\@nameuse{#2oheadl}}%
6722 {\@nameuse{#2oheadc}}{\@nameuse{#2oheadr}}%
6723 \makeevenfoot{#1}{\@nameuse{#2efootl}}%
6724 {\@nameuse{#2efootc}}{\@nameuse{#2efootr}}%
6725 \makeoddfoot{#1}{\@nameuse{#2ofootl}}%
6726 {\@nameuse{#2ofootc}}{\@nameuse{#2ofootr}}%
6727 % \end{macrocode}
6728 % Set the width.
6729 % \begin{macrocode}
6730 \makerunningwidth{#1}[\@nameuse{#2footrunwidth}]{\@nameuse{#2headrunwidth}}%
6731 % \end{macrocode}
6732 % Specify the \cs{headposition}.
6733 % \changes{v3.6k}{2012/05/31}{some macro renaming}
6734 % \begin{macrocode}
6735 \@namedef{#1evenheadpl}{\@nameuse{#2evenheadpl}}%
6736 \@namedef{#1oddheadpl}{\@nameuse{#2oddheadpl}}%
6737 \@namedef{#1evenheadpr}{\@nameuse{#2evenheadpr}}%
6738 \@namedef{#1oddheadpr}{\@nameuse{#2oddheadpr}}%
6739 % \end{macrocode}
6740 % Also vertically
6741 % \changes{v1.6180339c}{2008/01/13}{Also copy the vertical positions}
6742 % \changes{v1.6180339e}{2008/02/06}{Bug fix, reported by Per
6743 % Starb\"ack on ctt}
6744 % \begin{macrocode}
6745 \makeheadfootvposition{#1}{\@nameuse{#2headvplacement}}{\@nameuse{#2footvplacement}}%
6746 % \end{macrocode}
6747 % Specify the feet
6748 % \changes{v3.6k}{2012/05/31}{some macro renaming}
6749 % \begin{macrocode}
6750 \@namedef{#1evenfootpl}{\@nameuse{#2evenfootpl}}%
6751 \@namedef{#1oddfootpl}{\@nameuse{#2oddfootpl}}%
6752 \@namedef{#1evenfootpr}{\@nameuse{#2evenfootpr}}%
6753 \@namedef{#1oddfootpr}{\@nameuse{#2oddfootpr}}%
6754 % \end{macrocode}
6755 % Specify the head and foot rules and the prefixes.
6756 % \changes{v3.6h}{2011/01/25}{Added the \cs{makeheadfootruleprefix}}
6757 % \begin{macrocode}
6758 \@namedef{#1headrule}{\@nameuse{#2headrule}}%
6759 \@namedef{#1footrule}{\@nameuse{#2footrule}}%
6760 \@namedef{#1headruleprefix}{\@nameuse{#2headruleprefix}}%
6761 \@namedef{#1footruleprefix}{\@nameuse{#2footruleprefix}}%
6762 % \end{macrocode}
6763 % \changes{v3.6d}{2010/06/24}{Added strut copying to \cs{copypagestyle}}
6764 % And remember the struts
6765 % \begin{macrocode}
6766 \@namedef{#1psheadstrut}{\@nameuse{#2psheadstrut}}
6767 \@namedef{#1psfootstrut}{\@nameuse{#2psfootstrut}}
6768 % \end{macrocode}
6769 % \end{macro}
6770 % And pick up the hook. We end the macro here.
6771 % \begin{macrocode}
6772 \makepsmarks{#1}{\@nameuse{#2pshook}}}
6773
6774 % \end{macrocode}
6775 %
6776 %
6777 % \begin{macro}{\ifonlyfloats}
6778 % \cs{ifonlyfloats}\marg{yes}\marg{no} processes \meta{yes} if the macro is
6779 % called on a page consisting only of floats, otherwise \meta{no} is
6780 % processed. \cs{if@fcolmade} is specified in \file{ltoutput.dtx}.
6781 % \changes{v1.0}{2001/11/14}{Added \cs{ifonlyfloats}}
6782 % \begin{macrocode}
6783 \newcommand{\ifonlyfloats}[2]{\if@fcolmade #1\else #2\fi}
6784
6785 % \end{macrocode}
6786 % \end{macro}
6787 %
6788 % \begin{macro}{\mergepagefloatstyle}
6789 % \cs{mergepagefloatstyle}\marg{style}\marg{textstyle}\marg{floatstyle}
6790 % makes a new page style \meta{style} that is \meta{textstyle} on normal
6791 % pages but uses \meta{floatstyle} on float-only pages. Both \meta{textstyle}
6792 % and \meta{floatstyle} must have been previously defined.
6793 % \changes{v1.0}{2001/11/15}{Added \cs{mergepagefloatstyle}}
6794 % \begin{macrocode}
6795 \newcommand{\mergepagefloatstyle}[3]{%
6796 % \end{macrocode}
6797 % Make sure that the two styles have been called, otherwise we get some
6798 % undefined errors.
6799 % \begin{macrocode}
6800 \@nameuse{ps@#3}\@nameuse{ps@#2}%
6801 % \end{macrocode}
6802 % Specify the pagestyle's headers and footers.
6803 % \begin{macrocode}
6804 \@namedef{ps@#1}{%
6805 \def\@evenhead{\ifonlyfloats{\@nameuse{#3@evenhead}}%
6806 {\@nameuse{#2@evenhead}}}%
6807 \def\@oddhead{\ifonlyfloats{\@nameuse{#3@oddhead}}%
6808 {\@nameuse{#2@oddhead}}}%
6809 \def\@evenfoot{\ifonlyfloats{\@nameuse{#3@evenfoot}}%
6810 {\@nameuse{#2@evenfoot}}}%
6811 \def\@oddfoot{\ifonlyfloats{\@nameuse{#3@oddfoot}}%
6812 {\@nameuse{#2@oddfoot}}}%
6813 % \end{macrocode}
6814 % Set the hook to the \meta{textstyle} on the assumption that that is
6815 % more complex that required for a float page.
6816 % \begin{macrocode}
6817 \@namedef{#1pshook}{\@nameuse{#2pshook}}%
6818 % \end{macrocode}
6819 % That's it.
6820 % \begin{macrocode}
6821 }}
6822
6823 % \end{macrocode}
6824 % \end{macro}
6825 %
6826 % \begin{macro}{\makeheadfootstrut}
6827 % \changes{v3.6d}{2010/06/24}{Added \cs{makeheadfootstrut}}
6828 % In each `field' of the header a strut is added to keep alignment
6829 % right. This macro can be used to change a particular strut
6830 % configuration. Each combination is initialy set by
6831 % \cs{makepagestyle} to be equal to \cs{strut}, except the
6832 % \pstyle{empty} style, where the strut is empty by default.
6833 % \begin{macrocode}
6834 \newcommand*\makeheadfootstrut[3]{%
6835 \@namedef{#1psheadstrut}{#2}\@namedef{#1psfootstrut}{#3}}
6836 % \end{macrocode}
6837 % \end{macro}
6838 %
6839 % The pagestyles \pstyle{empty} and \pstyle{plain} are defined
6840 % in \file{latex.dtx}. However, I will redefine them here, just in
6841 % case someone takes a fancy to modifying them.
6842 %
6843 % \begin{macro}{\ps@empty}
6844 % The \pstyle{empty} pagestyle is simple, it's just what we get when
6845 % we call \cs{makepagestyle}.
6846 % \begin{macrocode}
6847 \makepagestyle{empty}
6848
6849 % \end{macrocode}
6850 % \end{macro}
6851 %
6852 % \begin{macro}{\ps@plain}
6853 % The \pstyle{plain} pagestyle is also simple, it just puts the
6854 % page number at the bottom middle of the page.
6855 % We call \verb?\makepagestyle{plain}? and then adjust as required.
6856 % \begin{macrocode}
6857 \makepagestyle{plain}
6858 \makeevenfoot{plain}{}{\thepage}{}
6859 \makeoddfoot{plain}{}{\thepage}{}
6860
6861 % \end{macrocode}
6862 % \end{macro}
6863 %
6864 % \begin{macro}{\ps@simple}
6865 % The \pstyle{simple} page style simply puts the page number in the header
6866 % at the outer margin.
6867 % \changes{v1.61803398}{2009/07/26}{PW: Added the `simple' pagestyle}
6868 % \begin{macrocode}
6869 \makepagestyle{simple}
6870 \makeevenhead{simple}{\thepage}{}{}
6871 \makeoddhead{simple}{}{}{\thepage}
6872
6873 % \end{macrocode}
6874 % \end{macro}
6875 %
6876 % \begin{macro}{\nouppercaseheads}
6877 % \begin{macro}{\uppercaseheads}
6878 % \begin{macro}{\memUChead}
6879 % Spurred by Lars Madsen's \Lpack{memexsupp} v0.5 package here is a
6880 % way of switching uppercasing in the headings pagestyle.
6881 % \changes{v1.61803}{2008/01/30}{Added \cs{(no)uppercaseheads} and
6882 % \cs{memUChead} (mempatch v4.9)}
6883 % \changes{v3.6k}{2011/05/20}{Making \cs{memUChead} equal to
6884 % \cs{relax} can cause problems when users want to \cs{provide} it in
6885 % other applications. It is now redefined into the empty string.}
6886 % \changes{v3.6k}{2012/09/13}{Default upper case now \cs{MakeTextUppercase}}
6887 % \changes{v3.8.4}{2025/08/08}{Default set to \cs{MakeUppercase} as it
6888 % can the same as \cs{MakeTextUppercase} in modern kernels}
6889 % \begin{macrocode}
6890 \newcommand*{\nouppercaseheads}{\def\memUChead{}}
6891 \newcommand*{\uppercaseheads}{\def\memUChead{\MakeUppercase}}
6892 \uppercaseheads
6893
6894 % \end{macrocode}
6895 % \end{macro}
6896 % \end{macro}
6897 % \end{macro}
6898 %
6899 % The macros \cs{createplainmark}, \cs{createmark} and \cs{addtopsmarks}
6900 % are modified versions of code supplied by Lars Madsen.
6901 % \changes{v1.61803}{2008/01/30}{Added, and used, \cs{createplainmark},
6902 % \cs{createmark} and \cs{addtopsmarks}}
6903 % \begin{macro}{\createplainmark}
6904 % \cs{createplainmark}\marg{type}\marg{marks}\marg{text} creates a
6905 % \cs{typemark} (\meta{type} is \texttt{toc}, \texttt{bib}, etc)
6906 % with \meta{marks} (left, both, right) whose contents are \meta{text}.
6907 % For example \verb?\createplainmark{toc}{both}{\contentsname}?. The
6908 % difference between plain and regular marks, is that plain marks use
6909 % a fixed text, whereas regular marks recieve dynamic text and thus
6910 % is given an argument.
6911 % \changes{v3.8.4}{2025/08/06}{Redone via \cs{str_case:nnF}}
6912 % \begin{macrocode}
6913 \ExplSyntaxOn
6914 \NewDocumentCommand\createplainmark{ mmm }
6915 {
6916 \str_case:nnF {#2}
6917 {
6918 {left} { \@namedef{#1mark}{\markboth{\memUChead{#3}}{}} }
6919 {right}{ \@namedef{#1mark}{\markright{\memUChead{#3}}} }
6920 {both} { \@namedef{#1mark}{\markboth{\memUChead{#3}}{\memUChead{#3}}} }
6921 }
6922 {
6923 \@memerror{
6924 Unknown~ mark~ setting~ type~ `#2'~ for~ #1mark}{
6925 I~ expected~ `left',~ `both'~ or~ `right'. \MessageBreak
6926 I~ will~ assume~ you~ meant~ `both'}
6927 }
6928 }
6929 \ExplSyntaxOff
6930 % \newcommand*{\createplainmark}[3]{%
6931 % \nametest{#2}{left}%
6932 % \ifsamename
6933 % \@namedef{#1mark}{\markboth{\memUChead{#3}}{}}%
6934 % \else
6935 % \nametest{#2}{right}%
6936 % \ifsamename
6937 % \@namedef{#1mark}{\markright{\memUChead{#3}}}%
6938 % \else
6939 % \nametest{#2}{both}%
6940 % \ifsamename\else
6941 % \@memerror{%
6942 % Unknown mark setting type `#2' for #1mark}{%
6943 % I expected `left', `both' or `right'. \MessageBreak
6944 % I will assume you meant `both'}%
6945 % \fi
6946 % \@namedef{#1mark}{\markboth{\memUChead{#3}}{\memUChead{#3}}}%
6947 % \fi
6948 % \fi}
6949
6950 % \end{macrocode}
6951 % \end{macro}
6952 %
6953 % \begin{macro}{\createmark}
6954 % \cs{createmark}\marg{division}\marg{marks}\marg{show}\marg{prefix}\marg{postfix}
6955 % creates a \cs{divisionmark} with \meta{marks} (= \texttt{left}, \texttt{both}
6956 % or \texttt{right}) controlling which marks are set,
6957 % \meta{show} (= \texttt{shownumber}, \texttt{nonumber} or \texttt{notitle}) controls the
6958 % display of the divison number in \cs{mainmatter}, \meta{prefix} is text
6959 % before the number and \meta{postfix} is text after the number.
6960 % \begin{macrocode}
6961 \newcommand\createmark[5]{%
6962 % \end{macrocode}
6963 % Handle \texttt{(show/no)number/notitle}.
6964 % \changes{v3.7i}{2019/11/07}{Added notitle show option and
6965 % reimplemented its checking a bit}
6966 % \begin{macrocode}
6967 % \def\@tempa{00}
6968 % \nametest{#3}{nonumber}%
6969 % \ifsamename
6970 % \def\@tempa{01}%
6971 % \else
6972 % \nametest{#3}{shownumber}
6973 % \ifsamename\else
6974 % \@memerror{Unknown numbering value `#3' for #1mark}%
6975 % {I expected `shownumber' or `nonumber'.\MessageBreak
6976 % I will assume you meant `shownumber'}%
6977 % \fi
6978 % \fi
6979 % \expandafter\if\@tempa% compares the two \@tempa digits
6980 % \@namedef{#1marksn}##1{##1}%
6981 % \else
6982 % \@namedef{#1marksn}{\@gobble}%
6983 % \fi
6984 \def\@tempa{1}
6985 \nametest{#3}{nonumber}%
6986 \ifsamename
6987 \def\@tempa{0}
6988 \else
6989 \nametest{#3}{shownumber}
6990 \ifsamename
6991 \def\@tempa{1}
6992 \else
6993 \nametest{#3}{notitle}
6994 \ifsamename
6995 \def\@tempa{2}
6996 \else
6997 \@memerror{Unknown numbering value `#3' for
6998 #1mark,\MessageBreak
6999 please use one of 'shownumber', 'nonumber' or 'notitle'}%
7000 {I expected `shownumber', `nonumber' or 'notitle'.\MessageBreak
7001 I will assume you meant `shownumber'}%
7002 \fi
7003 \fi
7004 \fi
7005 \@namedef{#1markst}##1{##1}
7006 \ifcase\@tempa\relax
7007 % nonumber
7008 \@namedef{#1marksn}{\@gobble}%
7009 \or % 1
7010 % shownumber
7011 \@namedef{#1marksn}##1{##1}
7012 \or % 2, 2 implies shownumber
7013 % shownumber
7014 \@namedef{#1marksn}##1{##1}
7015 \@namedef{#1markst}{\@gobble}
7016 \fi
7017 % \end{macrocode}
7018 % The three \meta{marks} cases, \texttt{left}, \texttt{both} and
7019 % \texttt{right}; fails to \texttt{both}.
7020 % \changes{v3.7f}{2015/08/25}{Sporious spaces}
7021 % \begin{macrocode}
7022 \nametest{#2}{left}%
7023 \ifsamename
7024 \@namedef{#1mark}##1{%
7025 \@setclcnt{#1}{@memmarkcntra}%
7026 \advance\c@@memmarkcntra\m@ne
7027 \markboth{%
7028 \memUChead{%
7029 \ifnum \c@secnumdepth > \c@@memmarkcntra
7030 \if@mainmatter
7031 \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
7032 \fi
7033 \fi
7034 % \end{macrocode}
7035 % \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
7036 % \begin{macrocode}
7037 \@nameuse{#1markst}{##1}%
7038 }%
7039 }%
7040 {}% just left
7041 }%
7042 \else
7043 \nametest{#2}{right}
7044 \ifsamename
7045 \@namedef{#1mark}##1{%
7046 \@setclcnt{#1}{@memmarkcntra}%
7047 \advance\c@@memmarkcntra\m@ne
7048 \markright{%
7049 \memUChead{%
7050 \ifnum \c@secnumdepth > \c@@memmarkcntra
7051 \if@mainmatter%
7052 \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
7053 \fi%
7054 \fi%
7055 % \end{macrocode}
7056 % \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
7057 % \begin{macrocode}
7058 \@nameuse{#1markst}{##1}%
7059 }%
7060 }%
7061 }%
7062 \else
7063 \nametest{#2}{both}%
7064 \ifsamename\else
7065 \@memerror{%
7066 Unknown mark setting type `#2' for #1mark}{%
7067 I expected `left', `both' or `right'. \MessageBreak
7068 I will assume you meant `both'}%
7069 \fi
7070 \@namedef{#1mark}##1{%
7071 \@setclcnt{#1}{@memmarkcntra}%
7072 \advance\c@@memmarkcntra\m@ne
7073 \markboth{%
7074 \memUChead{%
7075 \ifnum \c@secnumdepth > \c@@memmarkcntra
7076 \if@mainmatter
7077 \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
7078 \fi
7079 \fi
7080 % \end{macrocode}
7081 % \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
7082 % \begin{macrocode}
7083 \@nameuse{#1markst}{##1}%
7084 }%
7085 }{%
7086 \memUChead{%
7087 \ifnum \c@secnumdepth > \c@@memmarkcntra
7088 \if@mainmatter
7089 \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
7090 \fi
7091 \fi
7092 % \end{macrocode}
7093 % \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
7094 % \begin{macrocode}
7095 \@nameuse{#1markst}{##1}%
7096 }%
7097 }%
7098 }%
7099 \fi
7100 \fi
7101 }
7102
7103 % \end{macrocode}
7104 % \end{macro}
7105 %
7106 % \begin{macro}{\addtopsmarks}
7107 % \cs{addtopsmarks}\marg{pagestyle}\marg{prepend}\marg{append} inserts
7108 % \meta{prepend} and \meta{append} at the start and end of the current
7109 % definition of \cs{pagestylepshook}.
7110 % \changes{v1.61803398d}{2010/02/09}{Added safe to change test}
7111 % \changes{v3.8.4}{2025/06/12}{Forgot to redef this after we deprecated
7112 % \cs{addtodef}, we will use \cs{pretocmd} and \cs{apptocmd} from
7113 % \pkg{etoolbox} instead.}
7114 % \begin{macrocode}
7115 \NewDocumentCommand\addtopsmarks{ m m m }
7116 {
7117 \mem@ps@safe@change{#1}
7118 \IfBlankF{#2}{ \ExpandArgs{c}\pretocmd{#1pshook}{#2}{}{\typeout{prepending to #1marks failed}} }
7119 \IfBlankF{#3}{ \ExpandArgs{c}\apptocmd{#1pshook}{#3}{}{\typeout{appending to #1marks failed}} }
7120 }
7121 % \end{macrocode}
7122 % \end{macro}
7123 %
7124 % \begin{macro}{\clearplainmark}
7125 % \begin{macro}{\clearmark}
7126 % For some page styles it is handy to be able to make sure that no
7127 % section or otherwise add data to the \cs{left-} and
7128 % \cs{rightmark}. The macros \cs{clearplainmark} and \cs{clearmark}
7129 % will take one argument specifying which mark to clear, and then
7130 % redefine this mark to do nothing or to gobble its given argument.
7131 % \begin{macrocode}
7132 \newcommand\clearplainmark[1]{%
7133 \@namedef{#1mark}{}}
7134 \newcommand\clearmark[1]{%
7135 \@namedef{#1mark}{\@gobble}}
7136 % \end{macrocode}
7137 %
7138 % \end{macro}
7139 % \end{macro}
7140 %
7141 % \begin{macro}{\ps@headings}
7142 % The \pstyle{headings} pagestyle behaves differently for
7143 % twosided and onesided printing. This is a rewrite of the
7144 % standard style.
7145 % \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@headings}}
7146 % \changes{v1.61803}{2008/01/30}{Used \cs{memUChead} in \cs{ps@headings}
7147 % (mempatch v4.9)}
7148 % \changes{v1.61803}{2008/01/30}{For twosided docs set both marks for ToC, etc. (mempatch v4.9)}
7149 % \changes{v1.61803}{2008/01/30}{Eliminated \cs{@mkboth} as never used
7150 % (mempatch v4.9)}
7151 % \changes{v1.61803}{2008/01/30}{Added \cs{glossarymark} to \cs{ps@headings}}
7152 % \begin{macrocode}
7153 \if@twoside
7154 % \end{macrocode}
7155 % The footer is empty and the header contains the page number and
7156 % one of the marks.
7157 % \changes{v3.8.4}{2025/08/06}{No idea why this code wasn't outcommented years ago}
7158 % \begin{macrocode}
7159 \makepagestyle{headings}
7160 % \makepsmarks{headings}{%
7161 % \def\chaptermark##1{%
7162 % \markboth{\memUChead{%
7163 % \ifnum \c@secnumdepth >\m@ne
7164 % \if@mainmatter
7165 % \@chapapp\ \thechapter. \ %
7166 % \fi
7167 % \fi
7168 % ##1}}{}}%
7169 % \def\tocmark{\markboth{\memUChead{\contentsname}}{\memUChead{\contentsname}}}%
7170 % \def\lofmark{\markboth{\memUChead{\listfigurename}}{\memUChead{\listfigurename}}}%
7171 % \def\lotmark{\markboth{\memUChead{\listtablename}}{\memUChead{\listtablename}}}%
7172 % \def\bibmark{\markboth{\memUChead{\bibname}}{\memUChead{\bibname}}}%
7173 % \def\indexmark{\markboth{\memUChead{\indexname}}{\memUChead{\indexname}}}%
7174 % \def\sectionmark##1{%
7175 % \markright{\memUChead{%
7176 % \ifnum \c@secnumdepth > \z@
7177 % \thesection. \ %
7178 % \fi
7179 % ##1}}}}
7180 % \end{macrocode}
7181 % And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
7182 % \cs{createplainmark}.
7183 % \begin{macrocode}
7184 \makepsmarks{headings}{%
7185 \createmark{chapter}{left}{shownumber}{\@chapapp\ }{. \ }
7186 \createmark{section}{right}{shownumber}{}{. \ }
7187 \createplainmark{toc}{both}{\contentsname}
7188 \createplainmark{lof}{both}{\listfigurename}
7189 \createplainmark{lot}{both}{\listtablename}
7190 \createplainmark{bib}{both}{\bibname}
7191 \createplainmark{index}{both}{\indexname}
7192 \createplainmark{glossary}{both}{\glossaryname}
7193 }
7194 \makeevenhead{headings}{\thepage}{}{\slshape\leftmark}
7195 \makeoddhead{headings}{\slshape\rightmark}{}{\thepage}
7196 \else
7197 % \end{macrocode}
7198 % For one sided printing even and odd pages are treated the same,
7199 % so no need to bother with the evenhead, and
7200 % just the \cs{rightmark} is used.
7201 % \changes{v3.8.4}{2025/08/06}{No idea why this code wasn't outcommented years ago}
7202 % \begin{macrocode}
7203 \makepagestyle{headings}
7204 % \makepsmarks{headings}{%
7205 % \def\chaptermark##1{%
7206 % \markright{\memUChead{%
7207 % \ifnum \c@secnumdepth >\m@ne
7208 % \if@mainmatter
7209 % \@chapapp\ \thechapter. \ %
7210 % \fi
7211 % \fi
7212 % ##1}}}%
7213 % \def\tocmark{\markright{\memUChead{\contentsname}}}%
7214 % \def\lofmark{\markright{\memUChead{\listfigurename}}}%
7215 % \def\lotmark{\markright{\memUChead{\listtablename}}}%
7216 % \def\bibmark{\markright{\memUChead{\bibname}}}%
7217 % \def\indexmark{\markright{\memUChead{\indexname}}}}
7218 % \end{macrocode}
7219 % And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
7220 % \cs{createplainmark}.
7221 % \begin{macrocode}
7222 \makepsmarks{headings}{%
7223 \createmark{chapter}{right}{shownumber}{\@chapapp\ }{. \ }
7224 \createplainmark{toc}{right}{\contentsname}
7225 \createplainmark{lof}{right}{\listfigurename}
7226 \createplainmark{lot}{right}{\listtablename}
7227 \createplainmark{bib}{right}{\bibname}
7228 \createplainmark{index}{right}{\indexname}
7229 \createplainmark{glossary}{right}{\glossaryname}
7230 }
7231 \makeoddhead{headings}{\slshape\rightmark}{}{\thepage}
7232 \fi
7233
7234 % \end{macrocode}
7235 % \end{macro}
7236 %
7237 % \begin{macro}{\ps@myheadings}
7238 % The \pstyle{myheadings} page style is simpler because the user
7239 % has to specify the contents using \cs{markboth} and \cs{markright}
7240 % commands. This is the definition used in the standard classes.
7241 % \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@myheadings}}
7242 % \begin{verbatim}}
7243 % \newcommand{\ps@myheadings}{%
7244 % \let\@oddfoot\@empty\let\@evenfoot\@empty
7245 % \def\@evenhead{\thepage\hfil{\slshape\leftmark}}%
7246 % \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
7247 % \let\@mkboth\@gobbletwo
7248 % \let\chaptermark\@gobble
7249 % \let\sectionmark\@gobble
7250 % }
7251 % \end{verbatim}
7252 % Translating that into our terms we get:
7253 % \changes{v1.0}{2001/11/15}{Changed the code for creating the myheadings pagestyle}
7254 % \changes{v1.4}{2003/11/22}{Further change to myheadings pagestyle code}
7255 % \begin{macrocode}
7256 \makepagestyle{myheadings}
7257 \makepsmarks{myheadings}{%
7258 \let\chaptermark\@gobble
7259 \let\sectionmark\@gobble
7260 \def\tocmark{}%
7261 \def\lofmark{}%
7262 \def\lotmark{}%
7263 \def\bibmark{}%
7264 \def\indexmark{}%
7265 \def\glossarymark{}}
7266 \makeevenhead{myheadings}{\thepage}{}{\slshape\leftmark}
7267 \makeoddhead{myheadings}{\slshape\rightmark}{}{\thepage}
7268
7269 % \end{macrocode}
7270 % (Kai von Fintel emailed me on 2003/02/24 saying that the original
7271 % \verb?\let\tocmark\@gobble? in the myheadings pagestyle did nasty
7272 % things to the ToC, etc. Now using \verb?\def\tocmark{}?.)
7273 % \end{macro}
7274 %
7275 % \begin{macro}{\ps@chapter}
7276 % \begin{macro}{\ps@part}
7277 % \begin{macro}{\ps@cleared}
7278 % The standard classes use the \pstyle{plain} pagestyle for the first page
7279 % of a chapter. This class uses the \pstyle{chapter} instead, which is
7280 % aliased to \pstyle{plain}. Similarly for parts.
7281 % Further, \cs{cleardoublepage} uses whatever
7282 % pagestyle is in effect for the empty verso page. I find that this
7283 % looks odd if the header contains a chapter name. This class uses
7284 % the \pstyle{cleared} pagestyle in this case. I have aliased this
7285 % to \pstyle{empty}; the \pstyle{plain} would be another reasonable choice.
7286 % \begin{macrocode}
7287 \aliaspagestyle{chapter}{plain}
7288 \aliaspagestyle{part}{plain}
7289 \aliaspagestyle{cleared}{empty}
7290
7291 % \end{macrocode}
7292 % \end{macro}
7293 % \end{macro}
7294 % \end{macro}
7295 %
7296 % \begin{macro}{\cleardoublepage}
7297 % A slight adjustment to the kernel definition to set a pagestyle.
7298 % \begin{macrocode}
7299 \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
7300 \hbox{}\thispagestyle{cleared}%
7301 \newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
7302
7303 % \end{macrocode}
7304 % \end{macro}
7305 %
7306 %
7307 % \begin{macro}{\ps@ruled}
7308 % Partly to show how it is done, the class provides a \pstyle{ruled} pagestyle.
7309 % In this style the headers and footers are the same width as the textblock,
7310 % there is a rule under the header, page numbers are set in the footers
7311 % at the outside of the page. Even page headers have the chapter number
7312 % and title at the left, and odd page headers have the section title
7313 % at the right.
7314 %
7315 % Start by making the (empty) \pstyle{ruled} pagestyle.
7316 % \begin{macrocode}
7317 \makepagestyle{ruled}
7318 % \end{macrocode}
7319 % There is no need to change the default width (which is the \cs{textwidth}),
7320 % nor the default positions (centered),
7321 % nor to make the footrule visible. We do, though, have to put the page
7322 % numbers into the footers.
7323 % \begin{macrocode}
7324 \makeevenfoot{ruled}{\thepage}{}{}
7325 \makeoddfoot{ruled}{}{}{\thepage}
7326 % \end{macrocode}
7327 % Make the header rule visible and equal to the \cs{textwidth}.
7328 % \begin{macrocode}
7329 \makeheadrule{ruled}{\textwidth}{\normalrulethickness}
7330 % \end{macrocode}
7331 %
7332 % \begin{macro}{\@ruledmarks}
7333 % We have to make sure that the \cs{chapter} and \cs{section} commands make
7334 % the appropriate marks for use in the headers. We use the hook for this.
7335 % Note that contrary to normal \LaTeX{} practice, the titles are not
7336 % automatically upper-cased. The marks for the tocbibinds also need adjusting.
7337 % \changes{v1.1}{2002/03/10}{Changed \cs{@ruledmarks} to cater for tocbibind}
7338 % \changes{v3.8.4}{2025/08/06}{We only leave the version made with our marks}
7339 % \begin{macrocode}
7340 % \newcommand{\@ruledmarks}{%
7341 % \def\chaptermark##1{%
7342 % \markboth{%
7343 % \ifnum \c@secnumdepth >\m@ne
7344 % \if@mainmatter
7345 % \thechapter. \ %
7346 % \fi
7347 % \fi
7348 % ##1}{}}
7349 % \def\sectionmark##1{\markright{##1}}
7350 % \def\tocmark{\markboth{\contentsname}{}}
7351 % \def\lofmark{\markboth{\listfigurename}{}}
7352 % \def\lotmark{\markboth{\listtablename}{}}
7353 % \def\bibmark{\markboth{\bibname}{}}
7354 % \def\indexmark{\markboth{\indexname}{}}
7355 % \def\glossarymark{\markboth{\glossaryname}{}}
7356 % }
7357 % \end{macrocode}
7358 % Here's a version using \cs{createmark} and friends.
7359 % \begin{macrocode}
7360 \newcommand*{\@ruledmarks}{%
7361 \nouppercaseheads
7362 \createmark{chapter}{left}{shownumber}{}{. \space}
7363 \createmark{section}{right}{shownumber}{}{. \space}
7364 \createplainmark{toc}{both}{\contentsname}
7365 \createplainmark{lof}{both}{\listfigurename}
7366 \createplainmark{lot}{both}{\listtablename}
7367 \createplainmark{bib}{both}{\bibname}
7368 \createplainmark{index}{both}{\indexname}
7369 \createplainmark{glossary}{both}{\glossaryname}}
7370 \makepsmarks{ruled}{\@ruledmarks}
7371 % \end{macrocode}
7372 % \end{macro}
7373 %
7374 % We can now define the even page header which is to have the chapter title
7375 % at the left. As the chapter mark did no upper-casing we will print it
7376 % using small caps, but just use the normal font for section title on
7377 % the odd page header.
7378 % \begin{macrocode}
7379 \makeevenhead{ruled}{\scshape\leftmark}{}{}
7380 \makeoddhead{ruled}{}{}{\rightmark}
7381
7382 % \end{macrocode}
7383 % \end{macro}
7384 % This is all that we need to do for the \pstyle{ruled} pagestyle.
7385 %
7386 % \begin{macro}{\ps@Ruled}
7387 % Also define a \pstyle{Ruled} pagestyle similar to \pstyle{ruled} except that the
7388 % headers and footers are 10\% wider than the textblock, sticking out
7389 % into the fore edge.
7390 % \begin{macrocode}
7391 \makepagestyle{Ruled}
7392 \makerunningwidth{Ruled}{1.1\textwidth}
7393 \makeheadposition{Ruled}{flushright}{flushleft}{flushright}{flushleft}
7394 \makeevenfoot{Ruled}{\thepage}{}{}
7395 \makeoddfoot{Ruled}{}{}{\thepage}
7396 \makeheadrule{Ruled}{1.1\textwidth}{\normalrulethickness}
7397 \makepsmarks{Ruled}{\@ruledmarks}
7398 \makeevenhead{Ruled}{\scshape\leftmark}{}{}
7399 \makeoddhead{Ruled}{}{}{\rightmark}
7400
7401 % \end{macrocode}
7402 % \end{macro}
7403 %
7404 % \begin{macro}{\headwidth}
7405 % \begin{macro}{\ps@companion}
7406 % A \pstyle{companion} pagestyle like the one in the
7407 % \textit{\LaTeX{} Companion} series.
7408 % We need the \cs{headwidth} length for this.
7409 % \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@companion}}
7410 % \begin{macrocode}
7411 \newlength{\headwidth}
7412
7413 \makepagestyle{companion}
7414 \setlength{\headwidth}{\textwidth}
7415 \addtolength{\headwidth}{\marginparsep}
7416 \addtolength{\headwidth}{\marginparwidth}
7417 \makerunningwidth{companion}{\headwidth}
7418 \makeheadrule{companion}{\headwidth}{\normalrulethickness}
7419 \makeheadposition{companion}{flushright}{flushleft}{}{}
7420 % \end{macrocode}
7421 % \changes{v3.8.4}{2025/08/06}{might as well outcomment this as the \cs{create...} below overwrites it}
7422 % \begin{macrocode}
7423 % \makepsmarks{companion}{%
7424 % \def\chaptermark##1{\markboth{##1}{##1}} % left mark & right marks
7425 % \def\sectionmark##1{\markright{%
7426 % \ifnum \c@secnumdepth>\z@
7427 % \thesection. \ %
7428 % \fi
7429 % ##1}}
7430 % \def\tocmark{\markboth{\contentsname}{\contentsname}}
7431 % \def\lofmark{\markboth{\listfigurename}{\listfigurename}}
7432 % \def\lotmark{\markboth{\listtablename}{\listtablename}}
7433 % \def\bibmark{\markboth{\bibname}{\bibname}}
7434 % \def\indexmark{\markboth{\indexname}{\indexname}}}
7435 % \end{macrocode}
7436 % And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
7437 % \cs{createplainmark}.
7438 % \begin{macrocode}
7439 \makepsmarks{companion}{%
7440 \nouppercaseheads
7441 \createmark{chapter}{both}{nonumber}{}{}
7442 \createmark{section}{right}{shownumber}{}{. \space}
7443 \createplainmark{toc}{both}{\contentsname}
7444 \createplainmark{lof}{both}{\listfigurename}
7445 \createplainmark{lot}{both}{\listtablename}
7446 \createplainmark{bib}{both}{\bibname}
7447 \createplainmark{index}{both}{\indexname}
7448 \createplainmark{glossary}{both}{\glossaryname}}
7449 \makeevenhead{companion}{\normalfont\bfseries\thepage}{}%
7450 {\normalfont\bfseries\leftmark}
7451 \makeoddhead{companion}{\normalfont\bfseries\rightmark}{}%
7452 {\normalfont\bfseries\thepage}
7453
7454 % \end{macrocode}
7455 % \end{macro}
7456 % \end{macro}
7457 %
7458 % Another pagestyle called \pstyle{showlocs} can be used to show the
7459 % locations of the header, footer and textblock. I would expect that
7460 % this would be mainly used as an example for authors to create their
7461 % own similar styles.
7462 % \changes{v1.6180339c}{2008/12/28}{Added the showlocs pagestyle and supporting
7463 % macros}
7464 % \changes{v1.6180339c}{2009/01/25}{Added more supporting macros for the
7465 % showlocs pagestyle}
7466 %
7467 % \begin{macro}{\ifshowheadfootloc}
7468 % \begin{macro}{\showheadfootloctrue}
7469 % \begin{macro}{\showheadfootlocfalse}
7470 % \begin{macro}{\showheadfootlocon}
7471 % \begin{macro}{\showheadfootlocoff}
7472 % \begin{macro}{\ifshowtextblockloc}
7473 % \begin{macro}{\showtextblockloctrue}
7474 % \begin{macro}{\showtextblocklocfalse}
7475 % \begin{macro}{\showtextblocklocon}
7476 % \begin{macro}{\showtextblocklocoff}
7477 % Booleans controlling the appearance, or not, of the header/footer lines
7478 % and text frame in \pstyle{showlocs}.
7479 % \begin{macrocode}
7480 \newif\ifshowheadfootloc
7481 \showheadfootloctrue
7482 \newcommand*{\showheadfootlocon}{\showheadfootloctrue}
7483 \newcommand*{\showheadfootlocoff}{\showheadfootlocfalse}
7484 \newif\ifshowtextblockloc
7485 \showtextblockloctrue
7486 \newcommand*{\showtextblocklocon}{\showtextblockloctrue}
7487 \newcommand*{\showtextblocklocoff}{\showtextblocklocfalse}
7488
7489 % \end{macrocode}
7490 % \end{macro}
7491 % \end{macro}
7492 % \end{macro}
7493 % \end{macro}
7494 % \end{macro}
7495 % \end{macro}
7496 % \end{macro}
7497 % \end{macro}
7498 % \end{macro}
7499 % \end{macro}
7500 % \begin{macro}{\framepichook}
7501 % \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
7502 % The two macros \cs{framepichead} and \cs{framepictextfoot} are used
7503 % to make up the \texttt{showlocs} page style. They are both zero
7504 % width \texttt{picture} environments. The very first thing in these
7505 % \texttt{picture} environments, is a call to \cs{framepichook}
7506 % (empty by default), which could be used to change the color of the
7507 % frame.
7508 % \begin{macrocode}
7509 \newcommand\framepichook{}
7510 % \end{macrocode}
7511 %
7512 % \end{macro}
7513 % \begin{macro}{\framepichead}
7514 % For producing a zero-sized picture of a line at the base of the header.
7515 % It is meant to be used as the left part of the header for a pagestyle.
7516 % \changes{v1.6180339c}{2008/12/28}{Added \cs{framepichead}}
7517 % \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
7518 % \begin{macrocode}
7519 \newcommand*{\framepichead}{%
7520 \ifshowheadfootloc
7521 \begin{picture}(0,0)
7522 \framepichook
7523 \unitlength 1pt
7524 \put(0,0){\line(1,0){\strip@pt\textwidth}}
7525 \end{picture}%
7526 \fi}
7527
7528 % \end{macrocode}
7529 % \end{macro}
7530 %
7531 % \begin{macro}{\framepictextfoot}
7532 % For producing a zero-sized picture of a line at the base of the footer
7533 % and a frame around the text block. It is meant to be used as the left
7534 % part of a footer for a pagestyle.
7535 % \changes{v1.6180339c}{2008/12/28}{Added \cs{framepictextfoot}}
7536 % \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
7537 % \begin{macrocode}
7538 \newcommand*{\framepictextfoot}{%
7539 \begin{picture}(0,0)
7540 \framepichook
7541 \unitlength 1pt
7542 \ifshowheadfootloc
7543 \put(0,0){\line(1,0){\strip@pt\textwidth}}
7544 \fi
7545 \ifshowtextblockloc
7546 \put(0,\strip@pt\footskip)%
7547 {\framebox(\strip@pt\textwidth,\strip@pt\textheight){}}
7548 \fi
7549 \end{picture}}
7550
7551 % \end{macrocode}
7552 % \end{macro}
7553 %
7554 % \begin{macro}{\ps@showlocs}
7555 % The \pstyle{showlocs} pagestyle. This is more to show what can be done.
7556 % \changes{v1.6180339c}{2008/12/28}{Added the showlocs pagestyle}
7557 % \begin{macrocode}
7558 \makepagestyle{showlocs}
7559 \makeevenhead{showlocs}{\framepichead\thepage}{\thepage}{\thepage}
7560 \makeoddhead{showlocs}{\framepichead\thepage}{\thepage}{\thepage}
7561 \makeevenfoot{showlocs}{\framepictextfoot\thepage}{\thepage}{\thepage}
7562 \makeoddfoot{showlocs}{\framepictextfoot\thepage}{\thepage}{\thepage}
7563
7564 % \end{macrocode}
7565 % \end{macro}
7566 %
7567 % \begin{macro}{\fixheaderwidths}
7568 % The companion pagestyle, at least, needs adjusting (at \cs{fixthelayout} time)
7569 % if the \cs{textwidth} has changed from its initial value.
7570 % \changes{v1.6180339f}{2009/03/16}{Added \cs{fixheaderwidths}}
7571 % \begin{macrocode}
7572 \newcommand*{\fixheaderwidths}{%
7573 % companion pagestyle
7574 \setlength{\headwidth}{\textwidth}
7575 \addtolength{\headwidth}{\marginparsep}
7576 \addtolength{\headwidth}{\marginparwidth}
7577 \makerunningwidth{companion}{\headwidth}
7578 \makeheadrule{companion}{\headwidth}{\normalrulethickness}
7579 \makefootrule{companion}{\textwidth}{\footruleheight}{\footruleskip}
7580 }
7581
7582 % \end{macrocode}
7583 % \end{macro}
7584 %
7585 %
7586 % \subsection{Page numbering}
7587 %
7588 % The kernel includes the \cs{pagenumbering} command for setting the
7589 % style (arabic, roman, etc.) of the page numbers, and at the same
7590 % time it resets the page counter. I want a version that resets the
7591 % style but not the number\footnote{Added to meet a request by Daniel
7592 % Richard G. September 2001.}.
7593 %
7594 % \begin{macro}{\pagenumbering}
7595 % \begin{macro}{\pagenumbering*}
7596 % \cs{pagenumbering}\marg{style} is the normal version whereas
7597 % the starred version does not reset the counter.
7598 % \changes{v1.0}{2001/09/21}{Added \cs{pagenumbering} and \cs{pagenumbering*} }
7599 % \changes{v3.8}{2023/05/08}{Reimplemented as a single macro via \RenewDocumentCommand}
7600 % \begin{macrocode}
7601 \RenewDocumentCommand\pagenumbering{sm}{%
7602 \gdef\thepage{\csname @#2\endcsname \c@page}%
7603 \IfBooleanF{#1}{\global\c@page \@ne}% reset counter unless starred
7604 }
7605
7606 % \end{macrocode}
7607 % \end{macro}
7608 % \end{macro}
7609 %
7610 % \begin{macro}{\c@storedpagenumber}
7611 % A counter to store the page number.
7612 % \begin{macrocode}
7613 \newcounter{storedpagenumber}
7614 \setcounter{storedpagenumber}{1}
7615 % \end{macrocode}
7616 % \end{macro}
7617 %
7618 % \begin{macro}{\savepagenumber}
7619 % \begin{macro}{\restoregenumber}
7620 % \cs{savepagenumber} saves the current page number and \cs{restorepagenumber}
7621 % sets the page number to the stored value.
7622 % \changes{v1.0}{2001/09/24}{Added \cs{savepagenumber} and \cs{restorepagenumber}}
7623 % \begin{macrocode}
7624 \newcommand{\savepagenumber}{\global\c@storedpagenumber \c@page}
7625 \newcommand{\restorepagenumber}{\global\c@page \c@storedpagenumber}
7626
7627 % \end{macrocode}
7628 % \end{macro}
7629 % \end{macro}
7630 %
7631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7632 %
7633 % \section{Non-traditional spacing}
7634 % \changes{v1.61803}{2008/01/30}{Added non-traditional spacing
7635 % (mempatch v4.6)}
7636 %
7637 % \subsection{Double spacing}
7638 %
7639 % This is an embedding and extension of the code from the \Lpack{setspace}
7640 % package, with
7641 % names changed.
7642 %
7643 % \begin{macro}{\setSpacing}
7644 % \cs{setSpacing}\marg{num} effectively increases the \cs{baselineskip} to
7645 % \meta{num}*\cs{baselineskip}.
7646 % (In package was \cs{setstretch}).
7647 % \begin{macrocode}
7648 \newcommand*{\setSpacing}[1]{%
7649 \def\baselinestretch{#1}%
7650 \@currsize}
7651
7652 % \end{macrocode}
7653 % \end{macro}
7654 %
7655 % \begin{macro}{\setSingleSpace}
7656 % \begin{macro}{\setFootnoteSpacing}
7657 % \begin{macro}{\setFloatSpacing}
7658 % \cs{setSingleSpace}\marg{num} effectively increases the \cs{baselineskip} for
7659 % single spacing to \meta{num}*\cs{baselineskip} (\meta{num} should be
7660 % close to 1.0). (In package was \cs{SetSinglespace}). We extend with
7661 % two extra macros \cs{setFootnoteSpacing} and \cs{setFloatSpacing}
7662 % which can be used to explicitly set the spacing inside page notes
7663 % (fotnotes and friends) and inside floats. Changing
7664 % \cs{setSingleSpace} will also set page note and float spacings to
7665 % the same value.
7666 % \changes{v3.6g}{2010/09/19}{Added two extra 'single' spacing macros}
7667 % \begin{macrocode}
7668 \newcommand*{\setSingleSpace}[1]{%
7669 \def\m@m@singlespace{#1}%
7670 \def\m@m@footnote@spacing{#1}%
7671 \def\m@m@float@spacing{#1} %
7672 }
7673 \setSingleSpace{1}
7674 \newcommand*\setPagenoteSpacing[1]{\def\m@m@footnote@spacing{#1}}
7675 \newcommand*\setFloatSpacing[1] {\def\m@m@float@spacing{#1}}
7676
7677 % \end{macrocode}
7678 % \end{macro}
7679 % \end{macro}
7680 % \end{macro}
7681 %
7682 % \begin{macro}{\SingleSpacing}
7683 % \begin{macro}{\SingleSpacing*}
7684 % \cs{SingleSpacing} starts single spacing. (In package was \cs{singlespacing}).
7685 % \changes{v3.6g}{2010/09/19}{Added reset of the float and page note spacings}
7686 % \begin{macrocode}
7687 \newcommand*{\SingleSpacing}{%
7688 \setSpacing{\m@m@singlespace}%
7689 \edef\m@m@footnote@spacing{\baselinestretch}%
7690 \edef\m@m@float@spacing{\baselinestretch}%
7691 % \end{macrocode}
7692 % \changes{v3.7h}{2018/09/19}{Added the ifstar and \cs{@noocument}}
7693 % We can have a strange interaction with \Lpack{tikz} if this
7694 % \cs{vskip} is emitted in the preamble. We use a trick (via David
7695 % Carlisle) to check whether we are in the preamble, and only emit the
7696 % vskip if we are not. \cs{@ifstar} added to let the user disable the
7697 % vskip if needed.
7698 % \begin{macrocode}
7699 \@ifstar{}{\ifx\@nodocument\relax\vskip\baselineskip\fi}% correction for coming into single spacing
7700 }
7701 \SingleSpacing
7702
7703 % \end{macrocode}
7704 % \end{macro}
7705 % \end{macro}
7706 %
7707 %
7708 % \begin{macro}{\@OnehalfSpacing}
7709 % \begin{macro}{\OnehalfSpacing}
7710 % \cs{OnehalfSpacing} starts `one and a half' spacing, which to most
7711 % thesis nitpickers will look like double spacing.
7712 % (In package was \cs{onehalfspacing}). The starred version
7713 % \cs{OnehalfSpacing*} will also give page notes and floats the same spacing
7714 % \changes{v3.6g}{2010/09/19}{Made \cs{OnehalfSpacing} into a starred
7715 % version such that the starred version makes everything one half
7716 % spaced including page notes and floats}
7717 % \begin{macrocode}
7718 \newcommand*{\@OnehalfSpacing}{
7719 \setSpacing{1.25}% default (10pt)
7720 \ifcase \@ptsize \relax % 10pt
7721 \setSpacing{1.25}%
7722 \or% 11pt
7723 \setSpacing{1.213}%
7724 \or% 12pt
7725 \setSpacing{1.241}%
7726 \or\or% 14pt
7727 \setSpacing{1.20}%
7728 \or\or\or% 17pt
7729 \setSpacing{1.16}%
7730 \or\or% 9pt
7731 \setSpacing{1.35}%
7732 \else% the extended sizes
7733 \setSpacing{1.16}%
7734 \fi}
7735 \newcommand*\OnehalfSpacing{%
7736 \@ifstar{%
7737 \@OnehalfSpacing%
7738 \edef\m@m@footnote@spacing{\baselinestretch}%
7739 \edef\m@m@float@spacing{\baselinestretch}%
7740 }{\@OnehalfSpacing}%
7741 }
7742
7743 % \end{macrocode}
7744 % \end{macro}
7745 % \end{macro}
7746 %
7747 % \begin{macro}{\DoubleSpacing}
7748 % \begin{macro}{\@DoubleSpacing}
7749 % \cs{DoubleSpacing} starts double spacing, which to most thesis nitpickers
7750 % will look far too spaced out. (In package was
7751 % \cs{doublespacing}). The starred version will also set the page note
7752 % and float spacing to the same value.
7753 % \changes{v3.6g}{2010/09/19}{Extended with a starred version.}
7754 % \begin{macrocode}
7755 \newcommand*{\@DoubleSpacing}{
7756 \setSpacing{1.667}% default (10pt)
7757 \ifcase \@ptsize \relax % 10pt
7758 \setSpacing{1.667}%
7759 \or% 11pt
7760 \setSpacing{1.618}%
7761 \or% 12pt
7762 \setSpacing{1.655}%
7763 \or\or% 14pt
7764 \setSpacing{1.60}%
7765 \or\or\or% 17pt
7766 \setSpacing{1.545}%
7767 \or\or% 9pt
7768 \setSpacing{1.8}%
7769 \else% larger sizes
7770 \setSpacing{1.5}%
7771 \fi}
7772 \newcommand*\DoubleSpacing{%
7773 \@ifstar{%
7774 \@DoubleSpacing%
7775 \edef\m@m@footnote@spacing{\baselinestretch}%
7776 \edef\m@m@float@spacing{\baselinestretch}%
7777 }{\@DoubleSpacing}%
7778 }
7779
7780 % \end{macrocode}
7781 % \end{macro}
7782 % \end{macro}
7783 %
7784 %
7785 % \begin{macro}{\@setsize}
7786 % Modify the kernel command.
7787 % \changes{v3.8}{2023/08/08}{\cs{@setsize} redef removed. It came from
7788 % setspace.sty which note that it was needed for some 209 packages. In
7789 % the kernel it is just defined to use \cs{@setfontsize}. We remove it}
7790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check what this does!!!!!!!!
7791 % \begin{macrocode}
7792 % \renewcommand*{\@setsize}[4]{%
7793 % \@nomath#1%
7794 % \let\@currsize#1%
7795 % \baselineskip #2%
7796 % \baselineskip \baselinestretch\baselineskip
7797 % \parskip \baselinestretch\parskip
7798 % \setbox\strutbox \hbox{%
7799 % \vrule height.7\baselineskip
7800 % depth .3\baselineskip
7801 % width \z@}%
7802 % \skip\footins \baselinestretch\skip\footins
7803 % \normalbaselineskip\baselineskip#3#4}
7804
7805 % \end{macrocode}
7806 % \end{macro}
7807 %
7808 %
7809 % \begin{environment}{SingleSpace}
7810 % Environment form of \cs{SingleSpacing}. (In package was \texttt{singlespace}).
7811 % \begin{macrocode}
7812 \newenvironment{SingleSpace}{%
7813 \vskip\baselineskip
7814 \setSpacing{\m@m@singlespace}%
7815 \vskip -\baselineskip
7816 }{\par}
7817
7818 % \end{macrocode}
7819 % \end{environment}
7820 %
7821 % \begin{environment}{SingleSpace*}
7822 % Don't use this; it's only here to match the \Lpack{setspace} package.
7823 % (In package was \texttt{singlespace*}).
7824 % \begin{macrocode}
7825 \newenvironment{SingleSpace*}{%
7826 %% \vskip\baselineskip
7827 \setSpacing{\m@m@singlespace}%
7828 \vskip 0.5\baselineskip
7829 }{\vskip -0.5\baselineskip}
7830
7831 % \end{macrocode}
7832 % \end{environment}
7833 %
7834 % \begin{macro}{\m@mrestore@spacing}
7835 % \begin{macrocode}
7836 \newcommand*{\m@mrestore@spacing}{%
7837 \par
7838 \vskip \parskip
7839 \vskip \baselineskip
7840 \endgroup
7841 \vskip -\parskip
7842 \vskip -\baselineskip}
7843
7844 % \end{macrocode}
7845 % \end{macro}
7846 %
7847 % \begin{environment}{Spacing}
7848 % \verb?\begin{Spacing}{num}? increases the \cs{baselineskip}
7849 % to \verb?num*\baselineskip?. (In package was \texttt{spacing}).
7850 % \begin{macrocode}
7851 \newenvironment{Spacing}[1]{%
7852 \par
7853 \begingroup
7854 \setSpacing{#1}}{\m@mrestore@spacing}
7855
7856 % \end{macrocode}
7857 % \end{environment}
7858 %
7859 % \begin{environment}{OnehalfSpace}
7860 % Environment form of \cs{OnehalfSpacing}. (In package was \texttt{onehalfspace}).
7861 % \changes{v3.6g}{2010/09/19}{Added starred version of environment to
7862 % complement the starred macro version}
7863 % \begin{macrocode}
7864 \newenvironment{OnehalfSpace}{%
7865 \begingroup
7866 \OnehalfSpacing}{\m@mrestore@spacing}
7867 \newenvironment{OnehalfSpace*}{%
7868 \begingroup
7869 \OnehalfSpacing*}{\m@mrestore@spacing}
7870
7871 % \end{macrocode}
7872 % \end{environment}
7873 %
7874 % \begin{environment}{DoubleSpace}
7875 % Environment form of \cs{DoubleSpacing}. (In package was \texttt{doublespace}).
7876 % \changes{v3.6g}{2010/09/19}{Added starred version of environment to
7877 % complement the starred macro version}
7878 % \begin{macrocode}
7879 \newenvironment{DoubleSpace}{%
7880 \begingroup
7881 \DoubleSpacing}{\m@mrestore@spacing}
7882 \newenvironment{DoubleSpace*}{%
7883 \begingroup
7884 \DoubleSpacing}{\m@mrestore@spacing}
7885
7886 % \end{macrocode}
7887 % \end{environment}
7888 %
7889 %
7890 % Deal with spacing around displays.
7891 %
7892 % \begin{macro}{\memdskipstretch}
7893 % \begin{macro}{\setDisplayskipStretch}
7894 % \begin{macro}{\noDisplayskipStretch}
7895 % \cs{setDisplayskipStretch}\marg{num} changes space around displays by the
7896 % factor (1+\meta{num}). \cs{noDisplaydkipStretch} keeps the regular
7897 % spacing around displays. (In package were \cs{setdisplayskipstretch} and
7898 % the \texttt{nodisplayskipstretch} option).
7899 % \begin{macrocode}
7900 \newcommand*{\memdskipstretch}{0.0}
7901 \newcommand*{\setDisplayskipStretch}[1]{%
7902 \renewcommand*{\memdskipstretch}{#1}}
7903 \newcommand*{\noDisplayskipStretch}{\setDisplayskipStretch{0.0}}
7904
7905 % \end{macrocode}
7906 % \end{macro}
7907 % \end{macro}
7908 % \end{macro}
7909 %
7910 % \begin{macro}{\memdskips}
7911 % Macro added to the kernel hook \cs{everydisplay}, changing the settings
7912 % of displayskips
7913 % \begin{macrocode}
7914 \newcommand*{\memdskips}{%
7915 \advance\abovedisplayskip \memdskipstretch\abovedisplayskip
7916 \advance\belowdisplayskip \memdskipstretch\belowdisplayskip
7917 \advance\abovedisplayshortskip \memdskipstretch\abovedisplayshortskip
7918 \advance\belowdisplayshortskip \memdskipstretch\belowdisplayshortskip}
7919 % \end{macrocode}
7920 % \end{macro}
7921 %
7922 % \begin{macro}{\everydisplay}
7923 % \begin{macrocode}
7924 \everydisplay\expandafter{%
7925 \the\everydisplay
7926 \memdskips}
7927
7928 % \end{macrocode}
7929 % \end{macro}
7930 %
7931 % \begin{macro}{\@floatboxreset}
7932 % Reset \cs{baselinestretch} in floats. If the format version
7933 % supports it we add it via a cmd hook, if not, we delay until the
7934 % start of the document and use the older definition. Note that the
7935 % hook cannot access the arguments given to \cs{@xfloat}, luckily it
7936 % stores \#1 in \cs{@captype}.
7937 % \changes{v3.7d}{2014/07/28}{Delayed addition to \cs{@xfloat}. Reported by Ulrike Fischer}
7938 % \changes{v3.7g}{2017/05/08}{Delayed the addition of the adjustment
7939 % to the float until after \cs{normalsize}. Reported at \protect\url{https://tex.stackexchange.com/q/368422/3929}}
7940 % \changes{v3.8}{2023/05/08}{Additions to \cs{@xfloat} now added
7941 % via a cmd/after hook if the format supports it}
7942 % \changes{v3.8.1}{2023/08/21}{Changed the hook to add to
7943 % \cs{@floatboxreset} as the \Lpack{float} package redefines
7944 % \cs{@xfloat} so the Hook cannot access it.}
7945 % \changes{v3.8.4}{2025/09/24}{Format tjek removed as we now require kernel of 2023/06/01}
7946 % \begin{macrocode}
7947 \AddToHook{cmd/@floatboxreset/after}{%
7948 \def\baselinestretch{\m@m@float@spacing}%
7949 \normalsize%
7950 \@nameuse{\@captype adjustment}%
7951 }
7952
7953 % \end{macrocode}
7954 % \end{macro}
7955 %
7956 % The extra spacing does not add space before and after a minipage.
7957 % The solution, hinted at by Donald Arseneau, is to create a new
7958 % environment. I came up with a solution which DA then much improved upon
7959 % (CTT \textit{setspace and minipages}, 2006/11/28).
7960 % This is like minipage from an author's view, except that it is
7961 % always top positioned and acts like a paragraph.
7962 % \begin{macro}{\memPD}
7963 % \begin{macrocode}
7964 \newdimen\memPD
7965 % \end{macrocode}
7966 % \end{macro}
7967 % \begin{environment}{vminipage}
7968 % The user view, just as for \texttt{minipage}, but ensures the \texttt{t}
7969 % position and as a new paragraph. It is like \texttt{minipage} but with
7970 % better fore and aft spacing.
7971 % \begin{macrocode}
7972 \newenvironment{vminipage}{%
7973 \par
7974 \@ifnextchar[%]
7975 \@ivminipage
7976 {\@iiiminipage t\relax[s]}
7977 }{%
7978 \par\global\memPD=\prevdepth
7979 \endminipage
7980 \par
7981 \kern-\memPD% no pagebreak allowed here
7982 \hbox{\vrule depth \memPD width \z@}}
7983
7984 % \end{macrocode}
7985 % \end{environment}
7986 %
7987 % \begin{macro}{\@ivminipage}
7988 % Deal with first optional argument to \texttt{vminipage}.
7989 % \begin{macrocode}
7990 \def\@ivminipage[#1]{%
7991 \@ifnextchar[%]
7992 {\@iiminipage{t}}{\@iiiminipage{t}\relax[s]}}
7993 % \end{macrocode}
7994 % \end{macro}
7995 %
7996 %
7997 % \subsection{Abnormal parskips}
7998 %
7999 % Non-zero, positive \cs{parskip}, which is not to be encouraged. Code
8000 % based on Robin Fairbairns \Lpack{parskip} package and the NTG classes.
8001 %
8002 % \begin{macro}{\ifm@mnzpskip}
8003 % \begin{macro}{\m@mnzpskiptrue}
8004 % \begin{macro}{\m@mnzpskipfalse}
8005 % \cs{ifm@mnzpskip} is TRUE if \cs{parskip} set to anything but 0pt.
8006 % \begin{macrocode}
8007 \newif\ifm@mnzpskip
8008 % \end{macrocode}
8009 % \end{macro}
8010 % \end{macro}
8011 % \end{macro}
8012 %
8013 % \begin{macro}{\traditionalparskip}
8014 % \begin{macro}{\m@mabparskip}
8015 % \begin{macro}{\abnormalparskip}
8016 % \begin{macro}{\nonzeroparskip}
8017 % \cs{traditionalparskip} sets \cs{parskip} to 0pt.
8018 % \cs{abnormalparskip}\marg{length} sets \cs{parskip} to \meta{length}.
8019 % \cs{nonzeroparskip} sets \cs{parskip} to a non-zero value that might be
8020 % not too bad (any non-zero \cs{parskip} is not good).
8021 % \changes{v1.61803398c}{2009/11/13}{\cs{parskip} was set to \cs{z@},
8022 % thus the stretch was missing, this broke \cs{flushbottom}}
8023 % \begin{macrocode}
8024 \newcommand*{\traditionalparskip}{%
8025 \setlength\parskip{0\p@ \@plus \p@}
8026 \m@mnzpskipfalse}
8027 \newskip\m@mabparskip
8028 \newcommand*{\abnormalparskip}[1]{%
8029 \setlength{\parskip}{#1}\m@mabparskip=#1\relax
8030 \m@mnzpskiptrue}
8031 \newcommand*{\nonzeroparskip}{\abnormalparskip{%
8032 0.5\baselineskip
8033 \@plus .1\baselineskip \@minus .1\baselineskip% NTG
8034 %% 0.5/baselineskip \@plus 2pt% RF
8035 }}
8036 \traditionalparskip
8037
8038 % \end{macrocode}
8039 % \end{macro}
8040 % \end{macro}
8041 % \end{macro}
8042 % \end{macro}
8043 %
8044 %
8045 % \begin{macro}{\@minpagerestore}
8046 % This needs extending: here's what NTG does, but I've put the
8047 % appropriate code later.
8048 % \begin{verbatim}
8049 % \providecommand*{\@minipagerestore}{%
8050 % \parskip=.5\baselineskip \@plus .1\baselineskip \@minus .1\baselineskip}
8051 % \end{verbatim}
8052 % \end{macro}
8053 %
8054 % \section{Titles}
8055 %
8056 % For books the title is usually designed specifically for the particular
8057 % work, so originally the class did not provide a \cs{maketitle} command or
8058 % any of the \cs{title} and other commands that normally go along with this.
8059 % After some thought I decided to add in the code from the
8060 % \Lpack{titling} package~\cite{TITLING}. However, in this case life
8061 % is a bit simpler as there is no pre-existing class code.
8062 % \changes{v0.3}{2001/07/09}{Added titling code}
8063 %
8064 % \begin{macro}{\pretitle}
8065 % \begin{macro}{\@bspretitle}
8066 % \begin{macro}{\posttitle}
8067 % \begin{macro}{\@bsposttitle}
8068 % \begin{macro}{\preauthor}
8069 % \begin{macro}{\@bspreauthor}
8070 % \begin{macro}{\postauthor}
8071 % \begin{macro}{\@bspostauthor}
8072 % \begin{macro}{\predate}
8073 % \begin{macro}{\@bspredate}
8074 % \begin{macro}{\postdate}
8075 % \begin{macro}{\@bspostdate}
8076 % To provide some flexibilty in the titling style of the document,
8077 % user level commands are provided that can be changed to reconfigure
8078 % the appearance resulting from \cs{maketitle}.
8079 % \begin{macrocode}
8080 \newcommand{\pretitle}[1]{\def\@bspretitle{#1}}
8081 \newcommand{\posttitle}[1]{\def\@bsposttitle{#1}}
8082 \newcommand{\preauthor}[1]{\def\@bspreauthor{#1}}
8083 \newcommand{\postauthor}[1]{\def\@bspostauthor{#1}}
8084 \newcommand{\predate}[1]{\def\@bspredate{#1}}
8085 \newcommand{\postdate}[1]{\def\@bspostdate{#1}}
8086
8087 % \end{macrocode}
8088 % \end{macro}
8089 % \end{macro}
8090 % \end{macro}
8091 % \end{macro}
8092 % \end{macro}
8093 % \end{macro}
8094 % \end{macro}
8095 % \end{macro}
8096 % \end{macro}
8097 % \end{macro}
8098 % \end{macro}
8099 % \end{macro}
8100 %
8101 % These are defined initially
8102 % to mimic the normal \LaTeX{} style.
8103 % \begin{macrocode}
8104 \pretitle{\begin{center}\LARGE}
8105 \posttitle{\par\end{center}\vskip 0.5em}
8106 \preauthor{\begin{center}
8107 \large \lineskip .5em%
8108 \begin{tabular}[t]{c}}
8109 \postauthor{\end{tabular}\par\end{center}}
8110 \predate{\begin{center}\large}
8111 \postdate{\par\end{center}}
8112
8113 % \end{macrocode}
8114 %
8115 % \begin{macro}{\maketitlehooka}
8116 % \begin{macro}{\maketitlehookb}
8117 % \begin{macro}{\maketitlehookc}
8118 % \begin{macro}{\maketitlehookd}
8119 % The four hooks which will be called by \cs{maketitle}. These are initially
8120 % vacuous. The hooks are placed before title, before author, before
8121 % date and after date respectively.
8122 % \begin{macrocode}
8123 \newcommand{\maketitlehooka}{}
8124 \newcommand{\maketitlehookb}{}
8125 \newcommand{\maketitlehookc}{}
8126 \newcommand{\maketitlehookd}{}
8127
8128 % \end{macrocode}
8129 % \end{macro}
8130 % \end{macro}
8131 % \end{macro}
8132 % \end{macro}
8133 %
8134 %
8135 % \begin{macro}{\thanksmarkseries}
8136 % \begin{macro}{\@bsmarkseries}
8137 % \begin{macro}{\symbolthanksmark}
8138 % These are for specifying the kind of series for thanks markers.
8139 % \begin{macrocode}
8140 \newcommand{\thanksmarkseries}[1]{%
8141 \def\@bsmarkseries{\renewcommand{\thefootnote}%
8142 {\@nameuse{#1}{footnote}}}}
8143 \newcommand{\symbolthanksmark}{\thanksmarkseries{\fnsymbol}}
8144 % \end{macrocode}
8145 % \end{macro}
8146 % \end{macro}
8147 % \end{macro}
8148 %
8149 % \begin{macro}{\continuousmarks}
8150 % \begin{macro}{\@bscontmark}
8151 % These are for (non) zeroing of the footnote counter.
8152 % \begin{macrocode}
8153 \newcommand{\@bscontmark}{\setcounter{footnote}{0}}
8154 \newcommand{\continuousmarks}{\def\@bscontmark{}}
8155 % \end{macrocode}
8156 % \end{macro}
8157 % \end{macro}
8158 %
8159 % \begin{macro}{\thanksheadextra}
8160 % \begin{macro}{\@bsthanksheadpre}
8161 % \begin{macro}{\@bsthanksheadpost}
8162 % These are for inserting stuff before and after a mark in the titling.
8163 % \begin{macrocode}
8164 \newcommand{\thanksheadextra}[2]{%
8165 \def\@bsthanksheadpre{#1}%
8166 \def\@bsthanksheadpost{#2}}
8167 % \end{macrocode}
8168 % \end{macro}
8169 % \end{macro}
8170 % \end{macro}
8171 %
8172 % \changes{v1.2}{2002/08/10}{Deprecated \cs{thanksfootextra}}
8173 % \changes{v1.2}{2002/08/10}{Removed \cs{thanksfootpre} and \cs{thanksfootpost}}
8174 % \changes{v1.4}{2003/12/14}{Removed \cs{thanksfootextra}}
8175 %
8176 % \begin{macro}{\thanksmark}
8177 % This adds a thanks mark. The \cs{footnotemark} could have been used directly
8178 % but it is fragile in a moving argument.
8179 % \begin{macrocode}
8180 \DeclareRobustCommand{\thanksmark}[1]{\footnotemark[#1]}
8181 % \end{macrocode}
8182 % \end{macro}
8183 %
8184 % \begin{macro}{\thanksgap}
8185 % This specifies some horizontal space.
8186 % \begin{macrocode}
8187 \newcommand{\thanksgap}[1]{\hspace{#1}}
8188 % \end{macrocode}
8189 % \end{macro}
8190 %
8191 % \begin{macro}{\tamark}
8192 % This stores the current definition of \cs{@thefnmark}. For some reason
8193 % using \cs{@thefnmark} directly only gave the last value.
8194 % \begin{macrocode}
8195 \newcommand{\tamark}{\@thefnmark}
8196
8197 % \end{macrocode}
8198 % \end{macro}
8199 %
8200 % \begin{macro}{\thanksmarkwidth}
8201 % A length determining the size of the box for typesetting
8202 % a thanks marker.
8203 % \begin{macrocode}
8204 \newlength{\thanksmarkwidth}
8205 % \end{macrocode}
8206 % \end{macro}
8207 %
8208 % \begin{macro}{\thanksmarksep}
8209 % A length determining the inset of thanks footnotes.
8210 % \changes{v1.2}{2002/08/10}{Replaced \cs{thanksmargin} by \cs{thanksmarksep}}
8211 % \begin{macrocode}
8212 \newlength{\thanksmarksep}
8213 % \end{macrocode}
8214 % \end{macro}
8215 %
8216 % \begin{macro}{\thanksmarkstyle}
8217 % \begin{macro}{\thanksscript}
8218 % \cs{thanksscript} is a wrapper round the actual mark stuff to be typeset.
8219 % The user can define this via \cs{thanksmarkstyle}\marg{code}.
8220 % The default is a superscript mark.
8221 % \changes{v1.2}{2002/08/10}{Added \cs{thanksmarkstyle}}
8222 % \begin{macrocode}
8223 \newcommand{\thanksmarkstyle}[1]{\def\thanksscript##1{#1}}
8224 \thanksmarkstyle{\textsuperscript{#1}}
8225 % \end{macrocode}
8226 % \end{macro}
8227 % \end{macro}
8228 %
8229 % \begin{macro}{\makethanksmarkhook}
8230 % A vacuous macro used as a hook into \cs{makethanksmark}.
8231 % \begin{macrocode}
8232 \newcommand{\makethanksmarkhook}{}
8233
8234 % \end{macrocode}
8235 % \end{macro}
8236 %
8237 % \begin{macro}{\thanksfootmark}
8238 % This typesets the thanks footnote mark.
8239 % \changes{v1.2}{2002/08/10}{Complete rewrite of \cs{thanksfootmark}}
8240 % \begin{macrocode}
8241 \newcommand{\thanksfootmark}{%
8242 \ifdim\thanksmarkwidth < \z@
8243 % \end{macrocode}
8244 % Negative width, mark is in the margin.
8245 % \begin{macrocode}
8246 \llap{\hb@xt@ -\thanksmarkwidth{%
8247 \hss\normalfont\thanksscript{\tamark}}%
8248 \hspace*{-\thanksmarkwidth}}%
8249 \else
8250 \ifdim\thanksmarkwidth = \z@
8251 % \end{macrocode}
8252 % Zero width, mark is at (inside) the margin.
8253 % \begin{macrocode}
8254 {\normalfont\thanksscript{\tamark}}%
8255 \else
8256 % \end{macrocode}
8257 % Positive width.
8258 % \begin{macrocode}
8259 \hb@xt@\thanksmarkwidth{\hss\normalfont\thanksscript{\tamark}}%
8260 \fi
8261 \fi}
8262
8263 % \end{macrocode}
8264 % \end{macro}
8265 %
8266 % \begin{macro}{\makethanksmark}
8267 % This sets the general indentations for the thanks footnote,
8268 % and typesets the mark. The code is a simplified version of that
8269 % for typesetting ToC entries.
8270 % \changes{v1.2}{2002/08/10}{Minor changes to \cs{makethanksmark}}
8271 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{makethanksmark}}
8272 % \changes{v1.61803398b}{2009/09/21}{fixed typo, \cs{thanksmarksep}
8273 % not \cs{thanksmark}}
8274 % \begin{macrocode}
8275 \newcommand{\makethanksmark}{%
8276 \leavevmode%
8277 \parindent 1em\noindent
8278 \memRTLleftskip\thanksmarksep\relax
8279 \advance\memRTLleftskip\thanksmarkwidth
8280 \null\nobreak\hskip-\memRTLleftskip\relax
8281 \makethanksmarkhook\relax
8282 \thanksfootmark}
8283
8284 % \end{macrocode}
8285 % \end{macro}
8286 %
8287 % \begin{macro}{\usethanksrule}
8288 % \begin{macro}{\cancelhanksrule}
8289 % Simple macros that let \cs{footnoterule} to another rule definition.
8290 % \begin{macrocode}
8291 \newcommand{\usethanksrule}{\let\footnoterule\thanksrule}
8292 \newcommand{\cancelthanksrule}{\let\footnoterule\@bsfootnoterule}
8293
8294 % \end{macrocode}
8295 % \end{macro}
8296 % \end{macro}
8297 %
8298 %
8299 % Now set up the rest of the thanks defaults, styling having been
8300 % done earlier.
8301 % \begin{macrocode}
8302 \thanksmarkseries{fnsymbol} % symbols
8303 \thanksheadextra{}{}
8304 \setlength{\thanksmarkwidth}{1.8em}
8305 \setlength{\thanksmarksep}{-\thanksmarkwidth}
8306
8307 % \end{macrocode}
8308 % \begin{macro}{\thanksrule}
8309 % \begin{macro}{\@bsfootnoterule}
8310 % These are saved versions of the \cs{footnoterule} definition as it
8311 % is at the end of the preamble.
8312 % \begin{macrocode}
8313 \AtBeginDocument{%
8314 \let\thanksrule\footnoterule
8315 \let\@bsfootnoterule\footnoterule
8316 }
8317
8318 % \end{macrocode}
8319 % \end{macro}
8320 % \end{macro}
8321 %
8322 % \begin{macro}{\droptitle}
8323 % A titling block has \cs{droptitle} amount of additional vertical space
8324 % above it (normally zero).
8325 % \begin{macrocode}
8326 \newlength{\droptitle}
8327 \setlength{\droptitle}{0pt}
8328
8329 % \end{macrocode}
8330 % \end{macro}
8331 %
8332 % \begin{macro}{\maketitle}
8333 % The following is a
8334 % modification of \cs{maketitle} as in the \Lpack{article}, \Lpack{report},
8335 % and \Lpack{book} classes. It sets the pagestyle to \pstyle{title}
8336 % and as a default sets \pstyle{title} to point to \pstyle{plain}.
8337 % \changes{v1.4}{2004/01/21}{Removed the \cs{rlap} from \cs{@makefnmark}
8338 % in \cs{maketitle} so multiple \cs{thanks}
8339 % work per \cs{footnote}}
8340 % \changes{v1.618}{2005/09/03}{Fix to remove extra blank page when
8341 % \cs{maketitle} (and \cs{@maketitle}) is used within adjustwidth
8342 % inside a titlingpage (mempatch v3.2)}
8343 % \begin{macrocode}
8344 \newcommand{\maketitle}{\par
8345 \begingroup
8346 \@bsmarkseries
8347 \def\@makefnmark{\@textsuperscript{%
8348 \normalfont\@bsthanksheadpre \tamark \@bsthanksheadpost}}%
8349 \long\def\@makefntext##1{\makethanksmark ##1}
8350 \if@twocolumn
8351 \ifnum \col@number=\@ne
8352 \@maketitle
8353 \else
8354 \twocolumn[\@maketitle]%
8355 \fi
8356 \else
8357 \ifdim\pagetotal>\z@
8358 \newpage
8359 \fi
8360 \global\@topnum\z@
8361 \@maketitle
8362 \fi
8363 \thispagestyle{title}\@thanks
8364 \endgroup
8365 \@bscontmark % \setcounter{footnote}{0}%
8366 }
8367 \aliaspagestyle{title}{plain}
8368
8369 % \end{macrocode}
8370 % \end{macro}
8371 %
8372 % \begin{macro}{\@mem@titlefootkill}
8373 % \cs{@mem@titlefootkill}\marg{note} Warn about footnotes in titles.
8374 % \begin{macrocode}
8375 \newcommand*{\@mem@titlefootkill}[1]{%
8376 \@memwarn{Do not use \string\footnote\space in
8377 \string\maketitle.\MessageBreak
8378 Use \protect\thanks\space instead}}
8379
8380 % \end{macrocode}
8381 % \end{macro}
8382 %
8383 % \begin{macro}{\@maketitle}
8384 % Our version of \cs{@maketitle}.
8385 % Footnotes are killed in the title; see the thread `\cs{title}, \cs{author}
8386 % and \cs{footnote} feature in memoir class', February 2003.
8387 % \changes{v1.4}{2003/11/16}{Killed footnote in titles (from patch v1.4)}
8388 % \begin{macrocode}
8389 \newcommand{\@maketitle}{%
8390 \let\footnote\@mem@titlefootkill
8391 \ifdim\pagetotal>\z@
8392 \newpage
8393 \fi
8394 \null
8395 \vskip 2em%
8396 \vspace*{\droptitle}
8397 \maketitlehooka
8398 {\@bspretitle \@title \@bsposttitle}
8399 \maketitlehookb
8400 {\@bspreauthor \@author \@bspostauthor}
8401 \maketitlehookc
8402 {\@bspredate \@date \@bspostdate}
8403 \maketitlehookd
8404 \par
8405 \vskip 1.5em}
8406
8407 % \end{macrocode}
8408 % \end{macro}
8409 %
8410 % \begin{environment}{mem@titlingpage}
8411 % \begin{environment}{titlingpage}
8412 % \begin{environment}{titlingpage*}
8413 % \begin{macro}{\titlingpageend}
8414 % \begin{macro}{\settitlingpagenumbering}
8415 % The \Lenv{titlingpage} environment sets the pagestyle to be \pstyle{titlingpage},
8416 % disables the footnote rule and ensures that the page is single
8417 % column. At the end it switches back to twocolumn if neccessary,
8418 % and then starts a new page as number 1. On the other hand
8419 % \Lenv{titlingpage*}, does \emph{not} reset the page counter.
8420 %
8421 % At the end of the titlingpage we clear the page to let the next data
8422 % start on a new page. However there is a slight complication
8423 % here. Should we clear to next page or to next righthand page. One
8424 % could argue that under \Lopt{twoside} going to next right hand page
8425 % would be best, but then there is also \Lopt{openany}. In order to
8426 % make this configurable we will factor this out in a configurable
8427 % macro, and leave the defaults as they are so not to mess with
8428 % existing documents.
8429 % \changes{v3.6k}{2012/12/24}{Added \Lenv{titlingpage*} env}
8430 % \changes{v3.7g}{2018/03/06}{Added \cs{titlingpageend}}
8431 % \begin{macrocode}
8432 \NewDocumentCommand\settitlingpagenumbering{m}
8433 { \def\mem@titlingpage@numbering{#1} }
8434 \settitlingpagenumbering\arabic
8435
8436 \newcommand\titlingpageend[2]{%
8437 \def\mem@titlingpage@clear@for@twoside{#1}%
8438 \def\mem@titlingpage@clear@for@oneside{#2}%
8439 }
8440 % default
8441 \titlingpageend{\cleardoublepage}{\clearpage}
8442 \newenvironment{mem@titlingpage}%
8443 {\let\footnoterule\relax
8444 \let\footnotesize\small
8445 \def\thepage{\mem@titlingpage@numbering{page}}
8446 \if@twocolumn
8447 \@restonecoltrue\onecolumn
8448 \else
8449 \@restonecolfalse
8450 \fi
8451 \thispagestyle{titlingpage}%
8452 \if\mem@titlpg@reset\setcounter{page}{\@ne}\fi%
8453 }{%
8454 \thispagestyle{titlingpage}%
8455 \if@restonecol \twocolumn \fi
8456 % \if@twoside \cleardoublepage \else \clearpage \fi
8457 \if@twoside \mem@titlingpage@clear@for@twoside \else \mem@titlingpage@clear@for@oneside \fi
8458 \if\mem@titlpg@reset\setcounter{page}{\@ne}\fi}
8459 \newenvironment{titlingpage}{%
8460 \def\mem@titlpg@reset{00}%
8461 \begin{mem@titlingpage}}{%
8462 \end{mem@titlingpage}}
8463 \newenvironment{titlingpage*}{%
8464 \def\mem@titlpg@reset{01}%
8465 \begin{mem@titlingpage}}{%
8466 \end{mem@titlingpage}}
8467 \aliaspagestyle{titlingpage}{empty}
8468
8469 % \end{macrocode}
8470 % \end{macro}
8471 % \end{macro}
8472 % \end{environment}
8473 % \end{environment}
8474 % \end{environment}
8475 %
8476 % \begin{macro}{\emptythanks}
8477 % This macro discards all prior \cs{thanks} texts.
8478 % \begin{macrocode}
8479 \newcommand{\emptythanks}{\global\let\@thanks\@empty}
8480
8481 % \end{macrocode}
8482 % \end{macro}
8483 %
8484 % \begin{macro}{\andnext}
8485 % The kernel \cs{and} macro puts space between author's names. The
8486 % \cs{andnext} macro puts a newline between the names.
8487 % \changes{v1.6}{2004/01/28}{Added \cs{andnext}}
8488 % \begin{macrocode}
8489 \newcommand*{\andnext}{%
8490 \end{tabular}\\ \begin{tabular}[t]{c}}
8491
8492 % \end{macrocode}
8493 % \end{macro}
8494 %
8495 % \begin{macro}{\@bsmtitlempty}
8496 % \cs{@bsmtitlempty} is a helper macro to save some macro space.
8497 % It empties some elements of \cs{maketitle}.
8498 % \changes{v3.6k}{2012/07/01}{Removed \cs{thanksfootextra}, seems to
8499 % have been forgotten back in 2003.}
8500 % \begin{macrocode}
8501 \newcommand{\@bsmtitlempty}{%
8502 \global\let\maketitle\relax
8503 \global\let\@maketitle\relax
8504 \global\let\title\relax
8505 \global\let\author\relax
8506 \global\let\date\relax
8507 \global\let\thanksmarkseries\relax
8508 \global\let\thanksfootextra\relax
8509 \global\let\thanksmark\relax
8510 \global\let\thanksgap\relax}
8511
8512 % \end{macrocode}
8513 % \end{macro}
8514 %
8515 % \begin{macro}{\keepthetitle}
8516 % This macro undefines all the titling commands except for
8517 % \cs{thetitle}, \cs{theauthor} and \cs{thedate}.
8518 % \changes{v1.6}{2004/01/28}{changed \cs{keepthetitle} to cater for \cs{andnext}}
8519 % \begin{macrocode}
8520 \newcommand{\keepthetitle}{%
8521 \@bsmtitlempty
8522 \global\let\thanks\relax
8523 \global\let\and\relax
8524 \global\let\andnext\relax
8525 \global\let\@thanks\@empty
8526 \global\let\@title\@empty
8527 \global\let\@author\@empty
8528 \global\let\@date\@empty}
8529
8530 % \end{macrocode}
8531 % \end{macro}
8532 %
8533 % \begin{macro}{\killtitle}
8534 % \cs{killtitle} undefines the remaining macros of \cs{maketitle}.
8535 % \begin{macrocode}
8536 \newcommand{\killtitle}{%
8537 \keepthetitle
8538 \global\let\thetitle\relax
8539 \global\let\theauthor\relax
8540 \global\let\thedate\relax}
8541
8542 % \end{macrocode}
8543 % \end{macro}
8544 %
8545 %
8546 % \begin{macro}{\thetitle}
8547 % \begin{macro}{\theauthor}
8548 % \begin{macro}{\thedate}
8549 % In order to make the \cs{title}, etc., values available for printing
8550 % their definitions (in \file{ltsect.dtx}) need extending to save their
8551 % arguments. We have to make sure that extraneous material,
8552 % like \cs{thanks}, is excluded from the saved texts.
8553 % \changes{v1.4}{2003/11/16}{Gobble footnotes in \cs{title}, \cs{author}
8554 % and \cs{date} (from patch v1.4)}
8555 % \changes{v1.6}{2004/01/28}{Added \cs{andnext} handling to \cs{author}}
8556 % \changes{v3.8.3}{2024/02/02}{The changes to \cs{title}, \cs{author} and \cs{date} now moved to be done via \Lpack{xpatch}. }
8557 % \begin{macrocode}
8558 % \addtoiargdef{\title}{%
8559 % \begingroup\let\footnote\@gobble}{%
8560 % \begingroup
8561 % \renewcommand{\thanks}[1]{}
8562 % \renewcommand{\thanksmark}[1]{}
8563 % \renewcommand{\thanksgap}[1]{}
8564 % \protected@xdef\thetitle{#1}
8565 % \endgroup\endgroup}
8566
8567 \xpretocmd\title{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\title\space failed, please inform maintainer}}
8568 \xapptocmd\title{
8569 \begingroup%
8570 \renewcommand{\thanks}[1]{}%
8571 \renewcommand{\thanksmark}[1]{}%
8572 \renewcommand{\thanksgap}[1]{}%
8573 \protected@xdef\thetitle{#1}%
8574 \endgroup\endgroup%
8575 }{}{\typeout{patch 2 to \string\title\space failed, please inform maintainer}}
8576
8577 % \addtoiargdef{\author}{%
8578 % \begingroup\let\footnote\@gobble}{%
8579 % \begingroup
8580 % \renewcommand{\thanks}[1]{}
8581 % \renewcommand{\and}{\unskip, }
8582 % \renewcommand{\andnext}{\unskip, }
8583 % \renewcommand{\thanksmark}[1]{}
8584 % \renewcommand{\thanksgap}[1]{}
8585 % \protected@xdef\theauthor{#1}
8586 % \endgroup\endgroup}
8587
8588 \xpretocmd\author{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
8589 \xapptocmd\author{%
8590 \begingroup%
8591 \renewcommand{\thanks}[1]{}%
8592 \renewcommand{\and}{\unskip, }%
8593 \renewcommand{\andnext}{\unskip, }%
8594 \renewcommand{\thanksmark}[1]{}%
8595 \renewcommand{\thanksgap}[1]{}%
8596 \protected@xdef\theauthor{#1}%
8597 \endgroup\endgroup%
8598 }{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
8599
8600 % \addtoiargdef{\date}{%
8601 % \begingroup\let\footnote\@gobble}{%
8602 % \begingroup
8603 % \renewcommand{\thanks}[1]{}
8604 % \renewcommand{\thanksmark}[1]{}
8605 % \renewcommand{\thanksgap}[1]{}
8606 % \protected@xdef\thedate{#1}
8607 % \endgroup\endgroup}
8608
8609 \xpretocmd\date{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\date\space failed, please inform maintainer}}
8610 \xapptocmd\date{%
8611 \begingroup%
8612 \renewcommand{\thanks}[1]{}%
8613 \renewcommand{\thanksmark}[1]{}%
8614 \renewcommand{\thanksgap}[1]{}%
8615 \protected@xdef\thedate{#1}%
8616 \endgroup\endgroup%
8617 }{}{\typeout{patch 2 to \string\date\space failed, please inform maintainer}}
8618
8619 % \end{macrocode}
8620 % \end{macro}
8621 % \end{macro}
8622 % \end{macro}
8623 %
8624 %
8625 %
8626 % \section{Parts, chapters and other divisions}
8627 %
8628 % \subsection{Building blocks} The definitions in this part of a
8629 % class file usually make use of two internal macros, \cs{@startsection} and
8630 % \cs{secdef}. To understand
8631 % what is going on here, we describe their syntax.
8632 %
8633 % \DescribeMacro{\@startsection}
8634 % The macro \cs{@startsection} has 6 required arguments, optionally
8635 % followed by a $*$, an optional argument and a required argument:
8636 %
8637 % \cs{@startsection}\meta{name}\meta{level}\meta{indent}^^A
8638 % \meta{beforeskip}\meta{afterskip}\meta{style}
8639 % optional * %\\
8640 % \null\hphantom{\bslash @startsection}^^A
8641 % \oarg{altheading}\meta{heading}
8642 %
8643 % It is a generic command to start a section, the arguments have
8644 % the following meaning:
8645 %
8646 % \begin{description}
8647 % \item[\meta{name}] The name of the user level command, e.g.,
8648 % `section'.
8649 % \item[\meta{level}] A number, denoting the depth of the section
8650 % --- e.g., chapter = 0, section = 1, etc. A section number
8651 % will be printed if and only if \meta{level} $<=$ the value
8652 % of the \Lcount{secnumdepth} counter.
8653 % \item[\meta{indent}] The indentation of the heading from the left
8654 % margin
8655 % \item[\meta{beforeskip}] The absolute value of this argument
8656 % gives the skip to leave above the heading. If it is
8657 % negative, then the paragraph indent of the text following
8658 % the heading is suppressed.
8659 % \item[\meta{afterskip}] If positive, this gives the skip to leave
8660 % below the heading, else it gives the skip to leave to the
8661 % right of a run-in heading.
8662 % \item[\meta{style}] Commands to set the style of the heading.
8663 % \item[$*$] When this is missing the heading is numbered and the
8664 % corresponding counter is incremented.
8665 % \item[\meta{altheading}] Gives an alternative heading to use in
8666 % the table of contents and in the running heads. This should
8667 % be present when the $*$ form is used.
8668 % \item[\meta{heading}] The heading of the new section.
8669 % \end{description}
8670 % A sectioning command is normally defined to \cs{@startsection} and
8671 % its first six arguments.
8672 %
8673 % \DescribeMacro{\secdef}
8674 % The macro \cs{secdef} can be used when a sectioning command is
8675 % defined without using \cs{@startsection}. It has two arguments:
8676 %
8677 % \cs{secdef}\meta{unstarcmds}\meta{starcmds}
8678 %
8679 % \begin{description}
8680 % \item[\meta{unstarcmds}] Used for the normal form of a
8681 % sectioning command.
8682 % \item[\meta{starcmds}] Used for the $*$-form of a
8683 % sectioning command.
8684 % \end{description}
8685 %
8686 % You can use \cs{secdef} as follows:
8687 % \begin{verbatim}
8688 % \def\chapter { ... \secdef \CMDA \CMDB }
8689 % \def\CMDA [#1]#2{ ... } % Command to define
8690 % % \chapter[...]{...}
8691 % \def\CMDB #1{ ... } % Command to define
8692 % % \chapter*{...}
8693 % \end{verbatim}
8694 %
8695 % \DescribeMacro{\@hangfrom}
8696 % Internally the \cs{@startsection} macro uses \verb?\@hangfrom{NUM}?, where
8697 % \verb?NUM? is the sectional number, to produce a hanging paragraph. That is,
8698 % the second and later lines of a multiline title are indented from the
8699 % left margin by the width of the number.
8700 % The definition of \cs{@hangfrom}, from \file{ltsect.dtx}, is:
8701 % \begin{verbatim}
8702 % \def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
8703 % \hangindent \wd\@tempboxa\noindent\box\@tempboxa}
8704 % \end{verbatim}
8705 %
8706 % To get a normal paragraphed title you can do: \\
8707 % \verb?\renewcommand{\@hangfrom}[1]{#1}? \\
8708 % or as a block paragraph: \\
8709 % \verb?\renewcommand{\@hangfrom}[1]{\noindent #1}? \\
8710 %
8711 % \DescribeMacro{\@seccntformat}
8712 % The \cs{@startsection} macro also uses \verb?\@seccntformat{NUM}? to format
8713 % the section number, including the space after it. Its definition,
8714 % from \file{ltsect.dtx}, is
8715 % \begin{verbatim}
8716 % \def\@seccntformat#1{\csname the#1\endcsname\quad}
8717 % \end{verbatim}
8718 % This is the command to change if you need different number formatting. For
8719 % example the combination
8720 % \begin{verbatim}
8721 % \renewcommand{\@seccntformat}[1]{\llap{\csname the#1\endcsname\quad}}
8722 % \renewcommand{\@hangfrom}[1]{\noindent #1}
8723 % \end{verbatim}
8724 % will hang the section numbers in the margin.
8725 %
8726 % \begin{table}
8727 % \centering
8728 % \caption{Document division levels}\label{tab:levels}
8729 % \medskip
8730 % \begin{tabular}{lr} \hline
8731 % Division & Level \\ \hline
8732 % book & -2 \\
8733 % part & -1 \\
8734 % chapter & 0 \\
8735 % section & 1 \\
8736 % subsection & 2 \\
8737 % subsubsection & 3 \\
8738 % paragraph & 4 \\
8739 % subparagraph & 5 \\
8740 % \hline
8741 % \end{tabular}
8742 % \end{table}
8743 %
8744 % The values used for the document division levels are the same
8745 % as defined by the standard \LaTeX{} classes, with the exception
8746 % of the book division which is a memoir addition, and are given in
8747 % Table~\ref{tab:levels}.
8748 % \changes{v1.61803}{2008/01/30}{Added book division (from mempatch v4.4)}
8749 % \subsection{Mark commands}
8750 %
8751 % \begin{macro}{\bookpagemark}
8752 % \begin{macro}{\partmark}
8753 % \begin{macro}{\chaptermark}
8754 % \begin{macro}{\sectionmark}
8755 % \begin{macro}{\subsectionmark}
8756 % \begin{macro}{\subsubsectionmark}
8757 % \begin{macro}{\paragraphmark}
8758 % \begin{macro}{\subparagraphmark}
8759 % The default initialisations of the \cs{...mark} commands for use
8760 % in the pagestyles. Most are already defined in the kernel but they
8761 % are all noted here. In the rare occasion that there are text
8762 % between, say, a \cs{part} and a \cs{chapter}, the header from the
8763 % previous chapter may spill into this text. Therefore two marks
8764 % \cs{bookpagemark} and \cs{partmark} should default to resettting
8765 % the marks.
8766 % \changes{3.8.3}{2025/02/25}{Changed the default for \cs{partmark} and \cs{bookpagemark}}
8767 % \begin{macrocode}
8768 \newcommand*{\bookpagemark}[1]{\markboth{}{}}
8769 \newcommand*{\partmark}[1]{\markboth{}{}}
8770 \newcommand*{\chaptermark}[1]{}
8771 % \newcommand*{\sectionmark}[1]{}
8772 % \newcommand*{\subsectionmark}[1]{}
8773 % \newcommand*{\subsubsectionmark}[1]{}
8774 % \newcommand*{\paragraphmark}[1]{}
8775 % \newcommand*{\subparagraphmark}[1]{}
8776
8777 % \end{macrocode}
8778 % \end{macro}
8779 % \end{macro}
8780 % \end{macro}
8781 % \end{macro}
8782 % \end{macro}
8783 % \end{macro}
8784 % \end{macro}
8785 % \end{macro}
8786 %
8787 % \begin{macro}{\bibmark}
8788 % Marks for the bibliography, which may be filled with \cs{bibname}.
8789 % \changes{v1.1}{2002/03/10}{Added \cs{bibmark}}
8790 % \begin{macrocode}
8791 \newcommand*{\bibmark}{}
8792 % \end{macrocode}
8793 % \end{macro}
8794 %
8795 % \begin{macro}{\indexmark}
8796 % Marks for the index, which may be filled with \cs{indexname}.
8797 % \changes{v1.1}{2002/03/10}{Added \cs{indexmark}}
8798 % \begin{macrocode}
8799 \newcommand*{\indexmark}{}
8800 % \end{macrocode}
8801 % \end{macro}
8802 %
8803 % \begin{macro}{\glossarymark}
8804 % Marks for the glossary, which may be filled with \cs{glossaryname}.
8805 % \changes{v1.618}{2005/09/25}{Added \cs{glossarymark}}
8806 % \begin{macrocode}
8807 \newcommand*{\glossarymark}{}
8808
8809 % \end{macrocode}
8810 % \end{macro}
8811 %
8812 %
8813 % \subsection{Define Counters}
8814 %
8815 % \begin{macro}{\c@secnumdepth}
8816 % The value of the counter \Lcount{secnumdepth} gives the depth of
8817 % the highest-level sectioning command that is to produce section
8818 % numbers.
8819 % \begin{macrocode}
8820 \setcounter{secnumdepth}{2}
8821 % \end{macrocode}
8822 % \end{macro}
8823 %
8824 % \begin{macro}{\c@book}
8825 % \begin{macro}{\c@part}
8826 % \begin{macro}{\c@chapter}
8827 % \begin{macro}{\c@section}
8828 % \begin{macro}{\c@subsection}
8829 % \begin{macro}{\c@subsubsection}
8830 % \begin{macro}{\c@paragraph}
8831 % \begin{macro}{\c@subparagraph}
8832 % These counters are used for the sectioning numbers. The macro\\
8833 % \cs{newcounter}\marg{newctr}\oarg{oldctr}\\
8834 % defines\meta{newctr} to be a counter, which is reset to zero when
8835 % counter \meta{oldctr} is stepped. Counter \meta{oldctr} must
8836 % already be defined.
8837 %
8838 % Book, part and chapter are the top level document divisions.
8839 % \begin{macrocode}
8840 \newcounter{book} \setcounter{book}{0}
8841 \newcounter{part} \setcounter{part}{0}
8842 \newcounter{chapter} \setcounter{chapter}{0}
8843 % \end{macrocode}
8844 % The lower level divisions get reset by higher level divisions.
8845 % \begin{macrocode}
8846 \newcounter{section}[chapter]
8847 \newcounter{subsection}[section]
8848 \newcounter{subsubsection}[subsection]
8849 \newcounter{paragraph}[subsubsection]
8850 \newcounter{subparagraph}[paragraph]
8851 % \end{macrocode}
8852 % \end{macro}
8853 % \end{macro}
8854 % \end{macro}
8855 % \end{macro}
8856 % \end{macro}
8857 % \end{macro}
8858 % \end{macro}
8859 % \end{macro}
8860 %
8861 % \begin{macro}{\thebook}
8862 % \begin{macro}{\thepart}
8863 % \begin{macro}{\thechapter}
8864 % \begin{macro}{\thesection}
8865 % \begin{macro}{\thesubsection}
8866 % \begin{macro}{\thesubsubsection}
8867 % \begin{macro}{\theparagraph}
8868 % \begin{macro}{\thesubparagraph}
8869 % For any counter \Lcount{CTR}, \cs{theCTR} is a macro that defines
8870 % the printed version of counter \Lcount{CTR}. It is defined in
8871 % terms of the following macros:
8872 %
8873 % \cs{arabic}\marg{COUNTER} prints the value of
8874 % \meta{COUNTER} as an arabic numeral.
8875 %
8876 % \cs{roman}\marg{COUNTER} prints the value of
8877 % \meta{COUNTER} as a lowercase roman numeral.
8878 %
8879 % \cs{Roman}\marg{COUNTER} prints the value of
8880 % \meta{COUNTER} as an uppercase roman numeral.
8881 %
8882 % \cs{alph}\marg{COUNTER} prints the value of \meta{COUNTER}
8883 % as a lowercase letter: $1 =$~a, $2 =$~ b, etc.
8884 %
8885 % \cs{Alph}\marg{COUNTER} prints the value of \meta{COUNTER}
8886 % as an uppercase letter: $1 =$~A, $2 =$~B, etc.
8887 %
8888 % \begin{macrocode}
8889 \renewcommand*{\thebook}{\@Roman\c@book}
8890 \renewcommand*{\thepart}{\@Roman\c@part}
8891 \renewcommand*{\thechapter}{\@arabic\c@chapter}
8892 \renewcommand*{\thesection}{\thechapter.\@arabic\c@section}
8893 \renewcommand*{\thesubsection}{%
8894 \thesection.\@arabic\c@subsection}
8895 \renewcommand*{\thesubsubsection}{%
8896 \thesubsection.\@arabic\c@subsubsection}
8897 \renewcommand*{\theparagraph}{%
8898 \thesubsubsection.\@arabic\c@paragraph}
8899 \renewcommand*{\thesubparagraph}{%
8900 \theparagraph.\@arabic\c@subparagraph}
8901 % \end{macrocode}
8902 % \end{macro}
8903 % \end{macro}
8904 % \end{macro}
8905 % \end{macro}
8906 % \end{macro}
8907 % \end{macro}
8908 % \end{macro}
8909 % \end{macro}
8910 %
8911 % \begin{macro}{\@chapapp}
8912 % \cs{@chapapp} is initially defined as \cs{chaptername}. The \cs{appendix}
8913 % command redfines it as \cs{appendixname}.
8914 % \begin{macrocode}
8915 \newcommand{\@chapapp}{\chaptername}
8916
8917 % \end{macrocode}
8918 % \end{macro}
8919 %
8920 % \subsection{Front, main and back matter}
8921 %
8922 % These are the three main logical divisions in a book. As noted earlier,
8923 % the boolean \cs{if@mainmatter} is TRUE iff the main matter is being
8924 % processed. Chapters will be unnumbered when \cs{if@mainmatter} is FALSE.
8925 %
8926 % \begin{macro}{\frontmatter}
8927 % \begin{macro}{\frontmatter*}
8928 % The \cs{frontmatter} command starts roman numbering and turns off
8929 % chapter numbering. It ensures that lower level divisions will not
8930 % have chapter numbers, nor will figures or tables. It also ensures
8931 % that the next page will be recto. The starred version makes no
8932 % changes to the page numbering\footnote{The starred versions were
8933 % added to meet a request by Daniel Richard G. in September 2001.}.
8934 % \changes{v0.3}{2001/07/09}{\cs{frontmatter} switches off numbering via
8935 % the secnumdepth counter}
8936 % \changes{v1.0}{2001/09/21}{Added \cs{frontmatter*} command}
8937 % \begin{macrocode}
8938 \newcommand{\frontmatter}{%
8939 \@ifstar{\@smemfront}{\@memfront}}
8940 % \end{macrocode}
8941 % \begin{macro}{\@memfront@floats}
8942 % \changes{v1.6180339f}{Added \cs{@memfront@floats}}
8943 % Factoring out the float counter domination, in case someone wants
8944 % something added or changed
8945 % \begin{macrocode}
8946 \newcommand\@memfront@floats{%
8947 \counterwithout{figure}{chapter}
8948 \counterwithout{table}{chapter}
8949 }
8950 % \end{macrocode}
8951 % \end{macro}
8952 % \begin{macro}{\@smemfront}
8953 % \begin{macrocode}
8954 \newcommand{\@smemfront}{%
8955 \cleardoublepage
8956 \@mainmatterfalse
8957 \setcounter{secnumdepth}{-10}
8958 \@memfront@floats
8959 }
8960 % \end{macrocode}
8961 % \end{macro}
8962 % \begin{macro}{\@memfront}
8963 % \begin{macrocode}
8964 \newcommand{\@memfront}{%
8965 \@smemfront\pagenumbering{roman}}
8966
8967 % \end{macrocode}
8968 % \end{macro}
8969 % \end{macro}
8970 % \end{macro}
8971 %
8972 % \begin{macro}{\mainmatter}
8973 % \begin{macro}{\mainmatter*}
8974 % The \cs{mainmatter} command starts arabic numbering and turns on chapter numbering.
8975 % It sets numbering to the normal state. It
8976 % also ensures that the next page will be recto. The starred version does
8977 % not change the page numbering.
8978 %
8979 % Romano Giannetti suggested that \cs{mainmatter} (and \cs{backmatter}) should
8980 % be almost no-ops with the article option.
8981 % \changes{v0.3}{2001/07/09}{\cs{mainmatter} switches on section numbering
8982 % via the secnumdepth counter}
8983 % \changes{v1.0}{2001/09/21}{Added \cs{mainmatter*} command}
8984 % \begin{macrocode}
8985 \newcommand{\mainmatter}{%
8986 \@ifstar{\@smemmain}{\@memmain}}
8987 % \end{macrocode}
8988 % \end{macro}
8989 % \end{macro}
8990 %
8991 % \begin{macro}{\@memmain@floats}
8992 % \changes{v1.6180339f}{}{Added \cs{@memmain@floats}}
8993 % Factoring out the float counter domination, in case someone wants
8994 % something added or changed
8995 % \begin{macrocode}
8996 \newcommand\@memmain@floats{%
8997 \counterwithin{figure}{chapter}
8998 \counterwithin{table}{chapter}
8999 }
9000 % \end{macrocode}
9001 % \end{macro}
9002 % \begin{macro}{\@smemmain}
9003 % If \cs{frontmatter} and \cs{mainmatter} are used with the article option,
9004 % then a page numbering / margin problem can occur if the frontmatter ends
9005 % on an odd page --- the first mainmatter next page is odd as well which throws
9006 % puts two odd-margined pages together.
9007 %
9008 % One fix from Morten is to always \cs{cleardoublepage} for twosided articles.
9009 %
9010 % One fix from me is for the ...matter macros to just switch on/off section
9011 % numbering.
9012 %
9013 % Morten's is simpler to implement.
9014 %
9015 % \changes{v1.1}{2002/03/10}{Modified \cs{@smemmain} to reset the secnumdepth
9016 % counter to maxsecnumdepth}
9017 % \changes{v1.4}{2003/11/22}{Included cognizance of article option in \cs{@smemmain}
9018 % (from patch v1.7)}
9019 % \changes{v1.61803}{2008/01/30}{Changed timing of \cs{clear[double]page} in
9020 % \cs{@smemmain} (David Wilson, mempatch v4.5)}
9021 % \changes{v1.61803}{2008/01/30}{Changed clear pages in \cs{@smemmain}
9022 % (mempatch v4.9)}
9023 % \begin{macrocode}
9024 \newcommand*{\@smemmain}{%
9025 \@mainmattertrue
9026 \setcounter{secnumdepth}{\value{maxsecnumdepth}}
9027 \ifartopt
9028 \if@twoside
9029 \cleardoublepage
9030 \else
9031 \clearpage
9032 \fi
9033 \else
9034 \cleardoublepage
9035 \@memmain@floats
9036 \fi}
9037 % \end{macrocode}
9038 % \end{macro}
9039 %
9040 % \begin{macro}{\@memmain}
9041 % \begin{macrocode}
9042 \newcommand{\@memmain}{%
9043 \@smemmain\pagenumbering{arabic}}
9044
9045 % \end{macrocode}
9046 % \end{macro}
9047 %
9048 % \begin{macro}{\@memback@floats}
9049 % \changes{v1.6180339f}{Added \cs{@memback@floats}}
9050 % Factoring out the float counter domination, in case someone wants
9051 % something added or changed
9052 % \begin{macrocode}
9053 \newcommand\@memback@floats{%
9054 \counterwithout{figure}{chapter}
9055 \counterwithout{table}{chapter}
9056 \setcounter{figure}{0}
9057 \setcounter{table}{0}
9058 }
9059 % \end{macrocode}
9060 % \end{macro}
9061 % \begin{macro}{\backmatter}
9062 % This command turns off chapter numbering but leaves the page numbering alone.
9063 % It twiddles the numbering caption numbering.
9064 % The back matter may start on any new page.
9065 % \changes{v0.3}{2001/07/09}{\cs{backmatter} uses the secnumdepth counter}
9066 % \changes{v1.4}{2003/11/22}{Included cognizance of article option in \cs{backmatter}
9067 % (from patch v1.7)}
9068 % \begin{macrocode}
9069 \newcommand{\backmatter}{%
9070 \ifartopt
9071 \clearpage
9072 \else
9073 \if@openright
9074 \cleardoublepage
9075 \else
9076 \clearpage
9077 \fi
9078 \fi
9079 \@mainmatterfalse
9080 \setcounter{secnumdepth}{-10}
9081 \ifartopt\else
9082 \@memback@floats
9083 \fi}
9084
9085 % \end{macrocode}
9086 % \end{macro}
9087 %
9088 %
9089 % \subsection{Book}
9090 %
9091 % This was added at the request of Frederic Connes who said that in
9092 % French typography there was often a division above the \cs{part} level.
9093 %
9094 % \begin{macro}{\theHbook}
9095 % \begin{macro}{\toclevel@book}
9096 % These are needed if the \Lpack{hyperref} is used.
9097 % \changes{v3.7.19}{2022/10/25}{Changing \cs{theH...} definitions to
9098 % \cs{def} for better compability with future hyperref}
9099 % \changes{v3.8}{2023/06/20}{Changed \cs{theHbook} to use
9100 % \cs{the}\cs{value\{counter\}} as packages can mess up \cs{arabic}
9101 % advise from Ulrike}
9102 % \begin{macrocode}
9103 \def\theHbook{\the\value{book}}
9104 \def\toclevel@book{-2}
9105
9106 % \end{macrocode}
9107 % \end{macro}
9108 % \end{macro}
9109 %
9110 % \begin{macro}{\book}
9111 % \begin{macro}{\book*}
9112 % \cs{book}\marg{title} starts a new book division called \meta{title}.
9113 % The actual typesetting of the title is done by \cs{@book} or \cs{@sbook}.
9114 % \changes{v1.61803}{2008/01/30}{Added \cs{book} and its entourage (mempatch v4.4)}
9115 % \begin{macrocode}
9116 \newcommand*{\book}{%
9117 \@setupbook
9118 \secdef\@book\@sbook}
9119 % \end{macrocode}
9120 % \end{macro}
9121 % \end{macro}
9122 %
9123 % \begin{macro}{\beforebookskip}
9124 % \begin{macro}{\midbookskip}
9125 % \begin{macro}{\afterbookskip}
9126 % These three macros are the skips before, in the middle, and after the
9127 % Book heading.
9128 % \begin{macrocode}
9129 \newcommand*{\beforebookskip}{\null\vfil}
9130 \newcommand*{\midbookskip}{\par\vskip 2\onelineskip}
9131 \newcommand*{\afterbookskip}{\vfil\newpage}
9132
9133 % \end{macrocode}
9134 % \end{macro}
9135 % \end{macro}
9136 % \end{macro}
9137 %
9138 % \begin{macro}{\@setupbook}
9139 % This macro does the work of setting up for the \cs{book} command.
9140 % A single column page, normally recto, with a \pstyle{book} pagestyle is
9141 % started.
9142 % \begin{macrocode}
9143 \newcommand{\@setupbook}{%
9144 \if@openright
9145 \cleardoublepage
9146 \else
9147 \clearpage
9148 \fi
9149 \thispagestyle{book}%
9150 \if@twocolumn
9151 \onecolumn
9152 \@tempswatrue
9153 \else
9154 \@tempswafalse
9155 \fi
9156 \beforebookskip}
9157
9158 % \end{macrocode}
9159 % \end{macro}
9160 %
9161 % \begin{macro}{\booknamefont}
9162 % \begin{macro}{\booknumfont}
9163 % \begin{macro}{\booktitlefont}
9164 % These three macros specify the fonts for the book name and number, and
9165 % for the book title, respectively.
9166 % \begin{macrocode}
9167 \newcommand*{\booknamefont}{\normalfont\huge\bfseries}
9168 \newcommand*{\booknumfont}{\normalfont\huge\bfseries}
9169 \newcommand*{\booktitlefont}{\normalfont\Huge\bfseries}
9170
9171 % \end{macrocode}
9172 % \end{macro}
9173 % \end{macro}
9174 % \end{macro}
9175 %
9176 % \begin{macro}{\printbookname}
9177 % \begin{macro}{\booknamenum}
9178 % \begin{macro}{\printbooknum}
9179 % \begin{macro}{\printbooktitle}
9180 % Macros to print the various books of a Book heading.
9181 % \begin{macrocode}
9182 \newcommand*{\printbookname}{\booknamefont \bookname}
9183 \newcommand*{\booknamenum}{\space}
9184 \newcommand*{\printbooknum}{\booknumfont \thebook}
9185 \newcommand*{\printbooktitle}[1]{\booktitlefont #1}
9186
9187 % \end{macrocode}
9188 % \end{macro}
9189 % \end{macro}
9190 % \end{macro}
9191 % \end{macro}
9192 %
9193 % \begin{macro}{\membookinfo}
9194 % \begin{macro}{\membookstarinfo}
9195 % Hooks. Arguments given for \cs{membookinfo} will be \cs{thebook}
9196 % (unless secnumdepth), the data for the toc and the title. The
9197 % argument for \cs{membookstarinfo} (starred version) will just be
9198 % the title.
9199 % \begin{macrocode}
9200 \newcommand{\membookinfo}[3]{}
9201 \newcommand{\membookstarinfo}[1]{}
9202
9203 % \end{macrocode}
9204 % \end{macro}
9205 % \end{macro}
9206 %
9207 %
9208 % \begin{macro}{\@book}
9209 % \cs{@book}\oarg{short}\marg{long} typesets the title of a \cs{book}
9210 % book. There is a number if \cs{secnumdepth} is greater than -3.
9211 % \begin{macrocode}
9212 \long\def\@book[#1]#2{%
9213 \M@gettitle{#1}%
9214 % \end{macrocode}
9215 % For continuity we store the toc entry in \verb?\f@rtoc? before
9216 % writing it to the \verb?.toc? file. We also provide a hook to be
9217 % able to transform it.
9218 % \changes{v3.6k}{2012/09/18}{Provided \cs{f@rtoc} and hook}
9219 % \changes{v3.6k}{2013/04/24}{Added \cs{mempreaddbooktotochook} and \cs{mempostaddbooktotochook}}
9220 % \changes{v3.8.4}{2025/09/16}{Replacedd \cs{phantomsection} with \cs{MakeLinkTarget} and moved it to unnumbered branch}
9221 % \begin{macrocode}
9222 \def\f@rtoc{#1}%
9223 \@nameuse{book@f@rtoc@before@write@hook}%
9224 % \phantomsection
9225 \mempreaddbooktotochook
9226 \ifnum \c@secnumdepth >-3\relax
9227 \refstepcounter{book}%
9228 \addcontentsline{toc}{book}%
9229 {\protect\booknumberline{\thebook}\f@rtoc}%
9230 \membookinfo{\thebook}{\f@rtoc}{#2}%
9231 \else
9232 \MakeLinkTarget[book]{}%
9233 \addcontentsline{toc}{book}{\f@rtoc}%
9234 \membookinfo{}{\f@rtoc}{#2}%
9235 \fi
9236 \mempostaddbooktotochook
9237 % \end{macrocode}
9238 % Empty the marks, center the title on the page, and set the normal font.
9239 % \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero, such that a
9240 % non-zero \cs{parskip} does not interfer with the title layout}
9241 % \begin{macrocode}
9242 \bookpagemark{#1}%
9243 {\centering
9244 \interlinepenalty \@M
9245 \parskip\z@
9246 \normalfont
9247 % \end{macrocode}
9248 % Print the number, if there is one, then the title below. Macro \cs{@endbook}
9249 % tidies everything up at the end.
9250 % \begin{macrocode}
9251 \ifnum \c@secnumdepth >-3\relax
9252 \printbookname \booknamenum \printbooknum
9253 \midbookskip
9254 \fi
9255 \printbooktitle{#2}\par}%
9256 \@endbook}
9257
9258 % \end{macrocode}
9259 % \end{macro}
9260 %
9261 % \begin{macro}{\mempreaddbooktotochook}
9262 % \begin{macro}{\mempostaddbooktotochook}
9263 % Hooks executed just before and just after \cs{book} adds something
9264 % to the ToC. Does nothing by default
9265 % \begin{macrocode}
9266 \newcommand\mempreaddbooktotochook{}
9267 \newcommand\mempostaddbooktotochook{}
9268
9269 % \end{macrocode}
9270 % \end{macro}
9271 % \end{macro}
9272 %
9273 % \begin{macro}{\@sbook}
9274 % \cs{@sbook}\marg{long} formats the title of a \cs{book*} book. It is
9275 % simpler than \cs{@book} because there is no number to print.
9276 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@sbook}}
9277 % \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero here as well}
9278 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget}}
9279 % \begin{macrocode}
9280 \long\def\@sbook#1{%
9281 \M@gettitle{#1}%
9282 % \phantomsection
9283 \MakeLinkTarget[book]{}%
9284 \membookstarinfo{#1}%
9285 {\centering
9286 \interlinepenalty \@M
9287 \parskip\z@
9288 \normalfont
9289 \printbooktitle{#1}\par}%
9290 \@endbook}
9291
9292 % \end{macrocode}
9293 % \end{macro}
9294 %
9295 % \begin{macro}{\ifm@mnobooknewpage}
9296 % \begin{macro}{\m@mnobooknewpagetrue}
9297 % \begin{macro}{\m@mnobooknewpagefalse}
9298 % \begin{macro}{\bookblankpage}
9299 % \begin{macro}{\nobookblankpage}
9300 % The declaration \cs{nobookblankpage} prevents \cs{book} from
9301 % outputting a further (blank) page when it finishes. The default is set by
9302 % \cs{bookblankpage}.
9303 % \begin{macrocode}
9304 \newif\ifm@mnobooknewpage
9305 \m@mnobooknewpagefalse
9306 \newcommand*{\bookblankpage}{\m@mnobooknewpagefalse}
9307 \newcommand*{\nobookblankpage}{\m@mnobooknewpagetrue}
9308
9309 % \end{macrocode}
9310 % \end{macro}
9311 % \end{macro}
9312 % \end{macro}
9313 % \end{macro}
9314 % \end{macro}
9315 %
9316 % \begin{macro}{\bookpageend}
9317 % \begin{macro}{\@endbook}
9318 % This finishes off both \cs{@book} and \cs{@sbook}.
9319 % Following a \cs{nobookblankpage} nothing is done, otherwise
9320 % (after \cs{bookblankpage}) the current page is flushed,
9321 % and an extra blank page is created if both \Lopt{twoside} and
9322 % \Lopt{openright} are in effect.
9323 % At the end, if necessary, two column mode is switched back on.
9324 % \changes{v1.61803398}{2009/07/26}{PW: Added \cs{bookpageend} as cover for \cs{@endbook}}
9325 % \begin{macrocode}
9326 \newcommand*{\bookpageend}{\afterbookskip
9327 \ifm@mnobooknewpage
9328 \else
9329 \if@twoside
9330 \if@openright
9331 \null
9332 \thispagestyle{afterbook}%
9333 \newpage
9334 \fi
9335 \fi
9336 \fi
9337 \if@tempswa
9338 \twocolumn
9339 \fi}
9340 \def\@endbook{\bookpageend}
9341
9342 % \end{macrocode}
9343 % \end{macro}
9344 % \end{macro}
9345 %
9346 % \begin{macro}{\ps@book}
9347 % \begin{macro}{\ps@afterbook}
9348 % Pagestyles for the book page and the (blank) page after a book page.
9349 % \begin{macrocode}
9350 \aliaspagestyle{book}{empty}
9351 \aliaspagestyle{afterbook}{empty}
9352
9353 % \end{macrocode}
9354 % \end{macro}
9355 % \end{macro}
9356 %
9357 %
9358 % \subsection{Part}
9359 %
9360 % \begin{macro}{\part}
9361 % \cs{part}\marg{title} starts a new Part called \meta{title}.
9362 % The actual typesetting of the title is done by \cs{@part} or \cs{@spart}.
9363 % \begin{macrocode}
9364 \newcommand{\part}{%
9365 \@setuppart
9366 \secdef\@part\@spart}
9367 % \end{macrocode}
9368 % \end{macro}
9369 %
9370 % \begin{macro}{\beforepartskip}
9371 % \begin{macro}{\midpartskip}
9372 % \begin{macro}{\afterpartskip}
9373 % These three macros are the skips before, in the middle, and after the
9374 % Part heading.
9375 % \changes{v1.61803}{2008/01/30}{Changed \cs{midpartskip} (mempatch v4.9)}
9376 % \begin{macrocode}
9377 \newcommand{\beforepartskip}{\null\vfil}
9378 \newcommand{\midpartskip}{\par\vskip 2\onelineskip}
9379 \newcommand{\afterpartskip}{\vfil\newpage}
9380
9381 % \end{macrocode}
9382 % \end{macro}
9383 % \end{macro}
9384 % \end{macro}
9385 %
9386 % \begin{macro}{\@setuppart}
9387 % This macro does the work of setting up for the \cs{part} command.
9388 % A single column page, normally recto, with a \pstyle{part} pagestyle is started.
9389 % \begin{macrocode}
9390 \newcommand{\@setuppart}{%
9391 \if@openright
9392 \cleardoublepage
9393 \else
9394 \clearpage
9395 \fi
9396 \thispagestyle{part}%
9397 \if@twocolumn
9398 \onecolumn
9399 \@tempswatrue
9400 \else
9401 \@tempswafalse
9402 \fi
9403 \beforepartskip}
9404
9405 % \end{macrocode}
9406 % \end{macro}
9407 %
9408 % \begin{macro}{\partnamefont}
9409 % \begin{macro}{\partnumfont}
9410 % \begin{macro}{\parttitlefont}
9411 % These three macros specify the fonts for the part name and number, and
9412 % for the part title, respectively.
9413 % \changes{v0.2}{2001/06/03}{Rewrote the typesetting for Part titles}
9414 % \begin{macrocode}
9415 \newcommand{\partnamefont}{\normalfont\huge\bfseries}
9416 \newcommand{\partnumfont}{\normalfont\huge\bfseries}
9417 \newcommand{\parttitlefont}{\normalfont\Huge\bfseries}
9418
9419 % \end{macrocode}
9420 % \end{macro}
9421 % \end{macro}
9422 % \end{macro}
9423 %
9424 % \begin{macro}{\printpartname}
9425 % \begin{macro}{\partnamenum}
9426 % \begin{macro}{\printpartnum}
9427 % \begin{macro}{\printparttitle}
9428 % Macros to print the various parts of a Part heading.
9429 % \begin{macrocode}
9430 \newcommand{\printpartname}{\partnamefont \partname}
9431 \newcommand{\partnamenum}{\space}
9432 \newcommand{\printpartnum}{\partnumfont \thepart}
9433 \newcommand{\printparttitle}[1]{\parttitlefont #1}
9434
9435 % \end{macrocode}
9436 % \end{macro}
9437 % \end{macro}
9438 % \end{macro}
9439 % \end{macro}
9440 %
9441 % \begin{macro}{\mempartinfo}
9442 % \begin{macro}{\mempartstarinfo}
9443 % Hooks for the part data. Arguments as listed. Though first arg for
9444 % \cs{mempartinfo} might be empty if secnumdepth say so.
9445 %
9446 % \medskip\noindent
9447 % \verb?\mempartinfo{\thepart}{short}{long}? \\
9448 % \verb?\mempartstarinfo{long}? \\
9449 % \changes{v1.61803}{2008/01/30}{Made \cs{mempartinfo} long (mempatch v4.9).}
9450 % \begin{macrocode}
9451 \newcommand{\mempartinfo}[3]{}
9452 \newcommand{\mempartstarinfo}[1]{}
9453
9454 % \end{macrocode}
9455 % \end{macro}
9456 % \end{macro}
9457 %
9458 % \begin{macro}{\@part}
9459 % \cs{@part}\oarg{short}\marg{long} typesets the title of a \cs{part}
9460 % part. There is a number if \cs{secnumdepth} is greater than -2.
9461 % \changes{v1.3}{2002/11/14}{Used \cs{partnumberline} in \cs{@part}}
9462 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@part}}
9463 % \changes{v1.618}{2005/09/03}{Replaced \cs{markboth} by \cs{partmark}
9464 % in \cs{@part} courtesy of Frederic Connes (mempatch v3.11)}
9465 % \begin{macrocode}
9466 \long\def\@part[#1]#2{%
9467 \M@gettitle{#1}%
9468 % \end{macrocode}
9469 % For continuity we store the toc entry in \verb?\f@rtoc? before
9470 % writing it to the \verb?.toc? file. We also provide a hook to be
9471 % able to transform it.
9472 % \changes{v3.6k}{2012/09/18}{Provided \cs{f@rtoc} and hook}
9473 % \changes{v3.6k}{2013/04/24}{Added \cs{mempreaddparttotochook} and \cs{mempostaddparttotochook}}
9474 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phansomsection} by \cs{MakeLinkTarget} and moved it to unnumbered branch}
9475 % \begin{macrocode}
9476 \def\f@rtoc{#1}%
9477 \@nameuse{part@f@rtoc@before@write@hook}%
9478 %\phantomsection
9479 \mempreaddparttotochook
9480 \ifnum \c@secnumdepth >-2\relax
9481 \refstepcounter{part}%
9482 \addcontentsline{toc}{part}%
9483 {\protect\partnumberline{\thepart}\f@rtoc}%
9484 \mempartinfo{\thepart}{\f@rtoc}{#2}%
9485 \else
9486 \MakeLinkTarget[part]{}%
9487 \addcontentsline{toc}{part}{\f@rtoc}%
9488 \mempartinfo{}{\f@rtoc}{#2}%
9489 \fi
9490 \mempostaddparttotochook
9491 % \end{macrocode}
9492 % Empty the marks, center the title on the page, and set the normal font.
9493 % \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero inside the
9494 % group, such that a non-zero \cs{parskip} does not interfer with the
9495 % title layout}
9496 % \begin{macrocode}
9497 \partmark{#1}%
9498 {\centering
9499 \interlinepenalty \@M
9500 \parskip\z@
9501 \normalfont
9502 % \end{macrocode}
9503 % Print the number, if there is one, then the title below. Macro \cs{@endpart}
9504 % tidies everything up at the end.
9505 % \begin{macrocode}
9506 \ifnum \c@secnumdepth >-2\relax
9507 \printpartname \partnamenum \printpartnum
9508 \midpartskip
9509 \fi
9510 \printparttitle{#2}\par}%
9511 \@endpart}
9512
9513 % \end{macrocode}
9514 % \end{macro}
9515 %
9516 % \begin{macro}{\mempreaddparttotochook}
9517 % \begin{macro}{\mempostaddparttotochook}
9518 % Hooks executed just before and just after \cs{part} adds something
9519 % to the ToC. Does nothing by default
9520 % \begin{macrocode}
9521 \newcommand\mempreaddparttotochook{}
9522 \newcommand\mempostaddparttotochook{}
9523
9524 % \end{macrocode}
9525 % \end{macro}
9526 % \end{macro}
9527 %
9528 % \begin{macro}{\@spart}
9529 % \cs{@spart}\marg{long} formats the title of a \cs{part*} part. It is
9530 % simpler than \cs{@part} because there is no number to print.
9531 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@spart}}
9532 % \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero here as well}
9533 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget}}
9534 % \begin{macrocode}
9535 \long\def\@spart#1{%
9536 \M@gettitle{#1}%
9537 % \phantomsection
9538 \MakeLinkTarget[part]{}%
9539 \mempartstarinfo{#1}%
9540 {\centering
9541 \interlinepenalty \@M
9542 \parskip\z@
9543 \normalfont
9544 \printparttitle{#1}\par}%
9545 \@endpart}
9546
9547 % \end{macrocode}
9548 % \end{macro}
9549 %
9550 % \begin{macro}{\ifm@mnopartnewpage}
9551 % \begin{macro}{\m@mnopartnewpagetrue}
9552 % \begin{macro}{\m@mnopartnewpagefalse}
9553 % \begin{macro}{\partblankpage}
9554 % \begin{macro}{\nopartblankpage}
9555 % The declaration \cs{nopartblankpage} prevents \cs{part} from
9556 % outputting a blank page when it finishes. The default is set by
9557 % \cs{partblankpage}. This code was originally supplied by Frederic Connes.
9558 % \changes{v1.61803}{2008/01/30}{Added \cs{partblankpage} and
9559 % \cs{nopartblankpage} (mempatch v v4.4).}
9560 % \begin{macrocode}
9561 \newif\ifm@mnopartnewpage
9562 \m@mnopartnewpagefalse
9563 \newcommand*{\partblankpage}{\m@mnopartnewpagefalse}
9564 \newcommand*{\nopartblankpage}{\m@mnopartnewpagetrue}
9565
9566 % \end{macrocode}
9567 % \end{macro}
9568 % \end{macro}
9569 % \end{macro}
9570 % \end{macro}
9571 % \end{macro}
9572 %
9573 % \begin{macro}{\partpageend}
9574 % \begin{macro}{\@endpart}
9575 % This finishes off both \cs{@part} and \cs{@spart}.
9576 % Following a \cs{nopartblankpage} nothing is done, otherwise
9577 % (after \cs{partblankpage}) the current page is flushed.
9578 % In the standard \Lpack{book} class if
9579 % two-sided mode is on a blank page is then produced. I think that this looks
9580 % odd when the \Lopt{openany} option is in force, so here it only produces
9581 % an extra blank page if both \Lopt{twoside} and \Lopt{openright} are
9582 % in effect.
9583 %
9584 % At the end, if necessary, two column mode is switched back on.
9585 % \changes{v1.61803}{2008/01/30}{Used the afterpart pagestyle in \cs{@endpart}}
9586 % \changes{v1.61803398}{2009/07/26}{PW: Added \cs{partpageend} as cover for \cs{@endpart}}
9587 % \begin{macrocode}
9588 \newcommand*{\partpageend}{\afterpartskip
9589 \ifm@mnopartnewpage
9590 \else
9591 \if@twoside
9592 \if@openright
9593 \null
9594 \thispagestyle{afterpart}%
9595 \newpage
9596 \fi
9597 \fi
9598 \fi
9599 \if@tempswa
9600 \twocolumn
9601 \fi}
9602 \def\@endpart{\partpageend}
9603
9604 % \end{macrocode}
9605 % \end{macro}
9606 % \end{macro}
9607 %
9608 % \begin{macro}{\ps@afterpart}
9609 % Pagestyle for the (blank) page after a part page.
9610 % \changes{v1.61803}{2008/01/30}{Added afterpart pagestyle (mempatch v4.4)}
9611 % \begin{macrocode}
9612 \aliaspagestyle{afterpart}{empty}
9613
9614 % \end{macrocode}
9615 % \end{macro}
9616 %
9617 % \subsection{Chapter}
9618 %
9619 % \begin{macro}{\chapter}
9620 % The command to start a new chapter. Chapters always start on a new page
9621 % with a \pstyle{chapter} pagestyle. Floats are not allowed at the top of the page.
9622 % The typesetting is done by either \cs{@chapter} or \cs{@schapter}.
9623 % \changes{v0.3}{2001/07/09}{Changed \cs{chapter} for article option}
9624 % \changes{v1.0}{2001/10/24}{Changed chapter page clearing to \cs{clearforchapter}}
9625 % \changes{v1.2}{2002/07/27}{New optarg in \cs{chapter} for short heading}
9626 % \changes{v1.618}{2005/09/03}{Made article chapter start on a newline (mempatch v3.5)}
9627 % \changes{v3.6e}{2010/07/16}{Factored out the \cs{@afterindentfalse}}
9628 % \changes{v3.6h}{2011/02/07}{Added the chapter block}
9629 % \begin{macrocode}
9630 \newcommand\chapter{%
9631 % \end{macrocode}
9632 % The block macro can be defined to execute a \cs{FloatBlock} when we
9633 % are in article mode. Outside article mode \cs{clearforchapter} is
9634 % expected to be used for this.
9635 % \begin{macrocode}
9636 \ifartopt\par\@nameuse{chapterblock}\else
9637 \clearforchapter
9638 \thispagestyle{chapter}
9639 \global\@topnum\z@
9640 \fi
9641 % \@afterindentfalse
9642 \m@mindentafterchapter
9643 \@ifstar{\@m@mschapter}{\@m@mchapter}}
9644
9645 % \end{macrocode}
9646 % \end{macro}
9647 %
9648 % \begin{macro}{\m@mindentafterchapter}
9649 % \begin{macro}{\indentafterchapter}
9650 % \begin{macro}{\noindentafterchapter}
9651 % In order to make whether to indent the first paragraph after af
9652 % chapter configurable, we store \verb?\@afterindenttrue/false? in
9653 % \verb?\m@mindentafterchapter?, and provide
9654 % \verb?\indentafterchapter? and \verb?\noindentafterchapter? to set
9655 % it to a suitable value.
9656 % \begin{macrocode}
9657 \newcommand*\indentafterchapter{\def\m@mindentafterchapter{\@afterindenttrue}}
9658 \newcommand*\noindentafterchapter{\def\m@mindentafterchapter{\@afterindentfalse}}
9659 % \end{macrocode}
9660 % Default is not to indent.
9661 % \begin{macrocode}
9662 \noindentafterchapter
9663
9664 % \end{macrocode}
9665 %
9666 % \end{macro}
9667 % \end{macro}
9668 % \end{macro}
9669 %
9670 % \begin{macro}{\@m@mchapter}
9671 % \begin{macro}{\ch@pt@c}
9672 % \begin{macro}{\m@m@empty}
9673 % Intermediate and support macros for the extra optional argument
9674 % to \cs{chapter}. Have to do this long windedly otherwise dear old
9675 % \Lpack{hyperref} barfs.
9676 %
9677 % The code for two optional arguments is based on a posting
9678 % to \ctt{} by Robin Fairbairns (1997/04/12 \textit{Re: Several optional
9679 % arguments for macro?}).
9680 % \changes{v1.618}{2005/09/04}{Major changes to \cs{chapter} macros (from Morten Hogholm 2005/08/30)}
9681 % \begin{macrocode}
9682 \newcommand{\@m@mchapter}[1][]{%
9683 \def\ch@pt@c{#1}% capture first optional arg
9684 \@ifnextchar[{\@chapter}{\@chapter[]}%
9685 }
9686 \def\m@m@empty{\@empty}
9687
9688 % \end{macrocode}
9689 % \end{macro}
9690 % \end{macro}
9691 % \end{macro}
9692 %
9693 % \begin{macro}{\memchapinfo}
9694 % \begin{macro}{\memchapstarinfo}
9695 % \begin{macro}{\memappchapinfo}
9696 % \begin{macro}{\memappchapstarinfo}
9697 % \verb?\memchapinfo{num}{toc}{head}{full}? \\
9698 % \verb?\memchapstarinfo{short}{full}?
9699 % \changes{v1.618}{2005/09/06}{Added \cs{memchapinfo}}
9700 % \begin{macrocode}
9701 \newcommand{\memchapinfo}[4]{}
9702 \newcommand{\memchapstarinfo}[2]{}
9703 \newcommand{\memappchapinfo}[4]{}
9704 \newcommand{\memappchapstarinfo}[2]{}
9705
9706 % \end{macrocode}
9707 % \end{macro}
9708 % \end{macro}
9709 % \end{macro}
9710 % \end{macro}
9711 %
9712 % \begin{macro}{\ifm@mpn@new@chap}
9713 % \begin{macro}{\m@mpn@new@chapfalse}
9714 % \begin{macro}{\m@mpn@new@chaptrue}
9715 % \begin{macro}{\ifm@mpn@new@schap}
9716 % \begin{macro}{\m@mpn@new@schapfalse}
9717 % \begin{macro}{\m@mpn@new@schaptrue}
9718 % These are for supporting the page/end notes, flagging that a
9719 % \verb?\chapter(*)? has been called.
9720 % \changes{v1.61803}{2008/01/30}{Added \cs{ifm@mpn@new@chap} and
9721 % \cs{ifm@mpn@new@chap} (mempatch v4.5)}
9722 % \begin{macrocode}
9723 \newif\ifm@mpn@new@chap
9724 \m@mpn@new@chapfalse
9725 \newif\ifm@mpn@new@schap
9726 \m@mpn@new@schapfalse
9727
9728 % \end{macrocode}
9729 % \end{macro}
9730 % \end{macro}
9731 % \end{macro}
9732 % \end{macro}
9733 % \end{macro}
9734 % \end{macro}
9735 %
9736 % \begin{macro}{\@chapter}
9737 % \begin{macro}{\f@rtoc}
9738 % \begin{macro}{\f@rhdr}
9739 % \begin{macro}{\f@rbody}
9740 % \cs{@chapter}\oarg{tocmark}\marg{title}
9741 % typesets the title of a \cs{chapter}.
9742 % There is a number if \cs{secnumdepth} is greater than -1 and \cs{@mainmatter}
9743 % is TRUE.
9744 %
9745 % \changes{v1.2}{2002/07/27}{Complete rewrite of \cs{@chapter}}
9746 % \changes{v1.3}{2002/11/14}{Changed \cs{numberline} to \cs{chapternumberline}
9747 % in \cs{@chapter}}
9748 % \changes{v1.61803}{2008/01/30}{Added \cs{f@rbody} to \cs{@chapter},
9749 % plus newchapter flag (mempatch v4.5)}
9750 % \changes{v1.6180339g}{2009/07/13}{added \cs{m@mpn@new@schapfalse}
9751 % otherwise both might end up true at the same time}
9752 % \begin{macrocode}
9753 \def\@chapter[#1]#2{%
9754 \m@mpn@new@chaptrue%
9755 \m@mpn@new@schapfalse%
9756 \def\f@rbdy{#2}%
9757 \ifx\ch@pt@c\@empty % no optional args
9758 \def\f@rtoc{#2}%
9759 \def\f@rhdr{#2}%
9760 \else % at least one opt arg
9761 \let\f@rtoc\ch@pt@c
9762 \ifx\@empty#1\@empty
9763 \let\f@rhdr\ch@pt@c
9764 \else
9765 \def\f@rhdr{#1}%
9766 \fi
9767 \fi
9768 \m@m@Andfalse
9769 \ifnum \c@secnumdepth >\m@ne
9770 \if@mainmatter
9771 \m@m@Andtrue
9772 \fi
9773 \fi
9774 \ifm@m@And
9775 \refstepcounter{chapter}%
9776 % \end{macrocode}
9777 % \changes{v3.8.4}{2025/08/20}{Adding a feature from
9778 % \texttt{book.cls}, have each \cs{chapter} write to the log}
9779 % \begin{macrocode}
9780 \typeout{\@chapapp\space\thechapter.}%
9781 % \end{macrocode}
9782 % \changes{v3.8.4}{2025/09/16}{Added a link target for when unnumbered}
9783 % \begin{macrocode}
9784 \else
9785 \MakeLinkTarget[chapter]{}%
9786 \fi
9787 % \end{macrocode}
9788 % Deal with the \Lopt{article} option.
9789 % \begin{macrocode}
9790 \ifartopt
9791 \@makechapterhead{#2}%
9792 \@afterheading
9793 \chaptermark{\f@rhdr}%
9794 \else
9795 % \end{macrocode}
9796 % Store the (short) title via \cs{chaptermark}, and add some whitespace to
9797 % the LoF and LoT. Then fiddle when we are using two columns, calling
9798 % \cs{@makechapterhead} to do the typesetting.
9799 % \changes{v0.3}{2001/07/09}{Changed \cs{@chapter} for article option}
9800 % \begin{macrocode}
9801 \chaptermark{\f@rhdr}
9802 \insertchapterspace
9803 \if@twocolumn
9804 \@topnewpage[\@makechapterhead{#2}]%
9805 \else
9806 \@makechapterhead{#2}%
9807 \fi
9808 \@afterheading
9809 \fi
9810 % \end{macrocode}
9811 % When working with \Lpack{hyperref} it is not possible to add, say,
9812 % upper casing to ToC entries via \cs{cftchapterfont}. We provide a
9813 % hook, such that users can transform \cs{f@rtoc} before it is
9814 % actually written to the \texttt{.toc} file.
9815 % \changes{v3.6k}{2012/09/18}{Added}
9816 % \begin{macrocode}
9817 \@nameuse{chapter@f@rtoc@before@write@hook}%
9818 % \end{macrocode}
9819 %
9820 % Vittorio De Martino on 31 March 2003 reported that for articled
9821 % chapters, which do not do any \cs{clearpage}, \cs{addcontents} had
9822 % to come after the title.
9823 % \changes{v1.4}{2003/11/16}{Changed \cs{@chapter} to match patches v1.n}
9824 % \changes{v3.6k}{2013/04/24}{Added pretoc and posttoc hooks}
9825 % \begin{macrocode}
9826 \mempreaddchaptertotochook%
9827 \ifm@m@And
9828 \ifanappendix
9829 \addcontentsline{toc}{appendix}{%
9830 \protect\chapternumberline{\thechapter}\f@rtoc}%
9831 \memappchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
9832 \else
9833 \addcontentsline{toc}{chapter}{%
9834 \protect\chapternumberline{\thechapter}\f@rtoc}%
9835 \memchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
9836 \fi
9837 \else
9838 \addcontentsline{toc}{chapter}{\f@rtoc}%
9839 \ifanappendix
9840 \memappchapinfo{}{\f@rtoc}{\f@rhdr}{#2}%
9841 \else
9842 \memchapinfo{}{\f@rtoc}{\f@rhdr}{#2}%
9843 \fi
9844 \fi
9845 \mempostaddchaptertotochook%
9846 % \end{macrocode}
9847 % Add hook for title referencing.
9848 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@chapter}}
9849 % \changes{v3.6k}{2013/04/24}{Added \cs{memendofchapterhook}}.
9850 % The hook at the very end can be used to automatically add a new page
9851 % right after \cs{chapter}.
9852 % \changes{v3.70.20}{2023/07/24}{Redef of \cs{M@gettitle} requires
9853 % expansion for macro arguments}
9854 % \begin{macrocode}
9855 \ifheadnameref\ExpandArgs{V}\M@gettitle\f@rhdr\else\ExpandArgs{V}\M@gettitle\f@rtoc\fi%
9856 \memendofchapterhook%
9857 }
9858
9859 % \end{macrocode}
9860 % \end{macro}
9861 % \end{macro}
9862 % \end{macro}
9863 % \end{macro}
9864 % \begin{macro}{\mempreaddchaptertotochook}
9865 % \begin{macro}{\mempostaddchaptertotochook}
9866 % \begin{macro}{\memendofchapterhook}
9867 % These two hooks are executed before \cs{chapter} adds anything to
9868 % the TOC and after it does so. It can be used to add hooks into the
9869 % TOC such that parts can be switched on and off. By default they do nothing.
9870 % \begin{macrocode}
9871 \newcommand\mempreaddchaptertotochook{}
9872 \newcommand\mempostaddchaptertotochook{}
9873 \newcommand\memendofchapterhook{}
9874 % \end{macrocode}
9875 % \end{macro}
9876 % \end{macro}
9877 % \end{macro}
9878 %
9879 %
9880 % \begin{macro}{\settocpreprocessor}
9881 % \changes{v3.6k}{2012/09/18}{Added}
9882 % This can be used to set a hook which users can fill in in order to
9883 % get the toc material preprocessed before writing it to the
9884 % \verb?.toc? file. The primary use for this is as a workaround when
9885 % \Lpack{hyperref} is used, and one want to have, say, upper cased toc
9886 % entries. Example of use
9887 % \begin{verbatim}
9888 % \makeatletter
9889 % \settocpreprocessor{chapter}{%
9890 % \let\temp@f@rtoc\f@rtoc
9891 % \def\f@rtoc{\texorpdfstring{\MakeUppercase{\temp@f@rtoc}}{\temp@f@rtoc}}
9892 % }
9893 % \makeatother
9894 % \end{verbatim}
9895 % The idea comes from \url{http://tex.stackexchange.com/q/11892/3929}
9896 % eliminating the need for patching.
9897 % \begin{macrocode}
9898 \newcommand\settocpreprocessor[2]{%
9899 \MarkDeprecated{\settocpreprocessor}{in 2026, the problem it tried to solve \MessageBreak
9900 (see manual, section 9.2.3),\MessageBreak
9901 has been fixed in the kernel, and the feature is\MessageBreak
9902 no longer needed.}%
9903 \@namedef{#1@f@rtoc@before@write@hook}{#2}}
9904 % \end{macrocode}
9905 % \end{macro}
9906 %
9907 % \begin{macro}{\@makechapterhead}
9908 % This \emph{really} typesets a \cs{chapter}. Leave some whitespace and prepare to
9909 % set \cs{raggedright}.
9910 % \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to
9911 % \cs{@makechapterhead}}
9912 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@makechapterhead}}
9913 % \changes{v3.6j}{2011/03/01}{Set \cs{parskip} to zero such that a
9914 % non-zero \cs{parskip} to not interfer with the placement of the title}
9915 % \begin{macrocode}
9916 \def\@makechapterhead#1{%
9917 \chapterheadstart%
9918 {%
9919 \parskip \z@
9920 \parindent \z@ \memRTLraggedright \normalfont
9921 % \end{macrocode}
9922 % If there is a number, typeset it, otherwise call \cs{printchapternonum}.
9923 % \begin{macrocode}
9924 \ifm@m@And
9925 \printchaptername \chapternamenum \printchapternum
9926 \afterchapternum %
9927 \else
9928 \printchapternonum
9929 \fi
9930 % \end{macrocode}
9931 % Typeset the title.
9932 % \begin{macrocode}
9933 \interlinepenalty\@M
9934 \printchaptertitle{#1} %
9935 \afterchaptertitle %
9936 }}
9937
9938 % \end{macrocode}
9939 % \end{macro}
9940 %
9941 % \begin{macro}{\insertchapterspace}
9942 % By default, a \cs{chapter} inserts some vertical space into the LoF and LoT.
9943 % The macro \cs{insertchapterspace} performs the insertion.
9944 % \changes{v0.33}{2001/08/31}{Added \cs{insertchapterspace}}
9945 % \begin{macrocode}
9946 \newcommand*{\insertchapterspace}{%
9947 \addtocontents{lof}{\protect\addvspace{10pt}}%
9948 \addtocontents{lot}{\protect\addvspace{10pt}}}
9949
9950 % \end{macrocode}
9951 % \end{macro}
9952 %
9953 % \begin{macro}{\beforechapskip}
9954 % \begin{macro}{\midchapskip}
9955 % \begin{macro}{\afterchapskip}
9956 % Lengths separating the various parts of a chapter heading.
9957 % \begin{macrocode}
9958 \newlength{\beforechapskip} \setlength{\beforechapskip}{50pt}
9959 \newlength{\midchapskip} \setlength{\midchapskip}{20pt}
9960 \newlength{\afterchapskip} \setlength{\afterchapskip}{40pt}
9961
9962 % \end{macrocode}
9963 % \end{macro}
9964 % \end{macro}
9965 % \end{macro}
9966 %
9967 %
9968 % \begin{macro}{\@chs@def@ult}
9969 % This sets up all the definitions and defaults used in \cs{@makechapterhead}
9970 % and \cs{@makeschapterhead}.
9971 % \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to \cs{@chs@def@ult}}
9972 % \changes{v1.61803}{2008/01/30}{Made \cs{@chs@def@ult} set all default chapter values}
9973 % \begin{macro}{\chapterheadstart}
9974 % \begin{macro}{\printchaptername}
9975 % \begin{macro}{\chapternamenum}
9976 % \begin{macro}{\printchapternum}
9977 % \begin{macro}{\afterchapternum}
9978 % \begin{macro}{\printchapternum}
9979 % \begin{macro}{\printchapternonum}
9980 % \begin{macro}{\printchaptertitle}
9981 % \begin{macro}{\afterchaptertitle}
9982 % \begin{macrocode}
9983 \newcommand{\@chs@def@ult}{%
9984 \def\chapterheadstart{\vspace*{\beforechapskip}}%
9985 \def\printchaptername{\chapnamefont \@chapapp}%
9986 \def\chapternamenum{\space}%
9987 \def\printchapternum{\chapnumfont \thechapter}%
9988 \def\afterchapternum{\par\nobreak\vskip \midchapskip}%
9989 \def\printchapternonum{}%
9990 \def\printchaptertitle##1{\chaptitlefont ##1}%
9991 \def\afterchaptertitle{\par\nobreak\vskip \afterchapskip}%
9992 % \end{macrocode}
9993 % \end{macro}
9994 % \end{macro}
9995 % \end{macro}
9996 % \end{macro}
9997 % \end{macro}
9998 % \end{macro}
9999 % \end{macro}
10000 % \end{macro}
10001 %
10002 % \begin{macro}{\chapnamefont}
10003 % \begin{macro}{\chapnumfont}
10004 % \begin{macro}{\chaptitlefont}
10005 % Fonts for setting chapter name, number, and title.
10006 % \begin{macrocode}
10007 \def\chapnamefont{\normalfont\huge\bfseries}%
10008 \def\chapnumfont{\normalfont\huge\bfseries}%
10009 \def\chaptitlefont{\normalfont\Huge\bfseries}%
10010 \setlength{\beforechapskip}{50pt}%
10011 \setlength{\midchapskip}{20pt}%
10012 \setlength{\afterchapskip}{40pt}}
10013
10014 % \end{macrocode}
10015 % \end{macro}
10016 % \end{macro}
10017 % \end{macro}
10018 % \end{macro}
10019 %
10020 %
10021 %
10022 % \begin{macro}{\@m@mschapter}
10023 % This deals with the new optional argument for starred chapters.
10024 % \changes{v3.70.20}{2023/07/24}{Redef of \cs{M@gettitle} requires
10025 % expansion for macro arguments}
10026 % \begin{macrocode}
10027 \newcommand{\@m@mschapter}[2][\@empty]{%
10028 \@schapter{#2}%
10029 \ifx \@empty#1
10030 \def\f@rhdr{#2}%
10031 \else% opt arg
10032 \def\f@rhdr{#1}%
10033 \setcounter{secnumdepth}{-10}%
10034 \chaptermark{#1}%
10035 \setcounter{secnumdepth}{\value{maxsecnumdepth}}%
10036 \fi
10037 \ifanappendix
10038 \memappchapstarinfo{\f@rhdr}{#2}%
10039 \else
10040 \memchapstarinfo{\f@rhdr}{#2}%
10041 \fi
10042 \ifheadnameref\ExpandArgs\M@gettitle\f@rhdr\else\M@gettitle{#2}\fi}
10043
10044 % \end{macrocode}
10045 % \end{macro}
10046 %
10047 % \begin{macro}{\@schapter}
10048 % \begin{macro}{\f@rbdy}
10049 % \cs{@schapter}\marg{long} typesets the title of a
10050 % \cs{chapter*}. It is easier than the \cs{@chapter} as there is no number
10051 % to worry about.
10052 % \changes{v0.3}{2001/07/09}{Changed \cs{@schapter} for article option}
10053 % \changes{v1.2}{2002/07/27}{Major rewrite of \cs{@schapter}}
10054 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@schapter}}
10055 % \changes{v1.61803}{2008/01/30}{Changed \cs{@schapter} like
10056 % \cs{@chapter} (mempatch v4.5)}
10057 % \changes{v1.6180339g}{2009/07/13}{added \cs{m@mpn@new@chapfalse}
10058 % otherwise both might end up true at the same time}
10059 % \changes{v3.8.4}{2025/09/16}{Added a link target}
10060 % \begin{macrocode}
10061 \newcommand{\@schapter}[1]{%
10062 \m@mpn@new@schaptrue%
10063 \m@mpn@new@chapfalse%
10064 \MakeLinkTarget[chapter]{}%
10065 \def\f@rbdy{#1}%
10066 \ifartopt
10067 \@makeschapterhead{#1}%
10068 \else
10069 \if@twocolumn
10070 \@topnewpage[\@makeschapterhead{#1}]%
10071 \else
10072 \@makeschapterhead{#1}%
10073 \fi
10074 \fi
10075 \@afterheading}
10076
10077 % \end{macrocode}
10078 % \end{macro}
10079 % \end{macro}
10080 %
10081 % \begin{macro}{\@makeschapterhead}
10082 % This \emph{really} typesets a \cs{chapter*}, and is similar to \cs{@makechapterhead}.
10083 % \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to
10084 % \cs{@makeschapterhead}}
10085 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@makeschapterhead}}
10086 % \changes{v3.6j}{2011/0301}{Made sure the \cs{parskip} is zero inside
10087 % the title area, otherwise placement might come out wrong}
10088 % \begin{macrocode}
10089 \def\@makeschapterhead#1{%
10090 \chapterheadstart
10091 {%
10092 \parskip \z@%
10093 \parindent \z@ \memRTLraggedright \normalfont
10094 \printchapternonum
10095 \interlinepenalty\@M
10096 \printchaptertitle{#1}%
10097 \afterchaptertitle}%
10098 }
10099
10100 % \end{macrocode}
10101 % \end{macro}
10102 %
10103 %
10104 % \subsubsection{Chapter styling}
10105 %
10106 %
10107 % \begin{macro}{\makechapterstyle}
10108 % \begin{macro}{\chapterstyle}
10109 % \cs{chapterstyle}\marg{style} is like \cs{pagestyle}, except it's for
10110 % chapters.
10111 %
10112 % \medskip\noindent
10113 % \cs{makechapterstyle}\marg{style}\marg{text} creates
10114 % or overrides the \meta{style} chapter style defining it as \meta{text}
10115 % So, \verb?\makechapterstyle{fred}{code}? specifies that the chapter style
10116 % \pstyle{fred}
10117 % is defined as the macro \verb?\chs@fred{code}?,
10118 % and \verb?\chapterstyle{fred}? calls the macro \cs{chs@fred}.
10119 % \begin{macrocode}
10120 \newcommand{\makechapterstyle}[2]{\@namedef{chs@#1}{\@chs@def@ult #2}}
10121 \newcommand{\chapterstyle}[1]{\@nameuse{chs@#1}}
10122
10123 % \end{macrocode}
10124 % \end{macro}
10125 % \end{macro}
10126 %
10127 % Set the \pstyle{default} chapter style.
10128 % \changes{v0.2}{2001/06/03}{Added code when making the default chapterstyle}
10129 % \changes{v1.61803}{2008/01/30}{Simplified specification of the default chapterstyle}
10130 % \begin{macrocode}
10131 \makechapterstyle{default}{}%
10132 %% \setlength{\beforechapskip}{50pt}
10133 %% \def\chapterheadstart{\vspace*{\beforechapskip}}
10134 %% \def\chapnamefont{\normalfont\huge\bfseries}
10135 %% \def\printchaptername{\chapnamefont \@chapapp}
10136 %% \def\chapternamenum{\space}
10137 %% \def\chapnumfont{\normalfont\huge\bfseries}
10138 %% \def\printchapternum{\chapnumfont \thechapter}
10139 %% \setlength{\midchapskip}{20pt}
10140 %% \def\afterchapternum{\par\nobreak\vskip \midchapskip}
10141 %% \def\printchapternonum{}
10142 %% \def\chaptitlefont{\normalfont\Huge\bfseries}
10143 %% \def\printchaptertitle##1{\chaptitlefont ##1}
10144 %% \setlength{\afterchapskip}{40pt}
10145 %% \def\afterchaptertitle{\par\nobreak\vskip \afterchapskip}
10146 \chapterstyle{default}
10147
10148 % \end{macrocode}
10149 %
10150 % \begin{macro}{\chs@section}
10151 % The \pstyle{section} chapter style. It prints the heading as though it
10152 % were a section.
10153 % \changes{v1.0a}{2002/01/18}{Made \cs{chapnumfont} change in section
10154 % chapterstyle explicit}
10155 % \begin{macrocode}
10156 \makechapterstyle{section}{%
10157 \chapterstyle{default}
10158 \renewcommand{\printchaptername}{}
10159 \renewcommand{\chapternamenum}{}
10160 \renewcommand{\chapnumfont}{\normalfont\Huge\bfseries}
10161 \renewcommand{\printchapternum}{\chapnumfont \thechapter\space}
10162 \renewcommand{\afterchapternum}{}}
10163
10164 % \end{macrocode}
10165 % \end{macro}
10166 %
10167 % \begin{macro}{\chs@article}
10168 % The \pstyle{article} chapter style. It prints the heading as though it
10169 % were a section in an \Lpack{article} class document.
10170 % \changes{v0.3}{2001/07/09}{Added article chapterstyle}
10171 % \changes{v1.0a}{2002/01/18}{Made \cs{chapnumfont} change in article chapterstyle explicit}
10172 % \changes{v1.4}{2003/11/22}{Replaced \cs{space} by \cs{quad} in article chapterstyle
10173 % (from patch v1.7)}
10174 % \changes{v3.8.3}{2025/01/07}{Changed \cs{vspace} to \cs{addvspace} otherwise the spacing above \cs{chapter} does not behave like \cs{section}}
10175 % \begin{macrocode}
10176 \makechapterstyle{article}{%
10177 \chapterstyle{default}
10178 \setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
10179 \renewcommand*{\chapterheadstart}{\addvspace{\beforechapskip}}
10180 \setlength{\afterchapskip}{2.3ex \@plus .2ex}
10181 \renewcommand{\printchaptername}{}
10182 \renewcommand{\chapternamenum}{}
10183 \renewcommand{\chaptitlefont}{\normalfont\Large\bfseries}
10184 \renewcommand{\chapnumfont}{\chaptitlefont}
10185 \renewcommand{\printchapternum}{\chapnumfont \thechapter\quad}
10186 \renewcommand{\afterchapternum}{}}
10187
10188 % \end{macrocode}
10189 % \end{macro}
10190 %
10191 % \begin{macro}{\chs@reparticle}
10192 % The \pstyle{reparticle} chapter style. It replicates the appearance
10193 % of a \cs{section} in an \Lpack{article} class document.
10194 % \changes{v1.61803}{2008/01/30}{Added reparticle chapterstyle (mempatch v4.3)}
10195 % \begin{macrocode}
10196 \makechapterstyle{reparticle}{%
10197 \chapterstyle{default}
10198 \setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
10199 \renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
10200 \setlength{\afterchapskip}{2.3ex \@plus .2ex}
10201 \renewcommand*{\printchaptername}{}
10202 \renewcommand*{\chapternamenum}{}
10203 \renewcommand*{\chaptitlefont}{\normalfont\Large\bfseries}
10204 \renewcommand*{\chapnumfont}{\chaptitlefont}
10205 \renewcommand*{\printchapternum}{\@hangfrom{\chapnumfont \thechapter\quad}}%
10206 \renewcommand*{\afterchapternum}{}}
10207
10208 % \end{macrocode}
10209 % \end{macro}
10210 %
10211 % \begin{macro}{\reparticle}
10212 % Call this to get division heads to replicate the \Lopt{article} class.
10213 % For example: \\
10214 % \verb?\ifartopt \reparticle \fi? \\
10215 % The \cs{chapter} commands must still be used, though.
10216 % \changes{v1.61803}{2008/01/30}{Added \cs{reparticle} (mempatch v4.3)}
10217 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{reparticle}}
10218 % \begin{macrocode}
10219 \newcommand*{\reparticle}{%
10220 \chapterstyle{reparticle}
10221 \setsecheadstyle{\normalfont\large\bfseries\memRTLraggedright}%
10222 \setsubsecheadstyle{\normalfont\bfseries\memRTLraggedright}%
10223 }
10224
10225 % \end{macrocode}
10226 % \end{macro}
10227 %
10228 % \begin{macro}{\chs@hangnum}
10229 % The \pstyle{hangnum} style puts the chapter number in the margin.
10230 % \begin{macrocode}
10231 \makechapterstyle{hangnum}{%
10232 \chapterstyle{default}
10233 \renewcommand*{\chapnumfont}{\chaptitlefont}
10234 \settowidth{\chapindent}{\chapnumfont 999}
10235 \renewcommand*{\printchaptername}{}
10236 \renewcommand*{\chapternamenum}{}
10237 \renewcommand*{\printchapternum}{%
10238 \noindent\llap{\makebox[\chapindent][l]{\chapnumfont \thechapter}}}
10239 \renewcommand*{\afterchapternum}{}}
10240
10241 % \end{macrocode}
10242 % \end{macro}
10243 %
10244 % \begin{macro}{\chapindent}
10245 % \begin{macro}{\chs@companion}
10246 % The \pstyle{companion} style is like that in the \textit{\LaTeX{} Companion}
10247 % series. It requires the \cs{chapindent} length. The user needs
10248 % to be careful to have a wide enough spine margin on verso pages
10249 % if the title may appear on a verso page.
10250 % \changes{v0.31}{2001/07/24}{Changed adjustwidth* to adjustwidth in companion chapterstyle}
10251 % \begin{macrocode}
10252 \newlength{\chapindent}
10253
10254 \makechapterstyle{companion}{%
10255 \chapterstyle{default}
10256 \renewcommand*{\chapnamefont}{\normalfont\LARGE\scshape}
10257 \renewcommand*{\printchaptername}{\raggedleft\chapnamefont \@chapapp}
10258 \renewcommand*{\chapnumfont}{\normalfont\Huge}
10259 \setlength{\chapindent}{\marginparsep}
10260 \addtolength{\chapindent}{\marginparwidth}
10261 \renewcommand*{\printchaptertitle}[1]{%
10262 \begin{adjustwidth}{}{-\chapindent}
10263 \raggedleft \chaptitlefont ##1\par\nobreak
10264 \end{adjustwidth}}}
10265
10266 % \end{macrocode}
10267 % \end{macro}
10268 % \end{macro}
10269 %
10270 % \begin{macro}{\chs@demo}
10271 % An exotic chapter style for demonstration purposes.
10272 % \begin{macrocode}
10273 \makechapterstyle{demo}{%
10274 \chapterstyle{default}
10275 \renewcommand*{\printchaptername}{\centering}
10276 \renewcommand*{\printchapternum}{\chapnumfont \numtoName{\c@chapter}}
10277 \renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
10278 \renewcommand*{\printchaptertitle}[1]{%
10279 \hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
10280 \renewcommand*{\afterchaptertitle}%
10281 {\vskip\onelineskip \hrule\vskip \afterchapskip}}
10282
10283 % \end{macrocode}
10284 % \end{macro}
10285 %
10286 % \changes{v1.61803}{2008/01/30}{Added chapterstyles: bianchi, bringhurst,
10287 % brotherton, chappel, culver, dash, demo2, ell, Ger,
10288 % lyhne, madsen, pedersen, southall, thatcher, veelo,
10289 % verville, demo3 (mempatch v4.6)}
10290 % \begin{macro}{\chs@bianchi}
10291 % Posted to CTT on 2003/12/09, \textit{New chapter style: chapter vs chapter*}
10292 % by Stefano Bianchi.
10293 % \begin{macrocode}
10294 \makechapterstyle{bianchi}{%
10295 \chapterstyle{default}
10296 \renewcommand*{\chapnamefont}{\normalfont\Large\sffamily\itshape}
10297 \renewcommand*{\chapnumfont}{\normalfont\huge}
10298 \renewcommand*{\printchaptername}{%
10299 \chapnamefont\centering\@chapapp}
10300 \renewcommand*{\printchapternum}{\chapnumfont \textit{\thechapter}}
10301 \renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
10302 \renewcommand*{\printchaptertitle}[1]{%
10303 \hrule\vskip\onelineskip \centering \chaptitlefont\textbf{##1}\par}
10304 \renewcommand*{\afterchaptertitle}{\vskip\onelineskip \hrule\vskip
10305 \afterchapskip}
10306 \renewcommand*{\printchapternonum}{%
10307 \vphantom{\chapnumfont \textit{9}}\afterchapternum}}
10308
10309 % \end{macrocode}
10310 % \end{macro}
10311 %
10312 % \begin{macro}{\chs@bringhurst}
10313 % My bringhurst style.
10314 % \changes{v1.61803398}{2009/07/17}{Added bidi support to bringhurst chapterstyle}
10315 % \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
10316 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
10317 % \begin{macrocode}
10318 \makechapterstyle{bringhurst}{%
10319 \chapterstyle{default}
10320 \renewcommand*{\chapterheadstart}{}
10321 \renewcommand*{\printchaptername}{}
10322 \renewcommand*{\chapternamenum}{}
10323 \renewcommand*{\printchapternum}{}
10324 \renewcommand*{\afterchapternum}{}
10325 \renewcommand*{\printchaptertitle}[1]{%
10326 \memRTLraggedright\Large\scshape\MakeLowercase{##1}}
10327 \renewcommand*{\afterchaptertitle}{%
10328 \vskip\onelineskip \hrule\vskip\onelineskip}}
10329
10330 % \end{macrocode}
10331 % \end{macro}
10332 %
10333 % \begin{macro}{\chs@brotherton}
10334 % An extremely simple chapterstyle created by William Adams for Mike
10335 % Brotherton's science fiction novel \textit{Star Dragon}, posted to CTT
10336 % 2006/12/09, \textit{An example of a novel?}.
10337 % \begin{macrocode}
10338 \makechapterstyle{brotherton}{%
10339 \chapterstyle{default}
10340 \renewcommand*{\printchapternum}{\chapnumfont
10341 \ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}}
10342
10343 % \end{macrocode}
10344 % \end{macro}
10345 %
10346 % \begin{macro}{\chs@chappell}
10347 % My Chappell style
10348 % \begin{macrocode}
10349 \makechapterstyle{chappell}{%
10350 \chapterstyle{default}
10351 \setlength{\beforechapskip}{0pt}
10352 \renewcommand*{\chapnamefont}{\large\centering}
10353 \renewcommand*{\chapnumfont}{\large}
10354 \renewcommand*{\printchapternonum}{%
10355 \vphantom{\printchaptername \chapnumfont 1}
10356 \afterchapternum
10357 \vskip \onelineskip \vskip -\topskip}
10358 \renewcommand*{\chaptitlefont}{\Large\itshape}
10359 \renewcommand*{\printchaptertitle}[1]{%
10360 \hrule\vskip\onelineskip \centering\chaptitlefont ##1}}
10361
10362 % \end{macrocode}
10363 % \end{macro}
10364 %
10365 % \begin{macro}{\chs@culver}
10366 % By me in an answer to Christopher Culver on CTT,
10367 % \textit{"Biblical" formatting, how?} on 2004/03/29,where I called it
10368 % the `biblical' style.
10369 % \begin{macrocode}
10370 \makechapterstyle{culver}{%
10371 \chapterstyle{default}
10372 \chapterstyle{article}%
10373 \renewcommand*{\thechapter}{\Roman{chapter}}
10374 \renewcommand*{\printchapternum}{% center number/title
10375 \centering\chapnumfont \thechapter\space\space}%
10376 \renewcommand*{\printchapternonum}{\centering}
10377 \renewcommand*{\clearforchapter}{}% no new page
10378 \aliaspagestyle{chapter}{headings}}% no special pagestyle
10379
10380 % \end{macrocode}
10381 % \end{macro}
10382 %
10383 % \begin{macro}{\chs@dash}
10384 % A very simple style of mine but I couldn't think of a good name for it.
10385 % \begin{macrocode}
10386 \makechapterstyle{dash}{%
10387 \chapterstyle{default}
10388 \setlength{\beforechapskip}{5\onelineskip}
10389 \renewcommand*{\printchaptername}{}
10390 \renewcommand*{\chapternamenum}{}
10391 \renewcommand*{\chapnumfont}{\normalfont\large}
10392 \settoheight{\midchapskip}{\chapnumfont 1}
10393 \renewcommand*{\printchapternum}{\centering \chapnumfont
10394 \rule[0.5\midchapskip]{1em}{0.4pt} \thechapter\
10395 \rule[0.5\midchapskip]{1em}{0.4pt}}
10396 \renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
10397 \renewcommand*{\printchapternonum}{\centering
10398 \vphantom{\chapnumfont 1}\afterchapternum}
10399 \renewcommand*{\chaptitlefont}{\normalfont\Large}
10400 \renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont ##1}
10401 \setlength{\afterchapskip}{2.5\onelineskip}}
10402
10403 % \end{macrocode}
10404 % \end{macro}
10405 %
10406 % \begin{macro}{\chs@demo2}
10407 % My second version of the demo chapterstyle.
10408 % \begin{macrocode}
10409 \makechapterstyle{demo2}{%
10410 \chapterstyle{default}
10411 \renewcommand*{\printchaptername}{\centering}
10412 \renewcommand*{\printchapternum}{\chapnumfont
10413 \ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}
10414 \renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
10415 \renewcommand*{\printchaptertitle}[1]{%
10416 \hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
10417 \renewcommand*{\afterchaptertitle}{%
10418 \vskip\onelineskip \hrule\vskip \afterchapskip}
10419 \setlength{\beforechapskip}{3\baselineskip}
10420 \renewcommand*{\printchapternonum}{%
10421 \vphantom{\chapnumfont One}
10422 \afterchapternum%
10423 \vskip\topskip}
10424 \setlength{\beforechapskip}{2\onelineskip}}
10425
10426 % \end{macrocode}
10427 % \end{macro}
10428 %
10429 % \begin{macro}{\chs@demo3}
10430 % My third version of the demo chapterstyle.
10431 % \begin{macrocode}
10432 \makechapterstyle{demo3}{%
10433 \chapterstyle{default}
10434 \renewcommand*{\printchaptername}{\centering}
10435 \renewcommand*{\chapnumfont}{\normalfont\HUGE\itshape}
10436 \renewcommand*{\printchapternum}{\chapnumfont
10437 \ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}
10438 \renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
10439 \renewcommand*{\printchaptertitle}[1]{%
10440 \hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
10441 \renewcommand*{\afterchaptertitle}{%
10442 \vskip\onelineskip \hrule\vskip \afterchapskip}
10443 \setlength{\beforechapskip}{0pt}
10444 \setlength{\midchapskip}{2\onelineskip}
10445 \setlength{\afterchapskip}{2\onelineskip}
10446 \renewcommand*{\printchapternonum}{%
10447 \vphantom{\chapnumfont One}
10448 \afterchapternum%
10449 \vskip\topskip}}
10450
10451 % \end{macrocode}
10452 % \end{macro}
10453 %
10454 % \begin{macro}{\chs@ell}
10455 % Another of my styles which I'll probably use for my next book.
10456 %
10457 % James Dietrich (2014/05/29)
10458 % reports that the line and number part of the \textsf{ell} chapter
10459 % style does not align correctly if the page is excessively
10460 % stretched. The style is reimplemented using \Lenv{tabularx} instead.
10461 % \changes{v3.7d}{2014/11/05}{Reimplemeted the ell chapter style}
10462 % \begin{macro}{\chs@ell@helper}
10463 % For code reuse (the slightly strange values come from trial and
10464 % error to match the original look):
10465 % \begin{macrocode}
10466 \newcommand\chs@ell@helper[1]{%
10467 \par%
10468 \begin{adjustwidth}{}{-\chapindent}
10469 \begin{tabularx}{\linewidth}{>{\raggedleft\arraybackslash}X|}%|emacs
10470 \leavevmode\chapnumfont #1\vphantom{1}%
10471 \hspace*{3.6pt}%
10472 \rule[-13.5pt]{0pt}{14.8mm}%
10473 \\%
10474 \hline%
10475 \end{tabularx}%
10476 \end{adjustwidth}%
10477 \par%
10478 }%
10479
10480 % \end{macrocode}
10481 % \end{macro}
10482 %
10483 % \begin{macrocode}
10484 \makechapterstyle{ell}{%
10485 \chapterstyle{default}
10486 \renewcommand*{\chapnumfont}{\normalfont\HUGE\sffamily}
10487 \renewcommand*{\chaptitlefont}{\normalfont\huge\sffamily}
10488 \settowidth{\chapindent}{\chapnumfont 111}
10489 % \renewcommand*{\chapterheadstart}{\begingroup
10490 % \vspace*{\beforechapskip}%
10491 % \begin{adjustwidth}{}{-\chapindent}%
10492 % \hrulefill
10493 % \smash{\rule{0.4pt}{15mm}}
10494 % \end{adjustwidth}\endgroup}
10495 \renewcommand*{\printchaptername}{}
10496 \renewcommand*{\chapternamenum}{}
10497 \renewcommand*{\printchapternum}{%
10498 % \begin{adjustwidth}{}{-\chapindent}
10499 % \hfill
10500 % \raisebox{10mm}[0pt][0pt]{\chapnumfont \thechapter}%
10501 % \hspace*{1em}
10502 % \end{adjustwidth}\vspace*{-3.0\onelineskip}
10503 \chs@ell@helper{\thechapter}%
10504 }
10505 \renewcommand\printchapternonum{%
10506 \chs@ell@helper{}\afterchapternum}
10507 \renewcommand*{\printchaptertitle}[1]{%
10508 %\vskip\onelineskip
10509 \raggedleft {\chaptitlefont ##1}\par\nobreak}}
10510
10511 % \end{macrocode}
10512 % \end{macro}
10513 %
10514 % \begin{macro}{\chs@ger}
10515 % Posted to CTT on 2002/04/12 \textit{Fancy Headings, Chapter Headings} by Gerardo Garcia.
10516 % \begin{macrocode}
10517 \makechapterstyle{ger}{%
10518 \chapterstyle{default}
10519 \renewcommand*{\chapterheadstart}{\vspace*{\beforechapskip}
10520 \mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
10521 \setlength{\midchapskip}{20pt}
10522 \renewcommand*{\printchaptertitle}[1]{\chaptitlefont ##1
10523 \\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}}
10524
10525 % \end{macrocode}
10526 % \end{macro}
10527 %
10528 % \begin{macro}{\chs@lyhne}
10529 % Posted to CTT 2006/02/09 \textit{Glossary}, by Anders Lyhne.
10530 % It requires the \Lpack{graphicx} package. I have modified it to remove the
10531 % new length and adjusted the unnumbered appearance.
10532 % \begin{macrocode}
10533 \makechapterstyle{lyhne}{% needs graphicx package
10534 \chapterstyle{default}
10535 \setlength{\beforechapskip}{1.5cm}
10536 \setlength{\afterchapskip}{1cm}
10537 \setlength{\midchapskip}{2cm}
10538 \renewcommand*{\chapnamefont}{\normalfont\normalsize\scshape\raggedleft}
10539 \renewcommand*{\chaptitlefont}{\normalfont\normalsize\bfseries\sffamily\raggedleft}
10540 \renewcommand*{\chapternamenum}{}
10541 \renewcommand*{\printchapternum}{\makebox[0pt][l]{\hspace{0.2em}%
10542 \resizebox{!}{2ex}{\chapnamefont\bfseries\sffamily\thechapter}}}
10543 \renewcommand*{\afterchapternum}{\par\hspace{1.5cm}\hrule\vspace{0.2cm}}
10544 \renewcommand*{\printchapternonum}{\vphantom{\chapnamefont 1}\afterchapternum}
10545 \renewcommand*{\afterchaptertitle}{\vskip 0.2cm
10546 \hrule\vskip\afterchapskip}}
10547
10548 % \end{macrocode}
10549 % \end{macro}
10550 %
10551 %
10552 % \begin{macro}{\chs@madsen}
10553 % Posted to CTT on 2003/12/09, \textit{New chapter style: chapter vs chapter*}
10554 % by Lars Madsen.
10555 % This requires the \Lpack{graphicx} package,
10556 % \changes{v1.61803398c}{2009/11/15}{Updated to provide a better
10557 % unnumbered look}
10558 % \changes{v3.6d}{2010/05/13}{the unnumbered version may be executed
10559 % in a context where \cs{thechapter} is not weldefined, replaced with
10560 % a 1}
10561 % \begin{macrocode}
10562 \makechapterstyle{madsen}{% requires graphicx package
10563 \chapterstyle{default}
10564 \renewcommand*{\chapnamefont}{%
10565 \normalfont\Large\scshape\raggedleft}
10566 \renewcommand*{\chaptitlefont}{%
10567 \normalfont\Huge\bfseries\sffamily\raggedleft}
10568 \renewcommand*{\chapternamenum}{}
10569 \renewcommand*{\printchapternum}{%
10570 \makebox[0pt][l]{\hspace{0.4em}%
10571 \resizebox{!}{4ex}{%
10572 \chapnamefont\bfseries\sffamily\thechapter}%
10573 }%
10574 }%
10575 \renewcommand*{\printchapternonum}{%
10576 \chapnamefont \phantom{\printchaptername \chapternamenum%
10577 \makebox[0pt][l]{\hspace{0.4em}%
10578 \resizebox{!}{4ex}{%
10579 \chapnamefont\bfseries\sffamily 1}%
10580 }%
10581 }%
10582 \afterchapternum %
10583 }%
10584 \renewcommand*{\afterchapternum}{%
10585 \par\hspace{1.5cm}\hrule\vskip\midchapskip}}
10586
10587 % \end{macrocode}
10588 % \end{macro}
10589 %
10590 % \begin{macro}{\colorchapnum}
10591 % \begin{macro}{\colorchaptitle}
10592 % \begin{macro}{\chs@pedersen}
10593 % Posted to CTT 2006/01/31, \textit{Chapter style}, by Troels Pedersen.
10594 % It requires the \Lpack{graphicx} package and possibly the \Lpack{color}
10595 % package. I have used a \cs{sidebar} instead of the original \cs{marginpar},
10596 % and eliminated a new length. The original color specification, the same for
10597 % the title and nunmber, can now be set via \cs{colorchapnum} and
10598 % \cs{colorchaptitle}.
10599 % \begin{macrocode}
10600 \newcommand*{\colorchapnum}{}
10601 \newcommand*{\colorchaptitle}{}
10602 \makechapterstyle{pedersen}{%
10603 \chapterstyle{default}
10604 \setlength{\beforechapskip}{-20pt}
10605 \setlength{\afterchapskip}{10pt}
10606 \renewcommand*{\chapnamefont}{\normalfont\LARGE\itshape}
10607 \renewcommand*{\chapnumfont}{\normalfont\HUGE\itshape\colorchapnum}
10608 \renewcommand*{\chaptitlefont}{\normalfont\huge\itshape\colorchaptitle}
10609 \renewcommand*{\afterchapternum}{}
10610 \renewcommand*{\printchaptername}{}
10611 \setlength{\midchapskip}{20mm}% was \numberheight
10612 \renewcommand*{\chapternamenum}{}
10613 \renewcommand*{\printchapternum}{%
10614 \sidebar{\raisebox{0pt}[0pt][0pt]{\makebox[0pt][l]{%
10615 \resizebox{!}{\midchapskip}{\chapnumfont\thechapter}}}}}
10616 \renewcommand*{\printchaptertitle}[1]{\chaptitlefont ##1}}
10617
10618 % \end{macrocode}
10619 % \end{macro}
10620 % \end{macro}
10621 % \end{macro}
10622 %
10623 % \begin{macro}{\chs@southall}
10624 % Style provided by Thomas Dye. I have modified the original to eliminate
10625 % the use of new lengths.
10626 % \changes{v1.61803398}{2009/07/17}{Added bidi support to southall chapterstyle}
10627 % \begin{macrocode}
10628 %% Thomas Dye's southall chapter style
10629 \makechapterstyle{southall}{%
10630 \chapterstyle{default}
10631 \setlength{\afterchapskip}{5\baselineskip}
10632 \setlength{\beforechapskip}{36pt}% \headindent
10633 \setlength{\midchapskip}{\textwidth}% \rightblock
10634 \addtolength{\midchapskip}{-\beforechapskip}
10635 \renewcommand*{\chapterheadstart}{\vspace*{2\baselineskip}}
10636 \renewcommand*{\chaptitlefont}{\huge\rmfamily\memRTLraggedright}
10637 \renewcommand*{\chapnumfont}{\chaptitlefont}
10638 \renewcommand*{\printchaptername}{}
10639 \renewcommand*{\chapternamenum}{}
10640 \renewcommand*{\afterchapternum}{}
10641 \renewcommand*{\printchapternum}{%
10642 \begin{minipage}[t][\baselineskip][b]{\beforechapskip}
10643 {\vspace{0pt}\chapnumfont%%%\figureversion{lining}
10644 \thechapter}
10645 \end{minipage}}
10646 \renewcommand*{\printchaptertitle}[1]{%
10647 \hfill\begin{minipage}[t]{\midchapskip}
10648 {\vspace{0pt}\chaptitlefont ##1\par}\end{minipage}}
10649 \renewcommand*{\afterchaptertitle}{%
10650 \par\vspace{\baselineskip}%
10651 \hrulefill \par\nobreak\noindent \vskip \afterchapskip}}
10652
10653 % \end{macrocode}
10654 % \end{macro}
10655 %
10656 % \begin{macro}{\chs@thatcher}
10657 % Original posted to CTT on 2006/01/18 by Scott Thatcher,
10658 % \textit{memoir: chapter headings capitalize math symbols}. I have modified
10659 % it to cater for multiline titles, appendices, and unnumbered
10660 % chapters.
10661 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
10662 % \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
10663 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
10664 % \begin{macrocode}
10665 \makechapterstyle{thatcher}{%
10666 \chapterstyle{default}
10667 \renewcommand*{\chapterheadstart}{}
10668 \renewcommand*{\printchaptername}{%
10669 \centerline{\chapnumfont{\@chapapp\ \thechapter}}}
10670 \renewcommand*{\chapternamenum}{}
10671 \renewcommand*{\chapnumfont}{\normalfont\scshape\MakeLowercase}
10672 \renewcommand*{\printchapternum}{}
10673 \renewcommand*{\afterchapternum}{%
10674 \par\centerline{\parbox{0.5in}{\hrulefill}}\par}
10675 \renewcommand*{\printchapternonum}{%
10676 \vphantom{\chapnumfont \@chapapp 1}\par
10677 \parbox{0.5in}{}\par}
10678 \renewcommand*{\chaptitlefont}{\normalfont\large}
10679 \renewcommand*{\printchaptertitle}[1]{%
10680 \centering \chaptitlefont\MakeUppercase{##1}}}
10681
10682 % \end{macrocode}
10683 % \end{macro}
10684 %
10685 % \begin{macro}{\chs@veelo}
10686 % This, from Baastian Veelo, has been noted in the documentation for
10687 % quite a time.
10688 % I have modified the original to eliminate the need for extra lengths.
10689 % It well suits trimmed documents.
10690 % We are scaling the chapter number, which most DVI viewers
10691 % will not display accurately. It requires the graphicx package.
10692 % \changes{v3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
10693 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
10694 % \begin{macrocode}
10695 \makechapterstyle{veelo}{%
10696 % \chapterstyle{default}
10697 \setlength{\afterchapskip}{40pt}
10698 \renewcommand*{\chapterheadstart}{\vspace*{40pt}}
10699 \renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
10700 \renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright}
10701 \renewcommand*{\chapnumfont}{\normalfont\HUGE}
10702 \renewcommand*{\chaptitlefont}{\normalfont\HUGE\bfseries\flushright}
10703 \renewcommand*{\printchaptername}{%
10704 \chapnamefont\MakeUppercase{\@chapapp}}
10705 \renewcommand*{\chapternamenum}{}
10706 % \setlength{\numberheight}{18mm}
10707 % \setlength{\barlength}{\paperwidth}
10708 % \addtolength{\barlength}{-\textwidth}
10709 % \addtolength{\barlength}{-\spinemargin}
10710 \setlength{\beforechapskip}{18mm}% \numberheight
10711 \setlength{\midchapskip}{\paperwidth}% \barlength
10712 \addtolength{\midchapskip}{-\textwidth}
10713 \addtolength{\midchapskip}{-\spinemargin}
10714 \renewcommand*{\printchapternum}{%
10715 \makebox[0pt][l]{%
10716 \hspace{.8em}%
10717 \resizebox{!}{\beforechapskip}{\chapnumfont \thechapter}%
10718 \hspace{.8em}%
10719 \rule{\midchapskip}{\beforechapskip}%
10720 }%
10721 }%
10722 \makeoddfoot{plain}{}{}{\thepage}}
10723
10724 % \end{macrocode}
10725 % \end{macro}
10726 %
10727 % \begin{macro}{\chs@verville}
10728 % I posted the original to CTT on 2005/01/18, \textit{Headers and special
10729 % formatting of sections}, in answer to a question by
10730 % Guy Verville. This version caters for unnumbered chapters.
10731 % \begin{macrocode}
10732 \makechapterstyle{verville}{%
10733 % \chapterstyle{default}
10734 \setlength{\beforechapskip}{0pt}
10735 \renewcommand*{\printchaptername}{}
10736 \renewcommand*{\printchapternum}{%
10737 \hrule \vskip 0.5\onelineskip
10738 \Huge \centering \thechapter.\ }
10739 \renewcommand*{\printchapternonum}{%
10740 \hrule \vskip 0.5\onelineskip
10741 \Huge \centering}
10742 \renewcommand*{\afterchapternum}{}
10743 \setlength{\midchapskip}{0pt}
10744 \renewcommand*{\printchaptertitle}[1]{%
10745 ##1 \par
10746 \vskip 0.5\onelineskip
10747 \hrule}}
10748
10749 % \end{macrocode}
10750 % \end{macro}
10751 %
10752 % \begin{macro}{\chs@crosshead}
10753 % A centered chapterstyle (from Bringhurst)
10754 % \changes{v1.61803}{2008/01/30}{Added chapterstyles: crosshead, dowding,
10755 % komalike, ntglike, tandh, and wilsondob}
10756 % \begin{macrocode}
10757 \makechapterstyle{crosshead}{%
10758 \setlength{\beforechapskip}{2\onelineskip}%
10759 \renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}%
10760 \setlength{\afterchapskip}{2\onelineskip \@plus .2\onelineskip
10761 \@minus 0.2\onelineskip}%
10762 \renewcommand*{\printchaptername}{}%
10763 \renewcommand*{\chapternamenum}{}%
10764 \renewcommand*{\chapnumfont}{\normalfont\LARGE\bfseries}%
10765 \renewcommand*{\chaptitlefont}{\chapnumfont}%
10766 \renewcommand*{\printchapternum}{%
10767 \centering\chapnumfont \thechapter\quad}%
10768 \renewcommand{\afterchapternum}{}%
10769 \renewcommand*{\printchapternonum}{\centering}}
10770
10771 % \end{macrocode}
10772 % \end{macro}
10773 %
10774 % \begin{macro}{\chs@dowding}
10775 % A centered chapterstyle (from Dowding's \textit{Finer Points})
10776 % \begin{macrocode}
10777 \makechapterstyle{dowding}{%
10778 \setlength{\beforechapskip}{2\onelineskip}%
10779 \setlength{\afterchapskip}{1.5\onelineskip \@plus .1\onelineskip
10780 \@minus 0.167\onelineskip}%
10781 \renewcommand*{\chapnamefont}{\normalfont}%
10782 \renewcommand*{\chapnumfont}{\chapnamefont}%
10783 \renewcommand*{\printchapternum}{\centering\chapnumfont \ifanappendix \thechapter
10784 \else \numtoName{\c@chapter}\fi}%
10785 \renewcommand*{\chaptitlefont}{\normalfont\itshape\huge\centering}%
10786 \renewcommand*{\printchapternonum}{%
10787 \vphantom{\printchaptername}\vskip\midchapskip}}
10788
10789 % \end{macrocode}
10790 % \end{macro}
10791 %
10792 % \begin{macro}{\chs@komalike}
10793 % A chapterstyle approximating the KOMA script style (\texttt{scrbook.cls})
10794 % \begin{macrocode}
10795 \makechapterstyle{komalike}{%
10796 \setlength{\beforechapskip}{2\onelineskip}%
10797 \setlength{\afterchapskip}{1.5\onelineskip \@plus .1\onelineskip
10798 \@minus 0.167\onelineskip}%
10799 \renewcommand*{\printchaptername}{}%
10800 \renewcommand*{\chapternamenum}{}%
10801 \renewcommand*{\chapnumfont}{\normalfont\LARGE\sffamily\bfseries}%
10802 \renewcommand*{\printchapternum}{\chapnumfont \thechapter\space}%
10803 \renewcommand*{\afterchapternum}{}%
10804 \renewcommand*{\chaptitlefont}{\normalfont\LARGE\sffamily\bfseries}}
10805
10806 % \end{macrocode}
10807 % \end{macro}
10808 %
10809 % \begin{macro}{\chs@ntglike}
10810 % A chapterstyle approximating the NTG style (\texttt{boek.cls})
10811 % \begin{macrocode}
10812 \makechapterstyle{ntglike}{%
10813 \setlength{\beforechapskip}{50pt \@plus 20pt}%
10814 \renewcommand*{\chapnamefont}{\normalfont\Large\bfseries}%
10815 \renewcommand*{\chapnumfont}{\normalfont\Large\bfseries}%
10816 \renewcommand*{\chaptitlefont}{\normalfont\Large\bfseries}}
10817
10818 % \end{macrocode}
10819 % \end{macro}
10820 %
10821 % \begin{macro}{\chs@tandh}
10822 % A chapterstyle based on Thames \& Hudson \textit{Typography}.
10823 % \changes{v1.61803398}{2009/07/17}{Added bidi support to tandh chapterstyle}
10824 % \begin{macrocode}
10825 \makechapterstyle{tandh}{%
10826 \setlength{\beforechapskip}{1\onelineskip}%
10827 \setlength{\afterchapskip}{2\onelineskip \@plus .1\onelineskip
10828 \@minus 0.167\onelineskip}%
10829 \renewcommand*{\printchaptername}{}%
10830 \renewcommand*{\chapternamenum}{}%
10831 \renewcommand*{\chapnumfont}{\normalfont\huge\bfseries}%
10832 \renewcommand*{\printchapternum}{\chapnumfont \thechapter\quad}%
10833 \renewcommand*{\afterchapternum}{}%
10834 \renewcommand*{\chaptitlefont}{\chapnumfont\memRTLraggedright}}
10835
10836 % \end{macrocode}
10837 % \end{macro}
10838 %
10839 % \begin{macro}{\chs@wilsondob}
10840 % A chapterstyle based on Adrian Wilson's \textit{Design of books}.
10841 % \begin{macrocode}
10842 \makechapterstyle{wilsondob}{%
10843 \setlength{\beforechapskip}{2\onelineskip}%
10844 \setlength{\afterchapskip}{4\onelineskip \@plus .1\onelineskip
10845 \@minus 0.167\onelineskip}%
10846 \renewcommand*{\printchaptername}{}%
10847 \renewcommand*{\chapternamenum}{}%
10848 \renewcommand*{\chapnumfont}{\normalfont\Huge\itshape}%
10849 \renewcommand*{\printchapternum}{\raggedleft\chapnumfont \thechapter\quad}%
10850 \renewcommand*{\afterchapternum}{}%
10851 \renewcommand*{\chaptitlefont}{\chapnumfont}%
10852 \renewcommand*{\printchapternonum}{\raggedleft}}
10853
10854 % \end{macrocode}
10855 % \end{macro}
10856 %
10857 %
10858 % \subsection{Lower level headings}
10859 %
10860 % These commands all make use of \cs{@startsection}. However,
10861 % for the purposes of the class the kernel version needs modification
10862 % to support:
10863 % \begin{itemize}
10864 % \item make short pages (where a section heading is moved to the top
10865 % of the next page) ragged bottom;
10866 % \item provide headings with two optional arguments.
10867 % \end{itemize}
10868 %
10869 %
10870 % We will tweak \cs{@startsection} so that a short page (where a section
10871 % heading is moved from the bottom of the page to the top of the next)
10872 % can be set \cs{raggedbottom}.
10873 %
10874 % \begin{macro}{\ifraggedbottomsection}
10875 % \begin{macro}{\raggedbottomsectiontrue}
10876 % \begin{macro}{\raggedbottomsectionfalse}
10877 % \begin{macro}{\raggedbottomsection}
10878 % \begin{macro}{\normalbottomsection}
10879 % \begin{macro}{\bottomsectionpenalty}
10880 % \cs{raggedbottomsectiontrue} for ragged short pages.
10881 % \changes{v1.3}{2002/11/14}{Added \cs{ifraggedbottomsection}}
10882 % \changes{v1.61803}{2008/01/30}{Added \cs{raggedbottomsection} and
10883 % \cs{normalbottomsection}}
10884 % \changes{v3.6k}{2012/07/22}{Made the \cs{raggedbottomsection}
10885 % penalty configurable}
10886 % \begin{macrocode}
10887 \newif\ifraggedbottomsection
10888 \raggedbottomsectionfalse
10889 \newcommand*{\raggedbottomsection}{\raggedbottomsectiontrue}
10890 \newcommand*{\normalbottomsection}{\raggedbottomsectionfalse}
10891 \newcommand*{\bottomsectionpenalty}{\z@}
10892
10893 % \end{macrocode}
10894 % \end{macro}
10895 % \end{macro}
10896 % \end{macro}
10897 % \end{macro}
10898 % \end{macro}
10899 % \end{macro}
10900 %
10901 % \begin{macro}{\bottomsectionskip}
10902 % Decreasing this length increases short page bottom flushness.
10903 % \changes{v1.3}{2002/11/14}{Added \cs{bottomsectionskip}}
10904 % \begin{macrocode}
10905 \newlength{\bottomsectionskip}
10906 \setlength{\bottomsectionskip}{10mm}
10907
10908 % \end{macrocode}
10909 % \end{macro}
10910 %
10911 % We will add a second optional argument for \cs{section}, etc.
10912 % See the \ctt{} thread \textit{`Long headers'} 15 Jan 2003.
10913 %
10914 % The kernel \cs{@dblarg} is used in situations where the default
10915 % value for an optional argument is the same as the required argument.
10916 % Schematically, \\
10917 % \verb?\@dblarg -> Main, Main? \\
10918 % The macros \cs{@trplargomm} and \cs{@trplargoom} are extensions to this
10919 % idea for two optional arguments.
10920 %
10921 % \begin{macro}{\@trplargomm}
10922 % \begin{macro}{\@xtrplargomm}
10923 % \begin{macro}{\@xxtrplarg}
10924 % \verb?\@trplargomm -> Opt, Main, Main?
10925 % \begin{macrocode}
10926 \newcommand{\@trplargomm}[1]{%
10927 \@ifnextchar[{\@xtrplargomm{#1}}%
10928 {\@xxtrplarg{#1}}}
10929 \long\def\@xtrplargomm#1[#2]{\@dblarg{#1[#2]}}
10930 \newcommand{\@xxtrplarg}[2]{#1[{#2}][{#2}]{#2}}
10931 % \end{macrocode}
10932 % \end{macro}
10933 % \end{macro}
10934 % \end{macro}
10935 %
10936 % \begin{macro}{\@trplargoom}
10937 % \begin{macro}{\@xtrplargoom}
10938 % \verb?\@trplargoom -> Opt, Opt, Main?
10939 % \begin{macrocode}
10940 \newcommand{\@trplargoom}[1]{%
10941 \@ifnextchar[{\@xtrplargoom{#1}}%
10942 {\@xxtrplarg{#1}}}
10943 \long\def\@xtrplargoom#1[#2]{%
10944 \@ifnextchar[{#1[{#2}]}%
10945 {#1[{#2}][{#2}]}}
10946
10947 % \end{macrocode}
10948 % \end{macro}
10949 % \end{macro}
10950 %
10951 % \begin{macro}{\memsecinfo}
10952 % \begin{macro}{\memsecstarinfo}
10953 % \verb?\memsecinfo{secname}{\thenum}{toc}{head}{title}? \\
10954 % \verb?\memsecstarinfo{secname}{title}? \\
10955 % \begin{macrocode}
10956 \newcommand{\memsecinfo}[5]{}
10957 \newcommand{\memsecstarinfo}[2]{}
10958
10959 % \end{macrocode}
10960 % \end{macro}
10961 % \end{macro}
10962 %
10963 % \begin{macro}{\@startsection}
10964 % \begin{macro}{\m@msecn@me}
10965 % Change kernel \cs{@startsection} to: \\
10966 % \begin{itemize}
10967 % \item Make short pages raggedbottom. This is based on the thread
10968 % \textit{Can \cs{flushbottom} and \cs{section} be made to live together?}
10969 % on \ctt{} in September 2002.
10970 % \changes{v1.3}{2002/11/14}{Modified \cs{@startsection} for raggedbottoming}
10971 % \item add an extra optional argument.
10972 % \changes{v1.4}{2003/11/22}{Added extra optional arg to \cs{@startsection}
10973 % (from patch v1.4)}
10974 % \item make sure it is not effected by a non-zero \cs{parskip}
10975 % \changes{v3.6j}{2011/03/02}{added the above feature}
10976 % \item store the name of the type in \cs{m@msecn@me}
10977 % \end{itemize}
10978 % The original is in \file{latex.ltx}. \\
10979 % \cs{@startsection}\marg{name}\marg{level}\marg{indent} \\
10980 % \hspace*{1.5in} \marg{beforeskip}\marg{afterskip}\marg{style}
10981 %
10982 % In order to make experiments with the tagging code, we only make the
10983 % redefinition, if \textsf{dev-mode} is not active. Otherwise we
10984 % patch. It is intentional that the patches are ``talkative''.
10985 % \changes{v3.8.2}{2023/08/24}{Forgot to add this patching branch in 3.8}
10986 % \begin{macrocode}
10987 \ifmem@devmode
10988
10989 % \end{macrocode}
10990 % The first patch add the block hook, the raggedbottom secton code,
10991 % and the storing of the name of the section type.
10992 % \begin{macrocode}
10993 \patchcmd\@startsection{%
10994 \if@noskipsec \leavevmode \fi%
10995 }{%
10996 \@nameuse{#1block}%
10997 \ifraggedbottomsection\if@nobreak\else
10998 \vskip\z@\@plus\bottomsectionskip
10999 \penalty\bottomsectionpenalty
11000 \vskip\z@\@plus -\bottomsectionskip
11001 \fi\fi
11002 \def\m@msecn@me{#1}%
11003 \if@noskipsec \leavevmode \fi%
11004 }%
11005 {\typeout{\string\@startsection\space patch 1 success}}
11006 {\typeout{\string\@startsection\space patch 1 failed}}
11007
11008 % \end{macrocode}
11009 % The second patch adds a small adjustment that help counter the
11010 % effect of a non-zero \cs{parskip}
11011 % \begin{macrocode}
11012 \patchcmd\@startsection{%
11013 \addpenalty\@secpenalty\addvspace\@tempskipa%
11014 }{%
11015 \addpenalty\@secpenalty\addvspace\@tempskipa
11016 \addvspace{-\parskip}% <--- added 2011/03/02
11017 }%
11018 {\typeout{\string\@startsection\space patch 2 success}}
11019 {\typeout{\string\@startsection\space patch 2 failed}}
11020
11021 % \end{macrocode}
11022 % The third patch completely replaces
11023 % \begin{verbatim}
11024 % \@ifstar
11025 % {\@ssect{#3}{#4}{#5}{#6}}%
11026 % {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}
11027 % \end{verbatim}
11028 % as we need to handle two optional args not just the normal
11029 % 1. Perhaps there are better ways.
11030 % \begin{macrocode}
11031 \patchcmd\@startsection{%
11032 \@ifstar%
11033 {\@ssect{#3}{#4}{#5}{#6}}%
11034 {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
11035 }{%
11036 \@ifstar%
11037 {\@ssect{#3}{#4}{#5}{#6}}%
11038 {\@trplargoom{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
11039 }%
11040 {\typeout{\string\@startsection\space patch 3 success}}
11041 {\typeout{\string\@startsection\space patch 3 failed}}
11042
11043 \else % standard branch for dev-mode false
11044 % \end{macrocode}
11045 % Then the normal redefinition
11046 % ^^A name, level, indent, beforeskip, afterskip, style
11047 % \begin{macrocode}
11048 \renewcommand{\@startsection}[6]{%
11049 % \end{macrocode}
11050 % \changes{v3.6h}{2011/02/07}{Added float block hook}
11051 % \begin{macrocode}
11052 \@nameuse{#1block}%
11053 % \end{macrocode}
11054 % Do raggedbottom stuff.
11055 % \changes{v3.6k}{2012/07/22}{Made the \cs{raggedbottomsection}
11056 % penalty configurable}
11057 % \begin{macrocode}
11058 \ifraggedbottomsection\if@nobreak\else
11059 \vskip\z@\@plus\bottomsectionskip
11060 \penalty\bottomsectionpenalty
11061 \vskip\z@\@plus -\bottomsectionskip
11062 \fi\fi
11063 % \end{macrocode}
11064 % Save the section name.
11065 % \begin{macrocode}
11066 \def\m@msecn@me{#1}%
11067 % \end{macrocode}
11068 % The original code.
11069 % \begin{macrocode}
11070 \if@noskipsec \leavevmode \fi
11071 \par
11072 \@tempskipa #4\relax
11073 \@afterindenttrue
11074 \ifdim \@tempskipa <\z@
11075 \@tempskipa -\@tempskipa \@afterindentfalse
11076 \fi
11077 \if@nobreak
11078 \everypar{}%
11079 \else
11080 % \end{macrocode}
11081 % Slight change such that the effect of \cs{parskip} is cancelled
11082 % \changes{v3.6j}{2011/03/02}{Adding a negative \cs{parskip} seem to
11083 % be able to remove the effect of a non-zero \cs{parskip}}
11084 % \begin{macrocode}
11085 \addpenalty\@secpenalty\addvspace\@tempskipa
11086 \addvspace{-\parskip}% <--- added 2011/03/02
11087 \fi
11088 % \end{macrocode}
11089 % For the extra optional argument, change the original \verb?\@dblarg{\@sect{...?
11090 % below to \verb?\@trplargoom{\M@sect{...?.
11091 % \begin{macrocode}
11092 \@ifstar
11093 {\@ssect{#3}{#4}{#5}{#6}}%
11094 {\@trplargoom{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
11095
11096 % \end{macrocode}
11097 % end dev-mode-else branch for \cs{@startsection}:
11098 % \begin{macrocode}
11099
11100 \fi % en dev-mode else branch
11101
11102 % \end{macrocode}
11103 % \end{macro}
11104 % \end{macro}
11105 %
11106 % \changes{v3.6j}{2011/03/02}{Added the change of the kernel \cs{@xsect}}
11107 % \begin{macro}{\@xsect}
11108 % In order to fulfill removing the effect that a non-zero
11109 % \cs{parskip} has on the sectional spacing after the title, we also have to patch
11110 % the kernel \cs{@xsect}. (The original is found in latex.ltx)
11111 % \changes{v3.8.4}{2025/09/18}{Now done using a patch instead of copying and adding one line}
11112 % \changes{v3.8.4}{2025/10/02}{Tagging code may touch \cs{@xsect} and then the patch fails because of catcodes}
11113 % \begin{macrocode}
11114 % \def\@xsect#1{%
11115 % \@tempskipa #1\relax
11116 % \ifdim \@tempskipa>\z@
11117 % \par \nobreak
11118 % \vskip \@tempskipa
11119 % \vskip-\parskip%<--- added 2011/03/02
11120 % \@afterheading
11121 % \else
11122 % \@nobreakfalse
11123 % \global\@noskipsectrue
11124 % \everypar{%
11125 % \if@noskipsec
11126 % \global\@noskipsecfalse
11127 % {\setbox\z@\lastbox}%
11128 % \clubpenalty\@M
11129 % \begingroup \@svsechd \endgroup
11130 % \unskip
11131 % \@tempskipa #1\relax
11132 % \hskip -\@tempskipa
11133 % \else
11134 % \clubpenalty \@clubpenalty
11135 % \everypar{}%
11136 % \fi}%
11137 % \fi
11138 % \ignorespaces}
11139 \ExplSyntaxOn
11140 \xpatchcmd{\@xsect}{\@afterheading}
11141 {\vskip-\parskip\@afterheading}{}{\typeout{Patching~of~\string\@xsect~failed}}
11142 \ExplSyntaxOff
11143
11144 % \end{macrocode}
11145 % \end{macro}
11146 % %
11147 % \begin{macro}{\M@sect}
11148 % At least the \Lpack{hyperref} and \Lpack{nameref} packages, and
11149 % possibly other packages, modify the kernel \cs{@sect} assuming 8 args.
11150 % That's why I've called my version, which has 9 args, something
11151 % else (i.e., \cs{M@sect}). This version also has the support
11152 % for title referencing. \\
11153 % \cs{M@sect}\marg{name}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\ \hspace*{0.5in} \oarg{toc}\oarg{head}\marg{title}
11154 % \changes{v1.4}{2003/11/22}{Added \cs{M@sect}}
11155 % For now we will not add targets for section and friends as hyperref already does.
11156 % \begin{macrocode}
11157 \def\M@sect#1#2#3#4#5#6[#7][#8]#9{%
11158 \ifheadnameref\M@gettitle{#8}\else\M@gettitle{#7}\fi
11159 \ifnum #2>\c@secnumdepth
11160 \let\@svsec\@empty
11161 \memsecinfo{#1}{}{#7}{#8}{#9}%
11162 \else
11163 \refstepcounter{#1}%
11164 \protected@edef\@svsec{\@seccntformat{#1}\relax}%
11165 \memsecinfo{#1}{\@nameuse{the#1}}{#7}{#8}{#9}%
11166 \fi
11167 \@tempskipa #5\relax
11168 \ifdim \@tempskipa>\z@
11169 \begingroup
11170 #6{%
11171 \@hangfrom{\hskip #3\relax\@svsec}%
11172 \interlinepenalty \@M #9\@@par}%
11173 \endgroup
11174 \csname #1mark\endcsname{#8}%
11175 \addcontentsline{toc}{#1}{%
11176 \ifnum #2>\c@secnumdepth \else
11177 \protect\numberline{\csname the#1\endcsname}%
11178 \fi
11179 #7}%
11180 \else
11181 \def\@svsechd{%
11182 #6{\hskip #3\relax
11183 \@svsec #9}%
11184 \csname #1mark\endcsname{#8}%
11185 \addcontentsline{toc}{#1}{%
11186 \ifnum #2>\c@secnumdepth \else
11187 \protect\numberline{\csname the#1\endcsname}%
11188 \fi
11189 #7}}%
11190 \fi
11191 \@xsect{#5}}
11192
11193 % \end{macrocode}
11194 % \end{macro}
11195 %
11196 % \begin{macro}{\@sect}
11197 % \changes{v3.8}{2023/07/24}{Added patch.}
11198 % The \Lpack{pdfpages} package assumes \cs{@sect} in order to add
11199 % stuff to say \cs{@currentlabelname}. So in case others use it we map \cs{@sect}.
11200 % \begin{macrocode}
11201 \def\@sect#1#2#3#4#5#6[#7]#8{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#7}]{#8}}
11202
11203 % \end{macrocode}
11204 % \end{macro}
11205 %
11206 % \begin{macro}{\@ssect}
11207 % Add hook for name reference to \cs{section*} etc. \\
11208 % \cs{@ssect}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{title}
11209 % \changes{v1.61803}{2008/01/30}{Used corrected number of arguments to
11210 % \cs{memsecstarinfo} in \cs{@ssect} (Gabriel Guernik, mempatch v4.1)}
11211 % \begin{macrocode}
11212 \let\@mem@old@ssect\@ssect
11213 \def\@ssect#1#2#3#4#5{%
11214 \M@gettitle{#5}%
11215 \memsecstarinfo{\m@msecn@me}{#5}%
11216 \@mem@old@ssect{#1}{#2}{#3}{#4}{#5}}
11217
11218 % \end{macrocode}
11219 % \end{macro}
11220 %
11221 %
11222 %
11223 % \begin{macro}{\section}
11224 % A normal heading with white space above and below and no indentation
11225 % of the first paragraph.
11226 % By default the heading is set in a \verb?\Large\bfseries? font.
11227 % \begin{macrocode}
11228 \newcommand{\section}{%
11229 \sechook%
11230 \@startsection{section}{1}% level 1
11231 {\secindent}% heading indent
11232 {\beforesecskip}% skip before the heading
11233 {\aftersecskip}% skip after the heading
11234 {\normalfont\secheadstyle}} % font
11235 % \end{macrocode}
11236 % \end{macro}
11237 %
11238 % \begin{macro}{\sechook}
11239 % \begin{macro}{\setsechook}
11240 % \cs{sechook} is called at the start of a \cs{section} and
11241 % \cs{setsechook}\marg{code} redefines it.
11242 % \begin{macrocode}
11243 \newcommand{\sechook}{}
11244 \newcommand{\setsechook}[1]{\renewcommand{\sechook}{#1}}
11245 % \end{macrocode}
11246 % \end{macro}
11247 % \end{macro}
11248 %
11249 % \begin{macro}{\secindent}
11250 % \begin{macro}{\beforesecskip}
11251 % \begin{macro}{\aftersecskip}
11252 % \begin{macro}{\secheadstyle}
11253 % \begin{macro}{\setsecindent}
11254 % \begin{macro}{\setbeforesecskip}
11255 % \begin{macro}{\setaftersecskip}
11256 % \begin{macro}{\setsecheadstyle}
11257 % \cs{secindent} is the indentation of the section heading from the left margin,
11258 % \cs{beforesecskip} and \cs{aftersecskip} specify the white space before
11259 % and after the heading, and \cs{secheadstyle} specifies the heading style.
11260 % These are set to the default values for the \Lpack{book} class,
11261 % except that the heading will be \cs{raggedright}, thus preventing
11262 % hyphenation. The
11263 % \cs{set...} commands are for the user to change the values.
11264 % \changes{v1.61803398}{@009/07/17}{Added bidi support to default secheadstyle}
11265 % \begin{macrocode}
11266 \newlength{\secindent}
11267 \newcommand{\setsecindent}[1]{\setlength{\secindent}{#1}}
11268 \setsecindent{\z@}
11269 \newskip\beforesecskip
11270 \newcommand{\setbeforesecskip}[1]{\setlength{\beforesecskip}{#1}}
11271 \setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}
11272 \newskip\aftersecskip
11273 \newcommand{\setaftersecskip}[1]{\setlength{\aftersecskip}{#1}}
11274 \setaftersecskip{2.3ex \@plus .2ex}
11275 \newcommand{\secheadstyle}{}
11276 \newcommand{\setsecheadstyle}[1]{\renewcommand{\secheadstyle}{#1}}
11277 \setsecheadstyle{\Large\bfseries\memRTLraggedright}
11278
11279 % \end{macrocode}
11280 % \end{macro}
11281 % \end{macro}
11282 % \end{macro}
11283 % \end{macro}
11284 % \end{macro}
11285 % \end{macro}
11286 % \end{macro}
11287 % \end{macro}
11288 %
11289 % \begin{macro}{\subsection}
11290 % A normal heading with white space above and below and no indentation
11291 % of the first paragraph.
11292 % By default the heading is set in a \verb?\large\bfseries? font.
11293 % \begin{macrocode}
11294 \newcommand{\subsection}{%
11295 \subsechook%
11296 \@startsection{subsection}{2}% level 2
11297 {\subsecindent}% heading indent
11298 {\beforesubsecskip}% skip before the heading
11299 {\aftersubsecskip}% skip after the heading
11300 {\normalfont\subsecheadstyle}} % font
11301 % \end{macrocode}
11302 % \end{macro}
11303 %
11304 % \begin{macro}{\subsechook}
11305 % \begin{macro}{\setsubsechook}
11306 % \cs{subsechook} is called at the start of a \cs{subsection} and
11307 % \cs{setsubsechook}\marg{code} redefines it.
11308 % \begin{macrocode}
11309 \newcommand{\subsechook}{}
11310 \newcommand{\setsubsechook}[1]{\renewcommand{\subsechook}{#1}}
11311 % \end{macrocode}
11312 % \end{macro}
11313 % \end{macro}
11314 %
11315 %
11316 % \begin{macro}{\subsecindent}
11317 % \begin{macro}{\beforesubsecskip}
11318 % \begin{macro}{\aftersubsecskip}
11319 % \begin{macro}{\subsecheadstyle}
11320 % \begin{macro}{\setsubsecindent}
11321 % \begin{macro}{\setbeforesubsecskip}
11322 % \begin{macro}{\setaftersubsecskip}
11323 % \begin{macro}{\setsubsecheadstyle}
11324 % The macros for controlling \cs{subsection} headings.
11325 % \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsec headstyle}
11326 % \begin{macrocode}
11327 \newlength{\subsecindent}
11328 \newcommand{\setsubsecindent}[1]{\setlength{\subsecindent}{#1}}
11329 \setsubsecindent{\z@}
11330 \newskip\beforesubsecskip
11331 \newcommand{\setbeforesubsecskip}[1]{\setlength{\beforesubsecskip}{#1}}
11332 \setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}
11333 \newskip\aftersubsecskip
11334 \newcommand{\setaftersubsecskip}[1]{\setlength{\aftersubsecskip}{#1}}
11335 \setaftersubsecskip{1.5ex \@plus .2ex}
11336 \newcommand{\subsecheadstyle}{}
11337 \newcommand{\setsubsecheadstyle}[1]{\renewcommand{\subsecheadstyle}{#1}}
11338 \setsubsecheadstyle{\large\bfseries\memRTLraggedright}
11339
11340 % \end{macrocode}
11341 % \end{macro}
11342 % \end{macro}
11343 % \end{macro}
11344 % \end{macro}
11345 % \end{macro}
11346 % \end{macro}
11347 % \end{macro}
11348 % \end{macro}
11349 %
11350 %
11351 % \begin{macro}{\subsubsection}
11352 % A normal heading with white space above and below and no indentation
11353 % of the first paragraph.
11354 % By default the heading is set in a \verb?\normalsize\bfseries? font.
11355 % \begin{macrocode}
11356 \newcommand{\subsubsection}{%
11357 \subsubsechook%
11358 \@startsection{subsubsection}{3}% level 3
11359 {\subsubsecindent}% heading indent
11360 {\beforesubsubsecskip}% skip before the heading
11361 {\aftersubsubsecskip}% skip after the heading
11362 {\normalfont\subsubsecheadstyle}} % font
11363 % \end{macrocode}
11364 % \end{macro}
11365 %
11366 % \begin{macro}{\subsubsechook}
11367 % \begin{macro}{\setsubsubsechook}
11368 % \cs{subsubsechook} is called at the start of a \cs{subsubsection} and
11369 % \cs{setsubsubsechook}\marg{code} redefines it.
11370 % \begin{macrocode}
11371 \newcommand{\subsubsechook}{}
11372 \newcommand{\setsubsubsechook}[1]{\renewcommand{\subsubsechook}{#1}}
11373 % \end{macrocode}
11374 % \end{macro}
11375 % \end{macro}
11376 %
11377 %
11378 % \begin{macro}{\subsubsecindent}
11379 % \begin{macro}{\beforesubsubsecskip}
11380 % \begin{macro}{\aftersubsubsecskip}
11381 % \begin{macro}{\subsubsecheadstyle}
11382 % \begin{macro}{\setsubsubsecindent}
11383 % \begin{macro}{\setbeforesubsubsecskip}
11384 % \begin{macro}{\setaftersubsubsecskip}
11385 % \begin{macro}{\setsubsubsecheadstyle}
11386 % The macros for controlling \cs{subsubsection} headings.
11387 % \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsubsec headstyle}
11388 % \begin{macrocode}
11389 \newlength{\subsubsecindent}
11390 \newcommand{\setsubsubsecindent}[1]{%
11391 \setlength{\subsubsecindent}{#1}}
11392 \setsubsubsecindent{\z@}
11393 \newskip\beforesubsubsecskip
11394 \newcommand{\setbeforesubsubsecskip}[1]{%
11395 \setlength{\beforesubsubsecskip}{#1}}
11396 \setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}
11397 \newskip\aftersubsubsecskip
11398 \newcommand{\setaftersubsubsecskip}[1]{%
11399 \setlength{\aftersubsubsecskip}{#1}}
11400 \setaftersubsubsecskip{1.5ex \@plus .2ex}
11401 \newcommand{\subsubsecheadstyle}{}
11402 \newcommand{\setsubsubsecheadstyle}[1]{%
11403 \renewcommand{\subsubsecheadstyle}{#1}}
11404 \setsubsubsecheadstyle{\normalsize\bfseries\memRTLraggedright}
11405
11406 % \end{macrocode}
11407 % \end{macro}
11408 % \end{macro}
11409 % \end{macro}
11410 % \end{macro}
11411 % \end{macro}
11412 % \end{macro}
11413 % \end{macro}
11414 % \end{macro}
11415 %
11416 %
11417 %
11418 % \begin{macro}{\paragraph}
11419 % A runin heading with white space above and to the right of the heading.
11420 % By default the heading is set in a \verb?\normalsize\bfseries? font.
11421 % \begin{macrocode}
11422 \newcommand{\paragraph}{%
11423 \parahook%
11424 \@startsection{paragraph}{4}% level 4
11425 {\paraindent}% heading indent
11426 {\beforeparaskip}% skip before the heading
11427 {\afterparaskip}% skip after the heading
11428 {\normalfont\paraheadstyle}} % font
11429 % \end{macrocode}
11430 % \end{macro}
11431 %
11432 % \begin{macro}{\parahook}
11433 % \begin{macro}{\setparahook}
11434 % \cs{parahook} is called at the start of a \cs{paragraph} and
11435 % \cs{setparahook}\marg{code} redefines it.
11436 % \begin{macrocode}
11437 \newcommand{\parahook}{}
11438 \newcommand{\setparahook}[1]{\renewcommand{\parahook}{#1}}
11439 % \end{macrocode}
11440 % \end{macro}
11441 % \end{macro}
11442 %
11443 %
11444 % \begin{macro}{\paraindent}
11445 % \begin{macro}{\beforeparaskip}
11446 % \begin{macro}{\afterparaskip}
11447 % \begin{macro}{\paraheadstyle}
11448 % \begin{macro}{\setparaindent}
11449 % \begin{macro}{\setbeforeparaskip}
11450 % \begin{macro}{\setafterparaskip}
11451 % \begin{macro}{\setparaheadstyle}
11452 % The macros for controlling \cs{paragraph} headings.
11453 % \begin{macrocode}
11454 \newlength{\paraindent}
11455 \newcommand{\setparaindent}[1]{\setlength{\paraindent}{#1}}
11456 \setparaindent{\z@}
11457 \newskip\beforeparaskip
11458 \newcommand{\setbeforeparaskip}[1]{\setlength{\beforeparaskip}{#1}}
11459 \setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}
11460 \newskip\afterparaskip
11461 \newcommand{\setafterparaskip}[1]{\setlength{\afterparaskip}{#1}}
11462 \setafterparaskip{-1em}
11463 \newcommand{\paraheadstyle}{}
11464 \newcommand{\setparaheadstyle}[1]{\renewcommand{\paraheadstyle}{#1}}
11465 \setparaheadstyle{\normalsize\bfseries}
11466
11467 % \end{macrocode}
11468 % \end{macro}
11469 % \end{macro}
11470 % \end{macro}
11471 % \end{macro}
11472 % \end{macro}
11473 % \end{macro}
11474 % \end{macro}
11475 % \end{macro}
11476 %
11477 %
11478 %
11479 % \begin{macro}{\subparagraph}
11480 % A runin heading with white space above and to the right of the heading.
11481 % By default the heading is set in a \verb?\normalsize\bfseries? font.
11482 % \begin{macrocode}
11483 \newcommand{\subparagraph}{%
11484 \subparahook%
11485 \@startsection{subparagraph}{5}% level 5
11486 {\subparaindent}% heading indent
11487 {\beforesubparaskip}% skip before the heading
11488 {\aftersubparaskip}% skip after the heading
11489 {\normalfont\subparaheadstyle}} % font
11490 % \end{macrocode}
11491 % \end{macro}
11492 %
11493 % \begin{macro}{\subparahook}
11494 % \begin{macro}{\setsubparahook}
11495 % \cs{subparahook} is called at the start of a \cs{subparagraph} and
11496 % \cs{setsubparahook}\marg{code} redefines it.
11497 % \begin{macrocode}
11498 \newcommand{\subparahook}{}
11499 \newcommand{\setsubparahook}[1]{\renewcommand{\subparahook}{#1}}
11500 % \end{macrocode}
11501 % \end{macro}
11502 % \end{macro}
11503 %
11504 %
11505 % \begin{macro}{\subparaindent}
11506 % \begin{macro}{\beforesubparaskip}
11507 % \begin{macro}{\aftersubparaskip}
11508 % \begin{macro}{\subparaheadstyle}
11509 % \begin{macro}{\setsubparaindent}
11510 % \begin{macro}{\setbeforesubparaskip}
11511 % \begin{macro}{\setaftersubparaskip}
11512 % \begin{macro}{\setsubparaheadstyle}
11513 % The macros for controlling \cs{subparagraph} headings.
11514 % \begin{macrocode}
11515 \newlength{\subparaindent}
11516 \newcommand{\setsubparaindent}[1]{%
11517 \setlength{\subparaindent}{#1}}
11518 \setsubparaindent{\parindent}
11519 \newskip\beforesubparaskip
11520 \newcommand{\setbeforesubparaskip}[1]{%
11521 \setlength{\beforesubparaskip}{#1}}
11522 \setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}
11523 \newskip\aftersubparaskip
11524 \newcommand{\setaftersubparaskip}[1]{%
11525 \setlength{\aftersubparaskip}{#1}}
11526 \setaftersubparaskip{-1em}
11527 \newcommand{\subparaheadstyle}{}
11528 \newcommand{\setsubparaheadstyle}[1]{%
11529 \renewcommand{\subparaheadstyle}{#1}}
11530 \setsubparaheadstyle{\normalsize\bfseries}
11531
11532 % \end{macrocode}
11533 % \end{macro}
11534 % \end{macro}
11535 % \end{macro}
11536 % \end{macro}
11537 % \end{macro}
11538 % \end{macro}
11539 % \end{macro}
11540 % \end{macro}
11541 %
11542 % \begin{macro}{\sethangfrom}
11543 % The macro \cs{sethangfrom}\marg{code} is a user-level command
11544 % for changing the definition of \cs{@hangfrom}. Use \verb?#1? in \meta{code}
11545 % for the argument to \cs{@hangfrom} (or \verb?##1? if used inside another macro).
11546 % \changes{v0.2}{2001/06/03}{Added \cs{sethangfrom}}
11547 % \begin{macrocode}
11548 \newcommand{\sethangfrom}[1]{\renewcommand{\@hangfrom}[1]{#1}}
11549 % \end{macrocode}
11550 % \end{macro}
11551 %
11552 % \begin{macro}{\setsecnumformat}
11553 % The macro \cs{setsecnumformat}\marg{code} is a user-level command
11554 % for changing the definition of \cs{@seccntformat}. Use \verb?#1? in \meta{code}
11555 % for the argument to \cs{@seccntformat} (or \verb?##1? if used inside another macro).
11556 % \changes{v0.2}{2001/06/03}{Added \cs{setsecnumformat}}
11557 % \begin{macrocode}
11558 \newcommand{\setsecnumformat}[1]{\renewcommand{\@seccntformat}[1]{#1}}
11559 % \end{macrocode}
11560 % \end{macro}
11561 %
11562 % \begin{macro}{\hangsecnum}
11563 % \begin{macro}{\defaultsecnum}
11564 % These are declarations for putting sectional numbers in the margin,
11565 % or the default sectional number formatting.
11566 % \changes{v0.2}{2001/06/03}{Added \cs{hangsecnum} and \cs{defaultsecnum}}
11567 % \begin{macrocode}
11568 \newcommand{\hangsecnum}{%
11569 \def\@seccntformat##1{\llap{\csname the##1\endcsname\quad}}}
11570 \newcommand{\defaultsecnum}{%
11571 \def\@seccntformat##1{\csname the##1\endcsname\quad}}
11572
11573 % \end{macrocode}
11574 % \end{macro}
11575 % \end{macro}
11576 %
11577 % \subsubsection{Anonymous headings}
11578 %
11579 % \begin{macro}{\plainbreak}
11580 % \cs{plainbreak}\marg{num} generates \meta{num} blanks lines and
11581 % suppresses the indentation of a following paragraph. The starred
11582 % version, \cs{plainbreak*}, does not suppress paragraph indentation.
11583 % \changes{v0.2}{2001/06/03}{Added starred version of \cs{plainbreak}}
11584 % \begin{macrocode}
11585 \newcommand{\plainbreak}{\@ifstar{\@spbreak}{\@pbreak}}
11586 % \end{macrocode}
11587 % \end{macro}
11588 %
11589 % \begin{macro}{\@pbreak}
11590 % \begin{macro}{\@spbreak}
11591 % These are the internal forms for the two versions of \cs{plainbreak}.
11592 % The code for \cs{@pbreak} is almost a straight copy of code posted to
11593 % \ctt{} by Donald Arseneau on 2001/03/26.
11594 % \begin{macrocode}
11595 \newcommand*{\@pbreak}[1]{\par
11596 \penalty -100
11597 \vskip #1\onelineskip \@plus 2\onelineskip
11598 \penalty -20
11599 \vskip \z@ \@plus -2\onelineskip
11600 \@afterindentfalse
11601 \@afterheading}
11602 \newcommand*{\@spbreak}[1]{\par
11603 \penalty -100
11604 \vskip #1\onelineskip \@plus 2\onelineskip
11605 \penalty -20
11606 \vskip \z@ \@plus -2\onelineskip
11607 \@afterindenttrue
11608 \@afterheading}
11609
11610 % \end{macrocode}
11611 % \end{macro}
11612 % \end{macro}
11613 %
11614 %
11615 % \begin{macro}{\fancybreak}
11616 % \cs{fancybreak}\marg{text} typesets \meta{text} centered. For example,
11617 % \verb?\fancybreak{{*}\\{* * *}\\{*}}?. It suppresses indentation of the
11618 % following paragraph. The starred version leaves indentation as is.
11619 % \changes{v0.2}{2001/06/03}{Added starred version of \cs{fancybreak}}
11620 % \changes{v1.3}{2002/11/14}{Tweaked \cs{fancybreak} to remove underfull hbox}
11621 % \changes{v1.61803}{2008/01/30}{Changed fancybreak code to end the paragraph
11622 % it started (Dan Leucking mempatch v4.5)}
11623 % \begin{macrocode}
11624 \newcommand{\fancybreak}{\@ifstar{\@sfbreak}{\@fbreak}}
11625 % \end{macrocode}
11626 % \end{macro}
11627 %
11628 % \begin{macro}{\@fbreak}
11629 % \begin{macro}{\@sfbreak}
11630 % These are the internal forms for the two versions of \cs{fancybreak}.
11631 % \begin{macrocode}
11632 \newcommand{\@fbreak}[1]{\par
11633 \penalty -100
11634 \noindent\parbox{\linewidth}{\centering #1}%%\null
11635 \par
11636 %% \penalty -20
11637 %% \vskip -\onelineskip
11638 \@afterindentfalse
11639 \@afterheading}
11640 \newcommand{\@sfbreak}[1]{\par
11641 \penalty -100
11642 \noindent\parbox{\linewidth}{\centering #1}%%\null
11643 \par
11644 %% \penalty -20
11645 %% \vskip -\onelineskip
11646 \@afterindenttrue
11647 \@afterheading}
11648
11649 % \end{macrocode}
11650 % \end{macro}
11651 % \end{macro}
11652 %
11653 % \begin{macro}{\plainfancybreak}
11654 % The \cs{plainfancybreak}\marg{space}\marg{num}\marg{text} acts
11655 % like \cs{plainbreak}\marg{num} in the middle of a page and like
11656 % \cs{fancybreak}\marg{text} at the bottom of a page. The \meta{space}
11657 % argument is the vertical space required for the \meta{num} blank lines
11658 % and some additional lines of text. From experiments, it seems that
11659 % \meta{space} should be at least (3+\meta{num}) lines (\cs{onelineskip}).
11660 % There is also a starred version, \cs{plainfancybreak*}, to match the other
11661 % starred break commands.
11662 % \changes{v0.2}{2001/06/03}{Added \cs{plainfancybreak} and supporting macros}
11663 % \begin{macrocode}
11664 \newcommand{\plainfancybreak}{\@ifstar{\@spfbreak}{\@pfbreak}}
11665 % \end{macrocode}
11666 % \end{macro}
11667 %
11668 % \begin{macro}{\@pfbreak}
11669 % \begin{macro}{\@spfbreak}
11670 % These are the internal macros for the unstarred and starred versions
11671 % of \cs{plainfancybreak}. They essentially do the same thing, except they call,
11672 % respectively, the unstarred and starred internal versions of \cs{plainbreak}
11673 % and \cs{fancybreak}. The code for checking the amount of space left on the
11674 % page is from an early, and abandoned, version of the code for \cs{needspace}.
11675 % \begin{macrocode}
11676 \newcommand{\@pfbreak}[3]{\par
11677 \@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
11678 \ifdim #1>\@tempdimc \@fbreak{#3}\else \@pbreak{#2}\fi}
11679 \newcommand{\@spfbreak}[3]{\par
11680 \@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
11681 \ifdim #1>\@tempdimc \@sfbreak{#3}\else \@spbreak{#2}\fi}
11682
11683 % \end{macrocode}
11684 % \end{macro}
11685 % \end{macro}
11686 %
11687 % From the thread \textit{Customizing section hooks in memoir.cls} on \ctt{}
11688 % in October 2002 it appeared that \cs{plainfancybreak} may be fragile.
11689 % Donald Arseneau said that \cs{plainfancybreak} guessed at the amount
11690 % of space available and gave code based on a modified output routine
11691 % to make it more robust. The following code is based on that thread.
11692 % \changes{v1.3}{2002/11/14}{Added lots of code for new \cs{pfbreak}}
11693 %
11694 % \begin{macro}{\pen@ltyabovepfbreak}
11695 % \begin{macro}{\pen@ltybelowpfbreak}
11696 % Penalities for communication with the output routine.
11697 % \begin{macrocode}
11698 \newcommand*{\pen@ltyabovepfbreak}{2}
11699 \newcommand*{\pen@ltybelowpfbreak}{-4}
11700
11701 % \end{macrocode}
11702 % \end{macro}
11703 % \end{macro}
11704 %
11705 % \begin{macro}{\pfbreakskip}
11706 % The vertical space taken by the plain and fancy breaks.
11707 % \begin{macrocode}
11708 \newlength{\pfbreakskip}
11709 \setlength{\pfbreakskip}{2\baselineskip}
11710 % \end{macrocode}
11711 % \end{macro}
11712 %
11713 % \begin{macro}{\pfbreakdisplay}
11714 % This is the fancybreak display, which must fit into \cs{pfbreakskip}
11715 % vertical space.
11716 % \begin{macrocode}
11717 \newcommand{\pfbreakdisplay}{*\quad*\quad*}
11718
11719 % \end{macrocode}
11720 % \end{macro}
11721 %
11722 % \begin{macro}{\pfbre@kdispl@y}
11723 % Typesets \cs{pfbreakdisplay} vertically and horizontally centered.
11724 % \begin{macrocode}
11725 \def\pfbre@kdispl@y{\vbox to 1\pfbreakskip{\vss
11726 \hb@xt@ \columnwidth{\hss \pfbreakdisplay \hss}%
11727 \vss}}
11728
11729 % \end{macrocode}
11730 % \end{macro}
11731 %
11732 % \begin{macro}{\nopfbreakOutput}
11733 % Save the current output routine.
11734 % \begin{macrocode}
11735 \edef\nopfbreakOutput{\the\output}
11736 % \end{macrocode}
11737 % \end{macro}
11738 %
11739 % \begin{macro}{\pfbreakOutput}
11740 % Special output to handle the \cs{pfbreak}.
11741 % \begin{macrocode}
11742 \def\pfbreakOutput{%
11743 \ifnum\outputpenalty=\pen@ltyabovepfbreak
11744 \nopfbreakOutput
11745 \pfbre@kdispl@y
11746 \nobreak
11747 \vskip-\pfbreakskip
11748 \else\ifnum\outputpenalty=\pen@ltybelowpfbreak
11749 \unvbox 255\relax
11750 \nobreak
11751 \vskip-\pfbreakskip
11752 \pfbre@kdispl@y
11753 \break
11754 \else
11755 \nopfbreakOutput
11756 \fi
11757 \fi}
11758 % \end{macrocode}
11759 % \end{macro}
11760 %
11761 % \begin{macro}{\output}
11762 % Use the new \cs{pfbreak} output routine.
11763 % \begin{macrocode}
11764 \output={\pfbreakOutput}
11765
11766 % \end{macrocode}
11767 % \end{macro}
11768 %
11769 % \begin{macro}{\pfbreak}
11770 % Typesets a plain break in the middle of the page, otherwise
11771 % a fancybreak at either the bottom or top of the page.
11772 % \begin{macrocode}
11773 \newcommand{\pfbreak}{\@ifstar{\@spfbreakgap}{\@pfbreakgap}}
11774 % \end{macrocode}
11775 % \end{macro}
11776 %
11777 % \begin{macro}{\@pfbreakgap}
11778 % Unstarred version of \cs{pfbreak}.
11779 % \changes{v3.6h}{2010/10/06}{fixed \cs{@pfbreakgab} kudos to DA for
11780 % the fix}
11781 % \begin{macrocode}
11782 \newcommand{\@pfbreakgap}{%
11783 \par {%
11784 \skip@\lastskip
11785 \nobreak
11786 \vskip -\ifdim\prevdepth>\maxdepth \maxdepth
11787 \else\ifdim\prevdepth>-1000pt\prevdepth
11788 \else\ifinner 0pt
11789 \else \pagedepth
11790 \fi \fi \fi
11791 \vskip -\skip@
11792 \ifdim\skip@<\pfbreakskip
11793 \advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
11794 \fi
11795 \penalty\pen@ltyabovepfbreak
11796 \prevdepth\z@ % added
11797 \vskip\skip@
11798 \penalty\pen@ltybelowpfbreak
11799 }
11800 \@afterindentfalse
11801 \@afterheading
11802 }
11803 % \end{macrocode}
11804 % \end{macro}
11805 %
11806 % \begin{macro}{\@spfbreakgap}
11807 % Starred version of \cs{pfbreak}.
11808 % \changes{v3.6h}{2010/10/06}{fixed \cs{@pfbreakgab} kudos to DA for
11809 % the fix}
11810 % \begin{macrocode}
11811 \newcommand{\@spfbreakgap}{%
11812 \par {%
11813 \skip@\lastskip
11814 \nobreak
11815 \vskip -\ifdim\prevdepth>\maxdepth \maxdepth
11816 \else\ifdim\prevdepth>-1000pt\prevdepth
11817 \else\ifinner 0pt
11818 \else \pagedepth
11819 \fi \fi \fi
11820 \vskip -\skip@
11821 \ifdim\skip@<\pfbreakskip
11822 \advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
11823 \fi
11824 \penalty\pen@ltyabovepfbreak
11825 \prevdepth\z@ % added
11826 \vskip\skip@
11827 \penalty\pen@ltybelowpfbreak
11828 }
11829 \@afterindenttrue
11830 \@afterheading
11831 }
11832
11833 % \end{macrocode}
11834 % \end{macro}
11835 %
11836 %
11837 % While on the subject of breaks\ldots
11838 %
11839 % \begin{macro}{\noprelistbreak}
11840 % Putting this immediately before a list (e.g., \Lenv{itemize}) should
11841 % prevent a page break at that point.
11842 % \changes{v1.2}{2002/07/27}{Added \cs{noprelistbreak}}
11843 % \begin{macrocode}
11844 \newcommand*{\noprelistbreak}{\@nobreaktrue\nopagebreak}
11845
11846 % \end{macrocode}
11847 % \end{macro}
11848 %
11849 % \subsection{Division head styles}
11850 %
11851 % The styles of the division heads should go together. As an aid the
11852 % class supplies some ready made collections.
11853 % \changes{v1.6180}{2008/01/30}{Added division head styles}
11854 %
11855 % \begin{macro}{\makeheadstyles}
11856 % \begin{macro}{\headstyles}
11857 % \begin{macro}{\@hds@def@ult}
11858 % \begin{macro}{\hds@default}
11859 % \cs{makeheadstyles}\marg{name}\marg{code} creates the \meta{name} collection
11860 % of division head styles, defined by \meta{code}. \cs{headstyles}\marg{name}
11861 % makes the \meta{name} division head styles the current styles.
11862 % \begin{macrocode}
11863 \newcommand{\makeheadstyles}[2]{%
11864 \@namedef{hds@#1}{\@hds@def@ult #2}}
11865 \newcommand*{\headstyles}[1]{\@nameuse{hds@#1}}
11866 % \end{macrocode}
11867 % \cs{@hds@def@ult} is the default set of division head styles.
11868 % \begin{macrocode}
11869 \newcommand*{\@hds@def@ult}{%
11870 % Default \cs{book} style
11871 % \begin{macrocode}
11872 % book
11873 \renewcommand*{\beforebookskip}{\null\vfil}%
11874 \renewcommand*{\midbookskip}{\par\vskip 20pt}%
11875 \renewcommand*{\afterbookskip}{\vfil\newpage}%
11876 \renewcommand*{\booknamefont}{\normalfont\huge\bfseries}%
11877 \renewcommand*{\booknumfont}{\normalfont\huge\bfseries}%
11878 \renewcommand*{\booktitlefont}{\normalfont\Huge\bfseries}%
11879 \renewcommand*{\printbookname}{\booknamefont \bookname}%
11880 \renewcommand*{\booknamenum}{\space}%
11881 \renewcommand*{\printbooknum}{\booknumfont \thebook}%
11882 \renewcommand*{\printbooktitle}[1]{\booktitlefont{##1}}%
11883 % \end{macrocode}
11884 % Default \cs{part} style
11885 % \begin{macrocode}
11886 % part
11887 \renewcommand*{\beforepartskip}{\null\vfil}%
11888 \renewcommand*{\midpartskip}{\par\vskip 20pt}%
11889 \renewcommand*{\afterpartskip}{\vfil\newpage}%
11890 \renewcommand*{\partnamefont}{\normalfont\huge\bfseries}%
11891 \renewcommand*{\partnumfont}{\normalfont\huge\bfseries}%
11892 \renewcommand*{\parttitlefont}{\normalfont\Huge\bfseries}%
11893 \renewcommand*{\printpartname}{\partnamefont \partname}%
11894 \renewcommand*{\partnamenum}{\space}%
11895 \renewcommand*{\printpartnum}{\partnumfont \thepart}%
11896 \renewcommand*{\printparttitle}[1]{\parttitlefont{##1}}%
11897 % \end{macrocode}
11898 % Default \cs{chapter} style.
11899 % \begin{macrocode}
11900 \@chs@def@ult% default chapterstyle
11901 % \end{macrocode}
11902 % Default \cs{section} style
11903 % \changes{v1.61803398}{2009/07/17}{Added bidi support to default sec headstyle}
11904 % \begin{macrocode}
11905 % section
11906 \setsechook{}
11907 \setsecindent{\z@}%
11908 \setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}%
11909 \setaftersecskip{2.3ex \@plus .2ex}%
11910 \setsecheadstyle{\Large\bfseries\memRTLraggedright}%
11911 % \end{macrocode}
11912 % Default \cs{subsection} style
11913 % \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsec headstyle}
11914 % \begin{macrocode}
11915 % subsection
11916 \setsubsechook{}%
11917 \setsubsecindent{\z@}%
11918 \setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
11919 \setaftersubsecskip{1.5ex \@plus .2ex}%
11920 \setsubsecheadstyle{\large\bfseries\memRTLraggedright}%
11921 % \end{macrocode}
11922 % Default \cs{subsubsection} style
11923 % \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsubsec headstyle}
11924 % \begin{macrocode}
11925 % subsubsection
11926 \setsubsubsechook{}%
11927 \setsubsubsecindent{\z@}%
11928 \setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
11929 \setaftersubsubsecskip{1.5ex \@plus .2ex}%
11930 \setsubsubsecheadstyle{\normalsize\bfseries\memRTLraggedright}%
11931 % \end{macrocode}
11932 % Default \cs{paragraph} style
11933 % \begin{macrocode}
11934 % paragraph
11935 \setparahook{}%
11936 \setparaindent{\z@}%
11937 \setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
11938 \setafterparaskip{-1em}%
11939 \setparaheadstyle{\normalsize\bfseries}%
11940 % \end{macrocode}
11941 % Default \cs{paragraph} style
11942 % \begin{macrocode}
11943 % subparagraph
11944 \setsubparahook{}%
11945 \setsubparaindent{\parindent}%
11946 \setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
11947 \setaftersubparaskip{-1em}%
11948 \setsubparaheadstyle{\normalsize\bfseries}}
11949
11950 % \end{macrocode}
11951 % Set up and use the default head styles
11952 % \begin{macrocode}
11953 \makeheadstyles{default}{}
11954 \headstyles{default}
11955
11956 % \end{macrocode}
11957 % \end{macro}
11958 % \end{macro}
11959 % \end{macro}
11960 % \end{macro}
11961 %
11962 % \begin{macro}{\addperiod}
11963 % Puts a period at the end of its argument.
11964 % \begin{macrocode}
11965 \newcommand*{\addperiod}[1]{#1.}
11966
11967 % \end{macrocode}
11968 % \end{macro}
11969 %
11970 % \begin{macro}{\hds@memman}
11971 % Head styles used in the \textit{The Memoir Class} user guide. In this,
11972 % as the later ones, only changes from the defaults need specifying.
11973 % \changes{v1.61803398}{2009/07/17}{Added bidi support to the memman headstyles}
11974 % \begin{macrocode}
11975 \makeheadstyles{memman}{%
11976 % book changes
11977 \renewcommand*{\booknamefont}{\normalfont\huge\sffamily}
11978 \renewcommand*{\booknumfont}{\normalfont\huge\sffamily}
11979 \renewcommand*{\booktitlefont}{\normalfont\Huge\sffamily}
11980 \renewcommand*{\midbookskip}{\par\vskip 2\onelineskip}%
11981 % part changes
11982 \renewcommand*{\partnamefont}{\normalfont\huge\sffamily}
11983 \renewcommand*{\partnumfont}{\normalfont\huge\sffamily}
11984 \renewcommand*{\parttitlefont}{\normalfont\Huge\sffamily}
11985 \renewcommand*{\midpartskip}{\par\vskip 2\onelineskip}%
11986 % chapter
11987 \chapterstyle{demo3}
11988 % section
11989 \setbeforesecskip{-1.333\onelineskip
11990 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
11991 \setaftersecskip{0.667\onelineskip \@plus 0.1\onelineskip}%
11992 \setsecheadstyle{\normalfont\scshape\memRTLraggedright}%
11993 % subsection
11994 \setbeforesubsecskip{-0.667\onelineskip
11995 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
11996 \setaftersubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
11997 \setsubsecheadstyle{\normalfont\bfseries\memRTLraggedright}%
11998 % subsubsection
11999 \setbeforesubsubsecskip{-0.667\onelineskip
12000 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12001 \setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
12002 \setsubsubsecheadstyle{\normalfont\normalsize\itshape\memRTLraggedright}%
12003 % paragraph
12004 \setbeforeparaskip{1.0\onelineskip
12005 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12006 \setafterparaskip{-1em}%
12007 \setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
12008 % subparagraph
12009 \setsubparaindent{\parindent}%
12010 \setbeforesubparaskip{1.0\onelineskip
12011 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12012 \setaftersubparaskip{-1em}%
12013 \setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
12014
12015 % \end{macrocode}
12016 % \end{macro}
12017 %
12018 % \begin{macro}{\hds@bringhurst}
12019 % Head styles based on Bringhurst's book
12020 % \changes{v1.61803398}{2009/07/17}{Added bidi support to bringhurst headstyles}
12021 % \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
12022 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12023 % \begin{macrocode}
12024 \makeheadstyles{bringhurst}{%
12025 % chapter
12026 \chapterstyle{bringhurst}
12027 % section
12028 \setbeforesecskip{-1\onelineskip
12029 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
12030 \setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
12031 \setsecheadstyle{\normalfont\memRTLraggedright\scshape\MakeLowercase}%
12032 % subsection
12033 \setbeforesubsecskip{-1.0\onelineskip
12034 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12035 \setaftersubsecskip{1.0\onelineskip \@plus 0.1\onelineskip}%
12036 \setsubsecheadstyle{\sethangfrom{\noindent ####1}\normalfont\itshape\memRTLraggedright}%
12037 % subsubsection
12038 \setbeforesubsubsecskip{1.0\onelineskip
12039 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12040 \setaftersubsubsecskip{-1em}%
12041 \setsubsubsecheadstyle{\normalfont\normalsize\scshape\MakeLowercase}%
12042 % paragraph
12043 \setbeforeparaskip{1.0\onelineskip
12044 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12045 \setafterparaskip{-1em}%
12046 \setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
12047 % subparagraph
12048 \setsubparaindent{\parindent}%
12049 \setbeforesubparaskip{1.0\onelineskip
12050 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12051 \setaftersubparaskip{-1em}%
12052 \setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
12053
12054 % \end{macrocode}
12055 % \end{macro}
12056 %
12057 % \begin{macro}{\hds@crosshead}
12058 % Head styles based on one of Bringhurst's suggestions.
12059 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
12060 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12061 % \begin{macrocode}
12062 \makeheadstyles{crosshead}{%
12063 \chapterstyle{crosshead}
12064 % section
12065 \setbeforesecskip{-1.25\onelineskip
12066 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
12067 \setaftersecskip{0.75\onelineskip \@plus 0.1\onelineskip}%
12068 \setsecheadstyle{\normalfont\centering\MakeUppercase}%
12069 % subsection
12070 \setbeforesubsecskip{-1.25\onelineskip
12071 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12072 \setaftersubsecskip{0.75\onelineskip \@plus 0.1\onelineskip}%
12073 \setsubsecheadstyle{\normalfont\centering\bfseries}%
12074 % subsubsection
12075 \setbeforesubsubsecskip{-.667\onelineskip
12076 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12077 \setaftersubsubsecskip{.333\onelineskip \@plus 0.1\onelineskip}%
12078 \setsubsubsecheadstyle{\normalfont\normalsize\centering\scshape\MakeLowercase}%
12079 % paragraph
12080 \setbeforeparaskip{-.667\onelineskip
12081 \@plus -02.5\onelineskip \@minus -0.25\onelineskip}%
12082 \setafterparaskip{.333\onelineskip \@plus 0.1\onelineskip}%
12083 \setparaheadstyle{\normalfont\normalsize\centering\itshape}%
12084 % subparagraph
12085 \setsubparaindent{\parindent}%
12086 \setbeforesubparaskip{1.0\onelineskip
12087 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12088 \setaftersubparaskip{-1em}%
12089 \setsubparaheadstyle{\normalfont\normalsize\scshape\MakeLowercase}}
12090
12091 % \end{macrocode}
12092 % \end{macro}
12093 %
12094 % \begin{macro}{\hds@dowding}
12095 % Head styles based on Dowding's \textit{Finer Points}.
12096 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
12097 % \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
12098 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12099 % \begin{macrocode}
12100 \makeheadstyles{dowding}{%
12101 % chapter
12102 \chapterstyle{dowding}
12103 % section
12104 \setbeforesecskip{-2\onelineskip
12105 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
12106 \setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
12107 \setsecheadstyle{\normalfont\centering\MakeUppercase}%
12108 % subsection
12109 \setbeforesubsecskip{-1.2\onelineskip
12110 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12111 \setaftersubsecskip{0.8\onelineskip \@plus 0.1\onelineskip}%
12112 \setsubsecheadstyle{\normalfont\scshape\centering\MakeLowercase}%
12113 % subsubsection
12114 \setbeforesubsubsecskip{-0.667\onelineskip
12115 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12116 \setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
12117 \setsubsubsecheadstyle{\normalfont\normalsize\centering\itshape}%
12118 % paragraph
12119 \setbeforeparaskip{1.0\onelineskip
12120 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12121 \setafterparaskip{-1em}%
12122 \setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
12123 % subparagraph
12124 \setsubparaindent{\parindent}%
12125 \setbeforesubparaskip{1.0\onelineskip
12126 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12127 \setaftersubparaskip{-1em}%
12128 \setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
12129
12130 % \end{macrocode}
12131 % \end{macro}
12132 %
12133 % \begin{macro}{\hds@komalike}
12134 % Head styles based on KOMA script classes (\texttt{scrbook.cls}).
12135 % \changes{v1.61803398}{2009/07/17}{Added bidi support to komalike headstyles}
12136 % \begin{macrocode}
12137 \makeheadstyles{komalike}{%
12138 % part
12139 \renewcommand*{\partnamefont}{\huge\sffamily\bfseries}%
12140 \renewcommand*{\partnumfont}{\huge\sffamily\bfseries}%
12141 \renewcommand*{\parttitlefont}{\huge\sffamily\bfseries}%
12142 % chapter
12143 \chapterstyle{komalike}
12144 % section
12145 \setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}%
12146 \setaftersecskip{2.3ex \@plus .2ex}%
12147 \setsecheadstyle{\normalfont\Large\sffamily\bfseries\memRTLraggedright}%
12148 % subsection
12149 \setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
12150 \setaftersubsecskip{1.5ex \@plus .2ex}%
12151 \setsubsecheadstyle{\normalfont\large\sffamily\bfseries\memRTLraggedright}%
12152 % subsubsection
12153 \setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
12154 \setaftersubsubsecskip{1.5ex \@plus .2ex}%
12155 \setsubsubsecheadstyle{\normalfont\normalsize\sffamily\bfseries\memRTLraggedright}%
12156 % paragraph
12157 \setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
12158 \setafterparaskip{-1em}%
12159 \setparaheadstyle{\normalfont\normalsize\sffamily\bfseries}%
12160 % subparagraph
12161 \setsubparaindent{\parindent}%
12162 \setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
12163 \setaftersubparaskip{-1em}%
12164 \setsubparaheadstyle{\normalfont\normalsize\sffamily\bfseries}}
12165
12166 % \end{macrocode}
12167 % \end{macro}
12168 %
12169 % \begin{macro}{\hds@ntglike}
12170 % Head styles based on the NTG classes (\texttt{boek.cls}).
12171 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
12172 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12173 % \begin{macrocode}
12174 \makeheadstyles{ntglike}{%
12175 % part
12176 \renewcommand*{\partnamefont}{\Large\bfseries\MakeUppercase}%
12177 \renewcommand*{\partnumfont}{\Large\bfseries}%
12178 \renewcommand*{\parttitlefont}{\Large\MakeUppercase}%
12179 % chapter
12180 \chapterstyle{ntglike}
12181 % section
12182 \setbeforesecskip{-2\onelineskip
12183 \@plus -1\onelineskip \@minus -.5\onelineskip}%
12184 \setaftersecskip{0.5\onelineskip}%
12185 \setsecheadstyle{\normalfont\large\bfseries}%
12186 % subsection
12187 \setbeforesubsecskip{-1\onelineskip
12188 \@plus -.5\onelineskip \@minus -.25\onelineskip}%
12189 \setaftersubsecskip{0.01\onelineskip}%
12190 \setsubsecheadstyle{\normalfont\normalsize\bfseries}%
12191 % subsubsection
12192 \setbeforesubsubsecskip{-1\onelineskip
12193 \@plus -.5\onelineskip \@minus -.25\onelineskip}%
12194 \setaftersubsubsecskip{0.01\onelineskip}%
12195 \setsubsubsecheadstyle{\normalfont\normalsize\slshape}%
12196 % paragraph
12197 \setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
12198 \setafterparaskip{-1em}%
12199 \setparaheadstyle{\normalfont\normalsize\slshape}%
12200 % subparagraph
12201 \setsubparaindent{\parindent}%
12202 \setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
12203 \setaftersubparaskip{-1em}%
12204 \setsubparaheadstyle{\normalfont\normalsize\slshape}}
12205
12206 % \end{macrocode}
12207 % \end{macro}
12208 %
12209 % \begin{macro}{\hds@tandh}
12210 % Head styles based on Thames \& Hudson \textit{Typography}.
12211 % \changes{v1.61803398}{2009/07/17}{Added bidi support to tandh headstyles}
12212 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
12213 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12214 % \begin{macrocode}
12215 \makeheadstyles{tandh}{%
12216 % chapter
12217 \chapterstyle{tandh}
12218 % section
12219 \setbeforesecskip{-2\onelineskip
12220 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
12221 \setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
12222 \setsecheadstyle{\normalfont\memRTLraggedright\MakeUppercase}%
12223 % subsection
12224 \setbeforesubsecskip{-1.2\onelineskip
12225 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12226 \setaftersubsecskip{0.8\onelineskip \@plus 0.1\onelineskip}%
12227 \setsubsecheadstyle{\normalfont\Large\itshape\memRTLraggedright}%
12228 % subsubsection
12229 \setbeforesubsubsecskip{-0.667\onelineskip
12230 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12231 \setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
12232 \setsubsubsecheadstyle{\normalfont\normalsize\bfseries\memRTLraggedright}%
12233 % paragraph
12234 \setbeforeparaskip{1.0\onelineskip
12235 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12236 \setafterparaskip{-1em}%
12237 \setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
12238 % subparagraph
12239 \setsubparaindent{\parindent}%
12240 \setbeforesubparaskip{1.0\onelineskip
12241 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12242 \setaftersubparaskip{-1em}%
12243 \setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
12244
12245 % \end{macrocode}
12246 % \end{macro}
12247 %
12248 % \begin{macro}{\hds@wilsondob}
12249 % Head styles based on Adrian Wilson's \textit{The Design of Books}.
12250 % \changes{v1.61803398}{2009/07/17}{Added bidi support to wilsondob headstyles}
12251 % \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
12252 % \changes{v3.8.4}{2025/08/08}{Reverted \cs{Make...case} change}
12253 % \begin{macrocode}
12254 \makeheadstyles{wilsondob}{%
12255 % chapter
12256 \chapterstyle{wilsondob}
12257 % section
12258 \setbeforesecskip{-1.333\onelineskip
12259 \@plus -0.5\onelineskip \@minus -.5\onelineskip}%
12260 \setaftersecskip{0.667\onelineskip \@plus 0.1\onelineskip}%
12261 \setsecheadstyle{\normalfont\memRTLraggedright\MakeUppercase}%
12262 % subsection
12263 \setbeforesubsecskip{-0.667\onelineskip
12264 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12265 \setaftersubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
12266 \setsubsecheadstyle{\normalfont\Large\itshape\memRTLraggedright}%
12267 % subsubsection
12268 \setbeforesubsubsecskip{-0.667\onelineskip
12269 \@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
12270 \setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
12271 \setsubsubsecheadstyle{\normalfont\normalsize\memRTLraggedright\scshape\MakeLowercase}%
12272 % paragraph
12273 \setbeforeparaskip{1.0\onelineskip
12274 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12275 \setafterparaskip{-1em}%
12276 \setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
12277 % subparagraph
12278 \setsubparaindent{\parindent}%
12279 \setbeforesubparaskip{1.0\onelineskip
12280 \@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
12281 \setaftersubparaskip{-1em}%
12282 \setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
12283
12284 % \end{macrocode}
12285 % \end{macro}
12286 %
12287 %
12288 % \subsection{Appendices}
12289 %
12290 % \begin{macro}{\ifanappendix}
12291 % \begin{macro}{\anappendixtrue}
12292 % \begin{macro}{\anappendixfalse}
12293 % \begin{macro}{\appendix}
12294 % In the standard \Lpack{book} class the \cs{appendix} command does the
12295 % following:
12296 % \begin{itemize}
12297 % \item Resets the chapter and section counters to zero
12298 % \item Sets \cs{@chapapp} to \cs{appendixname}.
12299 % \item Redefines \cs{thechapter} to produce alphabetic appendix numbers.
12300 % \end{itemize}
12301 % \changes{v1.618}{2005/09/03}{Added \cs{ifanappendix} (mempatch v3.12)}
12302 % \begin{macrocode}
12303 \newif\ifanappendix
12304 \anappendixfalse
12305 \newcommand{\appendix}{\par
12306 \setcounter{chapter}{0}%
12307 \setcounter{section}{0}%
12308 \gdef\@chapapp{\appendixname}%
12309 \gdef\thechapter{\@Alph\c@chapter}%
12310 \anappendixtrue}
12311
12312 % \end{macrocode}
12313 % \end{macro}
12314 % \end{macro}
12315 % \end{macro}
12316 % \end{macro}
12317 %
12318 %
12319 % This class provides additional appendixing capabilities.
12320 %
12321 %
12322 % \begin{macro}{\appendixpage}
12323 % \begin{macro}{\appendixpage*}
12324 % The command to typeset a page announcing the start of the appendices.
12325 % It is based on the \cs{part} definition. The normal version
12326 % makes an entry in the ToC but the starred version does not.
12327 % \changes{v0.33}{2001/08/31}{Changed implementation of \cs{appendixpage}}
12328 % \begin{macrocode}
12329 \newcommand{\appendixpage}{%
12330 \@ifstar{\@sapppage}{\@apppage}}
12331 % \end{macrocode}
12332 % \end{macro}
12333 % \end{macro}
12334 %
12335 % \begin{macro}{\memapppageinfo}
12336 % \begin{macro}{\memapppagestarinfo}
12337 % \verb?\memapppageinfo{\appendixpagename}? \\
12338 % \verb?\memapppagestarinfo{\appendixpagename}? \\
12339 % \begin{macrocode}
12340 \newcommand{\memapppageinfo}[1]{}
12341 \newcommand{\memapppagestarinfo}[1]{}
12342
12343 % \end{macrocode}
12344 % \end{macro}
12345 % \end{macro}
12346 %
12347 % \begin{macro}{\@apppage}
12348 % \cs{@apppage} typesets an appendix page and makes an entry in the ToC.
12349 % \changes{v3.6k}{2013/04/25}{Added \cs{mempre/postaddchaptertotochook}}
12350 % \begin{macrocode}
12351 \def\@apppage{%
12352 \@setuppart
12353 \mempreaddapppagetotochook
12354 \addappheadtotoc
12355 \mempostaddapppagetotochook
12356 \partmark{\appendixpagename}%
12357 \memapppageinfo{\appendixpagename}%
12358 {\centering
12359 \interlinepenalty \@M
12360 \normalfont
12361 \printparttitle{\appendixpagename}\par}%
12362 \@endpart}
12363 % \end{macrocode}
12364 % \end{macro}
12365 % \begin{macro}{\mempreaddapppagetotochook}
12366 % \begin{macro}{\mempostaddapppagetotochook}
12367 % Hooks before and after adding something to the ToC. Does nothing
12368 % by default.
12369 % \begin{macrocode}
12370 \newcommand\mempreaddapppagetotochook{}
12371 \newcommand\mempostaddapppagetotochook{}
12372
12373 % \end{macrocode}
12374 %
12375 % \end{macro}
12376 % \end{macro}
12377 %
12378 % \begin{macro}{\@sapppage}
12379 % \cs{@sapppage} typesets an appendix page and does not make an entry in the ToC.
12380 % \begin{macrocode}
12381 \def\@sapppage{%
12382 \@setuppart
12383 \partmark{\appendixpagename}%
12384 \memapppagestarinfo{\appendixpagename}%
12385 {\centering
12386 \interlinepenalty \@M
12387 \normalfont
12388 \printparttitle{\appendixpagename}\par}%
12389 \@endpart}
12390
12391 % \end{macrocode}
12392 % \end{macro}
12393 %
12394 %
12395 % \begin{macro}{\addappheadtotoc}
12396 % This command adds an `appendices' line to the ToC. The style is the same
12397 % as used in \Lpack{tocbibind} for the `List of figures' line. That is,
12398 % as a Chapter heading.
12399 % \changes{v1.61803}{2008/01/30}{Added \cs{phantomsection} to \cs{addappheadtotoc}
12400 % (mempatch v4.9)}
12401 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget}}
12402 % \begin{macrocode}
12403 \def\addappheadtotoc{%
12404 % \phantomsection
12405 \MakeLinkTarget[chapter]{}%
12406 \addcontentsline{toc}{chapter}{\appendixtocname}}
12407 % \end{macrocode}
12408 % \end{macro}
12409 %
12410 % \begin{macro}{\@ppsavesec}
12411 % \begin{macro}{\@pprestoresec}
12412 % \begin{macro}{\@ppsaveapp}
12413 % \begin{macro}{\restoreapp}
12414 % For the \Lenv{appendices} environment we need to save and restore the
12415 % main document division number and the appendix number. The \cs{restoreapp}
12416 % command is the one for the user.
12417 % \begin{macrocode}
12418 \newcounter{@ppsavesec}
12419 \newcounter{@ppsaveapp}
12420 \setcounter{@ppsaveapp}{0}
12421 \newcommand{\@ppsavesec}{%
12422 \setcounter{@ppsavesec}{\value{chapter}}}
12423 \newcommand{\@pprestoresec}{%
12424 \setcounter{chapter}{\value{@ppsavesec}}}
12425 \newcommand{\@ppsaveapp}{%
12426 \setcounter{@ppsaveapp}{\value{chapter}}}
12427 \newcommand{\restoreapp}{%
12428 \setcounter{chapter}{\value{@ppsaveapp}}}
12429
12430 % \end{macrocode}
12431 % \end{macro}
12432 % \end{macro}
12433 % \end{macro}
12434 % \end{macro}
12435 %
12436 %
12437 % \begin{macro}{\@resets@pp}
12438 % Resets the appropriate sectioning counters and names. This does almost
12439 % exactly what the default \cs{appendix} command does, except that it saves and
12440 % restores sectional numbering. It saves the sectional number at the start
12441 % and restores the appendix number at the end.
12442 % \begin{macrocode}
12443 % \changes{v3.7p}{2021/06/16}{Moved \cs{theHchapter} def here from
12444 % \Lpack{memhfixc}. (discovered by Lars Hoemke, private email 20 Feb 2003)}
12445 \newcommand{\@resets@pp}{%
12446 \par
12447 \@ppsavesec
12448 \setcounter{section}{0}%
12449 \setcounter{chapter}{0}%
12450 \renewcommand\@chapapp{\appendixname}%
12451 \renewcommand\thechapter{\@Alph\c@chapter}%
12452 \restoreapp
12453 \def\theHchapter{\Alph{chapter}}
12454 }
12455
12456 % \end{macrocode}
12457 % \end{macro}
12458 %
12459 % \begin{environment}{appendices}
12460 % This is the heart of the package. Start it off by doing the resetting
12461 % done by the \cs{appendix} command but also save the main counters. At the
12462 % end of the environment save the appendix number and restore the main counters.
12463 % \begin{macrocode}
12464 \newenvironment{appendices}%
12465 {\@resets@pp\anappendixtrue}%
12466 {\@ppsaveapp\@pprestoresec\anappendixfalse}
12467
12468 % \end{macrocode}
12469 % \end{environment}
12470 %
12471 % \begin{macro}{\setthesection}
12472 % The user commands for specifying the numbering style for subappendices.
12473 % \begin{macrocode}
12474 \newcommand{\setthesection}{\thechapter.\Alph{section}}
12475
12476 % \end{macrocode}
12477 % \end{macro}
12478 %
12479 % \begin{macro}{\@resets@ppsub}
12480 % Similar to \cs{@resets@pp} except that it is for use within the
12481 % \Lenv{subappendices} environment; as such, it is a bit simpler.
12482 % \changes{v3.7p}{2021/06/16}{Moved \cs{theHsection} def here instead
12483 % of in \Lpack{memhfixc}, Problem reported by Ignasi Furio, private email 13 May 2004}
12484 % \begin{macrocode}
12485 \newcommand{\@resets@ppsub}{
12486 \par
12487 \setcounter{section}{0}
12488 \renewcommand{\thesection}{\setthesection}
12489 \def\theHsection{\theHchapter.\Alph{section}}
12490 }
12491
12492 % \end{macrocode}
12493 % \end{macro}
12494 %
12495 % \begin{macro}{\ifnamesubappendix}
12496 % \begin{macro}{\namesubappendixtrue}
12497 % \begin{macro}{\namesubappendixfalse}
12498 % \begin{macro}{\namedsubappendices}
12499 % \begin{macro}{\unnamedsubappendices}
12500 % Switch for adding an `appendix' name before subappendix numbers.
12501 % \changes{v1.0}{2001/11/13}{Added \cs{ifnamesubappendix}}
12502 % \changes{v1.61803}{2008/01/30}{Added \cs{namedsubappendices} and
12503 % \cs{unnamedsubappendices}}
12504 % \begin{macrocode}
12505 \newif\ifnamesubappendix
12506 \namesubappendixfalse
12507 \newcommand*{\namedsubappendices}{\namesubappendixtrue}
12508 \newcommand*{\unnamedsubappendices}{\namesubappendixfalse}
12509
12510 % \end{macrocode}
12511 % \end{macro}
12512 % \end{macro}
12513 % \end{macro}
12514 % \end{macro}
12515 % \end{macro}
12516 %
12517 % \begin{environment}{subappendices}
12518 % The environment for subappendices. Start it off by doing the resetting
12519 % of the \cs{section} command.
12520 % \changes{v1.0}{2001/11/13}{Modified subappendices environment}
12521 % \begin{macrocode}
12522 \newenvironment{subappendices}{%
12523 \@resets@ppsub
12524 % \end{macrocode}
12525 % Change the definition of \cs{addappheadtotoc} to give a \texttt{section} entry.
12526 % \changes{v1.618}{2005/09/02}{Fixed bookmark for \cs{appendixpage} (mempatch v2.3)}
12527 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by suitable \cs{MakeLinkTarget}}
12528 % \begin{macrocode}
12529 \def\addappheadtotoc{%
12530 %\phantomsection
12531 \MakeLinkTarget[section]{}%
12532 \addcontentsline{toc}{section}{\appendixtocname}}
12533 % \end{macrocode}
12534 % To implement the naming we do cunning things with the
12535 % \cs{@seccntformat} command.
12536 % \begin{macrocode}
12537 \ifnamesubappendix
12538 \def\sectionname{\appendixname}
12539 \def\@seccntformat##1{\@ifundefined{##1name}%
12540 {}{\csname ##1name\endcsname\ }%
12541 \csname the##1\endcsname\quad}
12542 \fi
12543 % \end{macrocode}
12544 % We end by redefining \cs{theHsection} introduced in \cs{@resets@ppsub}
12545 % \changes{v3.7p}{2021/06/16}{Moved redef of \cs{theHsection} here instead
12546 % of in \Lpack{memhfixc}}
12547 % \changes{v3.8}{2023/06/20}{Changed \cs{theHsection} to use
12548 % \cs{the}\cs{value\{counter\}} as packages can mess up \cs{arabic}
12549 % advise from Ulrike}
12550 % \begin{macrocode}
12551 }{%
12552 \def\theHsection{\theHchapter.\the\value{section}}
12553 }
12554
12555 % \end{macrocode}
12556 % \end{environment}
12557 %
12558 % \begin{macro}{\@formatsecmark@pp}
12559 % Formats the page header for a redefined \cs{sectionmark}.
12560 % \begin{macrocode}
12561 % unused?
12562 % \newcommand{\@formatsecmark@pp}[1]{%
12563 % \MakeUppercase{\appendixname\space
12564 % \ifnum \c@secnumdepth >\z@
12565 % \thesection\quad
12566 % \fi
12567 % #1}}
12568 % \end{macrocode}
12569 % \end{macro}
12570 %
12571 % \subsection{Appendixpage-like pages}
12572 % \changes{v1.618}{2005/09/03}{Added \cs{newleadpage} and friends (mempatch v3.0)}
12573 %
12574 %
12575 % This capability was suggested to me by Lars Madsen on 2004/11/28.
12576 %
12577 % \begin{macro}{\leadpagetoclevel}
12578 % \begin{macro}{\newleadpage}
12579 % \begin{macro}{\renewleadpage}
12580 % \verb?\newleadpage[<page-style>]{<cmdname>}{<title>}? creates new macros
12581 % called \verb?\cmdname? and \verb?\cmdname*? that when called typeset a
12582 % page like an Appendixpage, with a title \verb?<title>? using
12583 % page style \verb?<page-style>? (default empty). The
12584 % plain version adds an entry to the ToC but the starred \verb?\cmdname*?
12585 % does not. \cs{renewleadpage} changes the definitions.
12586 %
12587 % The ToC entry style is set by \cs{leadpagetoclevel} (default chapter). To have a part-type entry: \\
12588 % \verb?\renewcommand*{\leadpagetoclevel}{part}?. \\
12589 % The \cs{partmark} command is used if you need to mark the title.
12590 % \begin{macrocode}
12591 \newcommand*{\leadpagetoclevel}{chapter}
12592 \newcommand*{\newleadpage}[3][empty]{%
12593 \@namedef{#2}{\@ifstar{\dlfm@msapppage{#1}{#2}{#3}}%
12594 {\dlfm@mapppage{#1}{#2}{#3}}}}
12595 \newcommand*{\renewleadpage}[3][empty]{%
12596 \@namedef{#2}{\@ifstar{\dlfm@msapppage{#1}{#2}{#3}}%
12597 {\dlfm@mapppage{#1}{#2}{#3}}}}
12598
12599 % \end{macrocode}
12600 % \end{macro}
12601 % \end{macro}
12602 % \end{macro}
12603 %
12604 % \begin{macro}{\memleadpageinfo}
12605 % \begin{macro}{\memleadpagestarinfo}
12606 % \verb?\memleadpageinfo{pstyle}{name}{title}? \\
12607 % \verb?\memleadpagestarinfo{pstyle}{name}{title}? \\
12608 % \begin{macrocode}
12609 \newcommand{\memleadpageinfo}[3]{}
12610 \newcommand{\memleadpagestarinfo}[3]{}
12611
12612 % \end{macrocode}
12613 % \end{macro}
12614 % \end{macro}
12615 %
12616 % \begin{macro}{\dlfm@msapppage}
12617 % \begin{macro}{\dlfm@mapppage}
12618 % Implement the starred and regular versions of \verb?\(re)newleadpage?
12619 % \changes{v3.8.4}{2025/09/16}{Use \cs{MakeLinkTarget} instead of \cs{phantomsection}}
12620 % \begin{macrocode}
12621 \newcommand*{\dlfm@msapppage}[3]{%
12622 \@setuppart
12623 \partmark{#3}%
12624 \MakeLinkTarget[part]{}%
12625 \memleadpagestarinfo{#1}{#2}{#3}%
12626 {\centering
12627 \interlinepenalty \@M
12628 \normalfont
12629 \printparttitle{#3}\par
12630 \thispagestyle{#1}}%
12631 \dlfm@m@endpart{#1}}
12632 \newcommand*{\dlfm@mapppage}[3]{%
12633 \@setuppart
12634 % \phantomsection
12635 \MakeLinkTarget[part]{}%
12636 \addcontentsline{toc}{\leadpagetoclevel}{#3}%
12637 \partmark{#3}%
12638 \memleadpageinfo{#1}{#2}{#3}%
12639 {\centering
12640 \interlinepenalty \@M
12641 \normalfont
12642 \printparttitle{#3}\par
12643 \thispagestyle{#1}}%
12644 \dlfm@m@endpart{#1}}
12645
12646 % \end{macrocode}
12647 % \end{macro}
12648 % \end{macro}
12649 %
12650 % \begin{macro}{\dlfm@m@endpart}
12651 % Finishes off a part-like page.
12652 % \begin{macrocode}
12653 \newcommand*{\dlfm@m@endpart}[1]{%
12654 \if@twoside
12655 \if@openright
12656 \null
12657 \thispagestyle{#1}%
12658 \newpage
12659 \fi
12660 \fi
12661 \if@tempswa
12662 \twocolumn
12663 \fi}
12664
12665 % \end{macrocode}
12666 % \end{macro}
12667 %
12668 % \subsection{Paragraphs}
12669 %
12670 % Much of the code in this section is taken from my \textit{Glisterings}
12671 % columns~\cite{GLISTER07,GLISTER08}.
12672 % \changes{v1.6180339c}{2009/01/09}{Added several new paragraph types}
12673 %
12674 % \begin{macro}{\memorigdbs}
12675 % \begin{macro}{\memorigpar}
12676 % \begin{macro}{\atcentercr}
12677 % \cs{memorigdbs} saves the original definition of \verb?\\? and
12678 % \cs{memorigpar} saves the original \cs{par}. The macro \cs{atcentercr}
12679 % provides a user call to \cs{@centercr}. These could come in handy for
12680 % odd paragraph shapes.
12681 % \changes{v1.6180339c}{2009/01/09}{Added \cs{memorigdbs} and
12682 % \cs{memorigpar} \cs{atcentercr}}
12683 % \begin{macrocode}
12684 \let\memorigdbs\\
12685 \let\memorigpar\par
12686 \let\atcentercr\@centercr
12687
12688 % \end{macrocode}
12689 % \end{macro}
12690 % \end{macro}
12691 % \end{macro}
12692 %
12693 % \subsubsection{Normal (block) paragraphs}
12694 %
12695 %
12696 % \begin{macro}{\flushleftright}
12697 % Sets the paragraphing to \LaTeX's normal form.
12698 % \changes{v1.61803}{2008/01/30}{Used \cs{@flushglue} in \cs{flushleftright} and
12699 % \cs{centerlastline} (mempatch v4.7)}
12700 % \changes{v1.6180339c}{2009/01/09}{Extended \cs{flushleftright} to set all
12701 % the regular paragraphing controls}
12702 % \begin{macrocode}
12703 \newcommand*{\flushleftright}{%
12704 \let\\\memorigdbs
12705 \leftskip\z@skip
12706 \rightskip\leftskip
12707 \parfillskip\@flushglue
12708 \everypar{}}
12709
12710 % \end{macrocode}
12711 % \end{macro}
12712 %
12713 % \begin{macro}{\linenottooshort}
12714 % This declaration \cs{linenottooshort}\oarg{length} specifies paragraphs
12715 % such that the last line is at least about \meta{length} long (the default
12716 % is 4em).
12717 % \changes{v1.6180339c}{2009/01/09}{Added \cs{linenottooshort} paragraph}
12718 % \begin{macrocode}
12719 \newcommand*{\linenottooshort}[1][4em]{%
12720 \@tempdima=\hsize
12721 \advance\@tempdima -#1
12722 \leftskip\z@skip
12723 \rightskip\leftskip
12724 \parfillskip=\@tempdima \@minus \@tempdima}
12725
12726 % \end{macrocode}
12727 % \end{macro}
12728 %
12729 % \begin{macro}{\russianpar}
12730 % Using \cs{russianpar} instead of \cs{par} to end a paragraph causes it
12731 % to be set according to Russian typography, where the last line of a
12732 % multiline paragraph must be either at least as
12733 % long as \cs{parindent} and have at least \cs{parindent} space at the
12734 % right, or it must be flushleft and flushright.
12735 % \changes{v1.6180339c}{2009/01/09}{Added \cs{russianpar} paragraph}
12736 % \begin{macrocode}
12737 \newcommand*{\russianpar}{\ifhmode\unskip
12738 \strut\vadjust{}\nobreak
12739 \discretionary{}%
12740 {\hbox{\hskip2\parindent
12741 \vrule depth 273sp width 0sp height \ht\strutbox}}%
12742 {\hbox{\hskip\parindent}}%
12743 \hskip-2\parindent \@minus 2\parindent
12744 \hskip\hsize \@minus \hsize
12745 \kern\z@ \parfillskip\z@
12746 \memorigpar
12747 \ifdim\prevdepth=273sp
12748 \nobreak
12749 \vskip-2\baselineskip
12750 \hbox{\strut}%
12751 \fi\fi}
12752
12753 % \end{macrocode}
12754 % \end{macro}
12755 %
12756 % \begin{macro}{\lastlineparrule}
12757 % \begin{macro}{\lastlinerulefill}
12758 % Using \cs{lastlinerulefill} instead of \cs{par} to end a paragraph
12759 % causes all short lines to be filled at the right by a rule
12760 % (\cs{lastlineparrule}) extending to the righthand margin.
12761 % \changes{v1.6180339c}{2009/01/09}{Added \cs{lastlineparrule} and
12762 % \cs{lastlinerulefill} paragraph}
12763 % \begin{macrocode}
12764 \newcommand*{\lastlineparrule}{%
12765 \hrule height 0.5ex depth \@tempdimb\relax}
12766 \newcommand*{\lastlinerulefill}{%
12767 \let\\\@centercr
12768 \@tempdimb=-0.5ex \advance\@tempdimb 0.4pt
12769 \unskip\nobreak\space
12770 \leaders\lastlineparrule\hskip\@flushglue
12771 \vadjust{}{\parfillskip\z@\memorigpar}}
12772
12773 % \end{macrocode}
12774 % \end{macro}
12775 % \end{macro}
12776 %
12777 %
12778 % \subsubsection{Centered lines}
12779 %
12780 % \begin{macro}{\centerlastline}
12781 % This declaration specifies normal paragraphs except that the last line of
12782 % each is centered.
12783 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{centerlastline}}
12784 % \begin{macrocode}
12785 \newcommand*{\centerlastline}{%
12786 \memRTLleftskip\@flushglue
12787 \memRTLrightskip=\z@ plus -1fil
12788 \parfillskip=\z@ plus 2fil}
12789
12790 % \end{macrocode}
12791 % \end{macro}
12792 % \end{macro}
12793 %
12794 % \begin{macro}{\leftcenterright}
12795 % This declaration specifies paragraphs where the first line is flushleft
12796 % (raggedright), the
12797 % last is flushright (raggedleft) and all inbetween are centered.
12798 % Set \verb?\everypar{}? afterwards.
12799 % \changes{v1.6180339c}{2009/01/09}{Added \cs{leftcenterright} paragraph}
12800 % \begin{macrocode}
12801 \newcommand*{\leftcenterright}{%;
12802 \let\\\break
12803 \parindent\z@
12804 \leftskip\@flushglue
12805 \rightskip\leftskip
12806 \parfillskip \z@ \@plus -1fil
12807 \everypar={\hskip \z@ \@plus -1fil}}
12808
12809 % \end{macrocode}
12810 % \end{macro}
12811 %
12812 % \begin{macro}{\centerfloat}
12813 % This is a version of \cs{centering} that can be used to center a wide
12814 % float with respect to the text block (normally the left of a wide float
12815 % is aligned with the left of the textblock). This can only be used for
12816 % centering something where LaTeX knows the width (e.g., a figure or a
12817 % table / tabular).
12818 %
12819 % This is a modified version of code by Robin Fairbairns
12820 % (CTT, \textit{Re: Centering a table: problem with rotating.sty, maybe
12821 % a strange document class?}, 3 Jan 2009).
12822 % \changes{v1.6180339c}{2009/01/11}{Added \cs{centerfloat}}
12823 % \begin{macrocode}
12824 \newcommand*{\centerfloat}{%
12825 \parindent \z@
12826 \leftskip \z@ \@plus 1fil \@minus \textwidth
12827 \rightskip\leftskip
12828 \parfillskip \z@skip}
12829
12830 % \end{macrocode}
12831 % \end{macro}
12832 %
12833 % \subsubsection{Ragged}
12834 %
12835 % The kernel code for raggedright (in \file{ltmiscen.dtx}):
12836 % \begin{verbatim}
12837 % \def\raggedright{%
12838 % \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
12839 % \leftskip\z@skip
12840 % \parindent\z@}
12841 % %% \@flushglue = 0pt plus 1fil %% from ltalloc.dtx
12842 % %% \z@skip = 0pt plus 0pt minus 0pt %%
12843 % \end{verbatim}
12844 % produces very ragged text with no paragraph indent.
12845 %
12846 % \begin{macro}{\ragrparindent}
12847 % \begin{macro}{\raggedyright}
12848 % \cs{raggedyright}\oarg{plus} provides controllable ragged right paragraphs.
12849 % \changes{v1.4}{2003/12/10}{Added \cs{raggedyright}}
12850 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{raggedyright}}
12851 % \begin{macrocode}
12852 \newdimen\ragrparindent
12853 \setlength{\ragrparindent}{\parindent}
12854 \newcommand{\raggedyright}[1][2em]{%
12855 \let\\\@centercr\@rightskip \z@ \@plus #1\relax
12856 \memRTLrightskip\@rightskip
12857 \memRTLleftskip\z@skip
12858 \parindent\ragrparindent}
12859
12860 % \end{macrocode}
12861 % \end{macro}
12862 % \end{macro}
12863 %
12864 % \begin{macro}{\justlastraggedleft}
12865 % This declaration specifies paragraphs where the lines are justified,
12866 % except for the last which is raggedleft (flushright)..
12867 % \changes{v1.6180339c}{2009/01/09}{Added \cs{justlastraggedleft} paragraph}
12868 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{justlastraggedleft}}
12869 % \begin{macrocode}
12870 \newcommand*{\justlastraggedleft}{%
12871 \memRTLleftskip\@flushglue
12872 \memRTLrightskip-\memRTLleftskip
12873 \parfillskip\leftskip
12874 \parindent \z@}
12875
12876 % \end{macrocode}
12877 % \end{macro}
12878 %
12879 %
12880 % \begin{macro}{\raggedrightthenleft}
12881 % This declaration specifies paragraphs where the first line is raggedright
12882 % (flushleft) and all the rest are raggedleft (flushright). Note that
12883 % this alters \cs{everpar}, which may need to be reset afterwards to
12884 % \verb?\everypar{}?.
12885 % \changes{v1.6180339c}{2009/01/09}{Added \cs{raggedrightthenleft} paragraph}
12886 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{raggedrightthenleft}}
12887 % \begin{macrocode}
12888 \newcommand*{\raggedrightthenleft}{%
12889 \parindent \z@
12890 \memRTLleftskip \z@ \@plus 1fill
12891 \memRTLrightskip\@flushglue
12892 \parfillskip \z@
12893 \everypar{\hskip \z@ \@plus -1fill}}
12894
12895 % \end{macrocode}
12896 % \end{macro}
12897 %
12898 % \begin{macro}{\raggedwrap}
12899 %
12900 % \changes{v3.8.2}{2024/01/25}{Code moved here from the verbatim
12901 % section. The code where it was uses has been removed, but the
12902 % macro might still be interesting.}
12903 %
12904 % \cs{raggedwrap} is a variation on \cs{raggedright} (\cs{leftskip}
12905 % is set to \cs{@totalleftmargin} instead of 0pt), and seems to have
12906 % fixed the problem with the original code which used
12907 % \cs{raggedright}. \changes{v1.61803}{2008/01/30}{Added
12908 % \cs{raggedwrap} (mempatch v4.4)}
12909 % \changes{v1.61803398}{2009/07/18}{Added bidi support to
12910 % \cs{raggedwrap}}
12911 % \begin{macrocode}
12912 \newcommand*{\raggedwrap}{%
12913 \@rightskip\@flushglue
12914 %%% \rightskip\@rightskip
12915 \memRTLrightskip\@rightskip
12916 %%% \leftskip\@totalleftmargin
12917 \memRTLleftskip\@totalleftmargin
12918 \parindent\ragrparindent}
12919
12920 % \end{macrocode}
12921 % \end{macro}
12922 %
12923 % \subsubsection{Hanging}
12924 %
12925 % \begin{macro}{\hangfrom}
12926 % This is a user-level
12927 % version of the kernel \cs{@hangfrom} macro (only the name is
12928 % changed) as defined in \file{ltsec.dtx}.
12929 %
12930 % \cs{hangfrom}\marg{text} puts \meta{text} in a box and makes a hanging
12931 % paragraph of the following material (a bit like a description item).
12932 % \changes{v1.4}{2003/11/22}{Added \cs{hangfrom} (from patch v1.9)}
12933 % \begin{macrocode}
12934 \newcommand{\hangfrom}[1]{%
12935 \setbox\@tempboxa\hbox{{#1}}%
12936 \hangindent \wd\@tempboxa\noindent\box\@tempboxa}
12937
12938 % \end{macrocode}
12939 % \end{macro}
12940 %
12941 % \begin{macro}{\hangpara}
12942 % \cs{hangpara}\marg{indent}\marg{afternum} at the start of a
12943 % paragraph will make it hung. If \meta{indent} is positive the left
12944 % will be indented, otherwise the right. If \meta{afternum}, say N,
12945 % is positive the N+1 th lines onwards will be indented. For N negative,
12946 % the first N lines will be indented.
12947 % \begin{macrocode}
12948 \newcommand{\hangpara}[2]{\hangindent#1\hangafter#2\noindent}
12949 % \end{macrocode}
12950 % \end{macro}
12951 %
12952 % \begin{environment}{hangparas}
12953 % \verb?\begin{hangparas}?\marg{indent}\marg{afternum} hangs
12954 % a series of paragraphs.
12955 % \begin{macrocode}
12956 \newenvironment{hangparas}[2]{\setlength{\parindent}{\z@}
12957 \everypar={\hangpara{#1}{#2}}}{\par}
12958
12959 % \end{macrocode}
12960 % \end{environment}
12961 %
12962 % \subsubsection{Miscellaneous}
12963 %
12964 % \begin{macro}{\leftspringright}
12965 % \cs{leftspringright}\marg{leftfrac}\marg{rightfrac}\marg{lefttext}\marg{righttext}
12966 % sets the \meta{lefttext} flushleft (raggedright) in a column \meta{leftfrac}
12967 % of the current textwidth and the \meta{righttext} flushright (raggedleft)
12968 % in a column \meta{rightfrac} of the textwidth, with space
12969 % (1.0 - \meta{leftfrac} - \meta{rightfrac})
12970 % of the textwidth between them. Both \meta{leftfrac} and \meta{rightfrac}
12971 % must be given as decimal numbers (e.g., \texttt{0.25} not \texttt{1/4}).
12972 % \changes{v1.6180339c}{2009/01/09}{Added \cs{leftspringright} paragraph}
12973 % \begin{macrocode}
12974 \newcommand{\leftspringright}[4]{%
12975 \@tempdimb=\hsize
12976 \par\noindent\hbox to\@tempdimb{%
12977 \vtop{\hsize=#1\@tempdimb \flushleft#3\par}\hss
12978 \vtop{\hsize=#2\@tempdimb \flushright#4\par}}}
12979
12980 % \end{macrocode}
12981 % \end{macro}
12982 %
12983 % \begin{macro}{\sourceatright}
12984 % Putting \cs{sourceatright}\oarg{length}\marg{text} at the end of a
12985 % paragraph will set \meta{text} flushright on the same line provided the line
12986 % is short enough to allow \meta{length} (default 2em) between the end of the
12987 % line and \meta{text}. If there is not enough space then \meta{text} is
12988 % set flushright on the following line.
12989 % \changes{v1.6180339c}{2009/01/09}{Added \cs{sourceatright} paragraph}
12990 % \begin{macrocode}
12991 \newcommand*{\sourceatright}[2][2em]{{%
12992 \unskip\nobreak\hfil\penalty50
12993 \hskip#1\hbox{}\nobreak\hfil{#2}
12994 \parfillskip\z@\finalhyphendemerits=0\par}}
12995
12996 % \end{macrocode}
12997 % \end{macro}
12998 %
12999 %
13000 % \section{Lists}
13001 %
13002 % \subsection{General List Parameters}
13003 %
13004 % The following commands are used to set the default values for the list
13005 % environment's parameters. See the \LaTeX{} manual for an explanation
13006 % of the meanings of the parameters. Defaults for the list
13007 % environment are set as follows. First, \cs{rightmargin},
13008 % \cs{listparindent} and \cs{itemindent} are set to 0pt. Then, for a Kth
13009 % level list, the command \cs{@listK} is called, where `K' denotes `i',
13010 % '`i', ... , `vi'. (I.e., \cs{@listiii} is called for a third-level
13011 % list.) By convention, \cs{@listK} should set \cs{leftmargin} to
13012 % \cs{leftmarginK}.
13013 %
13014 %
13015 % \begin{macro}{\leftmargin}
13016 % \begin{macro}{\leftmargini}
13017 % \begin{macro}{\leftmarginii}
13018 % \begin{macro}{\leftmarginiii}
13019 % \begin{macro}{\leftmarginiv}
13020 % \begin{macro}{\leftmarginv}
13021 % \begin{macro}{\leftmarginvi}
13022 % For efficiency, level-one list's values are defined at top level, and
13023 % \cs{@listi} is defined to set only \cs{leftmargin}.
13024 %
13025 % In two column mode the margins should be smaller than in one column typesetting.
13026 % \begin{macrocode}
13027 \if@twocolumn
13028 \setlength{\leftmargini}{2em}
13029 \else
13030 \setlength{\leftmargini}{2.5em}
13031 \fi
13032 % \end{macrocode}
13033 % The value of \cs{leftmargin} has to be set at this outer level.
13034 % \begin{macrocode}
13035 \leftmargin \leftmargini
13036 % \end{macrocode}
13037 % Lower level list margins are calculated so that they are indented
13038 % more than the label in an outer list.
13039 % \begin{macrocode}
13040 \setlength{\leftmarginii}{2.2em}
13041 \setlength{\leftmarginiii}{1.87em}
13042 \setlength{\leftmarginiv}{1.7em}
13043 \if@twocolumn
13044 \setlength{\leftmarginv}{.5em}
13045 \setlength{\leftmarginvi}{.5em}
13046 \else
13047 \setlength{\leftmarginv}{1em}
13048 \setlength{\leftmarginvi}{1em}
13049 \fi
13050 % \end{macrocode}
13051 % \end{macro}
13052 % \end{macro}
13053 % \end{macro}
13054 % \end{macro}
13055 % \end{macro}
13056 % \end{macro}
13057 % \end{macro}
13058 %
13059 % \begin{macro}{\itemindent}
13060 % Here we set the \cs{itemindent} which is the extra indentation before
13061 % a label.
13062 % \begin{macrocode}
13063 \setlength{\itemindent}{\z@}
13064 % \end{macrocode}
13065 % \end{macro}
13066 %
13067 % \begin{macro}{\labelsep}
13068 % \begin{macro}{\labelwidth}
13069 % \cs{labelsep} is the distance between the label and the text of an
13070 % item; \cs{labelwidth} is the width of the label.
13071 % \begin{macrocode}
13072 \setlength{\labelsep}{0.5em}
13073 \setlength{\labelwidth}{\leftmargini}
13074 \addtolength{\labelwidth}{-\labelsep}
13075 % \end{macrocode}
13076 % \end{macro}
13077 % \end{macro}
13078 %
13079 % \begin{macro}{\@beginparpenalty}
13080 % \begin{macro}{\@endparpenalty}
13081 % These penalties are inserted before and after a list or paragraph
13082 % environment. They are set to a bonus value to encourage page
13083 % breaking at these points.
13084 % \begin{macro}{\@itempenalty}
13085 % This penalty is inserted between list items.
13086 % \begin{macrocode}
13087 \@beginparpenalty -\@lowpenalty
13088 \@endparpenalty -\@lowpenalty
13089 \@itempenalty -\@lowpenalty
13090
13091 % \end{macrocode}
13092 % \end{macro}
13093 % \end{macro}
13094 % \end{macro}
13095 %
13096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13097 %
13098 % \begin{macro}{\everylistparindent}
13099 % \begin{macro}{\list}
13100 % The kernel sets \cs{listparindent} to zero within a \cs{list}, where it
13101 % can be overridden in \cs{list}'s second argument. Here it is set to
13102 % \cs{everyparlistindent} by default, which in turn is 0pt.
13103 % \begin{macrocode}
13104 \newdimen\everylistparindent
13105 \everylistparindent \z@
13106 \renewcommand*{\list}[2]{%
13107 \ifnum \@listdepth >5\relax
13108 \@toodeep
13109 \else
13110 \global\advance\@listdepth\@ne
13111 \fi
13112 \rightmargin\z@
13113 \listparindent\everylistparindent
13114 \itemindent\z@
13115 \csname @list\romannumeral\the\@listdepth\endcsname
13116 \def\@itemlabel{#1}%
13117 \let\makelabel\@mklab
13118 \@nmbrlistfalse
13119 #2\relax
13120 \@trivlist
13121 \parskip\parsep
13122 \parindent\listparindent
13123 \advance\linewidth -\rightmargin
13124 \advance\linewidth -\leftmargin
13125 \advance\@totalleftmargin \leftmargin
13126 \parshape \@ne \@totalleftmargin \linewidth
13127 \ignorespaces}
13128
13129 % \end{macrocode}
13130 % \end{macro}
13131 % \end{macro}
13132 %
13133 %
13134 % \begin{macro}{\parsepi}
13135 % \begin{macro}{\topsepi}
13136 % \begin{macro}{\itemsepi}
13137 % \begin{macro}{\parsepii}
13138 % \begin{macro}{\topsepii}
13139 % \begin{macro}{\topsepiii}
13140 % Lists may be nested and the exact layout depends on the level
13141 % of nesting. These lengths are used to control the nesting-level
13142 % aspects.
13143 % \begin{macrocode}
13144 \newlength{\parsepi}
13145 \newlength{\topsepi}
13146 \newlength{\itemsepi}
13147 \newlength{\parsepii}
13148 \newlength{\topsepii}
13149 \newlength{\topsepiii}
13150
13151 % \end{macrocode}
13152 % \end{macro}
13153 % \end{macro}
13154 % \end{macro}
13155 % \end{macro}
13156 % \end{macro}
13157 % \end{macro}
13158 %
13159 % \begin{macro}{\itemsepii}
13160 % \begin{macro}{\itemsepiii}
13161 % \begin{macro}{\partopsepii}
13162 % \begin{macro}{\partopsepii}
13163 % We need some new lengths for lists to cater for non-zero \cs{parskip}.
13164 % \changes{v1.61803}{2008/01/30}{Added \cs{itemsepii}, \cs{itemsepiii} and
13165 % \cs{partopsepii} (mempatch v4.6)}
13166 % \begin{macrocode}
13167 \newlength{\itemsepii}
13168 \newlength{\itemsepiii}
13169 \newlength{\partopsepii}
13170 \newlength{\partopsepiii}
13171 % \end{macrocode}
13172 % \end{macro}
13173 % \end{macro}
13174 % \end{macro}
13175 % \end{macro}
13176 %
13177 % \begin{macro}{\setnzplist}
13178 % Common code for non-zero \cs{parskip} in lists.
13179 % \begin{macrocode}
13180 \newcommand*{\setnzplist}{%
13181 \partopsep \p@ \@plus\z@ \@minus\p@
13182 \topsepi\z@
13183 \parsepi\parskip
13184 \itemsepi\z@
13185 \topsepii\z@
13186 \parsepii\parskip
13187 \itemsepii\z@
13188 \topsepiii\z@
13189 %% \parsepiii\parskip
13190 \itemsepiii\z@}
13191
13192 % \end{macrocode}
13193 % \end{macro}
13194 %
13195 % \begin{macro}{\defaultlists}
13196 % The standard \LaTeX\ classes have list parameters that give some
13197 % separation between lists and \cs{item}s in lists. This macro sets
13198 % those values. This is a simplification of memoir's original, and will
13199 % apply to any font size.
13200 % \changes{v1.61803}{2008/01/30}{Complete replacement of \cs{defaultlists}
13201 % (mempatch 4.5)}
13202 % \begin{macrocode}
13203 \newcommand*{\defaultlists}{%
13204 \setlength{\partopsep}{0.2\onelineskip \@plus 0.1\onelineskip
13205 \@minus 0.1\onelineskip}%
13206 \parsepi = 0.3333\onelineskip \@plus 0.1667\onelineskip \@minus \p@
13207 \itemsepi = \parsepi
13208 \topsepi = 0.6667\onelineskip \@plus 0.3333\onelineskip
13209 \@minus 0.2\onelineskip
13210 \parsepii = 0.1667\onelineskip \@plus \p@ \@minus \p@
13211 \topsepii = \parsepi
13212 \topsepiii = \parsepii
13213 \everylistparindent \listparindent
13214 % \end{macrocode}
13215 % Additional code to cater for non-zero \cs{parskip}s.
13216 % \changes{v1.61803}{2008/01/30}{Modified \cs{defaultlists} for
13217 % non-zero \cs{parskip} (memptach v4.6)}
13218 % \begin{macrocode}
13219 \itemsepii\parsepii
13220 \itemsepiii\topsepiii
13221 \partopsepiii \p@ \@plus\z@ \@minus\p@
13222 \ifm@mnzpskip
13223 \setnzplist
13224 \fi}
13225 \defaultlists
13226
13227 % \end{macrocode}
13228 % \end{macro}
13229 %
13230 % \begin{macro}{\firmlists}
13231 % \begin{macro}{\firmlists*}
13232 % \begin{macro}{\m@msfirmlists}
13233 % \begin{macro}{\m@mfirmlists}
13234 % These give approximately half the vertical spacing of the default lists,
13235 % with all spaces equal. The starred version allows slightly less space
13236 % before and after the list when it is preceded by a blank line.
13237 % \changes{v1.61803}{2008/01/30}{Added \cs{firmlists}, etc. (mempatch v4.5)}
13238 % \begin{macrocode}
13239 \newcommand*{\firmlists}{%
13240 \@ifstar{\m@msfirmlists}{\m@mfirmlists}}
13241
13242 \newcommand*{\m@msfirmlists}{
13243 \setlength{\partopsep}{\z@ \@plus \p@ \@minus \p@}%
13244 \parsepi = 0.1667\onelineskip \@plus 0.0833\onelineskip \@minus \p@
13245 \itemsepi = \parsepi
13246 \topsepi = \parsepi
13247 \parsepii = 0.0833\onelineskip \@plus \p@ \@minus \p@
13248 \topsepii = \parsepi
13249 \topsepiii = \parsepii
13250 \everylistparindent\listparindent}
13251
13252 \newcommand*{\m@mfirmlists}{
13253 \setlength{\partopsep}{0.1\onelineskip \@plus 0.05\onelineskip
13254 \@minus 0.05\onelineskip}%
13255 \parsepi = 0.1667\onelineskip \@plus 0.0833\onelineskip \@minus \p@
13256 \itemsepi = \parsepi
13257 \topsepi = \parsepi
13258 \parsepii = 0.0833\onelineskip \@plus \p@ \@minus \p@
13259 \topsepii = \parsepi
13260 \topsepiii = \parsepii
13261 \everylistparindent\listparindent}
13262
13263 % \end{macrocode}
13264 % \end{macro}
13265 % \end{macro}
13266 % \end{macro}
13267 % \end{macro}
13268 %
13269 % \begin{macro}{\tightlists}
13270 % \begin{macro}{\tightlists*}
13271 % \begin{macro}{\m@mstightlists}
13272 % \begin{macro}{\m@mtightlists}
13273 % This macro sets the parameters for lists that have less open vertical
13274 % space in them. I think that these look neater than the defaults.
13275 % Effectively, no additional vertical space is added.
13276 % The starred version allows slightly no extra space
13277 % before and after the list when it is preceded by a blank line,
13278 % whereas the unstarred version puts half a \cs{onelineskip}
13279 % before \emph{and} after.
13280 % \changes{v1.61803}{2008/01/30}{Revised \cs{tightlists}, etc. (mempatch v4.5)}
13281 % \changes{v1.61803}{2008/01/30}{Revised \cs{tightlists} for non-zero
13282 % \cs{parskip}(mempatch v4.6)}
13283 % \begin{macrocode}
13284 \newcommand*{\tightlists}{%
13285 \@ifstar{\m@mstightlists}{\m@mtightlists}}
13286
13287 \newcommand*{\m@mstightlists}{%
13288 \setlength{\partopsep}{\z@ \@plus \p@ \@minus \p@}%
13289 \parsepi = \z@ \@plus \p@ \@minus \p@
13290 \itemsepi = \parsepi
13291 \topsepi = \z@ \@plus \p@ \@minus \p@
13292 \parsepii = \z@ \@plus \p@ \@minus \p@
13293 \topsepii = \parsepi
13294 \topsepiii = \parsepii
13295 \everylistparindent\parindent
13296 \ifm@mnzpskip
13297 \setnzplist
13298 \partopsepiii\partopsep
13299 \fi}
13300
13301 \newcommand*{\m@mtightlists}{%
13302 \setlength{\partopsep}{0.5\onelineskip \@plus \p@ \@minus \p@}%
13303 \parsepi = \z@ \@plus \p@ \@minus \p@
13304 \itemsepi = \parsepi
13305 \topsepi = \z@ \@plus \p@ \@minus \p@
13306 \parsepii = \z@ \@plus \p@ \@minus \p@
13307 \topsepii = \parsepi
13308 \topsepiii = \parsepii
13309 \everylistparindent\parindent
13310 \ifm@mnzpskip
13311 \setnzplist
13312 \partopsepiii\partopsep
13313 \fi}
13314
13315 % \end{macrocode}
13316 % \end{macro}
13317 % \end{macro}
13318 % \end{macro}
13319 % \end{macro}
13320 %
13321 % \begin{macro}{\firmlist}
13322 % \begin{macro}{\tightlist}
13323 % These two macros can be used at the start of a list environment to
13324 % reduce the vertical gaps. \cs{tightlist} removes all interior spaces
13325 % while \cs{firmlist} only removes some.
13326 % \changes{v0.3}{2001/07/09}{Added \cs{firmlist} and reimplemented the
13327 % original \cs{tightlist}}
13328 % \begin{macrocode}
13329 \newcommand{\firmlist}{%
13330 \setlength{\itemsep}{0.5\itemsep}\setlength{\parskip}{0.5\parskip}}
13331 \newcommand{\tightlist}{%
13332 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
13333
13334 % \end{macrocode}
13335 % \end{macro}
13336 % \end{macro}
13337 %
13338 % The space before and after a \Lenv{trivlist} environment is controlled
13339 % by the \cs{topsep} and \cs{partopsep} skips. There are several environments,
13340 % such as \Lenv{center}, that are defined as a \Lenv{trivlist}.
13341 %
13342 % \begin{macro}{\m@msavetopsep}
13343 % \begin{macro}{\m@msavepartopsep}
13344 % \begin{macro}{\savetrivseps}
13345 % \begin{macro}{\restoretrivseps}
13346 % Two skips to store the \cs{topsep} and \cs{partopsep} values and a means
13347 % of setting them and restoring them.
13348 % \changes{v1.6}{2004/01/28}{Added methods for adjusting the space around
13349 % a trivlist}
13350 % \begin{macrocode}
13351 \newskip\m@msavetopsep
13352 \newskip\m@msavepartopsep
13353 \newcommand*{\savetrivseps}{%
13354 \m@msavetopsep\topsep
13355 \m@msavepartopsep\partopsep}
13356 \newcommand*{\restoretrivseps}{%
13357 \topsep\m@msavetopsep
13358 \partopsep\m@msavepartopsep}
13359 % \end{macrocode}
13360 % Save the initial \cs{topsep} and \cs{partopsep} values.
13361 % \begin{macrocode}
13362 \savetrivseps
13363
13364 % \end{macrocode}
13365 % \end{macro}
13366 % \end{macro}
13367 % \end{macro}
13368 % \end{macro}
13369 %
13370 % \begin{macro}{\zerotrivseps}
13371 % A macro to zero \cs{topsep} and \cs{partopsep}.
13372 % \begin{macrocode}
13373 \newcommand*{\zerotrivseps}{%
13374 \topsep\z@
13375 \partopsep\z@}
13376
13377 % \end{macrocode}
13378 % \end{macro}
13379 %
13380 %
13381 % \begin{macro}{\@listI}
13382 % \begin{macro}{\@listi}
13383 % \cs{@listI} defines top level and \cs{@listi} values of
13384 % \cs{leftmargin}, \cs{parsep}, \cs{topsep}, and \cs{itemsep}
13385 %
13386 % \begin{macrocode}
13387 \def\@listi{\leftmargin\leftmargini
13388 \parsep\parsepi
13389 \topsep\topsepi
13390 \itemsep\itemsepi}
13391 \let\@listI\@listi
13392 % \end{macrocode}
13393 % We should initialise these parameters to the standard defaults
13394 % \begin{macrocode}
13395 \defaultlists
13396 \@listi
13397
13398 % \end{macrocode}
13399 % \end{macro}
13400 % \end{macro}
13401 %
13402 %
13403 % \begin{macro}{\@listii}
13404 % \begin{macro}{\@listiii}
13405 % \begin{macro}{\@listiv}
13406 % \begin{macro}{\@listv}
13407 % \begin{macro}{\@listvi}
13408 % Here are the same macros for the lower level lists.
13409 % \begin{macrocode}
13410 \def\@listii{\leftmargin\leftmarginii
13411 \labelwidth\leftmarginii
13412 \advance\labelwidth-\labelsep
13413 \topsep\topsepii
13414 \parsep\parsepii
13415 % \end{macrocode}
13416 % \changes{v3.7g}{2016/11/22}{Typo: \cs{itemsep} should here point at
13417 % \cs{itemsepii}, reported by Thomas Koeppe, private email}
13418 % \begin{macrocode}
13419 \itemsep\itemsepii}
13420
13421 \def\@listiii{\leftmargin\leftmarginiii
13422 \labelwidth\leftmarginiii
13423 \advance\labelwidth-\labelsep
13424 \topsep\topsepiii
13425 \parsep\z@
13426 %%% \itemsep\topsep
13427 %%% \partopsep \p@ \@plus\z@ \@minus\p@
13428 \itemsep\itemsepiii
13429 \partopsep\partopsepiii}
13430
13431 \def\@listiv{\leftmargin\leftmarginiv
13432 \labelwidth\leftmarginiv
13433 \advance\labelwidth-\labelsep}
13434
13435 \def\@listv{\leftmargin\leftmarginv
13436 \labelwidth\leftmarginv
13437 \advance\labelwidth-\labelsep}
13438
13439 \def\@listvi{\leftmargin\leftmarginvi
13440 \labelwidth\leftmarginvi
13441 \advance\labelwidth-\labelsep}
13442
13443 % \end{macrocode}
13444 % \end{macro}
13445 % \end{macro}
13446 % \end{macro}
13447 % \end{macro}
13448 % \end{macro}
13449 %
13450 %
13451 % \subsection{Enumerate}
13452 %
13453 %
13454 % The enumerate environment uses four counters: \Lcount{enumi},
13455 % \Lcount{enumii}, \Lcount{enumiii} and \Lcount{enumiv}, where
13456 % \Lcount{enumN} controls the numbering of the Nth level
13457 % enumeration.
13458 %
13459 % \begin{macro}{\theenumi}
13460 % \begin{macro}{\theenumii}
13461 % \begin{macro}{\theenumiii}
13462 % \begin{macro}{\theenumiv}
13463 % The counters are already defined in \file{latex.dtx}, but their
13464 % representation is changed here.
13465 %
13466 % \begin{macrocode}
13467 \renewcommand{\theenumi}{\@arabic\c@enumi}
13468 \renewcommand{\theenumii}{\@alph\c@enumii}
13469 \renewcommand{\theenumiii}{\@roman\c@enumiii}
13470 \renewcommand{\theenumiv}{\@Alph\c@enumiv}
13471 % \end{macrocode}
13472 % \end{macro}
13473 % \end{macro}
13474 % \end{macro}
13475 % \end{macro}
13476 %
13477 % \begin{macro}{\labelenumi}
13478 % \begin{macro}{\labelenumii}
13479 % \begin{macro}{\labelenumiii}
13480 % \begin{macro}{\labelenumiv}
13481 % The label for each item is generated by the commands\\
13482 % \cs{labelenumi} \ldots\ \cs{labelenumiv}.
13483 % \begin{macrocode}
13484 \newcommand{\labelenumi}{\theenumi.}
13485 \newcommand{\labelenumii}{\theenumii)}
13486 \newcommand{\labelenumiii}{\theenumiii.}
13487 \newcommand{\labelenumiv}{\theenumiv.}
13488 % \end{macrocode}
13489 % \end{macro}
13490 % \end{macro}
13491 % \end{macro}
13492 % \end{macro}
13493 %
13494 % \begin{macro}{\p@enumii}
13495 % \begin{macro}{\p@enumiii}
13496 % \begin{macro}{\p@enumiv}
13497 % The expansion of \verb?\p@enumN\theenumN? defines the output of a
13498 % \cs{ref} command when referencing an item of the Nth level of an
13499 % enumerated list.
13500 % \begin{macrocode}
13501 \renewcommand{\p@enumii}{\theenumi}
13502 \renewcommand{\p@enumiii}{\theenumi(\theenumii)}
13503 \renewcommand{\p@enumiv}{\p@enumiii\theenumiii}
13504 % \end{macrocode}
13505 % \end{macro}
13506 % \end{macro}
13507 % \end{macro}
13508 %
13509 %
13510 % The following is taken directly from David Carlisle's
13511 % \Lpack{enumerate} package.
13512 %
13513 % START OF DAVID CARLISLE'S CODE AND COMMENTARY
13514 %
13515 % This package gives the enumerate environment an optional argument
13516 % which determines the style in which the counter is printed.
13517 %
13518 % An occurence of one of the tokens \verb?A a I i? or \verb?1? produces the value
13519 % of the counter printed with (respectively) \verb?\Alph \alph \Roman \roman?
13520 % or \cs{arabic}.
13521 %
13522 % These letters may be surrounded by any strings involving any other
13523 % \TeX\ expressions, however the tokens \verb?A a I i 1? must be inside a
13524 % \verb?{ }? group if they are not to be taken as special.
13525 %
13526 %
13527 % \begin{macro}{\@enlab}
13528 % Internal token register used to build up the label command from the
13529 % optional argument.
13530 % \begin{macrocode}
13531 \newtoks\@enLab
13532 % \end{macrocode}
13533 % \end{macro}
13534 %
13535 % \begin{macro}{\@enQmark}
13536 % This just expands to a `?'. \cs{ref} will produce this, if no counter
13537 % is printed.
13538 % \begin{macrocode}
13539 \def\@enQmark{?}
13540 % \end{macrocode}
13541 % \end{macro}
13542 %
13543 % The next four macros build up the command that will print the item
13544 % label. They each gobble one token or group from the optional argument,
13545 % and add corresponding tokens to the register \cs{@enLab}. They each end
13546 % with a call to \cs{@enloop}, which starts the processing of the next
13547 % token.
13548 % \begin{macro}{\@enLabel}
13549 % Add the counter to the label. \verb?#2? will be one of the `special'
13550 % tokens \verb?A a I i 1?, and is thrown away. \verb?#1? will be a command
13551 % like \cs{Roman}.
13552 % \begin{macrocode}
13553 \def\@enLabel#1#2{%
13554 \edef\@enThe{\noexpand#1{\@enumctr}}%
13555 \@enLab\expandafter{\the\@enLab\csname the\@enumctr\endcsname}%
13556 \@enloop}
13557 % \end{macrocode}
13558 % \end{macro}
13559 %
13560 % \begin{macro}{\@enSpace}
13561 % \begin{macro}{\@enSp@ce}
13562 % Add a space to the label. The tricky bit is to gobble the space token,
13563 % as you can not do this with a macro argument.
13564 % \begin{macrocode}
13565 \def\@enSpace{\afterassignment\@enSp@ce\let\@memtempa= }
13566 \def\@enSp@ce{\@enLab\expandafter{\the\@enLab\space}\@enloop}
13567 % \end{macrocode}
13568 % \end{macro}
13569 % \end{macro}
13570 %
13571 % \begin{macro}{\@enGroup}
13572 % Add a \verb?{ }? group to the label.
13573 % \begin{macrocode}
13574 \def\@enGroup#1{\@enLab\expandafter{\the\@enLab{#1}}\@enloop}
13575 % \end{macrocode}
13576 % \end{macro}
13577 %
13578 % \begin{macro}{\@enOther}
13579 % Add anything else to the label
13580 % \begin{macrocode}
13581 \def\@enOther#1{\@enLab\expandafter{\the\@enLab#1}\@enloop}
13582 % \end{macrocode}
13583 % \end{macro}
13584 %
13585 % \begin{macro}{\@enloop}
13586 % \begin{macro}{\@enloop@}
13587 % The body of the main loop.
13588 % Eating tokens this way instead of using \cs{@tfor} lets you see
13589 % spaces and \textbf{all} braces. \cs{@tfor} would treat \verb?a? and
13590 % \verb?{a}? as special, but not \verb?{{a}}?.
13591 % \begin{macrocode}
13592 \def\@enloop{\futurelet\@entemp\@enloop@}
13593 % \end{macrocode}
13594 % \begin{macrocode}
13595 \def\@enloop@{%
13596 \ifx A\@entemp \def\@memtempa{\@enLabel\Alph }\else
13597 \ifx a\@entemp \def\@memtempa{\@enLabel\alph }\else
13598 \ifx i\@entemp \def\@memtempa{\@enLabel\roman }\else
13599 \ifx I\@entemp \def\@memtempa{\@enLabel\Roman }\else
13600 \ifx 1\@entemp \def\@memtempa{\@enLabel\arabic}\else
13601 \ifx \@sptoken\@entemp \let\@memtempa\@enSpace \else
13602 \ifx \bgroup\@entemp \let\@memtempa\@enGroup \else
13603 \ifx \@enum@\@entemp \let\@memtempa\@gobble \else
13604 \let\@memtempa\@enOther
13605 % \end{macrocode}
13606 % Hook for possible extensions
13607 % \begin{macrocode}
13608 \@enhook
13609 % \end{macrocode}
13610 %
13611 % \begin{macrocode}
13612 \fi\fi\fi\fi\fi\fi\fi\fi
13613 % \end{macrocode}
13614 % \end{macro}
13615 % Process the current token, then look at the next.
13616 % \begin{macrocode}
13617 \@memtempa}
13618 % \end{macrocode}
13619 % \end{macro}
13620 %
13621 % \begin{macro}{\@enhook}
13622 % Hook for possible extensions.
13623 % Some packages may want to extend the number of special characters
13624 % that are associated with counter representations. This feature
13625 % was requested to enable Russian alphabetic counting, but here
13626 % I give an example of a footnote symbol counter, triggered by \verb?*?.
13627 %
13628 % To enable a new counter type based on a letter, you just need
13629 % to add a new \cs{ifx} clause by analogy with the code above.
13630 % So for example to make \verb?*? trigger footnote symbol counting.
13631 % a package should do the following.
13632 %
13633 % Initialise the hook, in case the package is loaded before
13634 % \textsf{enumerate}.
13635 %\begin{verbatim}
13636 % \providecommand\@enhook{}
13637 %\end{verbatim}
13638 %
13639 % Add to the hook a new \cs{ifx} clause that associates \verb?*? with the
13640 % \cs{fnsymbol} counter command.
13641 %\begin{verbatim}
13642 % \g@addto@macro\@enhook{%
13643 % \ifx *\@entemp
13644 % \def\@memtempa{\@enLabel\fnsymbol}%
13645 % \fi}
13646 %\end{verbatim}
13647 % This code sequence should work whether it is loaded before or after
13648 % this enumerate package. Any number of new counter types may be added
13649 % in this way.
13650 %
13651 % At this point we just need initialise the hook, taking care not
13652 % to over write any definitions another package may already have added.
13653 % (PRW: as this is now in a class, it can be defined instead of
13654 % \cs{provide}d).
13655 % \begin{macrocode}
13656 %% \providecommand\@enhook{}
13657 \newcommand\@enhook{}
13658 % \end{macrocode}
13659 % \end{macro}
13660 %
13661 % \begin{macro}{\enumerate}
13662 % The new \Lenv{enumerate} environment. This is the first half of the
13663 % original enumerate environment. If there is an optional argument, call
13664 % \cs{@@enum@} to define the label commands, otherwise call
13665 % \cs{@enum@} which is the second half of the original definition.
13666 % \begin{macrocode}
13667 \def\enumerate{%
13668 \ifnum \@enumdepth >3 \@toodeep\else
13669 \advance\@enumdepth \@ne
13670 \edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi
13671 \@ifnextchar[{\@@enum@}{\@enum@}}
13672 % \end{macrocode}
13673 % \end{macro}
13674 %
13675 % \begin{macro}{\@@enum@}
13676 % Handle the optional argument..
13677 % \begin{macrocode}
13678 \def\@@enum@[#1]{%
13679 % \end{macrocode}
13680 % Initialise the loop which will break apart the optional argument.
13681 % The command to print the label is built up in \cs{@enlab}.
13682 % \cs{@enThe} will be used to define \cs{theenum}\,$n$.
13683 % \begin{macrocode}
13684 \@enLab{}\let\@enThe\@enQmark
13685 % \end{macrocode}
13686 % The \cs{@enum@} below is never expanded, it is used to detect the end
13687 % of the token list.
13688 % \begin{macrocode}
13689 \@enloop#1\@enum@
13690 % \end{macrocode}
13691 % Issue a warning if we did not find one of the `special' tokens.
13692 % \begin{macrocode}
13693 \ifx\@enThe\@enQmark\@warning{The counter will not be printed.%
13694 ^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi
13695 % \end{macrocode}
13696 % Define \cs{labelenum}$\,n$ and \cs{theenum}$\,n$.
13697 % \begin{macrocode}
13698 \expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}%
13699 \expandafter\let\csname the\@enumctr\endcsname\@enThe
13700 % \end{macrocode}
13701 % Set the counter to 7 so that we get the width of `vii' if roman
13702 % numbering is in force then set \cs{leftmargin}$\,n$. to the width of the
13703 % label plus \cs{labelsep}.
13704 % \begin{macrocode}
13705 \csname c@\@enumctr\endcsname7
13706 \expandafter\settowidth
13707 \csname leftmargin\romannumeral\@enumdepth\endcsname
13708 {\the\@enLab\hspace{\labelsep}}%
13709 % \end{macrocode}
13710 % Finally call \cs{@enum@} which is the second half of the original
13711 % definition.
13712 % \begin{macrocode}
13713 \@enum@}
13714 % \end{macrocode}
13715 % \end{macro}
13716 %
13717 % \begin{macro}{\@enum@}
13718 % All the list parameters have now been defined, so call \cs{list}. This
13719 % is taken straight from the original definition of \cs{enumerate}.
13720 % \begin{macrocode}
13721 \def\@enum@{\list{\csname label\@enumctr\endcsname}%
13722 {\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}}}
13723
13724 % \end{macrocode}
13725 % \end{macro}
13726 %
13727 % END OF DAVID CARLISLE'S CODE AND COMMENTARY
13728 %
13729 %
13730 %
13731 % \subsection{Itemize}
13732 %
13733 %
13734 % \begin{macro}{\labelitemi}
13735 % \begin{macro}{\labelitemii}
13736 % \begin{macro}{\labelitemiii}
13737 % \begin{macro}{\labelitemiii}
13738 % Itemization is controlled by the commands: \cs{labelitemi},
13739 % \cs{labelitemii}, etc., which define
13740 % the labels of the various itemization levels: the symbols used are:
13741 % bullet (\textbullet), bold en-dash (\textbf{\textendash}),
13742 % centered asterisk (\textasteriskcentered), and centered dot
13743 % (\textperiodcentered).
13744 %
13745 % \begin{macrocode}
13746 \newcommand{\labelitemi}{\textbullet}
13747 \newcommand{\labelitemii}{\normalfont\bfseries \textendash}
13748 \newcommand{\labelitemiii}{\textasteriskcentered}
13749 \newcommand{\labelitemiv}{\textperiodcentered}
13750 % \end{macrocode}
13751 % \end{macro}
13752 % \end{macro}
13753 % \end{macro}
13754 % \end{macro}
13755 %
13756 % It seems like a reasonable idea to give the \Lenv{itemize} environment
13757 % an optional argument to match \Lenv{enumerate}. Fortunately this seems
13758 % to be much simpler and I might even be able to work it out for myself.
13759 %
13760 % \begin{environment}{itemize}
13761 % This is a hack at the kernel code for \Lenv{itemize}.
13762 % \begin{macrocode}
13763 \renewcommand{\itemize}[1][\@empty]{%
13764 \ifnum \@itemdepth >\thr@@\@toodeep\else
13765 \advance\@itemdepth\@ne
13766 \ifx \@empty #1\else % optional argument
13767 \@namedef{labelitem\romannumeral\the\@itemdepth}{#1}%
13768 \fi
13769 \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
13770 \expandafter
13771 \list
13772 \csname\@itemitem\endcsname
13773 {\def\makelabel##1{\hss\llap{##1}}}%
13774 \fi}
13775 \let\enditemize =\endlist
13776
13777 % \end{macrocode}
13778 % \end{environment}
13779 %
13780 % \subsection{Description}
13781 %
13782 % The class defines two description environment, the standard one and a `block'
13783 % one, and also two semi-configurable versions.
13784 %
13785 % \changes{v1.2}{2002/07/27}{Now two `description' environments.}
13786 %
13787 % \begin{environment}{description}
13788 % The description environment is defined here -- while the default itemize
13789 % and enumerate environments are defined in \file{latex.dtx}.
13790 %
13791 % \changes{v1.2}{2002/07/27}{The \texttt{description} environment now matches
13792 % the standard layout.}
13793 % \begin{macrocode}
13794 \newenvironment{description}%
13795 {\list{}{\labelwidth\z@ \itemindent-\leftmargin
13796 \let\makelabel\descriptionlabel}}%
13797 {\endlist}
13798 % \end{macrocode}
13799 % \end{environment}
13800 %
13801 % \begin{macro}{\descriptionlabel}
13802 % To change the formatting of the label, you must redefine
13803 % \cs{descriptionlabel}.
13804 %
13805 % \begin{macrocode}
13806 \newcommand*{\descriptionlabel}[1]{\hspace\labelsep
13807 \normalfont\bfseries #1}
13808 % \end{macrocode}
13809 % \end{macro}
13810 %
13811 % \begin{environment}{blockdescription}
13812 % The `block' description environment.
13813 %
13814 % \changes{v1.2}{2002/07/27}{Renamed original \texttt{description} environment
13815 % to \texttt{blockdescription}.}
13816 % \begin{macrocode}
13817 \newenvironment{blockdescription}%
13818 {\list{}{\labelwidth\z@ \itemindent 0.5em \labelsep 0.5em
13819 \let\makelabel\blockdescriptionlabel}}%
13820 {\endlist}
13821 % \end{macrocode}
13822 % \end{environment}
13823 %
13824 % \begin{macro}{\blockdescriptionlabel}
13825 % In order to change the formatting of the label, you must redefine
13826 % the macro \cs{blockdescriptionlabel}.
13827 %
13828 % \begin{macrocode}
13829 \newcommand*{\blockdescriptionlabel}[1]{%%% \hspace\labelsep
13830 \normalfont\bfseries #1}
13831 % \end{macrocode}
13832 % \end{macro}
13833 %
13834 % \begin{environment}{labelled}
13835 % This is a version of the description environment which takes the
13836 % name, without the backslash, of some \cs{labelcode} as its argument.
13837 % For example:
13838 % \begin{verbatim}
13839 % \newcommand*{\sflabel}[1]{\hspace\labelsep \normalfont\sffamily #1}
13840 % \begin{labelled}{sflabel}
13841 % \item[label] using a sans font for the labels
13842 % \end{verbatim}
13843 % \changes{v1.6180339f}{2009/04/25}{Added labelled environment}
13844 % \begin{macrocode}
13845 \newenvironment{labelled}[1]%
13846 {\list{}{\labelwidth\z@ \itemindent-\leftmargin
13847 \def\m@malabel{\@nameuse{#1}} \let\makelabel\m@malabel}}%
13848 {\endlist}
13849
13850 % \end{macrocode}
13851 % \end{environment}
13852 %
13853 % \begin{environment}{flexlabelled}
13854 % \verb?\begin{flexlabelled}{labelcode}{labelwidth}{labelsep}{itemindent}{leftmargin}{rightmargin}?
13855 % lets you specify some of the parameters for a description-like list.
13856 % The first argument is as for the labelled environment. The others are all
13857 % lengths for the various parameters; a \verb?*? instead of a length means
13858 % that that argument is to be ignored.
13859 % \changes{v1.6180339f}{2009/04/25}{Added flexlabelled environment}
13860 % \begin{macrocode}
13861 \newenvironment{flexlabelled}[6]%
13862 {\list{}{\nametest{#2}{*}%
13863 \ifsamename\else \labelwidth #2 \fi
13864 \nametest{#3}{*}%
13865 \ifsamename\else \labelsep #3 \fi
13866 \nametest{#4}{*}%
13867 \ifsamename\else \itemindent #4 \fi
13868 \nametest{#5}{*}%
13869 \ifsamename\else \leftmargin #5 \fi
13870 \nametest{#6}{*}%
13871 \ifsamename\else \rightmargin #6 \fi
13872 \def\m@malabel{\@nameuse{#1}} \let\makelabel\m@malabel}}%
13873 {\endlist}
13874
13875 % \end{macrocode}
13876 % \end{environment}
13877 %
13878 %
13879 % \subsection{Quotation}
13880 %
13881 % \begin{environment}{quotation}
13882 % The quotation environment is defined by making clever use of
13883 % the list environment's parameters. The lines in the environment
13884 % are set smaller than \cs{textwidth}. The first line of a paragraph
13885 % inside this environment is indented.
13886 %
13887 % \begin{macrocode}
13888 \newenvironment{quotation}%
13889 {\list{}{\listparindent 1.5em%
13890 \itemindent \listparindent
13891 \rightmargin \leftmargin
13892 \parsep \z@ \@plus\p@}%
13893 \item[]}%
13894 {\endlist}
13895 % \end{macrocode}
13896 % \end{environment}
13897 %
13898 % \subsection{Quote}
13899 %
13900 %
13901 % \begin{environment}{quote}
13902 % The quote environment is like the quotation environment except
13903 % that paragraphs are not indented.
13904 %
13905 % \begin{macrocode}
13906 \newenvironment{quote}%
13907 {\list{}{\rightmargin\leftmargin}%
13908 \item[]}%
13909 {\endlist}
13910 % \end{macrocode}
13911 % \end{environment}
13912 %
13913 % \subsection{Theorem}
13914 %
13915 % This document class does not define it's own theorem environments,
13916 % the defaults, supplied by \file{latex.dtx} are available.
13917 %
13918 % \subsection{Listing of symbols and abbreviations}
13919 %
13920 % Another element is the listing of symbols
13921 % and abbreviations.
13922 %
13923 % \begin{environment}{symbols}
13924 % \begin{macro}{\symbollabel}
13925 % \begin{macrocode}
13926 \newcommand{\symbollabel}[1]{{#1 \hfill}}
13927 % \end{macrocode}
13928 % \end{macro}
13929 % \begin{macrocode}
13930 \newenvironment{symbols}{\list{}%
13931 {\itemindent 0em \leftmargin 8em
13932 \labelsep 1em \labelwidth 5em
13933 \let\makelabel\symbollabel}}%
13934 {\endlist}
13935 % \end{macrocode}
13936 % \end{environment}
13937 %
13938 % \begin{macro}{\symboldef}
13939 % Within a \Lenv{symbols} environment the command
13940 % \cs{symboldef}\marg{symbol}\marg{meaning}
13941 % is used to specify and explain each symbol or abbreviation.
13942 % \begin{macrocode}
13943 \newcommand{\symboldef}[2]{\item[#1] #2}
13944 % \end{macrocode}
13945 % \end{macro}
13946 %
13947 % \section{Abstracts}
13948 %
13949 % Books usually do not have abstracts, but I decided to add in the code
13950 % from the \Lpack{abstract}
13951 % package~\cite{ABSTRACT}.
13952 % \changes{v0.3}{2001/07/09}{Added code for abstracts}
13953 %
13954 %
13955 % We just have the \Lpack{report} or \Lpack{article} style for the
13956 % abstract with no \Lopt{titlepage} option. The original code,
13957 % from \file{classes.dtx} for this is:
13958 % \begin{verbatim}
13959 % \newenvironment{abstract}{%
13960 % \if@twocolumn
13961 % \section*{\abstractname}
13962 % \else
13963 % \small
13964 % \begin{center}%
13965 % {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%%
13966 % \end{center}%
13967 % \quotation
13968 % \fi}%
13969 % {\if@twocolumn\else\endquotation\fi}
13970 % \end{verbatim}
13971 %
13972 %
13973 % The following \cs{if...} commands are for implementing various options.
13974 % \begin{macro}{\if@bsonecol}
13975 % \begin{macro}{\ifadd@bstotoc}
13976 % \begin{macro}{\ifnumber@bs}
13977 % \begin{macro}{\if@bsrunin}
13978 % \begin{macrocode}
13979 \newif\if@bsonecol
13980 \@bsonecoltrue
13981 \newif\ifadd@bstotoc
13982 \add@bstotocfalse
13983 \newif\ifnumber@bs
13984 \number@bsfalse
13985 \newif\if@bsrunin
13986 \@bsruninfalse
13987
13988 % \end{macrocode}
13989 % \end{macro}
13990 % \end{macro}
13991 % \end{macro}
13992 % \end{macro}
13993 %
13994 % \begin{macro}{\abstractcol}
13995 % \begin{macro}{\abstractintoc}
13996 % \begin{macro}{\abstractnum}
13997 % \begin{macro}{\abstractrunin}
13998 % These are the use-level commands for setting the options. If
13999 % the abstract is runin, then it must not be numbered otherwise
14000 % adding it to the ToC might result in something peculiar.
14001 % \begin{macrocode}
14002 \newcommand{\abstractcol}{\@bsonecolfalse}
14003 \newcommand{\abstractintoc}{\add@bstotoctrue}
14004 \newcommand{\abstractnum}{\number@bstrue\@bsruninfalse}
14005 \newcommand{\abstractrunin}{\@bsrunintrue\number@bsfalse}
14006
14007 % \end{macrocode}
14008 % \end{macro}
14009 % \end{macro}
14010 % \end{macro}
14011 % \end{macro}
14012 %
14013 %
14014 % The next set of macros comprise the
14015 % implementation of the \Lenv{abstract} environment.
14016 %
14017 % \begin{macro}{\abstractnamefont}
14018 % \begin{macro}{\abstracttextfont}
14019 % These two macros are for specifying the fonts for typesetting the
14020 % abstract's title and text. They are initialised for the default case
14021 % (i.e., no class options).
14022 % \begin{macrocode}
14023 \newcommand{\abstractnamefont}{\normalfont\small\bfseries}
14024 \newcommand{\abstracttextfont}{\normalfont\small}
14025 % \end{macrocode}
14026 % \end{macro}
14027 % \end{macro}
14028 %
14029 % \begin{macro}{\abscolnamefont}
14030 % \begin{macro}{\abscoltextfont}
14031 % These two macros are for specifying the fonts for typesetting the
14032 % abstract's title and text in a two column document where the abstarct
14033 % is part of a column.
14034 % \changes{v1.61803}{2008/01/30}{Added \cs{abscolnamefont} and
14035 % \cs{abscoltextfont} (mempatch v4.8)}
14036 % \begin{macrocode}
14037 \newcommand{\abscolnamefont}{\normalfont\Large\bfseries}
14038 \newcommand{\abscoltextfont}{\normalfont}
14039
14040 % \end{macrocode}
14041 % \end{macro}
14042 % \end{macro}
14043 %
14044 % \begin{macro}{\absnamepos}
14045 % \begin{macro}{\abstitleskip}
14046 % \cs{absnamepos} specifies the environment in which the abstract's title
14047 % name will be typeset, and the length \cs{abstitleskip} is an adjustement
14048 % to the vertical space between the title and the abstract's text. These
14049 % are initialised for the default case.
14050 % \begin{macrocode}
14051 \newcommand{\absnamepos}{center}
14052 \newlength{\abstitleskip} \setlength{\abstitleskip}{-0.5em}
14053 % \end{macrocode}
14054 % \end{macro}
14055 % \end{macro}
14056 %
14057 % \begin{macro}{\absleftindent}
14058 % \begin{macro}{\abs@leftindent}
14059 % \begin{macro}{\absrightindent}
14060 % \begin{macro}{\absparindent}
14061 % \begin{macro}{\absparsep}
14062 % The abstract's text is typeset as a single item list, called
14063 % \texttt{@bstr@ctlist}. These lengths set the left and right margin indents, the
14064 % paragraph indentation, and the inter-paragraph vertical space. Their
14065 % initial values are all class option-dependent.
14066 % \changes{v1.618}{2005/09/03}{Added \cs{abs@leftindent} per Lars Madsen (mempatch v3.0)}
14067 % \begin{macrocode}
14068 \newlength{\absleftindent}
14069 \absleftindent=\leftmargin
14070 \newdimen\abs@leftindent
14071 \abs@leftindent=\leftmargin
14072 \newlength{\absrightindent}
14073 \absrightindent=\leftmargin
14074 \newlength{\absparindent}
14075 \newlength{\absparsep}
14076
14077 % \end{macrocode}
14078 % \end{macro}
14079 % \end{macro}
14080 % \end{macro}
14081 % \end{macro}
14082 % \end{macro}
14083 %
14084 % \begin{macro}{\abslabeldelim}
14085 % \begin{macro}{\@bslabeldelim}
14086 % The contents of \cs{abslabeldelim} are typeset after a run-in heading.
14087 % \begin{macrocode}
14088 \newcommand{\abslabeldelim}[1]{\def\@bslabeldelim{#1}}
14089 \abslabeldelim{}
14090 % \end{macrocode}
14091 % \end{macro}
14092 % \end{macro}
14093 %
14094 % \begin{macro}{\@bsrunintitle}
14095 % This macro typeset the run-in heading.
14096 % \begin{macrocode}
14097 \newcommand{\@bsrunintitle}{%
14098 \hspace*{\abstitleskip}{\abstractnamefont\abstractname\@bslabeldelim}}
14099
14100 % \end{macrocode}
14101 % \end{macro}
14102 %
14103 % \begin{macro}{\setup@bstract}
14104 % Now arrange to set all the class option-dependent values.
14105 % \changes{v1.618}{2005/09/03}{Used \cs{abs@leftindent} in \cs{setup@bstract} (mempatch v3.0)}
14106 % \changes{v1.61803}{2008/01/30}{Changed \cs{setup@bstract} to cater for
14107 % \cs{abscolnamefont}, etc., and don't set
14108 % \cs{absrightindent} to \cs{absleftindent}.}
14109 % \begin{macrocode}
14110 \newcommand{\setup@bstract}{%
14111 \abs@leftindent=\absleftindent
14112 \if@twocolumn
14113 % \end{macrocode}
14114 % Values for the \Lopt{twocolumn} class option.
14115 % \begin{macrocode}
14116 \if@bsonecol
14117 \else
14118 \abs@leftindent=\z@
14119 \absrightindent=\z@
14120 \renewcommand*{\abstractnamefont}{\abscolnamefont}
14121 \renewcommand*{\abstracttextfont}{\abscoltextfont}
14122 \renewcommand*{\absnamepos}{flushleft}
14123 \setlength{\abstitleskip}{-2ex}
14124 \fi
14125 \fi}
14126
14127 % \end{macrocode}
14128 % \end{macro}
14129 %
14130 % \begin{macrocode}
14131 \AtBeginDocument{\setlength{\absparindent}{\parindent}
14132 \setlength{\absparsep}{\parskip}}
14133
14134 % \end{macrocode}
14135 %
14136 % \begin{environment}{@bstr@ctlist}
14137 % The abstract's text is typeset within the \Lenv{@bstr@ctlist} list environment.
14138 % \changes{v1.618}{2005/09/03}{Used \cs{abs@leftindent} in \cs{@bstr@ctlist} (mempatch v3.0)}
14139 % \begin{macrocode}
14140 \newenvironment{@bstr@ctlist}{%
14141 \list{}{%
14142 %%\topsep \z@
14143 \partopsep \z@
14144 \listparindent \absparindent
14145 \itemindent \listparindent
14146 \leftmargin \abs@leftindent
14147 \rightmargin \absrightindent
14148 \parsep \absparsep}%
14149 \item\relax}
14150 {\endlist}
14151
14152 % \end{macrocode}
14153 % \end{environment}
14154 %
14155 % \begin{macro}{\put@bsintoc}
14156 % This macro adds the abstract's title to the ToC. It does nothing if
14157 % the abstract is being numbered.
14158 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget}}
14159 % \begin{macrocode}
14160 \newcommand{\put@bsintoc}{%
14161 \ifadd@bstotoc
14162 \ifnumber@bs\else
14163 % \phantomsection
14164 \MakeLinkTarget[chapter]{}%
14165 \addcontentsline{toc}{chapter}{\abstractname}
14166 \fi
14167 \fi}
14168
14169 % \end{macrocode}
14170 % \end{macro}
14171 %
14172 % \begin{macro}{\num@bs}
14173 % This macro generates a numbered abstract heading.
14174 % \begin{macrocode}
14175 \newcommand{\num@bs}{\chapter{\abstractname}}
14176
14177 % \end{macrocode}
14178 % \end{macro}
14179 %
14180 % \begin{environment}{abstract}
14181 % At last we are in position to define the \Lenv{abstract} environment. This
14182 % follows very much along the lines of the standard class definitions, but with
14183 % macros inserted at strategic points.
14184 %
14185 % The \Lopt{twocolumn} option and the default case. These use the same code
14186 % as any style differences are embedded in the new macros.
14187 % \begin{macrocode}
14188 \newenvironment{abstract}{%
14189 \setup@bstract
14190 \if@bsrunin\else
14191 \ifnumber@bs \num@bs \else
14192 \begin{\absnamepos}\abstractnamefont\abstractname\end\absnamepos%
14193 \vspace{\abstitleskip}%
14194 \fi
14195 \fi
14196 \put@bsintoc%
14197 \begin{@bstr@ctlist}\if@bsrunin\@bsrunintitle\fi\abstracttextfont}%
14198 {\par\end{@bstr@ctlist}}
14199
14200 % \end{macrocode}
14201 % \end{environment}
14202 %
14203 % \begin{environment}{onecolabstract}
14204 % An environment for typesetting a single column abstract,
14205 % particularly as the optional argument to the \cs{twocolumn} command.
14206 % \begin{macrocode}
14207 \newenvironment{onecolabstract}{%
14208 \begin{@twocolumnfalse}\begin{abstract}}{%
14209 \end{abstract}\end{@twocolumnfalse}}
14210
14211 % \end{macrocode}
14212 % \end{environment}
14213 %
14214 % \begin{macro}{\thanks}
14215 % \begin{macro}{\@bs@thanks}
14216 % We have to keep the contents of the \cs{thanks} commands as normally these
14217 % are emptied by the \cs{maketitle} command. I do this by extending the definition
14218 % of the \cs{thanks} (from \file{ltsect.dtx}) command,
14219 % so that \cs{@bs@thanks} has a copy of the contents
14220 % of \cs{@thanks}.
14221 % \changes{v3.8.3}{2024/02/02}{Changed using \cs{addtoiargdef} to \cs{xapptocmd} }
14222 % \begin{macrocode}
14223 % \addtoiargdef{\thanks}{}{%
14224 % \protected@xdef\@bs@thanks{\@bs@thanks
14225 % \protect\footnotetext[\the\c@footnote]{#1}}%
14226 % }
14227 \xapptocmd\thanks{%
14228 \protected@xdef\@bs@thanks{\@bs@thanks
14229 \protect\footnotetext[\the\c@footnote]{#1}}%
14230 }{}{\typeout{Patch to \string\thanks\space failed, please inform maintainer}}
14231 \let\@bs@thanks\@empty
14232
14233 % \end{macrocode}
14234 % \end{macro}
14235 % \end{macro}
14236 %
14237 % \begin{macro}{\saythanks}
14238 % This macro typesets any \cs{thanks} commands \emph{after} using
14239 % \texttt{onecolabstract}.
14240 % \begin{macrocode}
14241 \newcommand{\saythanks}{\begingroup
14242 \renewcommand{\thefootnote}{\fnsymbol{footnote}}\@bs@thanks
14243 \endgroup\global\let\@bs@thanks\@empty}
14244
14245 % \end{macrocode}
14246 % \end{macro}
14247 %
14248 %
14249 % \section{Verse}
14250 %
14251 % The class provides a more flexible \Lenv{verse} environment than the
14252 % standard classes. This is based on the \Lpack{verse}
14253 % package~\cite{VERSE}.
14254 % \changes{v1.0}{2001/10/30}{Complete rewrite of verse typesetting}
14255 %
14256 % \subsection{Environments}
14257 %
14258 % Before proceeding with the main, here are some macros for aspects
14259 % of line numbering.
14260 %
14261 % \begin{macro}{\c@vslineno}
14262 % \begin{macro}{\c@poemline}
14263 % \begin{macro}{\c@modulo@vs}
14264 % \begin{macro}{\c@memfvsline}
14265 % We need counters for stanza and poem lines. The \texttt{memfvsline}
14266 % counter is for adjusting the starting line for verse line numbers.
14267 % \changes{v1.1}{2002/03/10}{Added poemline and modulo@vs counters}
14268 % \changes{v1.61803}{2008/01/30}{Added memfvsline counter (mempatch v4.9)}
14269 % \begin{macrocode}
14270 \newcounter{vslineno}
14271 \newcounter{poemline}
14272 \newcounter{modulo@vs}
14273 \newcounter{memfvsline}
14274
14275 % \end{macrocode}
14276 % \end{macro}
14277 % \end{macro}
14278 % \end{macro}
14279 % \end{macro}
14280 %
14281 %
14282 % \changes{v3.8.3}{2024/02/05}{folly deleted the outcommented code for \cs{poemline}, have been outcommented for years.}
14283 %
14284 % \begin{macro}{\linenumberfont}
14285 % \begin{macro}{\vlvnumfont}
14286 % Set line numbering font(s).
14287 % \begin{macrocode}
14288 \newcommand{\linenumberfont}[1]{\def\vlvnumfont{#1}}
14289 %%% \linenumberfont{\small\rmfamily}
14290
14291 % \end{macrocode}
14292 % \end{macro}
14293 % \end{macro}
14294 %
14295 % \begin{macro}{\ifbvcountlines}
14296 % \begin{macro}{\bvcountlinestrue}
14297 % \begin{macro}{\bvcountlinesfalse}
14298 % Looking ahead, TRUE for (boxed) verbatim line numbers to be printed. Default
14299 % is not to print them. Not that \cs{linenumberfrequency} twiddles with this.
14300 % \begin{macrocode}
14301 \newif\ifbvcountlines% TRUE to print line numbers of (boxed) verbatim lines
14302 \bvcountlinesfalse
14303
14304 % \end{macrocode}
14305 % \end{macro}
14306 % \end{macro}
14307 % \end{macro}
14308 %
14309 % \begin{macro}{\linenumberfrequency}
14310 % \begin{macro}{\linemodnum}
14311 % Set numbering intervals (number modulo). Default is modulus 0.
14312 % \begin{macrocode}
14313 \newcommand{\linenumberfrequency}[1]{%
14314 \ifnum #1< \@ne
14315 \def\linemodnum{0\relax}
14316 \bvcountlinesfalse
14317 \else
14318 \def\linemodnum{#1\relax}
14319 \bvcountlinestrue
14320 \fi}
14321
14322 %%%%\linenumberfrequency{0}
14323
14324 % \end{macrocode}
14325 % \end{macro}
14326 % \end{macro}
14327 %
14328 % \begin{macro}{\setverselinenums}
14329 % \cs{setverselinenums}\marg{firstline}\marg{startnumsat} sets the first line
14330 % number to \meta{firstline} and the first line number to be printed is
14331 % \meta{startnumsat}. Use within the \Lenv{verse} environment before the
14332 % first verse. Note that \\
14333 % \verb?firstline <= startnumsat < firstline + linenumberfrequency?
14334 % \changes{v1.61803}{2008/01/30}{Added \cs{setverselinenums} (mempatch v4.9)}
14335 % \begin{macrocode}
14336 \newcommand*{\setverselinenums}[2]{%
14337 \c@poemline #1\relax \advance\c@poemline \m@ne
14338 \refstepcounter{poemline}%
14339 \ifnum\z@<\linemodnum% we are printing line numbers
14340 \@tempcnta #2\relax
14341 \divide\@tempcnta\linemodnum
14342 \multiply\@tempcnta\linemodnum
14343 \c@memfvsline #2\relax
14344 \advance\c@memfvsline-\@tempcnta
14345 \fi}
14346
14347 % \end{macrocode}
14348 % \end{macro}
14349 %
14350 % \changes{v1.1}{2002/03/24}{Added \cs{getmodulo@vs}}
14351 % \changes{v1.2}{2002/07/27}{Using \cs{getthelinenumber} instead of \cs{getmodulo@vs}}
14352 %
14353 % \begin{macro}{\getthelinenumber}
14354 % \cs{getthelinenumber}\marg{counter}\marg{start} returns \cs{thecounter}
14355 % if it is exactly divisible by \cs{linenumberfrequency}, provided this is
14356 % not zero. \meta{start} is the first number.
14357 % \changes{v1.61802}{2008/01/30}{Generalised \cs{getthelinenumber} to cater
14358 % for set of first line number.}
14359 % \begin{macrocode}
14360 \newcommand{\getthelinenumber}[2]{%
14361 \ifnum\@ne>\linemodnum% no line numbers
14362 \else
14363 \ifnum\@ne=\linemodnum% every line numbered
14364 \@nameuse{the#1}%
14365 \else
14366 \@tempcnta=\@nameuse{c@#1}%
14367 \advance\@tempcnta -\@nameuse{c@#2}%
14368 \divide\@tempcnta \linemodnum
14369 \multiply\@tempcnta \linemodnum
14370 \advance\@tempcnta \@nameuse{c@#2}%
14371 \ifnum\@tempcnta=\@nameuse{c@#1}\@nameuse{the#1}\fi
14372 \fi
14373 \fi}
14374
14375 % \end{macrocode}
14376 % \end{macro}
14377 %
14378 % \begin{macro}{\ifaltindent}
14379 % This should be set TRUE for indenting alternate lines.
14380 % \begin{macrocode}
14381 \newif\ifaltindent
14382 \altindentfalse
14383 % \end{macrocode}
14384 % \end{macro}
14385 %
14386 % \begin{macro}{\ifpattern}
14387 % This should be set TRUE for indenting lines according to a pattern.
14388 % \begin{macrocode}
14389 \newif\ifpattern
14390 \patternfalse
14391 % \end{macrocode}
14392 % \end{macro}
14393 %
14394 % \begin{macro}{\ifstarpattern}
14395 % This should be set TRUE for indenting lines according in a \Lenv{patverse*}
14396 % environment.
14397 % \changes{v1.1}{2002/03/8}{Added \cs{ifstarpattern}}
14398 % \begin{macrocode}
14399 \newif\ifstarpattern
14400 \starpatternfalse
14401
14402 % \end{macrocode}
14403 % \end{macro}
14404 %
14405 % \begin{macro}{\vleftskip}
14406 % \begin{macro}{\vrightskip}
14407 % Skips to the left and right of a line of verse.
14408 % \changes{v1.1}{2002/03/24}{Added \cs{vleftskip} and \cs{vrightskip}}
14409 % \changes{v1.2}{2002/07/27}{Changed defaults for \cs{vleftskip} and \cs{vrightskip}}
14410 % \begin{macrocode}
14411 \newlength{\vleftskip}
14412 \setlength{\vleftskip}{3em}
14413 \newlength{\vrightskip}
14414 \setlength{\vrightskip}{1em}
14415
14416 % \end{macrocode}
14417 % \end{macro}
14418 % \end{macro}
14419 %
14420 % \begin{macro}{\stanzaskip}
14421 % Skip between stanzas.
14422 % \changes{v1.2}{2002/07/07}{Added \cs{stanzaskip}}
14423 % \begin{macrocode}
14424 \newlength{\stanzaskip}
14425 \setlength{\stanzaskip}{\onelineskip}
14426
14427 % \end{macrocode}
14428 % \end{macro}
14429 %
14430 % \begin{macro}{\flagverse}
14431 % \cs{flagverse}\marg{flag} inserts \meta{flag} at the left (of a line).
14432 % \changes{v1.1}{2002/03/24}{Added \cs{flagverse}}
14433 % \changes{v1.61803398}{2009/07/17}{Added bidi suport to \cs{flagverse}}
14434 % \begin{macrocode}
14435 \newcommand{\flagverse}[1]{%
14436 %%% \hskip-\vleftskip\llap{#1}\hskip\vleftskip\ignorespaces}
14437 \hskip-\memRTLvleftskip\llap{#1}\hskip\memRTLvleftskip\ignorespaces}
14438
14439 % \end{macrocode}
14440 % \end{macro}
14441 %
14442 % \begin{macro}{\versewidth}
14443 % The length \cs{versewidth} is a convenience length for the user.
14444 % \begin{macrocode}
14445 \newlength{\versewidth}
14446 % \end{macrocode}
14447 % \end{macro}
14448 %
14449 % \begin{macro}{\vgap}
14450 % \begin{macro}{\vin}
14451 % \begin{macro}{\vindent}
14452 % The length \cs{vgap} is used as the basis for spacing. \cs{vin} makes
14453 % a horizontal space of \cs{vgap} and \cs{vindent} is the indentation
14454 % of wrapped lines.
14455 % \begin{macrocode}
14456 \newlength{\vgap} \setlength{\vgap}{1.5em}
14457 \newcommand{\vin}{\hspace*{\vgap}}
14458 \newlength{\vindent} \setlength{\vindent}{2\vgap}
14459 % \end{macrocode}
14460 % \end{macro}
14461 % \end{macro}
14462 % \end{macro}
14463 %
14464 % \begin{macro}{\vinphantom}
14465 % Macro to leave blank space coresponding to a string.
14466 % \changes{v1.4}{2003/02/27}{Added \cs{vinphantom} (patch 1.1)}
14467 % \begin{macrocode}
14468 \newcommand{\vinphantom}[1]{\leavevmode\phantom{#1}}
14469 % \end{macrocode}
14470 % \end{macro}
14471 %
14472 % \begin{macro}{\vleftofline}
14473 % Macro to insert something immediately to the left of the start
14474 % of the line.
14475 % \changes{v1.618}{2005/09/14}{Added \cs{vleftofline}}
14476 % \begin{macrocode}
14477 \newcommand*{\vleftofline}[1]{\leavevmode\llap{#1}}
14478 % \end{macrocode}
14479 % \end{macro}
14480 %
14481 % \begin{macro}{\vleftmargin}
14482 % Length to adjust the default left margin within a verse environment.
14483 % \changes{v1.618}{2005/09/18}{Added \cs{vleftmargin}}
14484 % \begin{macrocode}
14485 \newdimen\vleftmargin
14486 \vleftmargin=\leftmargini
14487
14488 % \end{macrocode}
14489 % \end{macro}
14490 %
14491 % \begin{macro}{\verselinebreak}
14492 % Break a verse line by inserting \cs{newline}.
14493 % \changes{v1.1}{2002/03/28}{Modified \cs{verselinebreak}}
14494 % \changes{v1.61803}{2008/01/30}{Removed extraneous space from \cs{verselinebreak} (mempatch v4.4, Aaron Rendahl)}
14495 % \begin{macrocode}
14496 \newcommand{\verselinebreak}[1][\z@]{\newline\hspace*{#1}\ignorespaces}
14497
14498 % \end{macrocode}
14499 % \end{macro}
14500 %
14501 % \begin{macro}{\incr@vsline}
14502 % Increment the line counters.
14503 % \changes{v1.1}{2002/03/24}{Added poemline counter to \cs{incr@vsline}}
14504 % \begin{macrocode}
14505 \newcommand{\incr@vsline}{%
14506 \refstepcounter{poemline}%
14507 \stepcounter{vslineno}}
14508
14509 % \end{macrocode}
14510 % \end{macro}
14511 %
14512 % \begin{macro}{\@vsifbang}
14513 % Like the kernel \cs{@ifstar} except it looks for an exclamation mark!
14514 % \changes{v1.1}{2002/03/24}{Added \cs{@vsifbang}}
14515 % \begin{macrocode}
14516 \newcommand{\@vsifbang}[1]{\@ifnextchar !{\@firstoftwo{#1}}}
14517 % \end{macrocode}
14518 % \end{macro}
14519 %
14520 % \begin{macro}{\@vsifgt}
14521 % Like the kernel \cs{@ifstar} except it looks for a \verb?>? character.
14522 % \changes{v1.1}{2002/03/28}{Added \cs{@vsifgt}}
14523 % \begin{macrocode}
14524 \newcommand{\@vsifgt}[1]{\@ifnextchar >{\@firstoftwo{#1}}}
14525
14526 % \end{macrocode}
14527 % \end{macro}
14528 %
14529 % \begin{macro}{\verselinenumbersright}
14530 % \begin{macro}{\verselinenumbersleft}
14531 % \begin{macro}{\@vstypelinenum}
14532 % Declarations for setting line numbers at the right (the default)
14533 % or the left..
14534 % \changes{v1.61803}{2008/01/30}{Added \cs{verselinenumbersright} and
14535 % \cs{verselinenumbersleft} (mempatch v4.4, v4.9)}
14536 % \begin{macrocode}
14537 \newcommand*{\verselinenumbersright}{\def\@vstypelinenum{\@vslnumright}}
14538 \newcommand*{\verselinenumbersleft}{\def\@vstypelinenum{\@vslnumleft}}
14539 \verselinenumbersright
14540
14541 % \end{macrocode}
14542 % \end{macro}
14543 % \end{macro}
14544 % \end{macro}
14545 %
14546 % \begin{macro}{\@vslnumright}
14547 % \begin{macro}{\@vslnumleft}
14548 % Internal code for right/left line numbers. This was reimplemented in 2024,
14549 % to be used in hooks instead of being added at the end of lines.
14550 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@vslnumright}
14551 % and \cs{@vslnumleft}}
14552 % \changes{v3.7g}{2018/02/28}{Added \cs{nobreak} to both
14553 % \cs{@vslnumright} and \cs{@vslnumleft}, reported on
14554 % \protect\url{https://tex.stackexchange.com/a/415939/3929}, to avoid strange
14555 % double line breaks}
14556 % \changes{v3.8.3}{2024/02/06}{Reimplemented as they are no longer added at the end of the line}
14557 % \begin{macrocode}
14558 \newcommand*{\@vslnumright}{%
14559 %\nobreak%
14560 %\hfill\rlap{%\kern\vrightskip\kern\rightmargin%
14561 % \kern\memRTLvrightskip\kern\rightmargin%
14562 % \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
14563 \rlap{%
14564 \hspace{\dimexpr-\@totalleftmargin+\textwidth+\memRTLvrightskip}%
14565 {\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
14566 }%
14567 }
14568 \newcommand*{\@vslnumleft}{%
14569 % \nobreak%
14570 % \hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
14571 % \kern-\textwidth\kern-\memRTLvrightskip%
14572 % \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
14573 \llap{%
14574 \llap{\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
14575 \hspace{\dimexpr\@totalleftmargin+\memRTLvrightskip}%
14576 }%
14577 }
14578 % \end{macrocode}
14579 % \end{macro}
14580 % \end{macro}
14581 %
14582 % \begin{macro}{\@vscentercr}
14583 % This puts the poem line number in the margin, increments
14584 % the line numbers, and then deals with the options. It is based
14585 % on the kernel \cs{@centercr}.
14586 % This has to handle various forms of the \verb?\\? command: \verb?\\?,
14587 % \verb?\\*?, \verb?\\!?, and \verb?\\>?, together with an optional length argument.
14588 % \changes{v1.1}{2002/03/28}{Major rewrite of \cs{@vscentercr} and friends}
14589 % \changes{v1.2}{2002/07/27}{Changed \cs{@vscentercr} to use general
14590 % linenumbering}
14591 % \changes{v1.61803}{2008/01/30}{Changed \cs{@vscentercr} for left/right numbers
14592 % (mempatch v4.4)}
14593 % \changes{v3.8.3}{2024/02/06}{Removed the line numbering from \cs{@vscentercr}, they are now added via hooks}
14594 % \begin{macrocode}
14595 \newcommand{\@vscentercr}{%
14596 \ifhmode \unskip\else \@nolnerr\fi
14597 % \@vstypelinenum% outcommented 2024/02/06
14598 % \end{macrocode}
14599 % For \verb?>? call \cs{verselinebreak} to process it.
14600 % \begin{macrocode}
14601 \@vsifgt{\verselinebreak}{%
14602 \incr@vsline
14603 % \end{macrocode}
14604 % If the call is \verb?\\*...? call \cs{@vsxcentercr} to handle the \verb?*...?.
14605 % If the call is \verb?\\!?, do nothing.
14606 % If the call is \verb?\\![...]?, call \cs{@vsicentercr} to handle the \verb?[...]?.
14607 % Otherwise, call \cs{@vsxcentercr}.
14608 % \begin{macrocode}
14609 \par\@ifstar{\nobreak\@vsxcentercr}{%
14610 % \end{macrocode}
14611 % \begin{macrocode}
14612 \@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}}}}
14613 % \end{macrocode}
14614 % \end{macro}
14615 %
14616 % \begin{macro}{\@vsxcentercr}
14617 % Processes \verb?\\*?, and either calls cs{@vsicentercr} to handle a \verb?[length]?,
14618 % or \cs{start@vsline}.
14619 % \changes{v1.1}{2002/03/24}{Added \cs{@vsxcentercr}}
14620 % \begin{macrocode}
14621 \newcommand{\@vsxcentercr}{\addvspace{-\parskip}%
14622 \@ifnextchar[ {\@vsicentercr}{\start@vsline}}
14623 % \end{macrocode}
14624 % \end{macro}
14625 %
14626 % \begin{macro}{\@vsicentercr}
14627 % Processes \verb?(\\...)[length]? and then calls \cs{start@vsline}.
14628 % \changes{v1.1}{2002/03/24}{Added \cs{@vsicentercr}}
14629 % \begin{macrocode}
14630 \def\@vsicentercr[#1]{\vskip #1\ignorespaces \start@vsline}
14631 % \end{macrocode}
14632 % \end{macro}
14633 %
14634 % \begin{macro}{\start@vsline}
14635 % This is called at the start of every verse line except the first.
14636 % \changes{v1.1}{2002/03/28}{Added \cs{ifstarpattern} to \cs{start@vsline}}
14637 % \changes{v1.61}{2004/03/21}{Used counter for vslineno, not \cs{thevslineno}
14638 % in \cs{start@vsline}}
14639 % \begin{macrocode}
14640 \newcommand{\start@vsline}{%
14641 \ifaltindent\ifodd\c@vslineno\else\vin\fi\fi%
14642 \ifpattern\get@vsindent\fi%
14643 \ifstarpattern\getstar@vsindent\fi}
14644
14645 % \end{macrocode}
14646 % \end{macro}
14647 %
14648 % \begin{macro}{\theHpoemline}
14649 % For the \Lpack{hyperref} package need a way of distinguishing
14650 % lines of a poem. See the thread \textit{PDFTEX/Hyperef hates memoir verse
14651 % environment?} on \ctt{} October 2002.
14652 % \changes{v1.3}{2002/11/14}{Added verse counter and \cs{theHpoemline}}
14653 % \changes{v3.7.19}{2022/10/25}{Changing \cs{theH...} definitions to
14654 % \cs{def} for better compability with future hyperref}
14655 % \begin{macrocode}
14656 \newcounter{verse}
14657 \setcounter{verse}{0}
14658 \def\theHpoemline{\theverse.\thepoemline}
14659
14660 % \end{macrocode}
14661 % \end{macro}
14662 %
14663 % \begin{environment}{verse}
14664 % The extended \Lenv{verse} environment. It sets the verse line counter,
14665 % then defines the particular list environment adjusting the margins
14666 % to center according to the length parameter. If the length parameter
14667 % is at least the \cs{linewidth} then the `centering' defaults to
14668 % the original \Lenv{verse} layout.
14669 % \changes{v1.1}{2001/08/03}{Initialise the line counter to 1, not 0, in
14670 % all cases}
14671 % \changes{v1.1}{2002/03/28}{Changes to verse environment for line numbering}
14672 % \changes{v1.3}{2002/11/14}{Changes to verse environment for hyperref}
14673 % \changes{v1.4}{2002/02/27}{Let verses wider than the \cs{linewidth}
14674 % take the full width (patch(1.1)}
14675 % \changes{v1.618}{2005/09/03}{Fix vertical spacing in the verse environment (mempatch v3.3)}
14676 % \begin{macrocode}
14677 \newenvironment{verse}[1][\linewidth]{%
14678 \refstepcounter{verse}%
14679 \setcounter{poemline}{0}\refstepcounter{poemline}%
14680 \setcounter{vslineno}{1}%
14681 \let\\=\@vscentercr
14682 \list{}{\itemsep \z@
14683 \itemindent -\vindent
14684 \listparindent\itemindent
14685 \leftmargin \vleftmargin
14686 \parsep \stanzaskip
14687 \ifdim #1<\linewidth% %% short line
14688 \rightmargin \z@
14689 \leftmargin \linewidth
14690 \advance\leftmargin -#1\relax
14691 \advance\leftmargin -0.5\leftmargin
14692 \advance\leftmargin \vindent
14693 \else
14694 \ifdim #1>\linewidth% %% long line
14695 \rightmargin \z@
14696 \leftmargin \vindent
14697 \else% %% default
14698 \rightmargin \leftmargin
14699 \advance\leftmargin \vindent
14700 \fi
14701 \fi}
14702 \item[]}{\endlist}
14703
14704 % \end{macrocode}
14705 % \end{environment}
14706 % Then we use the env and paragraph hooks to add support for line
14707 % numbers, the idea was suggested by Ulrike Fischer in chat. It is
14708 % also listed as an example in \cite{SOURCE2E}.
14709 %
14710 % \changes{v3.8.3}{2024/02/06}{Added the hooks to handle line numbers.}
14711 % \begin{macrocode}
14712 \AddToHook{env/verse/begin}{%
14713 \AddToHook{para/begin}[memoir/versenum]{\@vstypelinenum}}
14714 \AddToHook{env/verse/end}{\RemoveFromHook{para/begin}[memoir/versenum]}
14715
14716 % \end{macrocode}
14717 %
14718 % \begin{environment}{altverse}
14719 % This sets \cs{altindenttrue} (afterwards false) and initialises the line counter.
14720 % \changes{v1.1}{2002/03/28}{Added \cs{starpatternfalse} to altverse}
14721 % \begin{macrocode}
14722 \newenvironment{altverse}%
14723 {\starpatternfalse\patternfalse\altindenttrue
14724 \setcounter{vslineno}{1}}%
14725 {\altindentfalse}
14726
14727 % \end{macrocode}
14728 % \end{environment}
14729 %
14730 %
14731 % \subsection{Patterns}
14732 %
14733 % The pattern code is based on the idea of converting a string of
14734 % digits to an array of digits, and then being able to access the
14735 % digit at a particular position in the array.
14736 %
14737 %
14738 % \begin{macro}{\ifbounderror}
14739 % A flag set TRUE if an attempt is made to access an array element outside
14740 % the array limits.
14741 % \begin{macrocode}
14742 \newif\ifbounderror
14743 \bounderrorfalse
14744 % \end{macrocode}
14745 % \end{macro}
14746 %
14747 % \begin{macro}{\ifinteger}
14748 % A flag to indicate if a `number' is an integer (TRUE) or not (FALSE).
14749 % \begin{macrocode}
14750 \newif\ifinteger
14751
14752 % \end{macrocode}
14753 % \end{macro}
14754 %
14755 % \begin{macro}{\c@chrsinstr}
14756 % A counter for the number of characters.
14757 % \begin{macrocode}
14758 \newcounter{chrsinstr} % CHARactersINSTRing
14759
14760 % \end{macrocode}
14761 % \end{macro}
14762 %
14763 %
14764 % \begin{macro}{\newarray}
14765 % \cs{newarray}\marg{arrayname}\marg{low}\marg{high} defines
14766 % an array called \meta{arrayname} (no backslash e.g. \verb?MyArray?),
14767 % with low and high limts \meta{low} and \meta{high}.
14768 % \begin{macrocode}
14769 \newcommand{\newarray}[3]{%
14770 \@nameedef{#1-low}{#2}%
14771 \@nameedef{#1-high}{#3}%
14772 \ifnum #3<#2
14773 \@memerror{Limits for array #1 are in reverse order}{\@ehc}%
14774 \fi}
14775
14776 % \end{macrocode}
14777 % \end{macro}
14778 %
14779 %
14780 % \begin{macro}{\stringtoarray}
14781 % \cs{stringtoarray}\marg{arrayname}\marg{string} puts each character
14782 % from \meta{string} sequentially into the \meta{arrayname} array, starting
14783 % with \meta{low} = 1. It checks for an empty \meta{string} and handles that
14784 % specially.
14785 % \begin{macrocode}
14786 \newcommand{\stringtoarray}[2]{%
14787 \def\@vsarrayname{#1}%
14788 \protected@edef\the@vsstring{#2}%
14789 \newarray{\@vsarrayname}{1}{1}%
14790 \@ifmtarg{#2}{%
14791 \c@chrsinstr \z@
14792 \@namedef{\@vsarrayname-1}{}
14793 }{%
14794 \c@chrsinstr \@ne
14795 \expandafter\@vsstringtoarray \the@vsstring\@vsend
14796 }}
14797
14798 % \end{macrocode}
14799 % \end{macro}
14800 %
14801 %
14802 % \begin{macro}{\@vsstringtoarray}
14803 % Recursively adds characters to the array \cs{@vsarrayname}, incrementing
14804 % the array's high limit.
14805 % \begin{macrocode}
14806 \def\@vsstringtoarray #1#2\@vsend{%
14807 \@namedef{\@vsarrayname-\the\c@chrsinstr}{#1}
14808 \@nameedef{\@vsarrayname-high}{\the\c@chrsinstr}
14809 \@ifmtarg{#2}{%
14810 \def\@vsinext{}%
14811 }{%
14812 \advance\c@chrsinstr \@ne
14813 \def\@vsinext{%
14814 \@vsstringtoarray #2\@vsend%
14815 }%
14816 }
14817 \@vsinext}
14818
14819 % \end{macrocode}
14820 % \end{macro}
14821 %
14822 %
14823 % \begin{macro}{\setarrayelement}
14824 % \cs{setarrayelement}\marg{arrayname}\marg{index}\marg{value} sets
14825 % the \meta{arrayname} array's element at \meta{index} to \meta{value}.
14826 % \begin{macrocode}
14827 \newcommand{\setarrayelement}[3]{%
14828 \checkarrayindex{#1}{#2}%
14829 \@nameedef{#1-#2}{#3}}
14830 % \end{macrocode}
14831 % \end{macro}
14832 %
14833 %
14834 % \begin{macro}{\getarrayelement}
14835 % \cs{getarrayelement}\marg{arrayname}\marg{index}\marg{value}
14836 % defines the parameterless macro \meta{value} (e.g., \cs{result}) to be
14837 % the value at \meta{index} in the \meta{arrayname} array.
14838 % \begin{macrocode}
14839 \newcommand{\getarrayelement}[3]{%
14840 \checkarrayindex{#1}{#2}%
14841 \protected@edef#3{\@nameuse{#1-#2}}}
14842
14843 % \end{macrocode}
14844 % \end{macro}
14845 %
14846 %
14847 % \begin{macro}{\checkarrayindex}
14848 % \cs{checkarrayindex}\marg{arrayname}\marg{index} checks that
14849 % the \meta{index} of the \meta{arrayname} array is valid. \cs{ifbounderror}
14850 % is set FALSE if everything is OK, otherwise it is set TRUE.
14851 % \begin{macrocode}
14852 \newcommand{\checkarrayindex}[2]{%
14853 \bounderrorfalse
14854 \expandafter\ifx\csname #1-low\endcsname\relax%
14855 \ifpattern\else
14856 \@memerror{No array called #1}{\@ehc}%
14857 \fi
14858 \bounderrortrue
14859 \fi
14860 \ifnum #2<\@nameuse{#1-low}\relax%
14861 \ifpattern\else
14862 \@memerror{Index #2 outside limits for array #1}{\@ehc}%
14863 \fi
14864 \bounderrortrue
14865 \fi
14866 \ifnum #2>\@nameuse{#1-high}\relax%
14867 \ifpattern\else
14868 \@memerror{Index #2 outside limits for array #1}{\@ehc}%
14869 \fi
14870 \bounderrortrue
14871 \fi}
14872
14873 % \end{macrocode}
14874 % \end{macro}
14875 %
14876 %
14877 % \begin{macro}{\arraytostring}
14878 % \cs{arraytostring}\marg{arrayname}\marg{string} converts the
14879 % characters in the \meta{arrayname} array into the parameterless macro
14880 % \meta{string} (e.g., \cs{MyString}).
14881 % \begin{macrocode}
14882 \newcommand{\arraytostring}[2]{%
14883 \def#2{}%
14884 \c@chrsinstr = \@nameuse{#1-low}%
14885 \@vsarraytostring{#1}{#2}}
14886
14887 % \end{macrocode}
14888 % \end{macro}
14889 %
14890 %
14891 % \begin{macro}{\@vsarraytostring}
14892 % \cs{@vsarraytostring}\marg{arrayname}\marg{string} recursively
14893 % adds the (character) elements from \meta{arrayname} to \meta{string}.
14894 % \begin{macrocode}
14895 \newcommand{\@vsarraytostring}[2]{%
14896 \ifnum\c@chrsinstr>\@nameuse{#1-high}\else
14897 \protected@edef#2{#2\@nameuse{#1-\thechrsinstr}}%
14898 \advance\c@chrsinstr\@ne%
14899 \@vsarraytostring{#1}{#2}%
14900 \fi}
14901
14902 % \end{macrocode}
14903 % \end{macro}
14904 %
14905 %
14906 % \begin{macro}{\checkifinteger}
14907 % \cs{checkifinteger}\marg{num} checks if \meta{num} is an integer.
14908 % If it is, then \cs{ifinteger} is set TRUE, otherwise it is set FALSE.
14909 % (Code based on Donald Arseneau's \Lpack{cite} package).
14910 % \begin{macrocode}
14911 \newcommand{\checkifinteger}[1]{%
14912 \protected@edef\@vsa{#1}%
14913 \ifcat _\ifnum9<1\gobm{#1} _\else A\fi
14914 \integertrue%
14915 \else
14916 \integerfalse%
14917 \fi}
14918 % \end{macrocode}
14919 % \end{macro}
14920 %
14921 %
14922 % \begin{macro}{\gobm}
14923 % \cs{gobm}\marg{num} is defined as \meta{num}. It could be defined as: \\
14924 % \verb?\newcommand{\gobm}[1]{\ifx-#1\expandafter\gobm\else#1\fi}? \\
14925 % which would remove a leading minus sign (hyphen) from its argument
14926 % (\verb?gobm? = gobble minus sign).
14927 % (Code from a posting to \ctt{} by Donald Arseneau on 1997/07/21).
14928 % \begin{macrocode}
14929 \newcommand{\gobm}[1]{#1}
14930
14931 % \end{macrocode}
14932 % \end{macro}
14933 %
14934 % \begin{macro}{\indentpattern}
14935 % \cs{indentpattern}\marg{digits} stores \meta{digits} for use as
14936 % a verse indentation pattern.
14937 % \begin{macrocode}
14938 \newcommand{\indentpattern}[1]{%
14939 \stringtoarray{Array@vs}{#1}}
14940 % \end{macrocode}
14941 % \end{macro}
14942 %
14943 %
14944 % \begin{macro}{\get@vsindent}
14945 % \cs{get@vsindent} gets the indent pattern digit for the \cs{thevslineno},
14946 % then uses this to specify the line indentation as \verb?digit*\vgap?.
14947 % \changes{v1.61}{2004/03/21}{Changed \cs{get@vsindent} to use counter
14948 % value number instead of \cs{thevslineno}}
14949 % \begin{macrocode}
14950 \newcommand{\get@vsindent}{%
14951 \getarrayelement{Array@vs}{\number\value{vslineno}}{\@vspat}%
14952 \ifbounderror
14953 \arraytostring{Array@vs}{\@vsp@t}%
14954 \@memwarn{%
14955 Index `\thevslineno' for pattern `\@vsp@t' is out of bounds}%
14956 \def\@vspat{0}%
14957 \else
14958 \checkifinteger{\@vspat}%
14959 \ifinteger\else
14960 \arraytostring{Array@vs}{\@vsp@t}%
14961 \@memwarn{%
14962 `\@vspat' at index `\thevslineno' in pattern `\@vsp@t'
14963 is not a digit}%
14964 \def\@vspat{0}%
14965 \fi
14966 \fi
14967 \ifcase\@vspat\else\hspace*{\@vspat\vgap}\fi}
14968 % \end{macrocode}
14969 % \end{macro}
14970 %
14971 %
14972 % \begin{macro}{\getstar@vsindent}
14973 % \cs{getstar@vsindent} gets the indent pattern digit for the \Lenv{patverse*}
14974 % environment,
14975 % then uses this to specify the line indentation as \verb?digit*\vgap?.
14976 % It lets the pattern repeat by resetting the \texttt{vslineno} counter.
14977 % \changes{v1.1}{2002/03/28}{Added \cs{getstar@vsindent}}
14978 % \begin{macrocode}
14979 \newcommand{\getstar@vsindent}{%
14980 \expandafter\ifx\csname Array@vs-high\endcsname\relax
14981 \@memerror{A pattern has not been specified}{\@ehc}
14982 \else
14983 \ifnum\c@vslineno>\@nameuse{Array@vs-high}%
14984 \setcounter{vslineno}{1}%
14985 \fi
14986 \get@vsindent
14987 \fi}
14988
14989 % \end{macrocode}
14990 % \end{macro}
14991 %
14992 %
14993 % \begin{environment}{patverse}
14994 % The environment for setting verse line indents according to a pattern.
14995 % It starts by setting \cs{ifpattern} TRUE, any other flags to FALSE,
14996 % and initialises the line number. It ends by setting \cs{ifpattern} FALSE.
14997 % \changes{v1.1}{2002/03/28}{Added \cs{starpatternfalse} to patverse}
14998 % \begin{macrocode}
14999 \newenvironment{patverse}%
15000 {\starpatternfalse\patterntrue\altindentfalse
15001 \setcounter{vslineno}{1}}%
15002 {\patternfalse}
15003
15004 % \end{macrocode}
15005 % \end{environment}
15006 %
15007 % \begin{environment}{patverse*}
15008 % The environment for setting verse line indents according to a repeating
15009 % pattern.
15010 % It starts by setting \cs{ifstarpattern} TRUE, any other flags to FALSE,
15011 % and initialises the line number. It ends by setting \cs{ifstarpattern} FALSE.
15012 % \changes{v1.1}{2002/03/28}{Added patverse* environment}
15013 % \begin{macrocode}
15014 \newenvironment{patverse*}%
15015 {\starpatterntrue\patternfalse\altindentfalse
15016 \setcounter{vslineno}{1}}%
15017 {\starpatternfalse}
15018
15019 % \end{macrocode}
15020 % \end{environment}
15021 %
15022 %
15023 % \subsection{Titles}
15024 %
15025 % \begin{macro}{\poemtitle}
15026 % Typeset a poem title (like \cs{section} or other). The actual work
15027 % is done by \cs{@vsptitle} (plain) or \cs{@vssptitle} (starred).
15028 % \begin{macrocode}
15029 \newcommand{\poemtitle}{\par%
15030 \secdef\@vsptitle\@vssptitle}
15031 % \end{macrocode}
15032 % \end{macro}
15033 %
15034 % \begin{macro}{\poemtoc}
15035 % The kind of entry \cs{poemtitle} is to make in the ToC.
15036 % \begin{macrocode}
15037 \newcommand{\poemtoc}{section}
15038
15039 % \end{macrocode}
15040 % \end{macro}
15041 %
15042 % \begin{macro}{\mempoeminfo}
15043 % \begin{macro}{\mempoemstarinfo}
15044 % \verb?\mempoeminfo{title}? \\
15045 % \verb?\mempoemstarinfo{title}? \\
15046 % \changes{v1.61803}{2008/01/30}{Made \cs{mempoeminfo} and fiends \cs{long}
15047 % (mempatch v4.9)}
15048 % \begin{macrocode}
15049 \newcommand{\mempoeminfo}[1]{}
15050 \newcommand{\mempoemstarinfo}[1]{}
15051
15052 % \end{macrocode}
15053 % \end{macro}
15054 % \end{macro}
15055 %
15056 % \begin{macro}{\@vsptitle}
15057 % Typeset a \cs{poemtitle}.
15058 % \changes{v1.3}{2002/11/14}{Added \cs{phantomsection} to \cs{@vsptitle}}
15059 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@vsptitle}}
15060 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by suitable \cs{MakeLinkTarget}}
15061 % \begin{macrocode}
15062 \long\def\@vsptitle[#1]#2{%
15063 % \phantomsection
15064 \M@gettitle{#1}%
15065 \MakeLinkTarget[\poemtoc]{}%
15066 \addcontentsline{toc}{\poemtoc}{#1}%
15067 \mempoeminfo{#1}%
15068 \poemtitlemark{#1}%
15069 \@vstypeptitle{#2}%
15070 \@afterheading}
15071
15072 % \end{macrocode}
15073 % \end{macro}
15074 %
15075 % \begin{macro}{\@vssptitle}
15076 % Typeset a \cs{poemtitle*}.
15077 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@vssptitle}}
15078 % \changes{v3.8.4}{2025/09/16}{Added a \cs{MakeLinkTarget}}
15079 % \begin{macrocode}
15080 \long\def\@vssptitle#1{%
15081 \M@gettitle{#1}%
15082 \MakeLinkTarget[\poemtoc]{}%
15083 \mempoemstarinfo{#1}%
15084 \@vstypeptitle{#1}%
15085 \@afterheading}
15086
15087 % \end{macrocode}
15088 % \end{macro}
15089 %
15090 % \begin{macro}{\@vstypeptitle}
15091 % This \emph{really} typesets the title.
15092 % \begin{macrocode}
15093 \newcommand{\@vstypeptitle}[1]{%
15094 \vspace{\beforepoemtitleskip}%
15095 {\poemtitlefont #1\par}%
15096 \vspace{\afterpoemtitleskip}%
15097 }
15098
15099 % \end{macrocode}
15100 % \end{macro}
15101 %
15102 % \begin{macro}{\poemtitlefont}
15103 % \begin{macro}{\poemtitlemark}
15104 % Sets the appearance to the title of a poem, and something for a header.
15105 % \begin{macrocode}
15106 \newcommand{\poemtitlefont}{\normalfont\large\bfseries\centering}
15107 \newcommand{\poemtitlemark}[1]{}
15108
15109 % \end{macrocode}
15110 % \end{macro}
15111 % \end{macro}
15112 %
15113 % \begin{macro}{\beforepoemtitleskip}
15114 % \begin{macro}{\afterpoemtitleskip}
15115 % Lengths before and after a poem title, using approximately \cs{section}
15116 % values.
15117 % \begin{macrocode}
15118 \newlength{\beforepoemtitleskip}
15119 \setlength{\beforepoemtitleskip}{3.5ex \@plus 1ex \@minus .2ex}
15120 \newlength{\afterpoemtitleskip}
15121 \setlength{\afterpoemtitleskip}{2.3ex \@plus.2ex}
15122
15123 % \end{macrocode}
15124 % \end{macro}
15125 % \end{macro}
15126 %
15127 %
15128 % \begin{macro}{\if@numptitle}
15129 % \begin{macro}{\@numptitletrue}
15130 % \begin{macro}{\@numptitlefalse}
15131 % \begin{macro}{\NumberPoemTitle}
15132 % \begin{macro}{\PlainPoemTitle}
15133 % Following the \cs{NumberPoemTitle} declaration \cs{PoemTitle}s are numbered.
15134 % The \cs{PlainPoemTitle} declaration produces unnumbered titles.
15135 % \begin{macrocode}
15136 \newif\if@numptitle
15137 \newcommand*{\NumberPoemTitle}{\@numptitletrue}
15138 \newcommand*{\PlainPoemTitle}{\@numptitlefalse}
15139 \NumberPoemTitle
15140
15141 % \end{macrocode}
15142 % \end{macro}
15143 % \end{macro}
15144 % \end{macro}
15145 % \end{macro}
15146 % \end{macro}
15147 %
15148 % \begin{macro}{\c@poem}
15149 % \begin{macro}{\thepoem}
15150 % \begin{macro}{\theHpoem}
15151 % Counter for poem titles.
15152 % \changes{v3.8}{2023/06/20}{Changed \cs{theHpoem} to
15153 % \cs{providecommand} per request of the kernel team}
15154 % \begin{macrocode}
15155 \newcounter{poem}\setcounter{poem}{0}
15156 \renewcommand*{\thepoem}{\@arabic\c@poem}
15157 \providecommand*{\theHpoem}{\the\value{poem}}
15158
15159 % \end{macrocode}
15160 % \end{macro}
15161 % \end{macro}
15162 %
15163 % \begin{macro}{\poemtitlestarmark}
15164 % \begin{macro}{\poemtitlepstyle}
15165 % \begin{macro}{\poemtitlestarpstyle}
15166 % \cs{poemtitlemark}\marg{poemf@rhdr} is used for marks for a \cs{PoemTitle} and
15167 % \cs{poemtitlestarmark}\marg{poemf@hdr} is for marks for \cs{PoemTitle*}.
15168 % The \cs{poemtitlepstyle} and \cs{poemtitlestarpstyle} macros are provided
15169 % as hooks so that, for example, pagestyles can be set for the regular
15170 % and starred versions of \cs{PoemTitle}. By default these macros do nothing.
15171 % \begin{macrocode}
15172 \newcommand*{\poemtitlestarmark}[1]{}
15173 \newcommand*{\poemtitlepstyle}{}
15174 \newcommand*{\poemtitlestarpstyle}{}
15175
15176 % \end{macrocode}
15177 % \end{macro}
15178 % \end{macro}
15179 % \end{macro}
15180 %
15181 % \begin{macro}{\PoemTitle}
15182 % The command to produce a article style chapter-like (numbered) poem title.
15183 % \changes{v1.618}{2005/09/09}{Added \cs{PoemTitle}}
15184 % \begin{macrocode}
15185 \newcommand\PoemTitle{%
15186 \par
15187 \@afterindentfalse
15188 \@ifstar{\@m@msPoemTitle}{\@m@mPoemTitle}}
15189
15190 % \end{macrocode}
15191 % \end{macro}
15192 %
15193 % \begin{macro}{\@m@mPoemTitle}
15194 % \begin{macro}{\poemt@c}
15195 % Intermediate and support macros for the extra optional argument
15196 % to \cs{PoemTitle}. Have to do this long windedly otherwise dear old
15197 % \Lpack{hyperref} barfs.
15198 % \begin{macrocode}
15199 \newcommand{\@m@mPoemTitle}[1][]{%
15200 \def\poemt@c{#1}% capture first optional arg
15201 \@ifnextchar[{\@PoemTitle}{\@PoemTitle[]}%
15202 }
15203
15204 % \end{macrocode}
15205 % \end{macro}
15206 % \end{macro}
15207 % \end{macro}
15208 %
15209 % \begin{macro}{\memPoemTitleinfo}
15210 % \begin{macro}{\memPoemTitlestarinfo}
15211 % \verb?\memPoemTitleinfo{num}{toc}{head}{full}? \\
15212 % \verb?\memPoemTitlestarinfo{short}{full}?
15213 % \begin{macrocode}
15214 \newcommand{\memPoemTitleinfo}[4]{}
15215 \newcommand{\memPoemTitlestarinfo}[2]{}
15216
15217 % \end{macrocode}
15218 % \end{macro}
15219 % \end{macro}
15220 %
15221 % \begin{macro}{\@PoemTitle}
15222 % \begin{macro}{\poemf@rtoc}
15223 % \begin{macro}{\poemf@rhdr}
15224 % \cs{@PoemTitle}\oarg{tocmark}\marg{title}
15225 % typesets the title of a \cs{PoemTitle}.
15226 % There is a number for \cs{@numptitletrue} and \cs{@mainmattertrue}.
15227 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} with \cs{MakeLinkTarget}
15228 % in a better place}
15229 % \begin{macrocode}
15230 \def\@PoemTitle[#1]#2{%
15231 %\phantomsection
15232 \ifx\poemt@c\@empty % no optional args
15233 \def\poemf@rtoc{#2}%
15234 \def\poemf@rhdr{#2}%
15235 \else % at least one opt arg
15236 \let\poemf@rtoc\poemt@c
15237 \ifx\@empty#1\@empty
15238 \let\poemf@rhdr\poemt@c
15239 \else
15240 \def\poemf@rhdr{#1}%
15241 \fi
15242 \fi
15243 \m@m@Andfalse
15244 \if@numptitle
15245 \if@mainmatter
15246 \m@m@Andtrue
15247 \fi
15248 \fi
15249 \ifm@m@And
15250 \refstepcounter{poem}%
15251 \else
15252 \MakeLinkTarget[poem]{}%
15253 \fi
15254 % \end{macrocode}
15255 % Store the (short) title via \cs{poemtitlemark} and call
15256 % \cs{\@makePoemTitlehead} to do the typesetting.
15257 % \begin{macrocode}
15258 \@makePoemTitlehead{#2}%
15259 \@afterheading
15260 \poemtitlemark{\poemf@rhdr}%
15261 \poemtitlepstyle
15262 % \end{macrocode}
15263 % Add the title to the ToC.
15264 % \begin{macrocode}
15265 \ifm@m@And
15266 \addcontentsline{toc}{\poemtoc}{%
15267 \protect\numberline{\thepoem}\poemf@rtoc}%
15268 \memPoemTitleinfo{\thepoem}{\poemf@rtoc}{\poemf@rhdr}{#2}%
15269 \else
15270 \addcontentsline{toc}{\poemtoc}{\poemf@rtoc}%
15271 \memPoemTitleinfo{}{\poemf@rtoc}{\poemf@rhdr}{#2}%
15272 \fi
15273 % \end{macrocode}
15274 % Add hook for title referencing.
15275 % \changes{v3.70.20}{2023/07/24}{Redef of \cs{M@gettitle} requires
15276 % expansion for macro arguments}
15277 % \begin{macrocode}
15278 \ifheadnameref\ExpandArgs{V}\M@gettitle\poemf@rhdr\else\ExpandArgs{V}\M@gettitle\poemf@rtoc\fi}
15279
15280 % \end{macrocode}
15281 % \end{macro}
15282 % \end{macro}
15283 % \end{macro}
15284 %
15285 %
15286 % \begin{macro}{\@makePoemTitlehead}
15287 % This \emph{really} typesets a \cs{PoemTitle}. Leave some whitespace.
15288 % \begin{macrocode}
15289 \def\@makePoemTitlehead#1{{%
15290 \PoemTitleheadstart
15291 \parindent \z@ \normalfont
15292 % \end{macrocode}
15293 % If there is a number, typeset it, otherwise call \cs{printPoemTitlenonum}.
15294 % \begin{macrocode}
15295 \ifm@m@And
15296 \printPoemTitlenum
15297 \afterPoemTitlenum
15298 \else
15299 \printPoemTitlenonum
15300 \fi
15301 % \end{macrocode}
15302 % Typeset the title.
15303 % \begin{macrocode}
15304 \interlinepenalty\@M
15305 \printPoemTitletitle{#1}%
15306 \afterPoemTitle}}
15307
15308 % \end{macrocode}
15309 % \end{macro}
15310 %
15311 %
15312 %
15313 % \begin{macro}{\@PTchs@def@ult}
15314 % This sets up all the definitions used in \cs{@makePoemTitlehead}
15315 % and \cs{@makesPoemTitlehead}.
15316 % \begin{macro}{\PoemTitleheadstart}
15317 % \begin{macro}{\printPoemTitlenum}
15318 % \begin{macro}{\afterPoemTitlenum}
15319 % \begin{macro}{\printPoemTitlenonum}
15320 % \begin{macro}{\printPoemTitletitle}
15321 % \begin{macro}{\afterPoemTitle}
15322 % \begin{macrocode}
15323 \newcommand{\@PTchs@def@ult}{%
15324 \def\PoemTitleheadstart{\vspace{\beforePoemTitleskip}}
15325 \def\printPoemTitlenum{\PoemTitlenumfont \thepoem}
15326 \def\afterPoemTitlenum{\par\nobreak\vskip \midPoemTitleskip}
15327 \def\printPoemTitlenonum{}
15328 \def\printPoemTitletitle##1{\PoemTitlefont ##1}
15329 \def\afterPoemTitle{\par\nobreak\vskip \afterPoemTitleskip}}
15330 \@PTchs@def@ult
15331
15332 % \end{macrocode}
15333 % \end{macro}
15334 % \end{macro}
15335 % \end{macro}
15336 % \end{macro}
15337 % \end{macro}
15338 % \end{macro}
15339 % \end{macro}
15340 %
15341 %
15342 % \begin{macro}{\PoemTitlenumfont}
15343 % \begin{macro}{\PoemTitlefont}
15344 % Fonts for setting the Poem Title number and title.
15345 % \begin{macrocode}
15346 \newcommand*{\PoemTitlenumfont}{\normalfont\large\centering}
15347 \newcommand*{\PoemTitlefont}{\normalfont\large\centering}
15348 % \end{macrocode}
15349 % \end{macro}
15350 % \end{macro}
15351 %
15352 % \begin{macro}{\beforePoemTitleskip}
15353 % \begin{macro}{\midPoemTitleskip}
15354 % \begin{macro}{\afterPoemTitleskip}
15355 % Lengths separating the various parts of a Poem Title heading.
15356 % \begin{macrocode}
15357 \newlength{\beforePoemTitleskip}
15358 \setlength{\beforePoemTitleskip}{1\onelineskip}
15359 \newlength{\midPoemTitleskip}
15360 \setlength{\midPoemTitleskip}{0pt}
15361 \newlength{\afterPoemTitleskip}
15362 \setlength{\afterPoemTitleskip}{1\onelineskip}
15363
15364 % \end{macrocode}
15365 % \end{macro}
15366 % \end{macro}
15367 % \end{macro}
15368 %
15369 %
15370 % \begin{macro}{\@m@msPoemTitle}
15371 % This deals with the optional argument for starred PoemTitles.
15372 % \begin{macrocode}
15373 \newcommand{\@m@msPoemTitle}[2][\@empty]{%
15374 \@sPoemTitle{#2}%
15375 \ifx \@empty#1
15376 \def\poemf@rhdr{#2}%
15377 \else % opt arg
15378 \def\poemf@rhdr{#1}%
15379 \fi
15380 \poemtitlestarmark{\poemf@rhdr}%
15381 \poemtitlestarpstyle
15382 \memPoemTitlestarinfo{\poemf@rhdr}{#2}}
15383
15384 % \end{macrocode}
15385 % \end{macro}
15386 %
15387 % \begin{macro}{\@sPoemTitle}
15388 % \cs{@sPoemTitle}\marg{long} typesets the title of a
15389 % \cs{PoemTitle*}. It is easier than the \cs{@PoemTitle} as there is no number
15390 % or ToC entry to worry about.
15391 % \begin{macrocode}
15392 \newcommand{\@sPoemTitle}[1]{%
15393 \@makesPoemTitlehead{#1}%
15394 \@afterheading
15395 \M@gettitle{#1}}
15396
15397 % \end{macrocode}
15398 % \end{macro}
15399 %
15400 % \begin{macro}{\@makesPoemTitlehead}
15401 % This \emph{really} typesets a \cs{PoemTitle*}, and is similar to
15402 % \cs{@makePoemTitlehead}.
15403 % \begin{macrocode}
15404 \def\@makesPoemTitlehead#1{{%
15405 \PoemTitleheadstart
15406 \parindent \z@ \normalfont
15407 \printPoemTitlenonum
15408 \interlinepenalty\@M
15409 \printPoemTitletitle{#1}
15410 \afterPoemTitle}}
15411
15412 % \end{macrocode}
15413 % \end{macro}
15414 %
15415 %
15416 %
15417 %
15418 % \section{Setting parameters for existing environments}
15419 %
15420 % \subsection{Array and tabular}
15421 %
15422 % \begin{macro}{\arraycolsep}
15423 % The columns in an array environment are separated by
15424 % 2\cs{arraycolsep}.
15425 % \begin{macrocode}
15426 \setlength\arraycolsep{5\p@}
15427 % \end{macrocode}
15428 % \end{macro}
15429 %
15430 % \begin{macro}{\tabcolsep}
15431 % The columns in an tabular environment are separated by
15432 % 2\cs{tabcolsep}.
15433 % \begin{macrocode}
15434 \setlength\tabcolsep{6\p@}
15435 % \end{macrocode}
15436 % \end{macro}
15437 %
15438 % \begin{macro}{\arrayrulewidth}
15439 % The width of rules in the array and tabular environments is given
15440 % by\\ \cs{arrayrulewidth}.
15441 % \begin{macrocode}
15442 \setlength\arrayrulewidth{.4\p@}
15443 % \end{macrocode}
15444 % \end{macro}
15445 %
15446 % \begin{macro}{\doublerulesep}
15447 % The space between adjacent rules in the array and tabular
15448 % environments is given by \cs{doublerulesep}.
15449 % \begin{macrocode}
15450 \setlength\doublerulesep{2\p@}
15451 % \end{macrocode}
15452 % \end{macro}
15453 %
15454 % \subsection{Tabbing}
15455 %
15456 % \begin{macro}{\tabbingsep}
15457 % This controls the space that the \verb?\'? command puts in. (See
15458 % \LaTeX{} manual for an explanation.)
15459 % \begin{macrocode}
15460 \setlength\tabbingsep{\labelsep}
15461
15462 % \end{macrocode}
15463 % \end{macro}
15464 %
15465 % \subsection{Minipage}
15466 %
15467 % \begin{macro}{\@minipagerestore}
15468 % The macro \cs{@minipagerestore} is called upon entry to a minipage
15469 % environment to set up things that are to be handled differently
15470 % inside a minipage environment. In the standard styles it does
15471 % nothing, as was the case originally for memoir.
15472 %
15473 % Memoir extends it to support verbatim footnotes (see later) in minipages
15474 % and also for abnormal parskips (see later).
15475 % \changes{v1.61803}{2008/01/30}{Collected \cs{@minipagerestore} modifications together}
15476 % \begin{macrocode}
15477 \newcommand{\@minipagerestore}{%
15478 % \end{macrocode}
15479 % For \cs{verbfootnote} to work in a minipage we have to use
15480 % \cs{@verbmpfootnotetext} instead of \cs{@verbfootnotetext}.
15481 % \begin{macrocode}
15482 \let\@verbfootnotetext\@verbmpfootnotetext
15483 % \end{macrocode}
15484 % The next is for enabling the extended footnotes in a minipage.
15485 % \begin{macrocode}
15486 \m@mdoextrafeetmini
15487 % \end{macrocode}
15488 % And this is for abnormal parskips.
15489 % \begin{macrocode}
15490 \ifm@mnzpskip \parskip=\m@mabparskip\fi}
15491
15492 % \end{macrocode}
15493 % \end{macro}
15494 %
15495 % \begin{macro}{\@mpfootins}
15496 % Minipages have their own footnotes; \verb?\skip\@mpfootins? plays
15497 % the same r\^ole for footnotes in a minipage as \verb?\skip\footins? does
15498 % for ordinary footnotes.
15499 %
15500 % \begin{macrocode}
15501 \skip\@mpfootins = \skip\footins
15502
15503 % \end{macrocode}
15504 % \end{macro}
15505 %
15506 % \subsection{Framed boxes}
15507 %
15508 % \begin{macro}{\fboxsep}
15509 % The space left by \cs{fbox} and \cs{framebox} between the box and the
15510 % text in it.
15511 % \begin{macro}{\fboxrule}
15512 % The width of the rules in the box made by \cs{fbox} and \cs{framebox}.
15513 % \begin{macrocode}
15514 \setlength\fboxsep{3\p@}
15515 \setlength\fboxrule{.4\p@}
15516
15517 % \end{macrocode}
15518 % \end{macro}
15519 % \end{macro}
15520 %
15521 % \subsection{Equation and eqnarray}
15522 %
15523 % \begin{macro}{\theequation}
15524 % The equation counter will be reset at beginning of a new chapter
15525 % and the equation number will be prefixed by the chapter number.
15526 %
15527 % This code must follow the \cs{chapter} definition, or more exactly
15528 % the definition of the chapter counter.
15529 % \begin{macrocode}
15530 \@addtoreset{equation}{chapter}
15531 \renewcommand{\theequation}{%
15532 \ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@equation}
15533 % \end{macrocode}
15534 % \end{macro}
15535 %
15536 % \begin{macro}{\jot}
15537 % \cs{jot} is the extra space added between lines of an eqnarray
15538 % environment. The default value is used.
15539 % \begin{macrocode}
15540 % \setlength\jot{3pt}
15541 % \end{macrocode}
15542 % \end{macro}
15543 %
15544 % \begin{macro}{\@eqnnum}
15545 % The macro \cs{@eqnnum} defines how equation numbers are to appear in
15546 % equations. Again the default is used.
15547 %
15548 % \begin{macrocode}
15549 % \def\@eqnnum{(\theequation)}
15550
15551 % \end{macrocode}
15552 % \end{macro}
15553 %
15554 %
15555 % \section{Array and tabularx}
15556 %
15557 % \subsection{Array}%
15558 %
15559 % Here ealier versions of the class had an embedded copy of the
15560 % \Lpack{array} package. Now replaced by requiring the packge instead.
15561 % \begin{macrocode}
15562 \RequirePackage{array}[2018/04/30]
15563 % \end{macrocode}
15564 %
15565 % \subsubsection{Class additions to Array}
15566 %
15567 % \begin{macro}{\m@mold@addamp}
15568 % \begin{macro}{\m@m@addamp}
15569 % \begin{macro}{\@addamp}
15570 %
15571 % In the preamble a \verb?&? has to be inserted between any two columns;
15572 % before the first column there should not be a \verb?&?. As the user
15573 % preamble may start with a \verb?|? we have to remember somehow
15574 % if we have already inserted a \verb?#? (i.e.\ a column). This is done
15575 % with the boolean variable \cs{if@firstamp} that we test in
15576 % \cs{@addamp}, the macro that inserts the \verb?&?.
15577 %
15578 % \begin{PW}
15579 % PW: Later on, for horizontal lines in `continuous' tabulars,
15580 % I need to know how many columns there are in a tabular. I need a modified
15581 % kernel's \cs{@addamp} to do this and use the kernel's \cs{@curtab}
15582 % (a counter used in tabbing) to store the number of columns.
15583 %
15584 % \cs{m@mold@addamp} stores the kernel's definition of \cs{@addamp}, and
15585 % \cs{m@m@addamp} is the revised definition.
15586 % \end{PW}
15587 %
15588 % \changes{v3.7r}{2022/06/20}{Fixed sporious spaces}
15589 % \begin{macrocode}
15590 \newif \@iffirstamp
15591 \let\m@mold@addamp\@addamp
15592 \newcommand*{\m@m@addamp}{%
15593 \if@firstamp
15594 \@firstampfalse
15595 \global\@curtab\@ne
15596 \else
15597 \@addtopreamble{&}%
15598 \global\advance\@curtab\@ne
15599 \fi}
15600 \let\@addamp\m@m@addamp
15601
15602 % \end{macrocode}
15603 % \end{macro}
15604 % \end{macro}
15605 % \end{macro}
15606 %
15607
15608
15609
15610 % \subsection{D column specifiers} \label{sec:dcolumns}
15611 %
15612 %
15613 % Here ealier versions of the class had an embedded copy of the
15614 % \Lpack{cdolumn} package. Now replaced by requiring the packge instead.
15615 % \begin{macrocode}
15616 \RequirePackage{dcolumn}[2014/10/28]
15617 % \end{macrocode}
15618 % The embeded copy is outcommented for now and will be removed in a
15619 % later version.
15620 %
15621 % \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
15622 % \Lpack{dcolumn} and replaced it with requiring the \Lpack{dcolumn} package
15623 % instead.}
15624 %
15625 %
15626 %
15627 % \subsection{Support for delimeters}
15628 %
15629 % Here ealier versions of the class had an embedded copy of the
15630 % \Lpack{dearray} package. Now replaced by requiring the packge instead.
15631 % \begin{macrocode}
15632 \RequirePackage{delarray}[2014/10/28]
15633 % \end{macrocode}
15634 % The embeded copy is outcommented for now and will be removed in a
15635 % later version.
15636 %
15637 %
15638 %
15639 % \subsection{The tabularx environment}
15640 %
15641 % Here ealier versions of the class had an embedded copy of the
15642 % \Lpack{tabularx} package. Now replaced by requiring the packge instead.
15643 % \begin{macrocode}
15644 \RequirePackage{tabularx}[2016/02/03]
15645 % \end{macrocode}
15646 %
15647 % \subsection{Fear's rules}
15648 %
15649 % Simon Fear disapproves of the default \LaTeX{} table rules and
15650 % wrote the \Lpack{booktabs} package~\cite{BOOKTABS} to provide
15651 % better horizontal rules. Like many typographers, he abhors vertical rules.
15652 %
15653 %
15654 % \begin{macro}{\bktabrule}
15655 % The rules in this section are based on \verb?\hrule \@height#1? but this
15656 % does not
15657 % work for continuous tabulars. Provide a version of this that
15658 % can be \cs{let} when necessary.
15659 % \begin{macrocode}
15660 \newcommand*{\bktabrule}[1]{%
15661 \hrule \@height#1}
15662
15663 % \end{macrocode}
15664 % \end{macro}
15665 %
15666 % As of Summer 2023 we instead load \Lpack{booktabs} directly and
15667 % remove it from emulation. The only change from the class code and
15668 % the current \Lpack{booktabs} code was using \cmd{\bktabrule} which
15669 % never seem to be changed at all.
15670 % \changes{v3.8}{2023/07/28}{Replaced booktabs embedding by loading
15671 % \Lpack{booktabs}}
15672 % \begin{macrocode}
15673 \RequirePackage{booktabs}[2020/01/12]
15674 % \end{macrocode}
15675 %
15676 %
15677 % \subsection{Continuous tabulars}
15678 %
15679 % The standard \texttt{tabular} environment is wrapped inside a box
15680 % (see \verb?\@tabular?),
15681 % which means that it cannot break across pages. Equivalent environments
15682 % are provided which are not boxed and so can continue across page
15683 % boundaries.
15684 %
15685 % \begin{macro}{\ctableftskip}
15686 % \begin{macro}{\ctabrightskip}
15687 % These skips are inserted at the left and right of continuous tabulars
15688 % so that their horizontal location can be specified.
15689 % \begin{macrocode}
15690 \newskip\ctableftskip \ctableftskip=\fill
15691 \newskip\ctabrightskip \ctabrightskip=\fill
15692
15693 % \end{macrocode}
15694 % \end{macro}
15695 % \end{macro}
15696 %
15697 %
15698 % \begin{macro}{\ctabular*}
15699 % \begin{macro}{\@ctabularstar}
15700 % This starts off the \texttt{ctabular*} continuous tabular environment.
15701 % The default location is centered. NOTE: This is not for release.
15702 % \begin{macrocode}
15703 \expandafter\def\csname ctabular*\endcsname{%
15704 \@ifnextchar[ {\@ctabularstar}{\@ctabularstar[c]}}
15705 \def\@ctabularstar[#1]#2{\global\@curtab\@ne
15706 \ctableftskip\fill
15707 \ctabrightskip\fill
15708 \if l#1% left
15709 \ctableftskip\z@
15710 \else
15711 \if r#1% right
15712 \ctabrightskip\z@
15713 \fi
15714 \fi
15715 \setlength\dimen@{#2}%
15716 \xdef\@halignto{to\the\dimen@}\NC@tabular}
15717 % \end{macrocode}
15718 % \end{macro}
15719 % \end{macro}
15720 %
15721 % \begin{macro}{\ctabular}
15722 % \verb?\ctabular? is similar to \verb?\ctabular*? except that the
15723 % width is known to be \verb?\hsize?.
15724 % \begin{macrocode}
15725 \newcommand*{\ctabular}[1][c]{\global\@curtab\@ne
15726 \ctableftskip\fill
15727 \ctabrightskip\fill
15728 \if l#1% left
15729 \ctableftskip\z@
15730 \else
15731 \if r#1% right
15732 \ctabrightskip\z@
15733 \fi
15734 \fi
15735 \gdef\@halignto{to\hsize}\NC@tabular}
15736
15737 % \end{macrocode}
15738 % \end{macro}
15739 %
15740 % \begin{macro}{\NC@tabular}
15741 % \verb?\NC@tabular?
15742 % \begin{macrocode}
15743 \newcommand*{\NC@tabular}{%
15744 \par
15745 \addvspace{\topsep}
15746 \col@sep\tabcolsep
15747 \let\d@llarbegin\begingroup
15748 \let\d@llarend\endgroup
15749 \@NCtabarray}
15750
15751 % \end{macrocode}
15752 % \end{macro}
15753 %
15754 % \begin{macro}{\@NCialign}
15755 % \begin{macrocode}
15756 \newcommand*{\@NCialign}{\everycr{}\tabskip\ctableftskip\halign}
15757
15758 % \end{macrocode}
15759 % \end{macro}
15760 %
15761 % \begin{macro}{\@NCtabarray}
15762 % Effectively a modified version of \verb?\@array?
15763 % \begin{macrocode}
15764 \newcommand*{\@NCtabarray}[1]{%
15765 \@tempdima \ht\strutbox
15766 \advance\@tempdima\extrarowheight
15767 \setbox \@arstrutbox \hbox{\vrule
15768 \@height \arraystretch \@tempdima
15769 \@depth \arraystretch \dp\strutbox
15770 \@width\z@}%
15771 \begingroup
15772 %% \@mkpream{@{\hspace{\@totalleftmargin}}#1@{}}%
15773 \@mkpream{#1}%
15774 \xdef\@preamble{\@NCialign \@halignto
15775 \bgroup & \tabskip\z@
15776 \@arstrut
15777 \@preamble
15778 \tabskip\ctabrightskip
15779 \cr}%
15780 \endgroup
15781 \let\@sharp ##\let\protect\relax
15782 \lineskip\z@
15783 \baselineskip\z@
15784 \let\\\@arraycr
15785 \let\tabularnewline\\%
15786 \let\par\@empty
15787 \ctabsetlines
15788 \@preamble
15789 }
15790
15791 % \end{macrocode}
15792 % \end{macro}
15793 %
15794 % \begin{macro}{\endctabular}
15795 % \begin{macro}{\endctabular*}
15796 % End the environments.
15797 % \begin{macrocode}
15798 \def\endctabular{%
15799 \crcr \egroup
15800 \gdef\@preamble{}%
15801 \addvspace{\topsep}
15802 \noindent}
15803 \expandafter\let\csname endctabular*\endcsname=\endctabular
15804
15805 % \end{macrocode}
15806 % \end{macro}
15807 % \end{macro}
15808 %
15809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15810 %
15811 %
15812 % \subsubsection{Horizontal lines}
15813 %
15814 % The standard \cs{hline} can produce odd results when used with
15815 % continuous tabulars, but \cs{hhline} or \cs{cline} are OK.
15816 % I want a version of \cs{hline}
15817 % that works with continuous tabulars and has an adjustable width
15818 % (i.e., thickness). This will be based on a modified \cs{cline}
15819 %
15820 % For reference, here are the essentials of the kernel's definitions.
15821 % \begin{verbatim}
15822 % \def\hline{%
15823 % \noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
15824 % \reserved@a\@xhline}
15825 % \def\@xhline{%
15826 % \ifx\reserved@a\hline
15827 % \vskip\doublerulesep
15828 % \vskip-\arrayrulewidth
15829 % \fi
15830 % \ifnum0=`{\fi}}
15831 % \def\cline#1{\@cline#1\@nil}
15832 % \def\@cline#1-#2\@nil{%
15833 % \omit
15834 % \@multicnt#1%
15835 % \advance\@multispan\m@ne
15836 % \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
15837 % \@multicnt#2%
15838 % \advance\@multicnt-#1%
15839 % \advance\@multispan\@ne
15840 % \leaders\hrule\@height\arrayrulewidth\hfill
15841 % \cr
15842 % \noalign{\vskip-\arrayrulewidth}}
15843 % \end{verbatim}
15844 %
15845 % \begin{macro}{\memcline}
15846 % \begin{macro}{\m@m@cline}
15847 % This is a version of the kernel \cs{cline} code that provides
15848 % a variable width.
15849 % \begin{macrocode}
15850 \newcommand*{\memcline}[2]{\m@m@cline[#1]#2\@nil}
15851 \def\m@m@cline[#1]#2-#3\@nil{%
15852 \omit
15853 \@multicnt#2%
15854 \advance\@multispan\m@ne
15855 \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
15856 \@multicnt#3%
15857 \advance\@multicnt-#2%
15858 \advance\@multispan\@ne
15859 \leaders\hrule\@height #1\hfill % <- variable \@height value
15860 \cr
15861 \noalign{\vskip- #1}} % <- variable \@height value
15862
15863 % \end{macrocode}
15864 % \end{macro}
15865 % \end{macro}
15866 %
15867 % \begin{macro}{\memhline}
15868 % \begin{macro}{\m@mhline}
15869 % A version of \cs{hline}, based on \cs{memcline}, taking a
15870 % rule width as argument. It draws a \cs{memcline} from the
15871 % first to the last (\cs{@curtab}) column.
15872 % \begin{macrocode}
15873 \newcommand*{\memhline}[1][\arrayrulewidth]{\memcline{#1}{1-\@curtab}}
15874 \newcommand*{\m@mhline}{\cline{1-\@curtab}}
15875 % \end{macrocode}
15876 %\end{macro}
15877 %\end{macro}
15878 %
15879 % Fear's rules also do not play well within continuous tabulars.
15880 %
15881 % \begin{macro}{\m@m@BTnormal}
15882 % Special version of \cs{@BTnormal}
15883 % \begin{macrocode}
15884 \def\m@m@BTnormal{%
15885 \ifnum0=`{\fi} % closes the \noalign
15886 \multispan{\@curtab} \leaders\bktabrule{\@thisrulewidth}\hfill\cr
15887 \noalign{\ifnum0=`}\fi
15888 \futurenonspacelet\@tempa\@BTendrule}
15889
15890 % \end{macrocode}
15891 % \end{macro}
15892 %
15893 %
15894 % \begin{macro}{\ctabsetlines}
15895 % Continuous tabulars cannot use the standard horizontal lines.
15896 % \begin{macrocode}
15897 \def\ctabsetlines{%
15898 \let\hline\m@mhline
15899 \let\@BTnormal\m@m@BTnormal}
15900
15901 % \end{macrocode}
15902 % \end{macro}
15903 %
15904 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15905 %
15906 %
15907 % \subsection{Automated tabulations}
15908 %
15909 %
15910 % It can be convenient, especially while drafting a document, to have
15911 % a list of items put into a tabular without having to mark the ends
15912 % of the rows.
15913 %
15914 % The following is based on plain \TeX{} code given on pages 307--308 of
15915 % \textit{TeX for the Impatient}~\cite{bk:Impatient}, which provides
15916 % code for typesetting in columns.
15917 %
15918 %
15919 % \begin{macro}{\abovecolumnspenalty}
15920 % \begin{macro}{\@linestogo}
15921 % \begin{macro}{\@cellstogo}
15922 % \begin{macro}{\@cellsincolumn}
15923 % \begin{macro}{\crtok}
15924 % Counters and such.
15925 % \begin{macrocode}
15926 \newcount\abovecolumnspenalty
15927 \abovecolumnspenalty=10000
15928 \newcount\@linestogo % lines remaining to be procesed
15929 \newcount\@cellstogo % cells remaining in column or row
15930 \newcount\@cellsincolumn % number of lines per column
15931 \newtoks\crtok
15932 \crtok = {\cr}%
15933
15934 % \end{macrocode}
15935 % \end{macro}
15936 % \end{macro}
15937 % \end{macro}
15938 % \end{macro}
15939 % \end{macro}
15940 %
15941 % \begin{macro}{\@mincolumnwidth}
15942 % \begin{macro}{\c@lleftskip}
15943 % \begin{macro}{\c@lrightskip}
15944 % More things
15945 % \begin{macrocode}
15946 \newdimen\@mincolumnwidth
15947 \let\c@lleftskip\hfil % left skip within a column
15948 \let\c@lrightskip\hfil % right skip within a column
15949
15950 % \end{macrocode}
15951 % \end{macro}
15952 % \end{macro}
15953 % \end{macro}
15954 %
15955 % \begin{macro}{\preautotab}
15956 % \begin{macro}{\postautotab}
15957 % Hooks into the auto tabulations.
15958 % \begin{macrocode}
15959 \let\preautotab\relax
15960 \let\postautotab\relax
15961
15962 % \end{macrocode}
15963 % \end{macro}
15964 % \end{macro}
15965 %
15966 % \begin{macro}{\autocols}
15967 % \cs{autocols}\oarg{width}\marg{pos}\marg{num}\marg{style}\marg{comma separated list}
15968 % arranges the elements in the \meta{comma separated list} into \meta{num}
15969 % columns, the elements filling each column before moving to the next.
15970 % That is, the elements are ordered top to bottom and left to right.
15971 % \begin{macrocode}
15972 \newcommand{\autocols}[5][0pt]{\par\begingroup
15973 \ctabsetlines
15974 % \end{macrocode}
15975 % Set the table position
15976 % \begin{macrocode}
15977 \if l#2
15978 \raggedright
15979 \else
15980 \if r#2
15981 \raggedleft
15982 \else
15983 \centering
15984 \fi
15985 \fi
15986 % \end{macrocode}
15987 % Set the column position style
15988 % \begin{macrocode}
15989 \let\c@lleftskip\hfil
15990 \let\c@lrightskip\hfil
15991 \if l#4
15992 \let\c@lleftskip\relax
15993 \else
15994 \if r#4
15995 \let\c@lrightskip\relax
15996 \fi
15997 \fi
15998 % \end{macrocode}
15999 % Count the number of entries and the minimum width (max entry width)
16000 % for the columns.
16001 % \begin{macrocode}
16002 \@mincolumnwidth\z@
16003 \TX@cols=#3
16004 \@curtab=#3
16005 \@linestogo\z@
16006 \@for\@tempa:=#5\do{
16007 \advance\@linestogo\@ne
16008 \settowidth{\@tempdima}{\@tempa}
16009 \ifdim\@tempdima>\@mincolumnwidth
16010 \@mincolumnwidth=\@tempdima
16011 \fi
16012 }
16013 \advance\@mincolumnwidth\tabcolsep
16014 \linespercol
16015 % \end{macrocode}
16016 % Specify what is to be done after every entry
16017 % \begin{macrocode}
16018 \def\@endcolumnactions{%
16019 \global\advance\@linestogo\m@ne
16020 \ifnum\@cellstogo<\tw@
16021 \global\advance\TX@cols\m@ne
16022 \ifnum\TX@cols>\z@\linespercol\fi
16023 \the\crtok
16024 \else
16025 &\global\advance\@cellstogo\m@ne
16026 \fi}%
16027 % \end{macrocode}
16028 % Calculate the width of the columns
16029 % \begin{macrocode}
16030 \ifdim #1 > \z@
16031 \TX@col@width=#1
16032 \divide\TX@col@width \TX@cols
16033 \else
16034 \TX@col@width=\@mincolumnwidth
16035 \fi
16036 \penalty\abovecolumnspenalty
16037 \noindent% usually not a paragraph
16038 % \end{macrocode}
16039 % Create most of the preamble by looping to add \cs{@cellsincolumn}-1 slots,
16040 % then the last one which is different.
16041 % \begin{macrocode}
16042 \def\@preamble{}%
16043 \begingroup
16044 \let\@sharp\relax
16045 \ifnum\@cellsincolumn>\@ne
16046 \loop
16047 \g@addto@macro{\@preamble}{%
16048 \hb@xt@ \TX@col@width{%
16049 \c@lleftskip\strut\@sharp\c@lrightskip} &}%
16050 \advance\@cellsincolumn\m@ne
16051 \ifnum\@cellsincolumn>\@ne
16052 \repeat
16053 \fi
16054 \g@addto@macro{\@preamble}{%
16055 \hb@xt@ \TX@col@width{\c@lleftskip\strut\@sharp\c@lrightskip}}%
16056 \endgroup
16057 \let\@sharp ##
16058 % \end{macrocode}
16059 % Start the \cs{valign}
16060 % \begin{macrocode}
16061 \tabskip\ctableftskip
16062 %% \tabskip\z@
16063 \valign \bgroup
16064 \tabskip\z@
16065 \@preamble
16066 \tabskip\ctabrightskip\cr
16067 % \end{macrocode}
16068 % Add all the entries then finish off.
16069 % \begin{macrocode}
16070 \@for\@tempa:=#5\do{
16071 \@tempa\unskip\space\@endcolumnactions}%
16072 \the\crtok \egroup \par \endgroup}
16073
16074 % \end{macrocode}
16075 % \end{macro}
16076 %
16077 %
16078 % \begin{macro}{\linespercol}
16079 % \cs{linespercol} calculates the maximum number of lines that go into
16080 % a column, where there are \cs{TX@cols} columns and \cs{@linestogo}
16081 % lines, so that the columns are balanced as well as possible. The result
16082 % is \cs{@cellstogo}
16083 % \begin{macrocode}
16084 \newcommand*{\linespercol}{%
16085 \@cellsincolumn=\@linestogo
16086 \divide\@cellsincolumn \TX@cols
16087 \@cellstogo=\@cellsincolumn
16088 \multiply\@cellstogo \TX@cols
16089 \@tempcnta=\@linestogo
16090 \advance\@tempcnta -\@cellstogo
16091 \ifnum \@tempcnta>\z@
16092 \advance\@cellsincolumn \@ne
16093 \fi
16094 \global\@cellstogo=\@cellsincolumn}
16095
16096 % \end{macrocode}
16097 % \end{macro}
16098 %
16099 %
16100 % \begin{macro}{\autorows}
16101 % \cs{autorows}\oarg{width}\marg{pos}\marg{num}\marg{style}\marg{comma separated list}
16102 % arranges the elements in the \meta{comma separated list} into \meta{num}
16103 % columns, the elements filling each row before moving to the next.
16104 % That is, the elements are ordered left to right and top to bottom.
16105 % By default, each column is the same width, enough for the widest entry.
16106 % If \meta{width} is a negative length (e.g., -1pt) the columns are set
16107 % to their natural
16108 % widths. If \meta{width} is positive (e.g., \cs{textwidth}), column widths
16109 % are equal widths so that the overal width is \meta{width}.
16110 % The sideways location of thre tabular is \meta{pos} (l, c, or r), and
16111 % the column style id \meta{style} (l, c, or r).
16112 % \begin{macrocode}
16113 \newcommand{\autorows}[5][0pt]{\par\begingroup
16114 \ctabsetlines
16115 % \end{macrocode}
16116 % Set the table position
16117 % \begin{macrocode}
16118 \ctableftskip\fill
16119 \ctabrightskip\fill
16120 \if l#2
16121 \ctableftskip\z@
16122 \else
16123 \if r#2
16124 \ctabrightskip\z@
16125 \fi
16126 \fi
16127 % \end{macrocode}
16128 % Set the column position style
16129 % \begin{macrocode}
16130 \let\c@lleftskip\hfil
16131 \let\c@lrightskip\hfil
16132 \if l#4
16133 \let\c@lleftskip\relax
16134 \else
16135 \if r#4
16136 \let\c@lrightskip\relax
16137 \fi
16138 \fi
16139 % \end{macrocode}
16140 % Count the number of entries and the minimum width (max entry width)
16141 % for the columns.
16142 % \begin{macrocode}
16143 \TX@cols=#3\relax
16144 \@curtab=#3\relax
16145 \@cellstogo = \TX@cols
16146 \@mincolumnwidth\z@
16147 \@linestogo\z@
16148 \@for\@tempa:=#5\do{%
16149 \advance\@linestogo\@ne
16150 \settowidth{\@tempdima}{\@tempa}
16151 \ifdim\@tempdima>\@mincolumnwidth
16152 \@mincolumnwidth=\@tempdima
16153 \fi}%
16154 \advance\@mincolumnwidth\tabcolsep
16155 % \end{macrocode}
16156 % Specify what is to be done after every entry
16157 % \begin{macrocode}
16158 \def\@endcolumnactions{%
16159 \global\advance\@linestogo\m@ne
16160 \global\advance\@cellstogo\m@ne
16161 \ifnum\@cellstogo<\@ne
16162 \global\@cellstogo=\TX@cols
16163 \the\crtok
16164 \else
16165 &
16166 \fi}%
16167 % \end{macrocode}
16168 % Calculate the width of the columns
16169 % \begin{macrocode}
16170 \ifdim #1>\z@
16171 \TX@col@width=#1
16172 \else
16173 \TX@col@width=\hsize
16174 \fi
16175 \divide\TX@col@width \TX@cols
16176 \ifdim #1=\z@
16177 \TX@col@width=\@mincolumnwidth
16178 \fi
16179 \penalty\abovecolumnspenalty
16180 \noindent % usually not a paragraph
16181 \vskip -\z@ % don't know why we need this, but looks bad without it
16182 % \end{macrocode}
16183 % Create most of the preamble by looping to add \cs{@cellsincolumn}-1 slots,
16184 % then the last one which is different.
16185 % \begin{macrocode}
16186 \def\@preamble{}%
16187 \begingroup
16188 \let\@sharp\relax
16189 \ifnum\TX@cols>\@ne
16190 \loop
16191 \ifdim #1<\z@
16192 \g@addto@macro{\@preamble}{%
16193 \strut\c@lleftskip\@sharp\c@lrightskip &}%
16194 \else
16195 \g@addto@macro{\@preamble}{%
16196 \hb@xt@ \TX@col@width{%
16197 \strut\c@lleftskip\@sharp\c@lrightskip} &}%
16198 \fi
16199 \advance\TX@cols\m@ne
16200 \ifnum\TX@cols>\@ne
16201 \repeat
16202 \fi
16203 \ifdim #1<\z@
16204 \g@addto@macro{\@preamble}{%
16205 \strut\c@lleftskip\@sharp\c@lrightskip}%
16206 \else
16207 \g@addto@macro{\@preamble}{%
16208 \hb@xt@ \TX@col@width{\strut\c@lleftskip\@sharp\c@lrightskip}}%
16209 \fi
16210 \endgroup
16211 \let\@sharp ##
16212 % \end{macrocode}
16213 % Start the \verb?\halign?
16214 % \begin{macrocode}
16215 \tabskip\ctableftskip
16216 \halign to \hsize \bgroup
16217 \tabskip\z@
16218 \@preamble
16219 %% \tabskip\ctabrightskip\cr \preautotab
16220 \tabskip\ctabrightskip\cr
16221 % \end{macrocode}
16222 % Add all the entries then finish off.
16223 % \begin{macrocode}
16224 \@for\@tempa:=#5\do{%
16225 \@tempa\unskip\space\@endcolumnactions}%
16226 %% \the\crtok \postautotab \the\crtok \egroup \endgroup \par
16227 \the\crtok \egroup \endgroup \par}
16228
16229 % \end{macrocode}
16230 % \end{macro}
16231 %
16232 %
16233 %
16234 %
16235 % \section{Floating objects}
16236 %
16237 % The file \file{latex.dtx} only defines a number of tools with
16238 % which floating objects can be defined. This is done in the
16239 % document class. It needs to define the following macros for each
16240 % floating object of type \texttt{TYPE} (e.g., \texttt{TYPE} =
16241 % figure).
16242 %
16243 % \begin{description}
16244 % \item[\texttt{\bslash fps@TYPE}]
16245 % The default placement specifier for floats of type
16246 % \texttt{TYPE}.
16247 %
16248 % \item[\texttt{\bslash ftype@TYPE}]
16249 % The type number for floats of type \texttt{TYPE}. Each
16250 % \texttt{TYPE} has associated a unique positive \texttt
16251 % {TYPE} number, which is a power of two. E.g., figures might
16252 % have type number 1, tables type number 2, programs type
16253 % number 4, etc.
16254 %
16255 % \item[\texttt{\bslash ext@TYPE}]
16256 % The file extension indicating the file on which the contents
16257 % list for float type \texttt{TYPE} is stored. For example,
16258 % \cs{ext@figure} = `lof'.
16259 %
16260 % \item[\texttt{\bslash fnum@TYPE}]
16261 % A macro to generate the figure number for a caption. For
16262 % example, \cs{fnum@TYPE} == `Figure \cs{thefigure}'.
16263 %
16264 % \item[\texttt{\bslash @makecaption}{\meta{num}}{\meta{text}}]
16265 % A macro to make a caption, with \meta{num} the value produced
16266 % by \cs{fnum@...} and \meta{text} the text of the caption. It
16267 % can assume it's in a \cs{parbox} of the appropriate width.
16268 % This will be used for \emph{all} floating objects.
16269 %
16270 % \end{description}
16271 %
16272 % The actual environment that implements a floating object such as
16273 % a figure is defined using the macros \cs{@float} and \cs{end@float},
16274 % which are defined in \file{latex.dtx}.
16275 %
16276 % An environment that implements a single column floating object is
16277 % started with \verb?\@float{TYPE}?\oarg{placement} of type
16278 % \texttt{TYPE} with \meta{placement} as the placement specifier.
16279 % The default value of \meta{PLACEMENT} is defined by \cs{fps@TYPE}.
16280 %
16281 % The environment is ended by \cs{end@float}. E.g., \cs{figure} ==
16282 % \verb?\@float{figure}?, \cs{endfigure} == \cs{end@float}.
16283 %
16284 %
16285 % \subsection{Floats}
16286 %
16287 % To define a float environment, say \Lenv{fenv}, the following macros must be defined:
16288 % \begin{itemize}
16289 % \item \cs{fps@fenv} The default placement specifier (normally \verb?tbp?).
16290 % \item \cs{ftype@fenv} The type number which is an integer and a power of 2.
16291 % \item \cs{ext@fenv} The file extension for the contents list.
16292 % \item \cs{c@fenv} A counter for the environment (for caption numbering).
16293 % \item \cs{fnum@fenv} A macro to generate the caption `number'.
16294 % \item \cs{l@fenv} A macro to produce an entry in a list of\ldots.
16295 % \item \cs{flegtocfenv} A macro to write a \cs{namedlegend} title to a listof file.
16296 % \item \cs{flegfenv} A macro to typeset the name of a \cs{namedlegend}.
16297 % \item \cs{toclevel@fenv} Holding a bookmark level (required if the
16298 % \Lpack{hyperref} package will be used).
16299 % \end{itemize}
16300 %
16301 % \begin{macro}{newflo@tctr}
16302 % A counter for the type number of a new float. Normally
16303 % figures are of type 1, tables type 2, and the next float type is then 4, and so
16304 % on.
16305 % \begin{macrocode}
16306 \newcounter{newflo@tctr}
16307 \setcounter{newflo@tctr}{1}
16308
16309 % \end{macrocode}
16310 % \end{macro}
16311 %
16312 % \begin{macro}{\newfloat}
16313 % \cs{newfloat}oarg{within}\marg{fenv}\marg{ext}\marg{capname}
16314 % creates the commands for a new float environment, \meta{fenv} (aka \texttt{X}),
16315 % using \meta{ext} (aka \texttt{Z}) as the
16316 % file extension and \meta{capname} for the caption name.
16317 % \changes{v1.61803}{2008/01/30}{Changed setting of \cs{ftype@X} in
16318 % \cs{newfloat} to correctly assign float numbers, courtesy Flavian
16319 % Lambert (mempatch v4.9)}
16320 % \begin{macrocode}
16321 \newcommand{\newfloat}[4][\@empty]{%
16322 % \end{macrocode}
16323 % \begin{macro}{\ftype@X}
16324 % Define the float type, set it to the float counter, and increase
16325 % the counter afterwards.
16326 % \begin{macrocode}
16327 %%% \@namedef{ftype@#2}{\value{newflo@tctr}}
16328 %%% \addtocounter{newflo@tctr}{\value{newflo@tctr}}
16329 \expandafter\edef\csname ftype@#2\endcsname{\the\c@newflo@tctr}%
16330 \advance\c@newflo@tctr \c@newflo@tctr
16331 % \end{macrocode}
16332 % \end{macro}
16333 %
16334 % \begin{macro}{\c@X}
16335 % Create the counter for the caption, which must not have been previously
16336 % defined.
16337 % \begin{macrocode}
16338 \@ifundefined{c@#2}{% counter is not defined
16339 \ifx \@empty#1\relax
16340 \newcounter{#2}
16341 \else
16342 \newcounter{#2}[#1]
16343 \expandafter\edef\csname the#2\endcsname{%
16344 \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
16345 \fi}{}
16346 \setcounter{#2}{0}
16347
16348 % \end{macrocode}
16349 % \end{macro}
16350 %
16351 % \begin{macro}{\ext@X}
16352 % \begin{macro}{\c@Zdepth}
16353 % Define \cs{ext@X} for the file extension and set the new \verb?Zdepth?
16354 % depth counter to 1.
16355 % \begin{macrocode}
16356 \@namedef{ext@#2}{#3}% file extension
16357 \@ifundefined{c@#3depth}{\newcounter{#3depth}}{}
16358 \setcounter{#3depth}{1}
16359
16360 % \end{macrocode}
16361 % \end{macro}
16362 % \end{macro}
16363 %
16364 %
16365 % \begin{macro}{\fps@X}
16366 % \begin{macro}{\fnum@X}
16367 % \begin{macro}{\flegX}
16368 % \begin{macro}{\flegtocX}
16369 % \cs{fps@X} is the default float placement specification, \cs{fnum@X}
16370 % typesets the caption name and number, and \cs{flegX} and \cs{flegtocX} are for
16371 % named legends.
16372 % \begin{macrocode}
16373 \@namedef{fps@#2}{tbp} % position
16374 \@namedef{fnum@#2}{#4~\@nameuse{the#2}} % caption naming
16375 \@namedef{fleg#2}{#4} % legend naming
16376 \@namedef{flegtoc#2}##1{} % legend name in ToC
16377
16378 % \end{macrocode}
16379 % \end{macro}
16380 % \end{macro}
16381 % \end{macro}
16382 % \end{macro}
16383 %
16384 % \begin{environment}{X}
16385 % \begin{environment}{X*}
16386 % Finally define the new float environment, in both normal and starred
16387 % forms. We also al an internal macro that can be used to globally
16388 % adjust floats, e.g. making all tables in small size.
16389 % We would like to be able to insert adjustments inside the
16390 % floats. But the manner in which \cs{@float} works makes it
16391 % impossible for us to simple insert this into the definitions of the
16392 % floats.
16393 % \begin{macrocode}
16394 \newenvironment{#2}{\@float{#2}}{\end@float}
16395 \newenvironment{#2*}{\@dblfloat{#2}}{\end@dblfloat}
16396 % \end{macrocode}
16397 % \end{environment}
16398 % \end{environment}
16399 %
16400 % This ends the definition of \cs{newfloat}.
16401 % \begin{macrocode}
16402 } % end \newfloat
16403
16404 % \end{macrocode}
16405 % \end{macro}
16406 %
16407 % \begin{macro}{\@xfloat}
16408 % Was adjusted earlier.
16409 % \end{macro}
16410 %
16411 % \begin{macro}{\setfloatlocations}
16412 % \cs{setfloatlocations}\marg{float}\marg{locs} sets the defualt locations
16413 % for the \meta{float} class of floats (e.g., \texttt{figure}) to \meta{locs}
16414 % (initially \texttt{tbp}). For tables you might want to use: \\
16415 % \verb?\setfloatlocations{table}{htbp}?
16416 % \changes{v1.61803}{2008/01/30}{Added \cs{setfloatlocations} (mempatch v4.9)}
16417 % \begin{macrocode}
16418 \newcommand*{\setfloatlocations}[2]{\@namedef{fps@#1}{#2}}
16419
16420 % \end{macrocode}
16421 % \end{macro}
16422 % \changes{v3.6h}{2011/02/01}{Added \cs{setfloatadjustment}}
16423 % \begin{macro}{\setfloatadjustment}
16424 % \cs{setfloatadjustment}\marg{float}\marg{code} can be used to
16425 % globally add internal adjustments to all floats of a certain
16426 % type. For example to typeset the contents of all tables in
16427 % \cs{small} use \verb|\setfloatadjustment{table}{\small}|.
16428 % \begin{macrocode}
16429 \newcommand*\setfloatadjustment[2]{\@namedef{#1adjustment}{#2}}
16430
16431 % \end{macrocode}
16432 %
16433 % \end{macro}
16434 %
16435 %
16436 % To define subcaptions for use in a new float environment, say \texttt{fenv}, the
16437 % following macros must be defined:
16438 % \begin{itemize}
16439 % \item A new counter \texttt{subfenv} for subcaption numbering.
16440 % \item A new counter \texttt{extdepth}, where \texttt{ext} is the file extension
16441 % for the contents list of \texttt{fenv}, for setting the contents depth.
16442 % \item \cs{thesubfenv} for the formatting of the subcaption number.
16443 % \item \cs{@thesubfenv} for typesetting the number.
16444 % \item \cs{@@thesubfenv} for alternative label reference.
16445 % \item \cs{p@subfenv} for prepending to the subcaption number when it is referenced.
16446 % \item \cs{ext@subfenv} the file extension for the contents list.
16447 % \item \cs{l@subfenv} for formatting the contents list entry.
16448 % \item \cs{@makesubfloatcaption} for typesetting the subcaption.
16449 % \item \cs{toclevel@subfenv} for hyperref bookmarks
16450 % \end{itemize}
16451 %
16452 % \begin{macro}{\newsubfloat}
16453 % \cs{newsubfloat}\marg{fenv} creates the commands for a new
16454 % subfloat for \meta{fenv} (aka \texttt{X}).
16455 % \begin{macrocode}
16456 \newcommand{\newsubfloat}[1]{%
16457 % \end{macrocode}
16458 % Call \verb?\newlistentry[X]{subX}{extX}{1}? to get most of the work done.
16459 % \begin{macrocode}
16460 \newlistentry[#1]{sub#1}{\@nameuse{ext@#1}}{1}
16461 % \end{macrocode}
16462 %
16463 % \begin{macro}{\ext@subX}
16464 % \begin{macro}{\thesubX}
16465 % \begin{macro}{\@thesubX}
16466 % \begin{macro}{\@@thesubX}
16467 % \begin{macro}{\p@subX}
16468 % \begin{macro}{\toclevel@subX}
16469 % And now for the rest of the commands for subcaptions.
16470 % \changes{v1.1}{2002/03/10}{Added \cs{@namedef} of \cs{@@thesubenv}
16471 % to \cs{newsubfloat}}
16472 % \changes{v1.1}{2002/03/10}{Added \cs{@namedef} of \cs{toclevel@subenv}
16473 % to \cs{newsubfloat}}
16474 % \begin{macrocode}
16475 \@namedef{ext@sub#1}{\csname ext@#1\endcsname}
16476 \@namedef{thesub#1}{(\alph{sub#1})}
16477 \@namedef{@thesub#1}{\@nameuse{thesub#1}%
16478 \if@tightsubcap\hskip\subfloatlabelskip\else\space\fi}
16479 \@namedef{@@thesub#1}{\@nameuse{thesub#1}}
16480 \@namedef{p@sub#1}{\csname the#1\endcsname}
16481 \@namedef{toclevel@sub#1}{1}}
16482
16483 % \end{macrocode}
16484 % \end{macro}
16485 % \end{macro}
16486 % \end{macro}
16487 % \end{macro}
16488 % \end{macro}
16489 % \end{macro}
16490 % \end{macro}
16491 %
16492 % By permission of Steven Douglas Cochran the class provides similar
16493 % functionality as the \Lpack{subfigure} package~\cite{SUBFIGURE}.
16494 % This requires some changes to be made to \cs{@float} and \cs{end@float}.
16495 %
16496 % \begin{macro}{\ifdonemaincaption}
16497 % This is set TRUE after the \cs{(cont)caption} has been called in a float.
16498 % \changes{v1.1}{2002/03/10}{Changed \cs{if@contmaincaption} to
16499 % \cs{ifdonemaincaption}}
16500 % \begin{macrocode}
16501 \newif\ifdonemaincaption
16502 \donemaincaptionfalse
16503
16504 % \end{macrocode}
16505 % \end{macro}
16506 %
16507 % \begin{macro}{\@float}
16508 % \begin{macro}{\@dbfloat}
16509 % \begin{macro}{\@memresetsubcounter}
16510 % The kernel \cs{@float} and \cs{@dblfloat} macros are redefined to
16511 % set \cs{ifdonemaincaption} to FALSE, and also to zero the subfloat
16512 % counter, if it is defined. Ignasi Furi\`{o}
16513 % reported (Private email 2003/10/17) that floats embedded in text created an extra
16514 % space. This was caused by a missing \verb?%?.
16515 % \changes{v1.4}{2003/11/22}{Deleted spaces from \cs{@float} and
16516 % \cs{@dblfloat} (from patch v1.9)}
16517 % Axel Sommerfeldt (Private email, 2013/05/10) asked for the subcounter reset to be factored out into
16518 % a macro and provided the code.
16519 % \begin{macrocode}
16520 \let\@memoldfloat\@float
16521 \renewcommand{\@float}[1]{\donemaincaptionfalse
16522 \@memresetsubcounter{#1}%
16523 \@memoldfloat{#1}}
16524 \let\@memolddblfloat\@dblfloat
16525 \renewcommand{\@dblfloat}[1]{\donemaincaptionfalse
16526 \@memresetsubcounter{#1}%
16527 \@memolddblfloat{#1}}
16528 \newcommand{\@memresetsubcounter}[1]{%
16529 \@ifundefined{c@sub#1}{}{\csname c@sub#1\endcsname = 0\relax}}
16530
16531 % \end{macrocode}
16532 % \end{macro}
16533 % \end{macro}
16534 % \end{macro}
16535 %
16536 % \begin{macro}{\end@float}
16537 % \begin{macro}{\end@dblfloat}
16538 % We add extra functionality to the end of floats via cmd hooks.
16539 % \changes{v3.8.4}{2025/09/23}{Changed let+redef to cmd hooks.}
16540 % \begin{macrocode}
16541 %\let\@memoldefloat\end@float
16542 %\def\end@float{%
16543 % \@memlistsubcaptions{\@captype}\@memoldefloat}
16544 % \let\@memoldedblfloat\end@dblfloat
16545 % \def\end@dblfloat{%
16546 % \@memlistsubcaptions{\@captype}\@memoldedblfloat}
16547 \AddToHook{cmd/end@float/before}{\@memlistsubcaptions{\@captype}}
16548 \AddToHook{cmd/end@dblfloat/before}{\@memlistsubcaptions{\@captype}}
16549
16550 % \end{macrocode}
16551 % \end{macro}
16552 % \end{macro}
16553 %
16554 % \changes{v3.8.4}{2025/09/23}{Ooold reference to problems with
16555 % fixltx2e removed, have been redundant since 2015.}
16556 %
16557 % \changes{v3.6h}{2011/02/01}{Added \cs{FloatBlock}}
16558 % \subsubsection{Float blockage}
16559 %
16560 % This is basically a slightly modified copy of \cs{FloatBarrier} from
16561 % the \Lpack{placeins} package by Donald Arseneau, renamed such that
16562 % both can be used in the same document. We could have emulated the
16563 % \Lpack{placeins} package, but people might use it with options, so,
16564 % since the code is so short we just copy it. Kudos to Donald Arseneau.
16565 % For more defaults see
16566 % \cite{PLACEINS}.
16567 % \begin{macro}{\FloatBlock}
16568 % \begin{macro}{\FloatBlockAllowAbove}
16569 % \begin{macro}{\FloatBlockAllowBelow}
16570 % The two \cs{XAllowY} macros is our way of supporting the
16571 % \Lpack{placeins} package options.
16572 % \begin{macrocode}
16573 \def\mem@fb@botlist{\@botlist}
16574 \def\mem@fb@topblock{\suppressfloats[t]}
16575 % \end{macrocode}
16576 % \changes{v3.7d}{2015/03/12}{\cs{\@dbldeferlist} may be removed in a
16577 % comming LaTeX kernel update}
16578 % \begin{macrocode}
16579 \def\FloatBlock{\par\begingroup \let\@elt\relax
16580 \edef\@tempa{\mem@fb@botlist\@deferlist\@dbldeferlist}%
16581 \ifx\@tempa\@empty
16582 \else
16583 \ifx\@fltovf\relax % my indicator of recursion
16584 \if@firstcolumn
16585 \clearpage
16586 \else
16587 \null\newpage\FloatBlock
16588 \fi
16589 \else
16590 \newpage \let\@fltovf\relax
16591 \FloatBlock % recurse once only
16592 \fi\fi \endgroup
16593 \mem@fb@topblock}
16594 \newcommand*\FloatBlockAllowAbove{\def\mem@fb@topblock{}}
16595 \newcommand*\FloatBlockAllowBelow{\def\mem@fb@botlist{}}
16596
16597 % \end{macrocode}
16598 % \end{macro}
16599 % \end{macro}
16600 % \end{macro}
16601 % \begin{macro}{\setFloatBlockFor}
16602 % This can be used to add \cs{FloatBLock} into various sectional
16603 % macros. Supported: \cs{chapter} (when in article mode) and all
16604 % sectional macros made using \cs{@startsection}.
16605 % \begin{macrocode}
16606 \newcommand\setFloatBlockFor[1]{%
16607 \@namedef{#1block}{\FloatBlock}}
16608 % \end{macrocode}
16609 %
16610 % \end{macro}
16611 %
16612 % \subsubsection{Margin floats}
16613 %
16614 % The next two constructions are inspired by \texttt{tufte-common.def}
16615 % by Bil Kleb, Bill Wood, and Kevin Godby and provide a manner to
16616 % insert figures or tables into the margin. Note that the
16617 % \cs{setfloatadjustment} also applies here.
16618 % \begin{macro}{\mem@margin@floatbox}
16619 % Box to save the contents of a margin float in.
16620 % \begin{macrocode}
16621 \newsavebox{\mem@margin@floatbox}
16622 % \end{macrocode}
16623 % \end{macro}
16624 % % \begin{environment}{mem@margin@float}
16625 % \begin{environment}{marginfigure}
16626 % \begin{environment}{margintable}
16627 % \begin{macro}{\marginfloatmarginmacro}
16628 % Since the two environments only differ in `name' a constructor is used.
16629 % Since these margin floats are wrapped inside another type of float
16630 % (\cs{marginpar}) they may cause problems when used combined with
16631 % regular floats (the float order may be wrong). For that reason the
16632 % margin float throws a \cs{FloatBlock} before issuing the \cs{marginpar}.
16633 % \begin{macrocode}
16634 \newcommand\marginfloatmarginmacro{\marginpar}
16635 \newenvironment{mem@margin@float}[2][-1.2ex]%
16636 {\FloatBlock%
16637 \begin{lrbox}{\mem@margin@floatbox}%
16638 \begin{minipage}{\marginparwidth}%
16639 \def\@captype{#2}%
16640 \hbox{}\vspace*{#1}%
16641 \@nameuse{margin#2adjustment}%
16642 \@nameuse{margin#2captionadjustment}%
16643 \noindent%
16644 }
16645 {\end{minipage}%
16646 \end{lrbox}%
16647 \marginfloatmarginmacro{\usebox{\mem@margin@floatbox}}%
16648 }
16649 % \end{macrocode}
16650 % The two environment is then just two applications of the
16651 % constructor. The option can be used to move the margins float up and down.
16652 % \begin{macrocode}
16653 \newenvironment{marginfigure}[1][-1.2ex]{%
16654 \begin{mem@margin@float}[#1]{figure}}
16655 {\end{mem@margin@float}}
16656 \newenvironment{margintable}[1][-1.2ex]{%
16657 \begin{mem@margin@float}[#1]{table}}
16658 {\end{mem@margin@float}}
16659 \setfloatadjustment{marginfigure}{\centering}
16660 \setfloatadjustment{margintable}{\centering}
16661
16662 % \end{macrocode}
16663 % \end{macro}
16664 % \end{environment}
16665 % \end{environment}
16666 % \end{environment}
16667 % \begin{macro}{\setmarginfloatcaptionadjustment}
16668 % Because of the very narrow margin area, it may be fruitful to
16669 % reconfigure the caption style when used in a margin float. This can
16670 % be done globally for all captions (e.g. if all floats are margin
16671 % floats, or just for margin floats.
16672 % \begin{macrocode}
16673 \newcommand*\setmarginfloatcaptionadjustment[2]{%
16674 \@namedef{margin#1captionadjustment}{#2}}
16675
16676 % \end{macrocode}
16677 % \end{macro}
16678 % \changes{v3.6h}{2011/02/06}{Added these two macros}
16679 % \begin{macro}{\setmpjustification}
16680 % \begin{macro}{\mpjustification}
16681 % Can be just to use and configure a specialized justification. It
16682 % follows the \verb?\marginpar? placement, and make use of the first
16683 % argument when at the left of the text block and the other when at
16684 % the right. It makes use of an internal setting from within
16685 % \verb?\marginparmargin?, thus that need to have been executed.
16686 % \begin{macrocode}
16687 \newcommand\setmpjustification[2]{%
16688 \@namedef{mem@mp@justification}{%
16689 \ifm@msetmp\else\@memerror{In order to use
16690 \string\marginCmdAdjust,^^J%
16691 please make sure to specify into which margin the^^J%
16692 \string\marginpar\space should go, using \string\marginparmargin}{}\fi
16693 \m@mwhich@margin{\m@mmpar@margin}%
16694 \ifmemtortm #2 \else #1\fi}%
16695 }
16696 % \end{macrocode}
16697 % Default value
16698 % \begin{macrocode}
16699 \newcommand\mpjustification{%
16700 \@nameuse{mem@mp@justification}}
16701 \setmpjustification{\raggedleft}{\raggedright}
16702
16703 % \end{macrocode}
16704 %
16705 % \end{macro}
16706 % \end{macro}
16707 %
16708 % \subsection{Captions}
16709 %
16710 % The caption styling
16711 % is accomplished by redefining the \cs{@makecaption}
16712 % command. First, though, define and initialise the user-level commands.
16713 %
16714 % \begin{macro}{\if@contcw}
16715 % \begin{macro}{\if@conthang}
16716 % \begin{macro}{\if@contindent}
16717 % For use when checking caption width and captioning styles styles.
16718 % \begin{macrocode}
16719 \newif\if@contcw
16720 \newif\if@conthang
16721 \newif\if@contindent
16722
16723 % \end{macrocode}
16724 % \end{macro}
16725 % \end{macro}
16726 % \end{macro}
16727 %
16728 % \begin{macro}{\captiondelim}
16729 % \begin{macro}{\@contdelim}
16730 % For the caption delimiter.
16731 % \begin{macrocode}
16732 \newcommand{\captiondelim}[1]{\def\@contdelim{#1}}
16733 \captiondelim{: }
16734
16735 % \end{macrocode}
16736 % \end{macro}
16737 % \end{macro}
16738 %
16739 % \begin{macro}{\captionnamefont}
16740 % \begin{macro}{\@contnfont}
16741 % The font for the caption name.
16742 % \begin{macrocode}
16743 \newcommand{\captionnamefont}[1]{\def\@contnfont{#1}}
16744 \captionnamefont{}
16745
16746 % \end{macrocode}
16747 % \end{macro}
16748 % \end{macro}
16749 %
16750 % \begin{macro}{\captiontitlefont}
16751 % \begin{macro}{\@conttfont}
16752 % The font for the caption title.
16753 % \begin{macrocode}
16754 \newcommand{\captiontitlefont}[1]{\def\@conttfont{#1}}
16755 \captiontitlefont{}
16756
16757 % \end{macrocode}
16758 % \end{macro}
16759 % \end{macro}
16760 %
16761 %
16762 % \begin{macro}{\captionstyle}
16763 % \begin{macro}{\@contcstyle}
16764 % The paragraphing style for the caption.
16765 % \begin{macrocode}
16766 \newcommand*{\captionstyle}[1]{\def\@contcstyle{#1}}
16767 \captionstyle{}
16768
16769 % \end{macrocode}
16770 % \end{macro}
16771 % \end{macro}
16772 %
16773 % \begin{macro}{\captionstyle}
16774 % \begin{macro}{\@memcshort}
16775 % \begin{macro}{\@memcnom}
16776 % \begin{macro}{\@contcshortstyle}
16777 % \begin{macro}{\@contcstyle}
16778 % The paragraphing style for the caption.
16779 %
16780 % I had email from J{\o}rgen Larsen 2003/04/09,
16781 % asking for separate controls for the short and long captions. \\
16782 % \cs{captionstyle}\oarg{short}\marg{normal}.
16783 % \changes{v1.4}{2003/11/22}{Extended \cs{captionstyle} (from patch v1.5)}
16784 % \changes{v3.6h}{2011/01/16}{Removed sporadic spaces}
16785 % \begin{macrocode}
16786 \renewcommand{\captionstyle}{%
16787 \@ifnextchar[{\@memcshort}{\@memcnorm}}
16788 \def\@memcshort[#1]#2{%
16789 \def\@contcshortstyle{#1}%
16790 \def\@contcstyle{#2}}
16791 \def\@memcnorm#1{%
16792 \def\@contcshortstyle{#1}%
16793 \def\@contcstyle{#1}}
16794 \captionstyle{}
16795
16796 % \end{macrocode}
16797 % \end{macro}
16798 % \end{macro}
16799 % \end{macro}
16800 % \end{macro}
16801 % \end{macro}
16802 %
16803 %
16804 % \begin{macro}{\@contcwidth}
16805 % \begin{macro}{\captionwidth}
16806 % \begin{macro}{\changecaptionwidth}
16807 % \begin{macro}{\normalcaptionwidth}
16808 % The macros for dealing with the caption width.
16809 % \begin{macrocode}
16810 \newlength{\@contcwidth}
16811 \newcommand{\captionwidth}[1]{\setlength{\@contcwidth}{#1}}
16812 \captionwidth{\linewidth}
16813 \newcommand{\changecaptionwidth}{\@contcwtrue}
16814 \newcommand{\normalcaptionwidth}{\@contcwfalse}
16815 \normalcaptionwidth
16816
16817 % \end{macrocode}
16818 % \end{macro}
16819 % \end{macro}
16820 % \end{macro}
16821 % \end{macro}
16822 %
16823 % \begin{macro}{\@contindw}
16824 % \begin{macro}{\hangcaption}
16825 % \begin{macro}{\indentcaption}
16826 % \begin{macro}{\normalcaption}
16827 % The macros for hanging and indented captions.
16828 % \begin{macrocode}
16829 \newlength{\@contindw}
16830 \newcommand{\hangcaption}{\@conthangtrue\@contindentfalse}
16831 \newcommand{\indentcaption}[1]{\setlength{\@contindw}{#1}%
16832 \@conthangfalse\@contindenttrue}
16833 \newcommand{\normalcaption}{\@conthangfalse\@contindentfalse}
16834 \normalcaption
16835
16836 % \end{macrocode}
16837 % \end{macro}
16838 % \end{macro}
16839 % \end{macro}
16840 % \end{macro}
16841 %
16842 % \begin{macro}{\precaption}
16843 % \begin{macro}{\@contpre}
16844 % \begin{macro}{\postcaption}
16845 % \begin{macro}{\@contpost}
16846 % \begin{macro}{\midbicaption}
16847 % \begin{macro}{\@contmidbi}
16848 % The macros for the pre- and post-caption text/commands, and
16849 % for the mid-caption command for bilingual captions.
16850 % \begin{macrocode}
16851 \newcommand{\precaption}[1]{\def\@contpre{#1}}
16852 \precaption{}
16853 \newcommand{\postcaption}[1]{\def\@contpost{#1}}
16854 \postcaption{}
16855 \newcommand{\midbicaption}[1]{\def\@contmidbi{#1}}
16856 \midbicaption{}
16857
16858 % \end{macrocode}
16859 % \end{macro}
16860 % \end{macro}
16861 % \end{macro}
16862 % \end{macro}
16863 % \end{macro}
16864 % \end{macro}
16865 %
16866 % \begin{macro}{\captiontitlefinal}
16867 % \cs{captiontitlefinal}\marg{stuff} will put \meta{stuff} immediately
16868 % at the end of a \cs{caption}'s title text but it will not appear
16869 % in the LoF/LoT/etc. For example \\
16870 % \verb?\captiontitlefinal{.}? \\
16871 % The code was supplied by Frederic Connes.
16872 % \changes{v1.61803}{2008/01/30}{Added \cs{captiontitlefinal} (mempatch v4.4)}
16873 % \begin{macrocode}
16874 \newcommand*{\captiontitlefinal}[1]{\def\@contfinal{#1}}
16875 \captiontitlefinal{}
16876
16877 % \end{macrocode}
16878 % \end{macro}
16879 %
16880 % \begin{macro}{\abovecaptionskip}
16881 % \begin{macro}{\belowcaptionskip}
16882 % Vertical space above and below a caption. Make them sum to an
16883 % integral number of lines.
16884 % \begin{macrocode}
16885 \newlength{\abovecaptionskip}
16886 \setlength{\abovecaptionskip}{0.5\onelineskip}
16887 \newlength{\belowcaptionskip}
16888 \setlength{\belowcaptionskip}{0.5\onelineskip}
16889
16890 % \end{macrocode}
16891 % \end{macro}
16892 % \end{macro}
16893 %
16894 % \begin{macro}{\caption}
16895 % For subfloat support, the (kernel) \cs{caption} macro needs to note that it
16896 % has been called.
16897 % \begin{macrocode}
16898 \let\@memoldcaption\caption
16899 \def\caption{\donemaincaptiontrue\@memoldcaption}
16900
16901 % \end{macrocode}
16902 % \end{macro}
16903 %
16904 % \begin{macro}{\memcaptioninfo}
16905 % \verb?\memcaptioninfo{type}{\thetypenum}{short}{long}?
16906 % \changes{v1.618}{2005/09/10}{Added \cs{memcaptioninfo}}
16907 % \begin{macrocode}
16908 \newcommand{\memcaptioninfo}[4]{}
16909
16910 % \end{macrocode}
16911 % \end{macro}
16912 %
16913 % \begin{macro}{\@caption}
16914 % For title referencing support, the (kernel) \cs{@caption} macro needs
16915 % to store the title.
16916 % \changes{v1.618}{2005/09/03}{Added braces around second argument of \cs{@memold@caption} (per Dan Luecking, mempatch v3.0)}
16917 % \begin{macrocode}
16918 \let\@memold@caption\@caption
16919 \long\def\@caption#1[#2]#3{%
16920 \M@gettitle{#2}%
16921 \memcaptioninfo{#1}{\csname the#1\endcsname}{#2}{#3}%
16922 \@memold@caption{#1}[{#2}]{#3}}
16923
16924 % \end{macrocode}
16925 % \end{macro}
16926 %
16927 % \begin{macro}{\@makecaption}
16928 % This is a reimplementation of the kernel \cs{@makecaption} command.
16929 % As well as including the caption typesetting commands it enables
16930 % captions that include forced newlines (e.g., by \verb?\\?).
16931 %
16932 % The first part is due to Donald Arseneau from postings to the \ctt{}
16933 % newsgroup and Email discussions. The \cs{topskip} strut is used
16934 % whenever the caption is the first part of the float. This means,
16935 % among other things, that if a caption comes at the top of a page,
16936 % then the first line of the caption will be aligned with the normal
16937 % first line of a page. The \cs{abovecaptionskip} is only used when
16938 % there is something above the caption in the current float.
16939 % \changes{v0.31}{2001/07/24}{Changed \cs{@tempa} to \cs{@memtempa} in \cs{@makecaption}}
16940 % \changes{v1.0a}{2002/02/12}{Added extra centering code in \cs{@makecaption}}
16941 % \changes{v1.4}{2003/11/22}{Added separate short/long styles in \cs{@makecaption}
16942 % (from patch v1.5)}
16943 % \changes{v1.61803}{2008/01/30}{Added \cs{@contfinal} to \cs{@makecaption}
16944 % (mempatch v4.4)}
16945 %
16946 % Axel Sommerfelt\footnote{Private email discussion} suggested to
16947 % split \cs{@makecaption} into two macros, such that the caption
16948 % formatting and the space above and below are separate. This enables
16949 % us to use the formatting macro (\cs{@@makecaption}) to format, say,
16950 % \Lpack{longtable} captions.
16951 % \changes{v3.6k}{2013/05/13}{Split \cs{@makecaption} into
16952 % \cs{@makecaption} and \cs{@@makecaption}}
16953 % \begin{macrocode}
16954 \long\def\@makecaption#1#2{\let\@memtempa\relax
16955 \ifdim\prevdepth>-99\p@ \vskip\abovecaptionskip
16956 \else \def\@memtempa{\vbox to\topskip{}}\fi
16957 % \end{macrocode}
16958 % Inserting \cs{@@makecaption} to format the actual caption.
16959 % \begin{macrocode}
16960 \@@makecaption{#1}{#2}%
16961 % \end{macrocode}
16962 % Then add the below caption spacing.
16963 % \begin{macrocode}
16964 \vskip\belowcaptionskip}
16965
16966 % \end{macrocode}
16967 % \end{macro}
16968 %
16969 % \begin{macro}{\@@makecaption}
16970 % Next the rest of the caption code as \cs{@@makecaption}.
16971 % \begin{macrocode}
16972 \long\def\@@makecaption#1#2{%
16973 % \end{macrocode}
16974 % \begin{macro}{\@contfnote}
16975 % \begin{macro}{\@contfmark}
16976 % The caption title will be typeset twice, firstly to measure its width
16977 % and secondly to actually typeset it. To avoid problems caused by
16978 % a footnote in the caption getting processed twice, we temporarily
16979 % disable the expected relevant commands.
16980 % \changes{v3.6h}{2011/01/20}{Provided the same for \cs{pagentote}}
16981 % \begin{macrocode}
16982 \let\@contfnote\footnote \renewcommand{\footnote}[2][]{}
16983 \let\@contfmark\footnotemark \renewcommand{\footnotemark}[1][]{}
16984 \let\@contpnote\pagenote\renewcommand\pagenote[2][]{}
16985 % \end{macrocode}
16986 % \end{macro}
16987 % \end{macro}
16988 % Now measure the width of the total caption, not forgetting to take account
16989 % of the font specifications, and then restore the footnoting.
16990 % \changes{v3.6k}{2013/05/13}{Font grouping, suggested by Axel Sommerfelt}
16991 % \begin{macrocode}
16992 \sbox\@tempboxa{{\@contnfont #1\@contdelim}\@conttfont #2\@contfinal}
16993 \let\footnote\@contfnote
16994 \let\footnotemark\@contfmark
16995 \let\pagenote\@contpnote
16996 % \end{macrocode}
16997 % If the caption is less than one
16998 % line, then the whole caption needs to be centered on the page (otherwise
16999 % the short caption may be typeset flushleft).
17000 % \begin{macrocode}
17001 \ifdim\wd\@tempboxa<\linewidth \centering \fi
17002 \if@contcw
17003 % \end{macrocode}
17004 % For typesetting at anything other than the normal width, put the caption
17005 % into a \cs{parbox} of the specified width. This must be centered.
17006 % \changes{v3.6h}{2010/12/06}{Align inner parbox at top
17007 % line. Vertically centered parbox cause different spacing when
17008 % \cs{changecaptionwidth} compared when it is not used.}
17009 % \begin{macrocode}
17010 \centering
17011 \parbox[t]{\@contcwidth}{%
17012 % \end{macrocode}
17013 % Henrik Holm (email on 2002/02/10) proposed adding the next line to center short, narrow captions.
17014 % \begin{macrocode}
17015 \ifdim\wd\@tempboxa<\@contcwidth \centering \fi
17016 \fi
17017 % \end{macrocode}
17018 % Hanging and indenting doesn't apply to short captions, so do these
17019 % now.
17020 % \changes{v1.6180339f}{2009/06/25}{Short captions no longer hang or indent}
17021 % \begin{macrocode}
17022 \ifdim\wd\@tempboxa<\linewidth
17023 \@contpre
17024 {\@contnfont #1\@contdelim}\@memtempa
17025 {\@contcshortstyle \@conttfont #2\@contfinal\par}
17026 \else
17027 \if@conthang
17028 % \end{macrocode}
17029 % For a hanging caption we have to measure the width of the caption name,
17030 % then typeset the whole caption in a hanging paragraph.
17031 % \changes{v1.1}{2002/03/10}{Changed code for hangcaption in \cs{@makecaption}}
17032 % \begin{macrocode}
17033 \sbox\@tempboxa{\@contnfont #1\@contdelim}
17034 \@contpre%
17035 {\@contcstyle\hangindent=\wd\@tempboxa
17036 \noindent\box\@tempboxa\@memtempa \@conttfont #2\@contfinal\par}
17037 \else
17038 \if@contindent
17039 % \end{macrocode}
17040 % An indented caption is similar, except the amount of indentation is
17041 % kept in \cs{@contindw}.
17042 % \begin{macrocode}
17043 \@contpre%
17044 {\@contnfont #1\@contdelim}\@memtempa
17045 {\@contcstyle\hangindent=\@contindw
17046 \hangafter=\@ne\@conttfont #2\@contfinal\par}% <- v1.4
17047 \else
17048 % \end{macrocode}
17049 % For the normal style, just typeset the caption.
17050 % \begin{macrocode}
17051 \@contpre%
17052 {\@contnfont #1\@contdelim}\@memtempa
17053 {\@contcstyle \@conttfont #2\@contfinal\par}
17054 \fi
17055 \fi
17056 \fi
17057 % \end{macrocode}
17058 % Finish off the typesetting by processing the post-text, and if not using
17059 % the normal width then close off the \cs{parbox}, and lastly put in some
17060 % vertical space.
17061 % \changes{v3.6k}{2013/05/13}{Removed the below vertical skip}
17062 % \begin{macrocode}
17063 \@contpost
17064 \if@contcw
17065 \par
17066 } % end of the \parbox
17067 \fi
17068 }
17069
17070 % \end{macrocode}
17071 % \end{macro}
17072 %
17073 %
17074 %
17075 % \subsubsection{Continuation captions and legends}
17076 %
17077 % \begin{macro}{\contcaption}
17078 % \cs{contcaption}\marg{text} is a user-level command.
17079 % It is a simplified
17080 % version of the normal \cs{caption} command as it doesn't have to deal
17081 % with numbering or list of \dots entries.
17082 %
17083 % However, Brent Lievers\footnote{in \ctt{} thread
17084 % \textit{Figures}, 2003/11/14.} requested that \cs{label} should
17085 % pick up the correct caption number after a \cs{contcaption}.
17086 % \changes{v1.4}{2003/11/22}{Extended \cs{contcaption} (from patch v1.9)}
17087 % \begin{macrocode}
17088 \newcommand{\contcaption}{%
17089 \addtocounter{\@captype}{\m@ne}\refstepcounter{\@captype}%
17090 \@contcaption\@captype}
17091
17092 % \end{macrocode}
17093 % \end{macro}
17094 %
17095 %
17096 % \begin{macro}{\@@contcaption}
17097 % \begin{macro}{\@contcaption}
17098 % \cs{@contcaption} is the workhorse for the \cs{contcaption} command. In turn,
17099 % it uses the \cs{@makecaption} command (defined in the usual classes)
17100 % to do most of its work. It
17101 % uses the number of the previous \cs{caption} command in the same
17102 % type of float and its implementation includes much of the code
17103 % used in the \LaTeX{} \cs{@caption} command.
17104 %
17105 % First specify \cs{@@contcaption}\marg{type}\marg{title}
17106 % to save some repetitive code.
17107 % \begin{macrocode}
17108 \long\def\@@contcaption#1#2{%
17109 \par
17110 \begingroup
17111 \@parboxrestore
17112 \if@minipage
17113 \@setminipage
17114 \fi
17115 \normalsize
17116 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #2}\par
17117 \endgroup}
17118
17119 % \end{macrocode}
17120 % \end{macro}
17121 %
17122 % Now for \cs{@contcaption}\marg{type}\marg{title}.
17123 % It has to flush out any subcaptions at the
17124 % appropriate time, as well as typesetting the caption.
17125 % ^^A Why is \@memlistsubcaptions being executed here? We
17126 % ^^A it should be enough to do it at the end of the floats.
17127 % ^^A Works fine if they are removed
17128 % \begin{macrocode}
17129 \long\def\@contcaption#1#2{%
17130 \if@contbotsub
17131 \@memlistsubcaptions{#1}%
17132 \@@contcaption{#1}{#2}%
17133 \else
17134 \@@contcaption{#1}{#2}%
17135 \@memlistsubcaptions{#1}%
17136 \fi}
17137
17138 % \end{macrocode}
17139 % \end{macro}
17140 %
17141 %
17142 % \begin{macro}{\memlegendinfo}
17143 % \begin{macro}{\legend}
17144 % The macro \cs{legend}\marg{text}is intended
17145 % to be used in a float environment for an `anonymous' caption, but can be
17146 % used anywhere.
17147 %
17148 % The implementation is similar to the \cs{caption} command but we have
17149 % to eliminate printing of a delimeter.
17150 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{legend}}
17151 % \changes{v1.618}{2005/09/10}{Added \cs{memlegendinfo}}
17152 % \begin{macrocode}
17153 \newcommand{\memlegendinfo}[1]{}
17154 \newcommand{\legend}[1]{%
17155 \M@gettitle{#1}%
17156 \memlegendinfo{#1}%
17157 \par
17158 \begingroup
17159 \@parboxrestore
17160 \if@minipage
17161 \@setminipage
17162 \fi
17163 \normalsize
17164 \captiondelim{\mbox{}}
17165 \@makecaption{}{\ignorespaces #1}\par
17166 \endgroup}
17167
17168 % \end{macrocode}
17169 % \end{macro}
17170 % \end{macro}
17171 %
17172 %
17173 % \begin{macro}{\namedlegend}
17174 % \begin{macro}{\memnamedlegendinfo}
17175 % \cs{namedlegend}\oarg{short-title}\marg{long-title} is like the
17176 % \cs{caption} command except that it does not number the caption.
17177 %
17178 % \cs{memnamedlegendinfo}\marg{type}\marg{short-title}\marg{long-title}
17179 % \changes{v1.618}{2005/09/10}{Added \cs{memnamedlegendinfo}}
17180 % \begin{macrocode}
17181 \newcommand{\namedlegend}{\@dblarg{\@legend\@captype}}
17182 \newcommand{\memnamedlegendinfo}[3]{}
17183
17184 % \end{macrocode}
17185 % \end{macro}
17186 % \end{macro}
17187 %
17188 % \begin{macro}{\@legend}
17189 % \cs{@legend}\marg{type}\oarg{short-title}\marg{long-title}
17190 % is the workhorse for the \cs{namedlegend} command. In turn, it calls
17191 % \cs{@makelegend}. It requires two commands to have been defined, namely
17192 % \cs{flegtoctype} and \cs{flegtype}. The command \cs{flegtoctype}\marg{text}
17193 % is responsible for writing a title text to the appropriate listof file.
17194 % \cs{flegtype} is responsible for typeseting the name of the legend.
17195 % \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@legend}}
17196 % \begin{macrocode}
17197 \long\def\@legend#1[#2]#3{%
17198 \M@gettitle{#2}%
17199 \memnamedlegendinfo{#1}{#2}{#3}%
17200 \par
17201 \csname flegtoc#1\endcsname{#2}%
17202 \begingroup
17203 \@parboxrestore
17204 \if@minipage
17205 \@setminipage
17206 \fi
17207 \normalsize
17208 \@makecaption{\csname fleg#1\endcsname}{\ignorespaces #3}\par
17209 \endgroup}
17210
17211 % \end{macrocode}
17212 % \end{macro}
17213 %
17214 %
17215 % \subsubsection{Non-float captions}
17216 %
17217 % \begin{macro}{\newfixedcaption}
17218 % \begin{macro}{\renewfixedcaption}
17219 % \begin{macro}{\providefixedcaption}
17220 % These commands are defined in terms of their \verb?\...command? counterparts.\\
17221 % Call as \verb?\...fixedcaption?\oarg{capcommand}\marg{command}\marg{env}
17222 % \begin{macrocode}
17223 \newcommand{\newfixedcaption}[3][\caption]{%
17224 \newcommand{#2}{\def\@captype{#3}#1}}
17225 \newcommand{\renewfixedcaption}[3][\caption]{%
17226 \renewcommand{#2}{\def\@captype{#3}#1}}
17227 \newcommand{\providefixedcaption}[3][\caption]{%
17228 \providecommand{#2}{\def\@captype{#3}#1}}
17229
17230 % \end{macrocode}
17231 % \end{macro}
17232 % \end{macro}
17233 % \end{macro}
17234 %
17235 % \subsubsection{Bilingual captions}
17236 %
17237 % The bilingual caption commands all use internal grouping so
17238 % that any changes are kept local. This has the unfortunate side-effect
17239 % that any \cs{label} command must be within the grouping otherwise the
17240 % wrong number is picked up. To make the coding, if not necessarily the
17241 % use, of the commands simpler, I have not used the traditional style
17242 % of square brackets for optional caption text arguments. Instead, empty
17243 % `required' arguments are used as the implementation means.
17244 %
17245 % \begin{macro}{\membitwonumcaptioninfo}
17246 % \begin{macro}{\membionenumcaptioninfo}
17247 % \begin{macro}{\membicaptioninfo}
17248 % \verb?\membitwonumcaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
17249 % \hspace*{2in} \marg{name2}\marg{short2}\marg{long2} \\
17250 % \verb?\membionenumcaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
17251 % \hspace*{2in} \marg{name2}\marg{short2}\marg{long2} \\
17252 % \verb?\membicaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
17253 % \hspace{2in} \marg{name2}\marg{long2} \\
17254 % \changes{v1.618}{2005/09/10}{Added \cs{membitwonumcaptioninfo},
17255 % \cs{membitwonumcaptioninfo} and \cs{membicaptioninfo}}
17256 % \begin{macrocode}
17257 \newcommand{\membitwonumcaptioninfo}[7]{}
17258 \newcommand{\membionenumcaptioninfo}[7]{}
17259 \newcommand{\membicaptioninfo}[6]{}
17260
17261 % \end{macrocode}
17262 % \end{macro}
17263 % \end{macro}
17264 % \end{macro}
17265 %
17266 % \begin{macro}{\bitwonumcaption}
17267 % The 6 arguments are: optional label, short and long in language 1,
17268 % name in
17269 % language 2, and short and long in language 2. Both texts are put
17270 % into the List of as numbered entries.
17271 % \begin{macrocode}
17272 \newcommand{\bitwonumcaption}[6][\@empty]{%
17273 \begingroup
17274 \let\memcaptioninfo\@gobblefour
17275 % \end{macrocode}
17276 % Check if the first language argument is vacuous, then call
17277 % the normal \cs{caption} for language 1.
17278 % \begin{macrocode}
17279 \@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
17280 {\def\m@mscapi{#2}\caption[#2]{#3}}%
17281 % \end{macrocode}
17282 % Do the optional labeling.
17283 % \begin{macrocode}
17284 \ifx \@empty #1\else
17285 \label{#1}%
17286 \fi
17287 % \end{macrocode}
17288 % Remove any extra spacing between the captions, and set the
17289 % NAME for the second caption. Use a command to transfer
17290 % the NAME to the renewal code to avoid circularity if
17291 % for example, we are trying to redefine \cs{tablename} as
17292 % \cs{tablename}. Decrement the caption counter.
17293 % \begin{macrocode}
17294 \setlength{\abovecaptionskip}{0pt}%
17295 \setlength{\belowcaptionskip}{0pt}%
17296 \edef\@memtempc{#4}%
17297 \expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
17298 \addtocounter{\@captype}{-1}%
17299 % \end{macrocode}
17300 % To avoid duplicate targets (hyperref) we need to locally change
17301 % \cs{theH\cs{captype}}. Due to a bug in \Lpack{hyperref} cannot
17302 % just use \cs{LinkTargetOff}
17303 % \changes{v3.8.4}{2025/09/19}{Added fix}
17304 % \begin{macrocode}
17305 \ExpandArgs{c}\edef{theH\@captype}{\csname theH\@captype\endcsname-bitwonum-#4}%
17306 % \end{macrocode}
17307 % Now repeat for the second language caption.
17308 % \begin{macrocode}
17309 \@contmidbi
17310 \@ifmtarg{#5}{\def\m@mscapii{#6}\caption{#6}}%
17311 {\def\m@mscapii{#5}\caption[#5]{#6}}%
17312 \membitwonumcaptioninfo{\@captype}{\@nameuse{the\@captype}}%
17313 {\m@mscapi}{#3}{#4}{\m@mscapii}{#6}%
17314 \endgroup}
17315
17316 % \end{macrocode}
17317 % \end{macro}
17318 %
17319 % \begin{macro}{\bionenumcaption}
17320 % The 6 arguments are: optional labelling,
17321 % short and long in language 1, name in
17322 % language 2, and short and long in language 2. Both texts are put
17323 % into the List of, but only the first is numbered.
17324 % \begin{macrocode}
17325 \newcommand{\bionenumcaption}[6][\@empty]{%
17326 \begingroup
17327 \let\memcaptioninfo\@gobblefour
17328 % \end{macrocode}
17329 % Check if the first language argument is vacuous, then call
17330 % the normal \cs{caption} for language 1.
17331 % \begin{macrocode}
17332 \@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
17333 {\def\m@mscapi{#2}\caption[#2]{#3}}%
17334 % \end{macrocode}
17335 % Do the optional labeling.
17336 % \begin{macrocode}
17337 \ifx \@empty #1\else
17338 \label{#1}%
17339 \fi
17340 % \end{macrocode}
17341 % Do the between captions code.
17342 % \begin{macrocode}
17343 \setlength{\abovecaptionskip}{0pt}%
17344 \setlength{\belowcaptionskip}{0pt}%
17345 \edef\@memtempc{#4}%
17346 \expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}
17347 % \end{macrocode}
17348 % Use a continuation caption for the second language, not forgetting
17349 % to add the appropriate unnumbered text to the List.
17350 % \begin{macrocode}
17351 \@contmidbi
17352 \contcaption{#6}%
17353 \@ifmtarg{#5}{%
17354 \def\m@mscapii{#6}%
17355 \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
17356 {\protect\numberline{}{\ignorespaces #6}}}{%
17357 \def\m@mscapii{#5}%
17358 \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
17359 {\protect\numberline{}{\ignorespaces #5}}}%
17360 \membionenumcaptioninfo{\@captype}{\@nameuse{the\@captype}}%
17361 {\m@mscapi}{#3}{#4}{\m@mscapii}{#6}%
17362 \endgroup}
17363
17364 % \end{macrocode}
17365 % \end{macro}
17366 %
17367 % \begin{macro}{\bicaption}
17368 % The 5 arguments are: optional labelling,
17369 % short and long in language 1, name in
17370 % language 2, and long in language 2.
17371 % Only the first text is put into the List.
17372 % \begin{macrocode}
17373 \newcommand{\bicaption}[5][\@empty]{%
17374 \begingroup
17375 \let\memcaptioninfo\@gobblefour
17376 % \end{macrocode}
17377 % Check if the first language argument is vacuous, then call
17378 % the normal \cs{caption} for language 1.
17379 % \begin{macrocode}
17380 \@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
17381 {\def\m@mscapi{#2}\caption[#2]{#3}}%
17382 % \end{macrocode}
17383 % Do the optional labeling.
17384 % \begin{macrocode}
17385 \ifx \@empty #1\else
17386 \label{#1}%
17387 \fi
17388 % \end{macrocode}
17389 % Do the between captions code and
17390 % finally just use \cs{contcaption} for the
17391 % second language.
17392 % \begin{macrocode}
17393 \setlength{\abovecaptionskip}{0pt}%
17394 \setlength{\belowcaptionskip}{0pt}%
17395 \edef\@memtempc{#4}
17396 \expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
17397 \@contmidbi
17398 \contcaption{#5}%
17399 \membicaptioninfo{\@captype}{\@nameuse{the\@captype}}%
17400 {\m@mscapi}{#3}{#4}{#5}%
17401 \endgroup}
17402
17403 % \end{macrocode}
17404 % \end{macro}
17405 %
17406 % \begin{macro}{\bicontcaption}
17407 % The 3 arguments are long in language 1, name in
17408 % language 2, and long in language 2.
17409 % \begin{macrocode}
17410 \newcommand{\bicontcaption}[3]{%
17411 \begingroup
17412 % \end{macrocode}
17413 % Call \cs{contcaption} for language 1.
17414 % \begin{macrocode}
17415 \contcaption{#1}%
17416 % \end{macrocode}
17417 % Do the between captions code and use \cs{contcaption} for the second
17418 % language.
17419 % \begin{macrocode}
17420 \setlength{\abovecaptionskip}{0pt}%
17421 \setlength{\belowcaptionskip}{0pt}%
17422 \edef\@memtempc{#2}%
17423 \expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
17424 \@contmidbi
17425 \contcaption{#3}%
17426 \endgroup}
17427
17428 % \end{macrocode}
17429 % \end{macro}
17430 %
17431 %
17432 %
17433 % \subsubsection{Support for the \Lopt{subfigure} package like functionality}
17434 %
17435 % Much of the code in this section is based on the \Lpack{subfigure}
17436 % package code, by kind permission of its author, Steven Douglas Cochran.
17437 % To try and avoid clashes with the real \Lpack{subfigure} code I have
17438 % used different macro names, especially when I have copied the code.
17439 %
17440 % \begin{macro}{\subcaptionstyle}
17441 % \begin{macro}{\@contsubcstyle}
17442 % The paragraphing style for subcaptions.
17443 % \begin{macrocode}
17444 \newcommand{\subcaptionstyle}[1]{\def\@contsubcstyle{#1}}
17445 \subcaptionstyle{}
17446
17447 % \end{macrocode}
17448 % \end{macro}
17449 % \end{macro}
17450 %
17451 % \begin{macro}{\if@shortsubcap}
17452 % \begin{macro}{\if@hangsubcap}
17453 % \begin{macro}{\shortsubcaption}
17454 % \begin{macro}{\hangsubcaption}
17455 % \begin{macro}{\normalsubcaption}
17456 % For dealing with short and hanging subcaptions.
17457 % Analagous to the \Lpack{subfigure} \texttt{nooneline} and \texttt{hang} options.
17458 % The default is normal subcaptions.
17459 % \begin{macrocode}
17460 \newif\if@shortsubcap
17461 \newif\if@hangsubcap
17462 \newcommand*{\shortsubcaption}{\@shortsubcaptrue}
17463 \newcommand*{\hangsubcaption}{\@hangsubcaptrue}
17464 \newcommand*{\normalsubcaption}{\@shortsubcapfalse\@hangsubcapfalse}
17465 \normalsubcaption
17466
17467 % \end{macrocode}
17468 % \end{macro}
17469 % \end{macro}
17470 % \end{macro}
17471 % \end{macro}
17472 % \end{macro}
17473 %
17474 % \begin{macro}{\subfloattopskip}
17475 % \begin{macro}{\subfloatcapskip}
17476 % \begin{macro}{\subfloatcaptopadj}
17477 % \begin{macro}{\subfloatbottomskip}
17478 % \begin{macro}{\subfloatlabelskip}
17479 % \begin{macro}{\subfloatcapmargin}
17480 % These \cs{subfloat...} lengths are analagous to the \Lpack{subfigure}
17481 % \cs{subfig...} lengths.
17482 % \begin{macrocode}
17483 \newskip\subfloattopskip
17484 \newskip\subfloatcapskip
17485 \newskip\subfloatcaptopadj
17486 \newskip\subfloatbottomskip
17487 \newskip\subfloatlabelskip
17488 \newdimen\subfloatcapmargin
17489 % \end{macrocode}
17490 % \end{macro}
17491 % \end{macro}
17492 % \end{macro}
17493 % \end{macro}
17494 % \end{macro}
17495 % \end{macro}
17496 %
17497 % \begin{macro}{\if@tightsubcap}
17498 % \begin{macro}{\loosesubcaptions}
17499 % \begin{macro}{\tightsubcaptions}
17500 % Unlike the \Lpack{subfigure} package the class provides no options for
17501 % subcaptions. These macros provide the \Lpack{subfigure} loose/tight
17502 % option functions. Set the default to tight.
17503 % \begin{macrocode}
17504 \newif\if@tightsubcap
17505 \newcommand{\loosesubcaptions}{%
17506 \subfloattopskip = 10\p@
17507 \subfloatcapskip = 10\p@
17508 \subfloatcaptopadj = \z@
17509 \subfloatbottomskip = 10\p@
17510 \subfloatlabelskip = 0.33em
17511 \subfloatcapmargin = 10\p@
17512 \@tightsubcapfalse
17513 }
17514
17515 \newcommand{\tightsubcaptions}{%
17516 \subfloattopskip = 5\p@
17517 \subfloatcapskip = \z@
17518 \subfloatcaptopadj = 3\p@
17519 \subfloatbottomskip = 5\p@
17520 \subfloatlabelskip = 0.33em \@plus 0.07em \@minus 0.03em
17521 \subfloatcapmargin = \z@
17522 \@tightsubcaptrue
17523 }
17524 \tightsubcaptions
17525
17526 % \end{macrocode}
17527 % \end{macro}
17528 % \end{macro}
17529 % \end{macro}
17530 %
17531 % \begin{macro}{\subcaptionsize}
17532 % \begin{macro}{\@subcapsize}
17533 % \begin{macro}{\subcaptionlabelfont}
17534 % \begin{macro}{\@subcaplabelfont}
17535 % \begin{macro}{\subcaptionfont}
17536 % \begin{macro}{\@subcapfont}
17537 % These macros set the size and fonts for the subcaptions. Set the defaults
17538 % to \cs{footnotesize}, and the normal roman font.
17539 % \begin{macrocode}
17540 \newcommand*{\subcaptionsize}[1]{\def\@subcapsize{#1}}
17541 \newcommand*{\subcaptionlabelfont}[1]{\def\@subcaplabelfont{#1}}
17542 \newcommand*{\subcaptionfont}[1]{\def\@subcapfont{#1}}
17543 \subcaptionsize{\footnotesize}
17544 \subcaptionlabelfont{\normalfont}
17545 \subcaptionfont{\normalfont}
17546
17547 % \end{macrocode}
17548 % \end{macro}
17549 % \end{macro}
17550 % \end{macro}
17551 % \end{macro}
17552 % \end{macro}
17553 % \end{macro}
17554 %
17555 % \begin{macro}{\@contkeep}
17556 % \begin{macro}{\@contset}
17557 % \begin{macro}{\subconcluded}
17558 % \cs{@contkeep} stores
17559 % the current subfloat number in counter \verb?@contsubnum? and
17560 % \cs{@contset} sets the subfloat number to the value of \verb?@contsubnum?.
17561 % \cs{subconcluded} sets the subfloat number to zero.
17562 % \begin{macrocode}
17563 \newcounter{@contsubnum}
17564 \newcommand{\@contkeep}{%
17565 \setcounter{@contsubnum}{\value{sub\@captype}}}
17566 \newcommand{\@contset}{%
17567 \setcounter{sub\@captype}{\value{@contsubnum}}}
17568 \newcommand{\subconcluded}{%
17569 \setcounter{sub\@captype}{0}}
17570 % \end{macrocode}
17571 % \end{macro}
17572 % \end{macro}
17573 % \end{macro}
17574 %
17575 %
17576 %
17577 % \begin{macro}{\if@contbotsub}
17578 % A flag indicating whether the subcaption is to be at the bottom or
17579 % top of the subfloat; TRUE for the subcaption at the bottom.
17580 % \begin{macrocode}
17581 \newif\if@contbotsub
17582 \@contbotsubtrue
17583
17584 % \end{macrocode}
17585 % \end{macro}
17586 %
17587 % \begin{macro}{\mem@addto@label}
17588 % In earlier versions of the code (pre 2025) we would mess with
17589 % \cs{label} inside the various sub commands. This is not a good
17590 % idea, as others may do that as well. Better to directly use the
17591 % \cs{label} hook instead. By default this hook does nothing.
17592 % \changes{v3.8.4}{2025/09/22}{Added}
17593 % \begin{macrocode}
17594 \AddToHookWithArguments{label}{\mem@addto@label@hook{#1}}
17595 \let\mem@addto@label@hook\@gobble
17596 % \end{macrocode}
17597 % \end{macro}
17598 % \begin{macro}{\memsub@addto@label@hook}
17599 % This is the version of the hook we actually want to run inside sub
17600 % captions and friends. Inside a group we set
17601 % \cs{@currentlabelname} and \cs{@currentlabel} to something
17602 % appropriate. Then \emph{manually} add a label entry. TODO: make
17603 % the name inside \cs{@currentlabelname} configurable.
17604 % \changes{v3.8.4}{2025/09/22}{Added}
17605 % \begin{macrocode}
17606 \newcommand\memsub@addto@label@hook[1]{%
17607 \begingroup%
17608 \protected@edef\@currentlabelname{%
17609 Sub\@captype\space%
17610 \@nameuse{p@sub\@captype}%
17611 \@nameuse{thesub\@captype}%
17612 }%
17613 \protected@edef\@currentlabel{\@nameuse{@@thesub\@captype}}%
17614 \protected@write\@auxout{}%
17615 {%
17616 \string\newlabel{sub@#1}{%
17617 {\@currentlabel}%
17618 {\thepage}%
17619 {\@currentlabelname}%x
17620 {\@currentHref}%
17621 {\@kernel@reserved@label@data}%
17622 }%
17623 }%
17624 \endgroup%
17625 }
17626 % \end{macrocode}
17627 % \end{macro}
17628 %
17629 %
17630 % \begin{macro}{\subcaption}
17631 % \cs{subcaption}\oarg{list-entry}\marg{caption} is a generic
17632 % subcaption. There is no \Lpack{subfigure} equivalent.
17633 %
17634 % \changes{v3.7i}{2019/10/24}{Added a \cs{par} to the start. This can
17635 % get rid of sporadic spaces caused by hyperref changing \cs{refstepcounter}}
17636 % \changes{v3.8}{2023/08/02}{Added \cs{mem@step@subcounter} instead
17637 % of refstep}
17638 % \changes{v3.8.4}{2025/09/22}{Changed how we add the extra label}
17639 % \begin{macrocode}
17640 \newcommand{\subcaption}{%
17641 \par
17642 \bgroup
17643 % \let\label=\memsub@label
17644 \let\mem@addto@label@hook\memsub@addto@label@hook
17645 \ifdonemaincaption\else
17646 \advance\csname c@\@captype\endcsname\@ne
17647 \fi
17648 \mem@step@subcounter%
17649 \@ifnextchar [%
17650 {\@memsubcap{sub\@captype}}%
17651 {\@memsubcap{sub\@captype}[\@empty]}}
17652 % \end{macrocode}
17653 % \end{macro}
17654 %
17655 % \begin{macro}{\@memsubcap}
17656 % This handles the optional argument to \cs{subcaption}. It sets \cs{@tempdima}
17657 % to \cs{hsize} as later on \cs{@makesubfloatcaption} uses this.
17658 % \changes{v1.1a}{2002/04/28}{Added \cs{@tempdima} to \cs{@memsubcap}}
17659 % \begin{macrocode}
17660 \long\def\@memsubcap#1[#2]#3{%
17661 \@tempdima=\hsize
17662 \vskip\subfloatcapskip
17663 \ifx \@empty #2
17664 \@memsubcaption{#1}{#3}{#3}%
17665 \else
17666 \@memsubcaption{#1}{#2}{#3}%
17667 \fi
17668 \vskip\subfloatcapskip
17669 \egroup}
17670 % \end{macrocode}
17671 % \end{macro}
17672 %
17673 %
17674 % \begin{macro}{\@memsubcaption}
17675 % \cs{@memsubcaption}\marg{type}\marg{list-entry}\marg{caption}
17676 % typesets a subcaption. This is a copy of the \Lpack{subfigure}
17677 % \cs{@subcaption} macro.
17678 % \begin{macrocode}
17679 \newcommand{\@memsubcaption}[3]{%
17680 \ifx \relax#2\relax \else
17681 \bgroup
17682 \let\label\@gobble
17683 \let\protect\string
17684 \def\@memsubcaplabel{\@nameuse{@@the#1}}%
17685 \xdef\@memsubfigcaptionlist{%
17686 \@memsubfigcaptionlist,%
17687 {\protect\numberline{\@memsubcaplabel}\noexpand{\ignorespaces #2}}}%
17688 \egroup
17689 \fi
17690 \@makesubfloatcaption{\@nameuse{@the#1}}{#3}}
17691
17692 % \end{macrocode}
17693 % \end{macro}
17694 %
17695 %
17696 % \begin{macro}{\contsubcaption}
17697 % \cs{contsubcaption}\oarg{caption} is the continued version of
17698 % \cs{subcaption}.
17699 % \changes{v3.8}{2023/08/02}{Added \cs{mem@step@subcounter} instead
17700 % of refstep}
17701 % \changes{v3.8.4}{2025/09/22}{Changed how we add the extra label}
17702 % \begin{macrocode}
17703 \newcommand{\contsubcaption}{%
17704 \bgroup%
17705 % \let\label=\memsub@label
17706 \let\mem@addto@label@hook\memsub@addto@label@hook
17707 \@contset%
17708 \mem@step@subcounter%
17709 \@ifnextchar [%
17710 {\@memsubcap{sub\@captype}}%
17711 {\@memsubcap{sub\@captype}[\@empty]}}
17712 % \end{macrocode}
17713 % \end{macro}
17714 %
17715 %
17716 % \begin{environment}{subfloat}
17717 % The \Lpack{subfigure} documentation suggests a way of defining a \Lenv{subfloat}
17718 % environment. This is a trivial implementation because the \cs{subcaption}
17719 % and \cs{contsubcaption} commands are provided by the class, and can be used
17720 % within a \Lenv{subfloat}.
17721 % \begin{macrocode}
17722 \newenvironment{subfloat}{}{}
17723
17724 % \end{macrocode}
17725 % \end{environment}
17726 %
17727 % \begin{macro}{\mem@step@subcounter}
17728 % \changes{v3.7i}{2019/10/24}{Added}
17729 % Utility macro to save some typing.
17730 % \changes{v3.8}{2023/08/02}{Added
17731 % \Lhook{memoir/subcaption/aftercounter} hook}
17732 % \begin{macrocode}
17733 \newcommand\mem@step@subcounter{%
17734 \refstepcounter{sub\@captype}\@contkeep%
17735 \UseHook{memoir/subcaption/aftercounter}%
17736 }
17737 % \end{macrocode}
17738 % \end{macro}
17739 %
17740 % \begin{macro}{\subbottom}
17741 % \begin{macro}{\@memsubbody}
17742 % \cs{subbottom}\oarg{list-entry}\oarg{subcaption}\marg{text}
17743 % typesets a subcaption below the \meta{text}. Most of the work is
17744 % performed by the \cs{@memsubbody} macro.
17745 % \changes{v3.8.4}{2025/09/22}{Changed how we add extra label in \cs{@memsubbody}}
17746 % \begin{macrocode}
17747 \newcommand{\subbottom}{%
17748 \@contbotsubtrue
17749 \@memsubbody}
17750
17751 \newcommand{\@memsubbody}{%
17752 \bgroup
17753 % \let\label=\memsub@label
17754 \let\mem@addto@label@hook\memsub@addto@label@hook
17755 \ifdonemaincaption\else
17756 \advance\csname c@\@captype\endcsname\@ne
17757 \fi
17758 % \end{macrocode}
17759 % To help with hyperref target placement (hyperref usually uses
17760 % \cs{refstepcounter} to make the anchors) we move the counter
17761 % business into \cs{@memsubfloat} instead. This way they come right at
17762 % the top.
17763 % \begin{macrocode}
17764 % \changes{v3.7i}{2019/10/24}{Moved \cs{refstepcounter}}
17765 % \refstepcounter{sub\@captype}\@contkeep%
17766 \leavevmode
17767 \@ifnextchar [%
17768 {\@memsubfig}%
17769 {\@memsubfig[\@empty]}}
17770
17771 % \end{macrocode}
17772 % \end{macro}
17773 % \end{macro}
17774 %
17775 % \begin{macro}{\contsubbottom}
17776 % \begin{macro}{\@memcontsubbody}
17777 % These are the continued versions of \cs{subbottom} and \cs{@memsubbody}.
17778 % \changes{v3.8.4}{2025/09/22}{Changed how we add the extra label}
17779 % \begin{macrocode}
17780 \newcommand{\contsubbottom}{%
17781 \@contbotsubtrue
17782 \@memcontsubbody}
17783
17784 \newcommand{\@memcontsubbody}{%
17785 \bgroup
17786 % \let\label=\memsub@label
17787 \let\mem@addto@label@hook\memsub@addto@label@hook
17788 \@contset
17789 % To help with hyperref target placement (hyperref usually uses
17790 % \cs{refstepcounter} to make the anchors) we move the counter
17791 % business into \cs{@memsubfloat} instead. This way they come right at
17792 % the top.
17793 % \begin{macrocode}
17794 % \changes{v3.7i}{2019/10/24}{Moved \cs{refstepcounter}}
17795 % \refstepcounter{sub\@captype}\@contkeep%
17796 \leavevmode
17797 \@ifnextchar [%
17798 {\@memsubfig}%
17799 {\@memsubfig[\@empty]}}
17800
17801 % \end{macrocode}
17802 % \end{macro}
17803 % \end{macro}
17804 %
17805 % \begin{macro}{\subtop}
17806 % \begin{macro}{\contsubtop}
17807 % These are similar to \cs{subbottom} and \cs{contsubbottom} except that they
17808 % put the subcaption on top of the \meta{text}.
17809 % \begin{macrocode}
17810 \newcommand{\subtop}{%
17811 \@contbotsubfalse
17812 \@memsubbody}
17813
17814 \newcommand{\contsubtop}{%
17815 \@contbotsubfalse
17816 \@memcontsubbody}
17817
17818 % \end{macrocode}
17819 % \end{macro}
17820 % \end{macro}
17821 %
17822 % \changes{v1.1a}{2002/04/28}{Deleted \cs{@contsubfloat} as it was not used}
17823 %
17824 % \begin{macro}{\@memsubfig}
17825 % This is a revised version of the \Lpack{subfigure} \cs{@subfigure} command
17826 % --- just the called macro names are changed.
17827 % \begin{macrocode}
17828 \def\@memsubfig[#1]{%
17829 \@ifnextchar [%
17830 {\@memsubfloat{sub\@captype}[#1]}%
17831 {\@memsubfloat{sub\@captype}[\@empty #1][#1]}}
17832
17833 % \end{macrocode}
17834 % \end{macro}
17835 %
17836 % \begin{macro}{\@memsubfloat}
17837 % This is a modified version of the \Lpack{subfigure} \cs{@subfloat}
17838 % command Essentially the \verb?\csname if#1topcap\endcsname? constructs are
17839 % replaced by \cs{if@contbotsub}.
17840 % \changes{v3.6k}{2011/05/16}{This ought to be long}
17841 % ^^A #1: subcaptype; #2: for list; #3: subtitle incl label; #4 contents
17842 % \begin{macrocode}
17843 \long\def\@memsubfloat#1[#2][#3]#4{%
17844 \@tempcnta=\@ne
17845 \if@tightsubcap
17846 \if@minipage
17847 \@tempcnta=\z@
17848 \else
17849 \ifdim\lastskip=\z@
17850 \@tempcnta=\@ne
17851 \else
17852 \@tempcnta=\tw@
17853 \fi
17854 \fi
17855 \fi
17856 \if@contbotsub
17857 \def\subfig@top{\subfloattopskip}%
17858 \def\subfig@bottom{\subfloatbottomskip}%
17859 \else
17860 \def\subfig@top{\subfloatbottomskip}%
17861 \def\subfig@bottom{\subfloattopskip}%
17862 \fi
17863 % \end{macrocode}
17864 % We move the refstep business here to help \Lpack{hyperref} get
17865 % better anchors.
17866 % \changes{v3.7i}{2019/10/24}{moved counter stepping, additionally
17867 % changed \cs{vtop} to \cs{vbox}, otherwise we align the images at the
17868 % top}
17869 % \changes{v3.8.4}{2025/09/24}{Moved the boxing of the contents in
17870 % after \cs{mem@step@subcounter} that way a label can be placed inside
17871 % contents (\#4).}
17872 % \begin{macrocode}
17873 \vbox\bgroup%
17874 \mem@step@subcounter%
17875 \setbox\@tempboxa \hbox{#4}%
17876 \@tempdima=\wd\@tempboxa
17877 \vbox\bgroup
17878 \ifcase\@tempcnta
17879 \@minipagefalse
17880 \or
17881 \vspace{\subfig@top}
17882 \or
17883 \ifdim \lastskip=\z@ \else
17884 \@tempskipb\subfig@top\@xaddvskip
17885 \fi
17886 \fi
17887 \if@contbotsub
17888 \box\@tempboxa\egroup
17889 \ifx \@empty#3\relax \else
17890 \vskip\subfloatcapskip
17891 \@memsubcaption{#1}{#2}{#3}%
17892 \fi
17893 \else
17894 \ifx \@empty#3\relax \else
17895 \@memsubcaption{#1}{#2}{#3}%
17896 \vskip\subfloatcapskip
17897 \vskip\subfloatcaptopadj
17898 \fi\egroup
17899 \box\@tempboxa
17900 \fi
17901 \vspace{\subfig@bottom}
17902 \egroup
17903 \egroup}
17904
17905 % \end{macrocode}
17906 % \end{macro}
17907 %
17908 %
17909 % The following series of macros, from \Lpack{subfigure}, control the
17910 % typesetting of the subcaptions.
17911 %
17912 % \begin{macro}{\@memsubfigcaptionlist}
17913 % A copy of \cs{@subfigcaptionlist}.
17914 % \begin{macrocode}
17915 \newcommand*{\@memsubfigcaptionlist}{}
17916 % \end{macrocode}
17917 % \end{macro}
17918 %
17919 %
17920 % \begin{macro}{\memlistsubcaptions}
17921 % A copy of \cs{listsubcaptions}.
17922 % ^^A note this is not mentioned in the manual
17923 % \begin{macrocode}
17924 \newcommand*{\memlistsubcaptions}{%
17925 \@ifstar
17926 {\gdef\@memsubfigcaptionlist{}}%
17927 {\@memlistsubcaptions{\@captype}}}
17928
17929 % \end{macrocode}
17930 % \end{macro}
17931 %
17932 %
17933 % \begin{macro}{\@memlistsubcaptions}
17934 % A copy of \cs{@listsubcaptions}. Note that is is executed by
17935 % either \cs{end@float}, \cs{end@dblfloat} or \cs{@contcaption}.
17936 % \begin{macrocode}
17937 \newcommand*{\@memlistsubcaptions}[1]{%
17938 \@ifundefined{@captype}{}{%
17939 \@ifundefined{ext@sub#1}{}{%
17940 \@for \@tempa:=\@memsubfigcaptionlist \do {%
17941 \ifx \@empty\@tempa\relax \else
17942 \addcontentsline{\@nameuse{ext@sub#1}}{sub#1}{\@tempa}%
17943 \fi}}}%
17944 \gdef\@memsubfigcaptionlist{}}
17945
17946 % \end{macrocode}
17947 % \end{macro}
17948 %
17949 % \begin{macro}{\@makesubfloatcaption}
17950 % This is a copy of \cs{@makesubfigurecaption}.
17951 % \changes{v3.6k}{2011/07/21}{Added a \cs{unskip} to remove a space if
17952 % the text is empty}
17953 % \begin{macrocode}
17954 \newcommand{\@makesubfloatcaption}[2]{%
17955 \setbox\@tempboxa\hbox{%
17956 \@subcapsize
17957 {\@subcaplabelfont #1}{\@subcapfont\ignorespaces #2}\unskip}%
17958 \@tempdimb=-\subfloatcapmargin
17959 \multiply\@tempdimb\tw@
17960 \advance\@tempdimb\@tempdima
17961 \hb@xt@\@tempdima{%
17962 \hss
17963 \ifdim \wd\@tempboxa >\@tempdimb
17964 \memsubfig@caption{#1}{#2}%
17965 \else
17966 \if@shortsubcap
17967 \memsubfig@caption{#1}{#2}%
17968 \else
17969 \box\@tempboxa
17970 \fi
17971 \fi
17972 \hss}}
17973
17974 % \end{macrocode}
17975 % \end{macro}
17976 %
17977 % \begin{macro}{\memsubfig@caption}
17978 % This is a copy of \cs{subfig@caption}.
17979 % \changes{v3.6k}{2011/07/21}{Added a \cs{unskip} to remove a space if
17980 % the text is empty}
17981 % \begin{macrocode}
17982 \newcommand{\memsubfig@caption}[2]{%
17983 \if@hangsubcap
17984 \sbox{\@tempboxa}{\@subcapsize\@subcaplabelfont #1}%
17985 \addtolength{\@tempdimb}{-\wd\@tempboxa}%
17986 \usebox{\@tempboxa}%
17987 \memsubfig@captionpar{\@tempdimb}{%
17988 {\@subcapfont\ignorespaces #2}\unskip}%
17989 \else
17990 \memsubfig@captionpar{\@tempdimb}{{\@subcaplabelfont #1}%
17991 {\@subcapfont\ignorespaces #2}\unskip}%
17992 \fi}
17993
17994 % \end{macrocode}
17995 % \end{macro}
17996 %
17997 % \begin{macro}{\memsubfig@captionpar}
17998 % This replaces \cs{subfig@captionpar}.
17999 % \begin{macrocode}
18000 \newcommand{\memsubfig@captionpar}[2]{%
18001 \parbox[t]{#1}{\@subcapsize\@contsubcstyle #2}}
18002
18003 % \end{macrocode}
18004 % \end{macro}
18005 %
18006 % \begin{macro}{\memsub@label}
18007 % Basically we want a \cmd{\label} inside the caption to set
18008 % \emph{two} labels with different values of
18009 % \cmd{\@currentlabel}. First locally \cmd{\label} is set to
18010 % \cmd{\mem@sublabel} defined as
18011 % \changes{v3.8.4}{2025/09/22}{No longer needed due to reimplementation}
18012 % \begin{macrocode}
18013 % \newcommand{\memsub@label}{%
18014 % \@ifnextchar (%
18015 % {\sf@memsub@label}%
18016 % {\sf@memsub@label(Sub\@captype\space
18017 % \@nameuse{p@sub\@captype}%
18018 % \@nameuse{thesub\@captype})}}
18019 % \end{macrocode}
18020 % \end{macro}
18021 %
18022 % As of summer 2023 we are autoloading \Lpack{nameref}, thus the code
18023 % for \cmd{\sf@@memsub@label} can be greatly reduced plus we can use
18024 % the \cmd{\label} that has the \Lpack{nameref} extensions, then we
18025 % don't have to look out for changes in say \Lpack{hyperref} etc.
18026 %
18027 % \begin{macro}{\sf@memsub@label}
18028 % \changes{v3.8}{2023/07/31}{Set \cs{@currentlabelname} directly
18029 % instad of using \cs{mem@currentlabelname}}
18030 % \changes{v3.8.4}{2025/09/22}{No longer needed due to reimplementation}
18031 % \begin{macrocode}
18032 % \def\sf@memsub@label(#1)#2{%
18033 % \protected@edef\@currentlabelname{#1}%
18034 % % if available we can also use % \ExpandArgs{x}\mem@set@cln{#1}
18035 % \sf@@memsub@label{#2}}
18036
18037 % \end{macrocode}
18038 % \end{macro}
18039 %
18040 % \begin{macro}{\sf@@memsub@label}
18041 % \changes{v3.8}{2023/07/31}{reimplemented}
18042 % This sets two labels, the user given one an one prefixed by
18043 % \verb?sub@?. The difference between them is the value of
18044 % \cmd{\@currentlabel}. For the latter we will aditionally locally
18045 % disable showkeys.
18046 %
18047 % First we'd like to have a copy of the ``kernel'' \cmd{\label}
18048 % command. Packages may have added stuff to make a copy at begin doc.
18049 % \begin{macro}{\mem@kernel@label}
18050 % \changes{v3.8.4}{2025/09/22}{No longer needed due to reimplementation}
18051 % \begin{macrocode}
18052 % \AtBeginDocument{
18053 % \let\mem@kernel@label\label
18054 % }
18055
18056 % \end{macrocode}
18057 % Next we define the macro it self in terms of this
18058 % \changes{v3.8.4}{2025/09/22}{No longer needed due to reimplementation}
18059 % \begin{macrocode}
18060 % \newcommand\sf@@memsub@label[1]{%
18061 % \@bsphack%
18062 % \mem@kernel@label{#1}% normal label
18063 % \end{macrocode}
18064 % Next locally redefine \cmd{\@currentlabel} so the next label only
18065 % gets the sub number. TODO: make the format
18066 % configurable. Additionally disable showkeys for this extra
18067 % label. This way we do not need a hook into the construction to
18068 % support \Lpack{showkeys} that just comes from the normal \cmd{\label}.
18069 % \begin{macrocode}
18070 % \begingroup%
18071 % % \ExpandArgs{x}\mem@set@cln{\@nameuse{@@thesub\@captype}}
18072 % \protected@edef\@currentlabel{\@nameuse{@@thesub\@captype}}% sub@label
18073 % \def\showkeyslabelformat##1{}% disable showkeys for this extra label
18074 % \mem@kernel@label{sub@#1}% internally generated sub@label
18075 % \endgroup%
18076 % \@esphack%
18077 % }
18078
18079 % \end{macrocode}
18080 % \end{macro}
18081 % \end{macro}
18082 %
18083 % \begin{macro}{\subcaptionref}
18084 % This is a copy of the \cs{subref} macro.
18085 % \begin{macrocode}
18086 \DeclareRobustCommand{\subcaptionref}{%
18087 \@ifstar{\ssc@ref}{\sc@ref}}
18088 % \end{macrocode}
18089 % \end{macro}
18090 %
18091 % \begin{macro}{\ssc@ref}
18092 % \begin{macro}{\sc@ref}
18093 % The implementation of the starred and unstarred forms of \cs{subcaptionref}.
18094 % \begin{macrocode}
18095 \newcommand*{\ssc@ref}[1]{\ref{sub@#1}}
18096 \newcommand*{\sc@ref}[1]{{\@subcaplabelfont\ref{sub@#1}}}
18097
18098 % \end{macrocode}
18099 % \end{macro}
18100 % \end{macro}
18101 %
18102 % \subsubsection{Side captions}
18103 % \changes{v1.61803}{2008/01/30}{Added all the code for side captions
18104 % (mempatch v4.1)}
18105 %
18106 % \begin{macro}{\m@mscap@capbox}
18107 % \begin{macro}{\m@mscap@fbox}
18108 % We need two save boxes, one to hold the caption and the other
18109 % for the float material.
18110 % \begin{macrocode}
18111 \newsavebox{\m@mscap@capbox}
18112 \newsavebox{\m@mscap@fbox}
18113
18114 % \end{macrocode}
18115 % \end{macro}
18116 % \end{macro}
18117 %
18118 % \begin{macro}{\sidecapsep}
18119 % \begin{macro}{\sidecapwidth}
18120 % \cs{sidecapsep} is the space between the text and the caption, which
18121 % is set in a box \cs{sidecapwidth} wide. These are initialized to
18122 % the \cs{marginpar...} values.
18123 % \begin{macrocode}
18124 \newdimen\sidecapsep
18125 \sidecapsep=\marginparsep
18126 \newdimen\sidecapwidth
18127 \sidecapwidth=\marginparwidth
18128 % \end{macrocode}
18129 % \end{macro}
18130 % \end{macro}
18131 %
18132 % \begin{macro}{\setsidecaps}
18133 % \cs{setsidecaps}\marg{sep}\marg{width} sets the \cs{sidecapsep} and
18134 % \cs{sidecapwidth} (Ivars Finvers noted that the initial values don't change
18135 % if the \cs{marginpar...} values change, such as at \cs{checkandfixthelayout}).
18136 % \changes{v1.61803}{2008/01/30}{Added \cs{setsidecaps} (mempatch v4.6)}
18137 % \begin{macrocode}
18138 \newcommand*{\setsidecaps}[2]{%
18139 \setlength{\sidecapsep}{#1}\@memznegtest{\sidecapsep}%
18140 \setlength{\sidecapwidth}{#2}\@memznegtest{\sidecapwidth}}
18141
18142 % \end{macrocode}
18143 % \end{macro}
18144 %
18145 % \begin{macro}{\m@m@tempdima}
18146 % \begin{macro}{\m@mscapraise}
18147 % Lengths for internal use. \cs{m@m@tempdima} is meant for general
18148 % temporary use.
18149 % \begin{macrocode}
18150 \newdimen\m@m@tempdima
18151 \newdimen\m@mscapraise
18152 % \end{macrocode}
18153 % \end{macro}
18154 % \end{macro}
18155 %
18156 % \begin{macro}{\sidecapraise}
18157 % Length to make (small) adjustments to the position of the caption wrt the float.
18158 % \begin{macrocode}
18159 \newdimen\sidecapraise
18160 \sidecapraise \z@
18161
18162 % \end{macrocode}
18163 % \end{macro}
18164 %
18165 % \begin{macro}{\setsidecappos}
18166 % \begin{macro}{\m@mscappos}
18167 % \cs{setsidecappos}\marg{pos}, where \meta{pos} is one of \texttt{t},
18168 % \texttt{c}, or \texttt{b}, sets the vertical position of the caption
18169 % in relation to the float and the result is saved as \cs{m@mscappos}.
18170 % The default is \texttt{c}.
18171 % \begin{macrocode}
18172 \newcommand*{\setsidecappos}[1]{%
18173 \def\m@mscappos{#1}\def\@tempb{t}%
18174 \ifx\@tempb\m@mscappos
18175 \else
18176 \def\@tempb{b}%
18177 \ifx\@tempb\m@mscappos
18178 \else
18179 \def\@tempb{c}%
18180 \ifx\@tempb\m@mscappos
18181 \else
18182 \@memerror{Argument to \string\setsidecappos\space is not t or c or b.
18183 \MessageBreak Set to c}{\@ehc}%
18184 \def\m@mscappos{c}%
18185 \fi
18186 \fi
18187 \fi}
18188 \setsidecappos{c}
18189
18190 % \end{macrocode}
18191 % \end{macro}
18192 % \end{macro}
18193 %
18194 % \begin{macro}{\sidecapmargin}
18195 % \begin{macro}{\m@mscapmarg}
18196 % \cs{sidecapmargin}\marg{margin}, where \meta{marg} is one of
18197 % \texttt{left}, \texttt{right}, \texttt{inner}, or \texttt{outer},
18198 % controls the margin where the caption will be put. The result
18199 % is saved as \cs{m@mscapmarg} as a number. The default
18200 % is \texttt{left}.
18201 % \begin{macrocode}
18202 \newcommand{\sidecapmargin}[1]{%
18203 \def\@tempa{#1}\def\@tempb{left}%
18204 \ifx\@tempb\@tempa
18205 \def\m@mscapmarg{0}% left
18206 \else
18207 \def\@tempb{right}%
18208 \ifx\@tempb\@tempa
18209 \def\m@mscapmarg{1}% right
18210 \else
18211 \def\@tempb{outer}%
18212 \ifx\@tempb\@tempa
18213 \def\m@mscapmarg{2}% outer
18214 \else
18215 \def\@tempb{inner}%
18216 \ifx\@tempb\@tempa
18217 \def\m@mscapmarg{3}% inner
18218 \else
18219 \@memerror{Unrecognized argument for \string\sidecapmargin}%
18220 {\@ehc}%
18221 \def\m@mscapmarg{-1}% error
18222 \fi
18223 \fi
18224 \fi
18225 \fi}
18226 \sidecapmargin{left}
18227
18228 % \end{macrocode}
18229 % \end{macro}
18230 % \end{macro}
18231 %
18232 % \begin{macro}{\ifscapmargleft}
18233 % \begin{macro}{\scapmarglefttrue}
18234 % \begin{macro}{\scapmargleftfalse}
18235 % \cs{ifscapmargleft} is TRUE the caption should be in the left hand margin,
18236 % otherwise in the right hand margin.
18237 % \begin{macrocode}
18238 \newif\ifscapmargleft
18239
18240 % \end{macrocode}
18241 % \end{macro}
18242 % \end{macro}
18243 % \end{macro}
18244 %
18245 % \begin{macro}{\sidecapfloatwidth}
18246 % \begin{macro}{\m@mscapmainwidth}
18247 % \cs{sidecapfloatwidth} is the width of the box holding the float.
18248 % Note that this is a macro,
18249 % not a length, so must be changed using \cs{renewcommand*}.
18250 % The default is \cs{linewidth}. Later, \cs{m@mscapmainwidth} will be set
18251 % to the current length specification from \cs{sidecapfloatwidth}.
18252 % \begin{macrocode}
18253 \def\sidecapfloatwidth{\linewidth}
18254 \newdimen\m@mscapmainwidth
18255
18256 % \end{macrocode}
18257 % \end{macro}
18258 % \end{macro}
18259 %
18260 % \begin{macro}{\m@mscaplkern}
18261 % \begin{macro}{\setm@mscaplkern}
18262 % \cs{setm@mscaplkern} is a utility macro to calculate the kern
18263 % (\cs{m@mscaplkern}) required when the caption is in the left margin.
18264 % \begin{macrocode}
18265 \newdimen\m@mscaplkern
18266 \newcommand*{\setm@mscaplkern}{%
18267 \m@mscaplkern=\sidecapwidth
18268 \advance\m@mscaplkern \sidecapsep
18269 \advance\m@mscaplkern \m@mscapmainwidth}
18270
18271 % \end{macrocode}
18272 % \end{macro}
18273 % \end{macro}
18274 %
18275 % \begin{macro}{\sidecapstyle}
18276 % \cs{sidecapstyle} is called just before the caption is set. It can
18277 % be redefined to set different caption style parameters. The default
18278 % is raggedleft for left margin captions and raggedright for right
18279 % margin captions.
18280 % \begin{macrocode}
18281 \newcommand*{\sidecapstyle}{%
18282 \ifscapmargleft
18283 \captionstyle{\raggedleft}%
18284 \else
18285 \captionstyle{\raggedright}%
18286 \fi}
18287
18288 % \end{macrocode}
18289 % \end{macro}
18290 %
18291 % \begin{macro}{\sidecaption}
18292 % The whole shebang is in the \texttt{sidecaption} environment but
18293 % it is more convenient to specify this via macros rather than
18294 % directly as an environment.
18295 %
18296 % \cs{sidecaption}\oarg{fortoc}\marg{title}\oarg{label} is what it
18297 % looks like to the user, but internally further macros handle
18298 % all the arguments.
18299 % \begin{macrocode}
18300 \newcommand*{\sidecaption}{%
18301 \@ifnextchar [{\@sidecaption}{\@sidecaption[]}}
18302 % \end{macrocode}
18303 % \end{macro}
18304 %
18305 % \begin{macro}{\@sidecaption}
18306 % \cs{@sidecaption}\oarg{fortoc}\marg{title} grabs the first
18307 % two arguments.
18308 % \begin{macrocode}
18309 \def\@sidecaption[#1]#2{%
18310 \@ifnextchar [{\@@sidecaption{#1}{#2}}{\@@sidecaption{#1}{#2}[]}}
18311 % \end{macrocode}
18312 % \end{macro}
18313 %
18314 % \begin{macro}{\@mem@scap@beforehook}
18315 % \begin{macro}{\@mem@scap@afterhook}
18316 % Two hooks into the 'scap' internals. By default they do nothing, but
18317 % can be used make say sidecaption align towards the spine in twosided
18318 % documents. This is done by redefining \emph{before} to
18319 % \verb+\checkoddpage\ifoddpage\else\raggedleft\fi+ and redefining
18320 % \emph{after} to \verb+\par+. Note that since 'sidecontcaption',
18321 % 'sidenamedlegend' and 'sidelegend' all share the same basic
18322 % internals redefining the two hooks will affect those as well. The
18323 % user might want to create their own special environment, say, like this:
18324 % \begin{verbatim}
18325 % \makeatletter
18326 % \newenvironment{sidecaption*}{
18327 % \renewcommand\@mem@scap@beforehook{\checkoddpage\ifoddpage\else\raggedleft\fi}
18328 % \renewcommand\@mem@scap@afterhook{\par}
18329 % \begin{sidecaption}}
18330 % {\end{sidecaption}}
18331 % \makeatother
18332 % \end{verbatim}
18333 % \changes{v1.6180339c}{2009/01/21}{Added 'before' and 'after' hooks
18334 % to shared sidecaption internals}
18335 % \begin{macrocode}
18336 \newcommand\@mem@scap@beforehook{}
18337 \newcommand\@mem@scap@afterhook{}
18338
18339 % \end{macrocode}
18340 % \end{macro}
18341 % \end{macro}
18342 %
18343 % \begin{macro}{\@@sidecaption}
18344 % \cs{@@sidecaption}\marg{fortoc}\marg{title}\oarg{label} is the
18345 % last macro in the chain and handles all three arguments.
18346 % This does all the work for \verb?\begin{sidecaption}?
18347 % \begin{macro}{\m@mscap@fortoc}
18348 % \begin{macro}{\m@mscap@forcap}
18349 % \begin{macro}{\m@mscaplabel}
18350 % First, save all the arguments as macros.
18351 % \begin{macrocode}
18352 \def\@@sidecaption#1#2[#3]{%
18353 \ifx\@empty#1\@empty
18354 \def\m@mscap@fortoc{#2}%
18355 \else
18356 \def\m@mscap@fortoc{#1}%
18357 \fi
18358 \def\m@mscap@forcap{#2}%
18359 \ifx\@empty#3\@empty
18360 \def\m@mscaplabel{}%
18361 \else
18362 \def\m@mscaplabel{\@bsphack\label{#3}\@esphack}%
18363 \fi
18364 % \end{macrocode}
18365 % \end{macro}
18366 % \end{macro}
18367 % \end{macro}
18368 % Set the float width, calculate the left margin kern, and start
18369 % a \texttt{minipage} to hold the float, saving it in box
18370 % \cs{m@mscap@fbox}.
18371 % \begin{macrocode}
18372 \m@mscapstart@fbox}
18373
18374 % \end{macrocode}
18375 % \end{macro}
18376 %
18377 % \begin{macro}{\m@mscapstart@fbox}
18378 % \begin{macro}{\m@mscapend@fbox}
18379 % \cs{m@mscapstart@fbox} is the macro that actually sets the float width,
18380 % calculates the left margin kern, and starts the float's \texttt{minipage}.
18381 % The macro \cs{m@mscapend@fbox} ends the box.
18382 % \begin{macrocode}
18383 \newcommand*{\m@mscapstart@fbox}{%
18384 % \end{macrocode}
18385 % \changes{v1.6180339c}{2009/01/21}{Added \cs{@mem@scap@beforehook}}
18386 % \begin{macrocode}
18387 \@mem@scap@beforehook%
18388 \setlength{\m@mscapmainwidth}{\sidecapfloatwidth}%
18389 \setm@mscaplkern
18390 \begin{lrbox}{\m@mscap@fbox}%
18391 \begin{minipage}[c]{\m@mscapmainwidth}}
18392 \newcommand*{\m@mscapend@fbox}{%
18393 \end{minipage}%
18394 \end{lrbox}}
18395
18396 % \end{macrocode}
18397 % \end{macro}
18398 % \end{macro}
18399 %
18400 % \begin{macro}{\endsidecaption}
18401 % \begin{macro}{\endsidecaption@refstepcounter}
18402 % \cs{endsidecaption} does the work for
18403 % \verb?\end{sidecaption}?.
18404
18405 % First we define a helper macro that others can hook into. Here is
18406 % the default definition. The two arguments are either two copies of
18407 % \cs{@captype} or for the cont version, \cs{@captype} and
18408 % \texttt{memhycontfloat}. Then this macro is redefined whenever
18409 % \Lpack{hyperref} is loaded (via \Lpack{memhfixc}). The addition
18410 % eliminates the need for a full macro redef in \Lpack{memhfixc}.
18411 % \changes{v3.8.2}{2023/09/10}{Added macro at the suggestion of Axel Sommerfelt}
18412 % \begin{macrocode}
18413 \newcommand*\sidecaption@refstepcounter[2]{\refstepcounter{#1}}
18414 % \end{macrocode}
18415 %
18416 % Finish the float minipage, then increment the caption counter and
18417 % call \cs{label} via \cs{m@mscaplabel}.
18418 % \begin{macrocode}
18419 \def\endsidecaption{%
18420 \m@mscapend@fbox
18421 % \end{macrocode}
18422 % % \changes{v3.8.2}{2023/09/10}{Added macro call at the suggestion of Axel Sommerfelt}
18423 % \begin{macrocode}
18424 \sidecaption@refstepcounter\@captype\@captype
18425 \m@mscaplabel
18426 % \end{macrocode}
18427 % \changes{v3.6k}{2012/08/19}{We need to move \cs{m@mscapcheckside}
18428 % here or the \cs{sidecapstyle} inside the box, will never work correctly.}
18429 % \begin{macrocode}
18430 \m@mscapcheckside%
18431 % \end{macrocode}
18432 % Set the caption inside a minipage, saving it in box \cs{m@mscap@capbox}.
18433 % \begin{macrocode}
18434 \begin{lrbox}{\m@mscap@capbox}%
18435 \begin{minipage}[c]{\sidecapwidth}%
18436 \sidecapstyle
18437 \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
18438 \end{minipage}%
18439 \end{lrbox}%
18440 % \end{macrocode}
18441 % Output the float and caption.
18442 % \begin{macrocode}
18443 \m@mscapopboxes}
18444 % \end{macrocode}
18445 % \end{macro}
18446 % \end{macro}
18447 %
18448 % \begin{macro}{\m@mscapopboxes}
18449 % Having determined how high the caption box must be raised with
18450 % respect to the float box, output the boxes.
18451 % \begin{macrocode}
18452 \newcommand*{\m@mscapopboxes}{%
18453 \m@mcalcscapraise
18454 % \end{macrocode}
18455 % Set the float (from box \cs{m@mscap@fbox}) then the caption (from
18456 % box \cs{m@mscap@capbox}) kerning it to the left or right as
18457 % appropriate.
18458 % \changes{v3.6k}{2012/08/19}{Moved \cs{m@mscapcheckside} into
18459 % \cs{endsidecaption}, otherwise \cs{sidecapstyle} never see the side check}
18460 % \begin{macrocode}
18461 \usebox{\m@mscap@fbox}%\m@mscapcheckside
18462 \ifscapmargleft%
18463 \rlap{\kern-\m@mscaplkern
18464 \raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
18465 \else%
18466 \rlap{\kern\sidecapsep
18467 \raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
18468 \fi
18469 % \end{macrocode}
18470 % Finally, make \cs{m@mscapthisside} a no-op.
18471 % \begin{macrocode}
18472 \gdef\m@mscapthisside{}%
18473 % \end{macrocode}
18474 % \changes{v1.6180339c}{2009/01/21}{Added \cs{@mem@scap@afterhook}}
18475 % \begin{macrocode}
18476 \@mem@scap@afterhook%
18477 }
18478
18479 % \end{macrocode}
18480 % \end{macro}
18481 %
18482 % \begin{macro}{\m@mcalcscapraise}
18483 % Calculate the amount the caption might have to be raised wrt the
18484 % float. This depends on the position: \\
18485 % \texttt{t:} raise by the difference in heights \\
18486 % \texttt{c:} shouldn't have to do anything as the minipages are meant
18487 % to center aligned \\
18488 % \texttt{b:} lower by the difference in depths \\
18489 %
18490 % However, experiments showed that a little bit of tweaking might
18491 % help. The final adjustment, \cs{sidecapraise} is controlled by
18492 % the user.
18493 % \begin{macrocode}
18494 \newcommand*{\m@mcalcscapraise}{%
18495 \def\@tempb{t}%
18496 \ifx\m@mscappos\@tempb
18497 \settoheight{\m@m@tempdima}{\strut\usebox{\m@mscap@capbox}}%
18498 \settoheight{\m@mscapraise}{\usebox{\m@mscap@fbox}}%
18499 \advance\m@mscapraise -\m@m@tempdima
18500 \advance\m@mscapraise 0.5ex
18501 \else
18502 \def\@tempb{b}%
18503 \ifx\m@mscappos\@tempb
18504 \settodepth{\m@m@tempdima}{\usebox{\m@mscap@fbox}}%
18505 \settodepth{\m@mscapraise}{\strut\usebox{\m@mscap@capbox}}%
18506 \advance\m@mscapraise -\m@m@tempdima
18507 \else
18508 \m@mscapraise=\z@
18509 \advance\m@mscapraise 0.25ex
18510 \fi
18511 \fi
18512 \advance\m@mscapraise \sidecapraise}
18513
18514 % \end{macrocode}
18515 % \end{macro}
18516 %
18517 % \begin{macro}{\m@mscapcheckside}
18518 % This macro determines whether the caption should be set in the
18519 % left or right margin. In twocolumn documents the caption for a single
18520 % column float is always set in the adjacent margin. Starred floats
18521 % are treated as regular floats as in a onecolumn document.
18522 % \begin{macrocode}
18523 \newcommand*{\m@mscapcheckside}{%
18524 \if@twocolumn
18525 \ifdim\hsize=\textwidth% float*
18526 \m@mscapcheckregside
18527 \else
18528 \if@firstcolumn
18529 \scapmarglefttrue
18530 \else
18531 \scapmargleftfalse
18532 \fi
18533 \fi
18534 \else
18535 \m@mscapcheckregside
18536 \fi
18537 % \end{macrocode}
18538 % Finally apply any user's override.
18539 % \begin{macrocode}
18540 \m@mscapthisside}
18541 % \end{macrocode}
18542 % \end{macro}
18543 %
18544 % \begin{macro}{\m@mscapcheckregside}
18545 % This performs the margin calculation for onecolumn documents.
18546 % \begin{macrocode}
18547 \newcommand*{\m@mscapcheckregside}{%
18548 \if@twoside
18549 \checkoddpage
18550 \ifnum\m@mscapmarg<\@ne% % left
18551 \scapmarglefttrue
18552 \else
18553 \ifnum\m@mscapmarg=\@ne% % right
18554 \scapmargleftfalse
18555 \else
18556 \ifnum\m@mscapmarg=\tw@% % outer
18557 \scapmarglefttrue
18558 \ifoddpage
18559 \scapmargleftfalse
18560 \fi
18561 \else% % inner
18562 \scapmargleftfalse
18563 \ifoddpage
18564 \scapmarglefttrue
18565 \fi
18566 \fi
18567 \fi
18568 \fi
18569 \else% oneside
18570 % \end{macrocode}
18571 % In oneside documents, inner and outer is the same as left and right.
18572 % \changes{v3.7f}{2015/08/10}{Side caption placement bugfix for
18573 % onesided docs. Related to \protect\url{http://tex.stackexchange.com/q/259324/3929}.
18574 % }
18575 % \begin{macrocode}
18576 % \scapmarglefttrue% 0 and 3
18577 % \ifnum\m@mscapmarg>\@ne
18578 % \ifnum\m@mscapmarg<\thr@@
18579 % \scapmargleftfalse
18580 % \fi
18581 % \fi
18582 \ifcase\m@mscapmarg\relax% 0
18583 \scapmarglefttrue%
18584 \or% 1
18585 \scapmargleftfalse%
18586 \or% 2
18587 \scapmargleftfalse%
18588 \or% 3
18589 \scapmarglefttrue%
18590 \fi%
18591 \fi}
18592
18593 % \end{macrocode}
18594 % \end{macro}
18595 %
18596 % \begin{macro}{\overridescapmargin}
18597 % \begin{macro}{\m@mscapthisside}
18598 % User macro to override the calculated caption margin. Call as either:\\
18599 % \verb?\overridescapmargin{left}? or \verb?\overridescapmargin{right}? \\
18600 % \begin{macrocode}
18601 \newcommand*{\overridescapmargin}[1]{%
18602 \def\@tempb{#1}\def\@tempa{left}%
18603 \ifx\@tempa\@tempb
18604 \def\m@mscapthisside{\scapmarglefttrue}%
18605 \else
18606 \def\@tempa{right}%
18607 \ifx\@tempa\@tempb
18608 \def\m@mscapthisside{\scapmargleftfalse}%
18609 \else
18610 \@memerror{Argument to \string\overridescapmargin\space neither
18611 left nor right}{\@ehc}%
18612 \def\m@mscapthisside{}%
18613 \fi
18614 \fi}
18615 \newcommand*{\m@mscapthisside}{}
18616
18617 % \end{macrocode}
18618 % \end{macro}
18619 % \end{macro}
18620 %
18621 % Now for the other kinds of captions.
18622 %
18623 % \begin{macro}{\sidecontcaption}
18624 % \cs{sidecontcaption}\marg{title}\oarg{label} is for
18625 % a continuation sidecaption.
18626 % \begin{macrocode}
18627 \newcommand*{\sidecontcaption}{%
18628 \@sidecontcaption}
18629 % \end{macrocode}
18630 % \end{macro}
18631 %
18632 % \begin{macro}{\@sidecontcaption}
18633 % \cs{@sidecontcaption}\marg{title} grabs the first
18634 % argument.
18635 % \begin{macrocode}
18636 \def\@sidecontcaption#1{%
18637 \@ifnextchar [{\@@sidecontcaption{#1}}{\@@sidecontcaption{#1}[]}}
18638 % \end{macrocode}
18639 % \end{macro}
18640 %
18641 % \begin{macro}{\@@sidecontcaption}
18642 % \cs{@@sidecontcaption}\marg{title}\oarg{label} is the
18643 % last macro in the chain and handles all two arguments.
18644 % This does all the work for \verb?\begin{sidecontcaption}?
18645 % \begin{macrocode}
18646 \def\@@sidecontcaption#1[#2]{%
18647 \def\m@mscap@forcap{#1}%
18648 \ifx\@empty#2\@empty
18649 \def\m@mscaplabel{}%
18650 \else
18651 \def\m@mscaplabel{\@bsphack\label{#2}\@esphack}%
18652 \fi
18653 \m@mscapstart@fbox}
18654
18655 % \end{macrocode}
18656 % \end{macro}
18657 %
18658 % \begin{macro}{\endsidecontcaption}
18659 % \cs{endsidecontcaption} does the work for \verb?\end{sidecontcaption}?.
18660 %
18661 % \begin{macrocode}
18662 \def\endsidecontcaption{%
18663 \m@mscapend@fbox
18664 \addtocounter{\@captype}{\m@ne}
18665 % \end{macrocode}
18666 % \changes{3.8.2}{2023/09/10}{factor refstep counter as in \cs{endsidecaption}}
18667 % \begin{macrocode}
18668 \sidecaption@refstepcounter\@captype{memhycontfloat}
18669 %\refstepcounter\@captype
18670 \m@mscaplabel
18671 % \end{macrocode}
18672 % \changes{v3.7b}{2013/05/30}{Forgot the side check}
18673 % \begin{macrocode}
18674 \m@mscapcheckside %<--- added 2013/05/30
18675 \begin{lrbox}{\m@mscap@capbox}%
18676 \begin{minipage}[c]{\sidecapwidth}%
18677 \sidecapstyle
18678 \@contcaption\@captype{\m@mscap@forcap}
18679 \end{minipage}%
18680 \end{lrbox}%
18681 \m@mscapopboxes}
18682
18683 % \end{macrocode}
18684 % \end{macro}
18685 %
18686 %
18687 % \begin{macro}{\sidenamedlegend}
18688 % \begin{macro}{\@sidenamedlegend}
18689 % \cs{sidenamedlegend}\oarg{fortoc}\marg{title} is for
18690 % a namedlegend sidecaption.
18691 % \begin{macrocode}
18692 \newcommand*{\sidenamedlegend}{%
18693 \@ifnextchar [{\@sidenamedlegend}{\@sidenamedlegend[]}}
18694 \def\@sidenamedlegend[#1]#2{%
18695 \@@sidenamedlegend{#1}{#2}}
18696 % \end{macrocode}
18697 % \end{macro}
18698 % \end{macro}
18699 %
18700 % \begin{macro}{\@@sidenamedlegend}
18701 % \cs{@@sidenamedlegend}\marg{fortoc}\marg{title} is the
18702 % last macro in the chain and handles all arguments.
18703 % This does all the work for \verb?\begin{sidenamedlegend}?
18704 % \begin{macrocode}
18705 \def\@@sidenamedlegend#1#2{%
18706 \ifx\@empty#1\@empty
18707 \def\m@mscap@fortoc{#2}%
18708 \else
18709 \def\m@mscap@fortoc{#1}%
18710 \fi
18711 \def\m@mscap@forcap{#2}%
18712 \def\m@mscaplabel{}%
18713 \m@mscapstart@fbox}
18714
18715 % \end{macrocode}
18716 % \end{macro}
18717 %
18718 % \begin{macro}{\endsidenamedlegend}
18719 % \cs{endsidenamedlegend} does the work for \verb?\end{sidenamedlegend}?.
18720 % \begin{macrocode}
18721 \def\endsidenamedlegend{%
18722 \m@mscapend@fbox
18723 \begin{lrbox}{\m@mscap@capbox}%
18724 \begin{minipage}[c]{\sidecapwidth}%
18725 \sidecapstyle
18726 \@legend\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
18727 \end{minipage}%
18728 \end{lrbox}%
18729 \m@mscapopboxes}
18730
18731 % \end{macrocode}
18732 % \end{macro}
18733 %
18734 %
18735 % \begin{macro}{\sidelegend}
18736 % \cs{sidelegend}\marg{title} is for
18737 % a legend sidecaption.
18738 % \begin{macrocode}
18739 \newcommand*{\sidelegend}{%
18740 \@@sidelegend}
18741 % \end{macrocode}
18742 % \end{macro}
18743 %
18744 % \begin{macro}{\@@sidelegend}
18745 % \cs{@@sidelegend}\marg{title} is the
18746 % last macro in the chain and handles all arguments.
18747 % This does all the work for \verb?\begin{sidelegend}?
18748 % \begin{macrocode}
18749 \def\@@sidelegend#1{%
18750 \def\m@mscap@forcap{#1}%
18751 \m@mscapstart@fbox}
18752
18753 % \end{macrocode}
18754 % \end{macro}
18755 %
18756 % \begin{macro}{\endsidelegend}
18757 % \cs{endsidelegend} does the work for \verb?\end{sidelegend}?.
18758 % \begin{macrocode}
18759 \def\endsidelegend{%
18760 \m@mscapend@fbox
18761 \begin{lrbox}{\m@mscap@capbox}%
18762 \begin{minipage}[c]{\sidecapwidth}%
18763 \sidecapstyle
18764 \legend{\m@mscap@forcap}
18765 \end{minipage}%
18766 \end{lrbox}%
18767 \m@mscapopboxes}
18768
18769 % \end{macrocode}
18770 % \end{macro}
18771 %
18772 % \changes{v3.6k}{2013/015/13}{Added \Lpack{longtable} caption
18773 % support}
18774 %
18775 % \subsubsection{Handling \Lpack{longtable} captions}
18776 %
18777 % In \Lpack{longtable} the caption ends up as a special row in the
18778 % table. In order to use our caption formatting we need to redefine
18779 % \cs{LT@makecaption} to use our formatting macro plus
18780 % \cs{belowcaptionskip}. It needs to be
18781 % done after \Lpack{longtable} is loaded, and \emph{not} if the
18782 % \Lpack{ltcaption} package is loaded. The later is used by the
18783 % \Lpack{caption} package to aid caption formatting i
18784 % \Lpack{longtable}. Special thanks to Axel Sommerfelt.
18785 % \begin{macro}{\LT@makecaption}
18786 % \begin{macrocode}
18787 \AtBeginDocument{
18788 \@ifpackageloaded{longtable}{
18789 \@ifpackageloaded{ltcaption}{}{%
18790 \def\LT@makecaption#1#2#3{%
18791 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
18792 \let\@memtempa\relax%
18793 % starred form -> #1 = \@gobble
18794 \ifx#1\@gobble%
18795 \let\@contnfont\@empty%
18796 \let\@contdelim\@empty%
18797 \@@makecaption{}{#3}%
18798 \else%
18799 \@@makecaption{#2}{#3}%
18800 \fi%
18801 \endgraf\vskip\belowcaptionskip}%
18802 \hss}}}
18803 }
18804 }{}
18805 }
18806 % \end{macrocode}
18807 % At a later point, we will supplement with a \cs{legend} for
18808 % \Lpack{longtable} as well.
18809 % \end{macro}
18810 %
18811 % \section{Epigraphs}
18812 %
18813 % This code comes from the \Lpack{epigraph} package~\cite{EPIGRAPH}.
18814 %
18815 % \begin{macro}{\beforeepigraphskip}
18816 % \begin{macro}{\afterepigraphskip}
18817 % \begin{macro}{\epigraphwidth}
18818 % \begin{macro}{\epigraphrule}
18819 % The several length commands, which can be changed by the user with
18820 % \cs{setlength}.
18821 % \begin{macrocode}
18822 \newlength{\beforeepigraphskip}
18823 \setlength{\beforeepigraphskip}{.5\baselineskip}
18824 \newlength{\afterepigraphskip}
18825 \setlength{\afterepigraphskip}{.5\baselineskip}
18826 \newlength{\epigraphwidth}
18827 \setlength{\epigraphwidth}{.4\textwidth}
18828 \newlength{\epigraphrule}
18829 \setlength{\epigraphrule}{.4\p@}
18830 % \end{macrocode}
18831 % \end{macro}
18832 % \end{macro}
18833 % \end{macro}
18834 % \end{macro}
18835 %
18836 % \begin{macro}{\epigraphsize}
18837 % The size of the font to be used.
18838 % \begin{macrocode}
18839 \newcommand{\epigraphsize}{\small}
18840 % \end{macrocode}
18841 % \end{macro}
18842 %
18843 % \begin{macro}{\epigraphflush}
18844 % \begin{macro}{\textflush}
18845 % \begin{macro}{\sourceflush}
18846 % The three commands to position epigraphs in the textblock and to position
18847 % the components of the epigraph.
18848 % \begin{macrocode}
18849 \newcommand{\epigraphflush}{flushright}
18850 \newcommand{\textflush}{flushleft}
18851 \newcommand{\sourceflush}{flushright}
18852 % \end{macrocode}
18853 % \end{macro}
18854 % \end{macro}
18855 % \end{macro}
18856 %
18857 % \begin{macro}{\epigraphfontsize}
18858 % \begin{macro}{\epigraphposition}
18859 % \begin{macro}{\epigraphtextposition}
18860 % \begin{macro}{\epigraphsourceposition}
18861 % These are declarative forms of the above. It's a bit late now, but
18862 % the previous macros should have been internal.
18863 % \changes{v1.2}{2002/08/10}{Added some declarations for epigraphs.}
18864 % \begin{macrocode}
18865 \newcommand{\epigraphfontsize}[1]{\def\epigraphsize{#1}}
18866 \newcommand{\epigraphposition}[1]{\long\def\epigraphflush{#1}}
18867 \newcommand{\epigraphtextposition}[1]{\def\textflush{#1}}
18868 \newcommand{\epigraphsourceposition}[1]{\def\sourceflush{#1}}
18869
18870 % \end{macrocode}
18871 % \end{macro}
18872 % \end{macro}
18873 % \end{macro}
18874 % \end{macro}
18875 %
18876 %
18877 %
18878 %
18879 % \begin{macro}{\@epirule}
18880 % The internal command to draw a rule between text and source.
18881 % \begin{macrocode}
18882 \newcommand{\@epirule}{\rule[.5ex]{\epigraphwidth}{\epigraphrule}}
18883 % \end{macrocode}
18884 % \end{macro}
18885 %
18886 % \begin{macro}{\@epitext}
18887 % The internal command to typeset the \meta{text}. Put it into a minipage of the
18888 % right size and typeset per \cs{textflush}.
18889 % \changes{v1.61803}{2008/01/30}{Added \cs{par} to \cs{@epitext} and
18890 % \cs{@episource} (mempatch v4.7)}
18891 % \begin{macrocode}
18892 \newcommand{\@epitext}[1]{%
18893 \begin{minipage}{\epigraphwidth}\begin{\textflush} #1\par
18894 % \end{macrocode}
18895 % Draw a rule if it will be visible, otherwise add some extra vertical space.
18896 % \begin{macrocode}
18897 \ifdim\epigraphrule>\z@ \@epirule \else \vspace*{1ex} \fi
18898 \end{\textflush}\end{minipage}}
18899 % \end{macrocode}
18900 % \end{macro}
18901 %
18902 % \begin{macro}{\@episource}
18903 % The internal command for typesetting the \meta{source}, which is put
18904 % into a minipage and typeset according to \cs{sourceflush}.
18905 % \begin{macrocode}
18906 \newcommand{\@episource}[1]{%
18907 \begin{minipage}{\epigraphwidth}
18908 \begin{\sourceflush} #1\par
18909 \end{\sourceflush}\end{minipage}}
18910
18911 % \end{macrocode}
18912 % \end{macro}
18913 %
18914 % \begin{macro}{\epigraph}
18915 % Having got the preliminaries out of the way, here's the user command
18916 % for a single epigraph. This is set in a minipage to prevent breaking
18917 % across a page. Position it according to \cs{epigraphflush}.
18918 % \begin{macrocode}
18919 \newcommand{\epigraph}[2]{\vspace{\beforeepigraphskip}
18920 {\epigraphsize\begin{\epigraphflush}\begin{minipage}{\epigraphwidth}
18921 \@epitext{#1}\\ \@episource{#2}
18922 \end{minipage}\end{\epigraphflush}
18923 \vspace{\afterepigraphskip}}}
18924 % \end{macrocode}
18925 % \end{macro}
18926 %
18927 %
18928 % \begin{macro}{\qitem}
18929 % \begin{macro}{\qitemlabel}
18930 % \cs{qitem} is the epigraph list version of \cs{item}.
18931 % Set everything inside a minipage.
18932 % \begin{macrocode}
18933 \newcommand{\qitem}[2]{{%
18934 \raggedright\item \begin{minipage}{\epigraphwidth}
18935 \@epitext{#1}\\ \@episource{#2}
18936 \end{minipage}}}
18937 % \end{macrocode}
18938 % \cs{qitemlabel} is needed for a list as well. It is not going to
18939 % typeset anything.
18940 % \begin{macrocode}
18941 \newcommand{\qitemlabel}[1]{\hfill}
18942 % \end{macrocode}
18943 % \end{macro}
18944 % \end{macro}
18945 %
18946 %
18947 % \begin{environment}{epigraphs}
18948 % Now for the epigraph list. This is defined in terms of a \Lenv{list}
18949 % environment.
18950 % \begin{macrocode}
18951 \newenvironment{epigraphs}{%
18952 % \end{macrocode}
18953 % Do the vertical space, set the font size, position according to
18954 % \cs{epigraphflush}, and put everything into a minipage.
18955 % \begin{macrocode}
18956 \vspace{\beforeepigraphskip}\begin{\epigraphflush}
18957 \epigraphsize
18958 \begin{minipage}{\epigraphwidth}
18959 \list{}%
18960 % \end{macrocode}
18961 % Make the list just fit the minipage (i.e., no indents).
18962 % \begin{macrocode}
18963 {\itemindent\z@ \labelwidth\z@ \labelsep\z@
18964 \leftmargin\z@ \rightmargin\z@
18965 \let\makelabel\qitemlabel}}%
18966 {\endlist\end{minipage}\end{\epigraphflush}
18967 \vspace{\afterepigraphskip}}
18968 % \end{macrocode}
18969 % \end{environment}
18970 %
18971 % \subsection{Epigraphs before a chapter title}
18972 %
18973 %
18974 % \begin{macro}{\@epichapapp}
18975 % \begin{macro}{\dropchapter}
18976 % \begin{macro}{\undodrop}
18977 % Commands to drop and restore positions of chapter titles. Dropping is
18978 % accomplished by inserting vertical space before the \cs{@chapapp} command.
18979 % \begin{macrocode}
18980 \newcommand{\dropchapter}[1]{%
18981 \let\@epichapapp\@chapapp
18982 \renewcommand{\@chapapp}{\vspace*{#1}\@epichapapp}}
18983 \newcommand{\undodrop}{\let\@chapapp\@epichapapp}
18984 % \end{macrocode}
18985 % \end{macro}
18986 % \end{macro}
18987 % \end{macro}
18988 %
18989 % Placing an epigraph before a chapter title uses the scheme outlined
18990 % by Piet van Oostrum~\cite{FANCYHDR}. This is to put a zero sized
18991 % picture into the page header.
18992 %
18993 % \begin{macro}{\if@epirhs}
18994 % \begin{macro}{\if@epicenter}
18995 % Two booleans for testing whether an epigraph is to be at the RH margin,
18996 % centered, or at the LH margin. The default is RH margin.
18997 % \begin{macrocode}
18998 \newif\if@epirhs \@epirhstrue
18999 \newif\if@epicenter \@epicentertrue
19000 % \end{macrocode}
19001 % \end{macro}
19002 % \end{macro}
19003 %
19004 % \begin{macro}{\@epipos}
19005 % This routine sets the \cs{if@epi...} booleans according to the value of
19006 % \cs{epigraphflush}. If \cs{epigraphflush} is neither \texttt{center} nor
19007 % \texttt{flushleft}
19008 % then it defaults to \texttt{flushright}. We have to use this to be upward
19009 % compatible with \cs{epigraphflush} being set by the user with \cs{renewcommand}.
19010 % \begin{macrocode}
19011 \newcommand{\@epipos}{
19012 \long\def\@ept{flushleft}
19013 \ifx\epigraphflush\@ept
19014 \@epirhsfalse \@epicenterfalse
19015 \else
19016 \long\def\@ept{center}
19017 \ifx\epigraphflush\@ept
19018 \@epirhsfalse \@epicentertrue
19019 \else
19020 \@epirhstrue \@epicenterfalse
19021 \fi
19022 \fi}
19023 % \end{macrocode}
19024 % \end{macro}
19025 %
19026 %
19027 % \begin{macro}{\epigraphhead}
19028 % \cs{epigraphhead}\oarg{distance}\marg{text} puts \meta{text} at
19029 % \meta{distance} (a number, not a length) below the header at the
19030 % page position specified by \cs{epigraphflush}.
19031 % \begin{macrocode}
19032 \newcommand{\epigraphhead}[2][95]{%
19033 % \end{macrocode}
19034 % We have to use \cs{def} instead of the normal \LaTeX{} definition commands
19035 % as we will keep on
19036 % (re)defining things. For reasons that are not fully clear to me \LaTeX{}
19037 % doesn't seem to like me using a \cs{savebox} for storing the epigraph text,
19038 % so I'll use a command instead.
19039 % \begin{macrocode}
19040 \def\@epitemp{\begin{minipage}{\epigraphwidth}#2\end{minipage}}
19041 % \end{macrocode}
19042 % Define an \texttt{epigraph} page style.
19043 % \begin{macrocode}
19044 \def\ps@epigraph{\let\@mkboth\@gobbletwo
19045 % \end{macrocode}
19046 % There are three possible definitions for \cs{@oddhead} depending on the
19047 % value of \cs{epigraphflush}. We call \cs{@epipos} to decide which one to do.
19048 % \begin{macrocode}
19049 \@epipos
19050 \if@epirhs
19051 \def\@oddhead{\hfil\begin{picture}(0,0)
19052 \put(0,-#1){\makebox(0,0)[r]{\@epitemp}}
19053 \end{picture}}
19054 \else
19055 \if@epicenter
19056 \def\@oddhead{\hfil\begin{picture}(0,0)
19057 \put(0,-#1){\makebox(0,0)[b]{\@epitemp}}
19058 \end{picture}\hfil}
19059 \else
19060 \def\@oddhead{\begin{picture}(0,0)
19061 \put(0,-#1){\makebox(0,0)[l]{\@epitemp}}
19062 \end{picture}\hfil}
19063 \fi
19064 \fi
19065 \let\@evenhead\@oddhead
19066 \def\@oddfoot{\reset@font\hfil\thepage\hfil}
19067 \let\@evenfoot\@oddfoot}
19068 % \end{macrocode}
19069 % Make \texttt{epigraph} be the page style for this page.
19070 % \begin{macrocode}
19071 \thispagestyle{epigraph}}
19072
19073 % \end{macrocode}
19074 % \end{macro}
19075 %
19076 % The above produces a \texttt{plain} pagestyle with the epigraph. Life is
19077 % more complex if someone wants a fancy style with the epigraph. They
19078 % will have to do some work, though.
19079 %
19080 % \begin{macro}{\the@epigraph}
19081 % \begin{macro}{\@epidrop}
19082 % \begin{macro}{\epigraphforheader}
19083 % \cs{the@pigraph} is a macro to store the contents of an epigraph, and \cs{@pidrop}
19084 % stores the \meta{distance} number.
19085 % \cs{epigraphforheader}\oarg{distance}\marg{text} defines the internal macros
19086 % appropriately.
19087 % \changes{v1.2}{2002/08/10}{Added \cs{the@epigraph}, \cs{@epidrop}}
19088 % \changes{v1.2}{2002/08/10}{Added \cs{epigraphforheader}}
19089 % \begin{macrocode}
19090 \newcommand{\the@epigraph}{}
19091 \newcommand{\@epidrop}{95}
19092 \newcommand{\epigraphforheader}[2][95]{%
19093 \def\@epidrop{#1}\long\def\the@epigraph{#2}}
19094
19095 % \end{macrocode}
19096 % \end{macro}
19097 % \end{macro}
19098 % \end{macro}
19099 %
19100 % \begin{macro}{\epigraphpicture}
19101 % \cs{epigraphpicture} puts \cs{the@epigraph} into a zero-sized picture at location
19102 % \verb?(0,-\@epidrop)?. This can then be used as part of a fancy chapter header.
19103 % The coding is similar to \cs{epigraphhead}.
19104 % \changes{v1.2}{2002/08/10}{Added \cs{epigraphpicture}}
19105 % \begin{macrocode}
19106 \newcommand{\epigraphpicture}{%
19107 \def\@epitemp{%
19108 \begin{minipage}{\epigraphwidth}\the@epigraph\end{minipage}}%
19109 \@epipos
19110 \if@epirhs
19111 \begin{picture}(0,0)%
19112 \put(0,-\@epidrop){\makebox(0,0)[r]{\@epitemp}}%
19113 \end{picture}%
19114 \else
19115 \if@epicenter
19116 \begin{picture}(0,0)%
19117 \put(0,-\@epidrop){\makebox(0,0)[b]{\@epitemp}}%
19118 \end{picture}%
19119 \else
19120 \begin{picture}(0,0)%
19121 \put(0,-\@epidrop){\makebox(0,0)[l]{\@epitemp}}%
19122 \end{picture}%
19123 \fi
19124 \fi}
19125
19126 % \end{macrocode}
19127 % \end{macro}
19128 %
19129 %
19130 %
19131 % \section{The deprecated font commands}
19132 %
19133 % The class does not support the old font changing commands unless the
19134 % \Lopt{oldfontcommands} option is used.
19135 %
19136 % \begin{macro}{\@memoldfonterr}
19137 % \begin{macro}{\@memoldfontwarn}
19138 % Macros for old font class error and warning. E.g., \\
19139 % \verb?\@memoldfonterr{\tt}{\ttfamily}{\texttt}?
19140 % \changes{v1.4}{2003/02/27}{Added \cs{@memoldfonterr} and \cs{@memoldfontwarn}}
19141 % \changes{v1.618}{2005/09/03}{Fiddled with the braces in \cs{@memoldfontwarn} (mempatch v3.0)}
19142 % \begin{macrocode}
19143 \newcommand*{\@memoldfonterr}[3]{%
19144 \@memerror{Font command \protect#1\space is not supported}{%
19145 Use \protect#2, or \protect#3{...}, or the oldfontcommands option}}
19146 \newcommand*{\@memoldfontwarn}[3]{%
19147 \@memwarn{The \protect#1\space font command is deprecated.
19148 \MessageBreak Use \protect#2{...} or {\protect#3... } instead}}
19149
19150 % \end{macrocode}
19151 % \end{macro}
19152 % \end{macro}
19153 %
19154 % Just give a single warning when an old font command is used following the
19155 % \Lopt{oldfontcommands} option.
19156 % \changes{v1.4}{2003/11/22}{Just issue a single warning for an old font
19157 % (from patch v1.9)}
19158 %
19159 % \begin{macro}{\@mem@rmwarn}
19160 % \begin{macro}{\rm}
19161 % The old command for roman font.
19162 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{rm}}
19163 % \changes{v1.4}{2003/02/27}{More efficient coding of all the old font commands}
19164 % \begin{macrocode}
19165 \if@memoldfont
19166 \def\@mem@rmwarn{\@memoldfontwarn{\rm}{\textrm}{\rmfamily}}
19167 \DeclareOldFontCommand{\rm}{\@mem@rmwarn\gdef\@mem@rmwarn{}%
19168 \normalfont\rmfamily}{\mathrm}
19169 \else
19170 \def\rm{\@memoldfonterr{\rm}{\textrm}{\rmfamily}}
19171 \fi
19172
19173 % \end{macrocode}
19174 % \end{macro}
19175 % \end{macro}
19176 %
19177 % \begin{macro}{\@mem@sfwarn}
19178 % \begin{macro}{\sf}
19179 % The old sans font command.
19180 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sf}}
19181 % \begin{macrocode}
19182 \if@memoldfont
19183 \def\@mem@sfwarn{\@memoldfontwarn{\sf}{\textsf}{\sffamily}}
19184 \DeclareOldFontCommand{\sf}{\@mem@sfwarn\gdef\@mem@sfwarn{}%
19185 \normalfont\sffamily}{\mathsf}
19186 \else
19187 \def\sf{\@memoldfonterr{\sf}{\textsf}{\sffamily}}
19188 \fi
19189
19190 % \end{macrocode}
19191 % \end{macro}
19192 % \end{macro}
19193 %
19194 % \begin{macro}{\@mem@ttwarn}
19195 % \begin{macro}{\tt}
19196 % The old typewriter font command.
19197 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{tt}}
19198 % \begin{macrocode}
19199 \if@memoldfont
19200 \def\@mem@ttwarn{\@memoldfontwarn{\tt}{\texttt}{\ttfamily}}
19201 \DeclareOldFontCommand{\tt}{\@mem@ttwarn\gdef\@mem@ttwarn{}%
19202 \normalfont\ttfamily}{\mathtt}
19203 \else
19204 \def\tt{\@memoldfonterr{\tt}{\texttt}{\ttfamily}}
19205 \fi
19206
19207 % \end{macrocode}
19208 % \end{macro}
19209 % \end{macro}
19210 %
19211 % \begin{macro}{\@mem@bfwarn}
19212 % \begin{macro}{\bf}
19213 % The old bold font command.
19214 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{bf}}
19215 % \begin{macrocode}
19216 \if@memoldfont
19217 \def\@mem@bfwarn{\@memoldfontwarn{\bf}{\textbf}{\bfseries}}
19218 \DeclareOldFontCommand{\bf}{\@mem@bfwarn\gdef\@mem@bfwarn{}%
19219 \normalfont\bfseries}{\mathbf}
19220 \else
19221 \def\bf{\@memoldfonterr{\bf}{\textbf}{\bfseries}}
19222 \fi
19223
19224 % \end{macrocode}
19225 % \end{macro}
19226 % \end{macro}
19227 %
19228 % \begin{macro}{\@mem@itwarn}
19229 % \begin{macro}{\it}
19230 % The old italic font command.
19231 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{it}}
19232 % \begin{macrocode}
19233 \if@memoldfont
19234 \def\@mem@itwarn{\@memoldfontwarn{\it}{\textit}{\itshape}}
19235 \DeclareOldFontCommand{\it}{\@mem@itwarn\gdef\@mem@itwarn{}%
19236 \normalfont\itshape}{\mathit}
19237 \else
19238 \def\it{\@memoldfonterr{\it}{\textit}{\itshape}}
19239 \fi
19240
19241 % \end{macrocode}
19242 % \end{macro}
19243 % \end{macro}
19244 %
19245 % \begin{macro}{\@mem@slwarn}
19246 % \begin{macro}{\sl}
19247 % The old slanted font command.
19248 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sl}}
19249 % \begin{macrocode}
19250 \if@memoldfont
19251 \def\@mem@slwarn{\@memoldfontwarn{\sl}{\textsl}{\slshape}}
19252 \DeclareOldFontCommand{\sl}{\@mem@slwarn\gdef\@mem@slwarn{}%
19253 \normalfont\slshape}{\@nomath\sl}
19254 \else
19255 \def\sl{\@memoldfonterr{\sl}{\textsl}{\slshape}}
19256 \fi
19257
19258 % \end{macrocode}
19259 % \end{macro}
19260 % \end{macro}
19261 %
19262 % \begin{macro}{\@mem@scwarn}
19263 % \begin{macro}{\sc}
19264 % The old small caps font command.
19265 % \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sc}}
19266 % \begin{macrocode}
19267 \if@memoldfont
19268 \def\@mem@scwarn{\@memoldfontwarn{\sc}{\textsc}{\scshape}}
19269 \DeclareOldFontCommand{\sc}{\@mem@scwarn\gdef\@mem@scwarn{}%
19270 \normalfont\scshape}{\@nomath\sc}
19271 \else
19272 \def\sc{\@memoldfonterr{\sc}{\textsc}{\scshape}}
19273 \fi
19274
19275 % \end{macrocode}
19276 % \end{macro}
19277 % \end{macro}
19278 %
19279 % \begin{macro}{\@mem@calwarn}
19280 % \begin{macro}{\cal}
19281 % The old calligraphic font command.
19282 % \changes{v1.0a}{2002/01/29}{Added definition of \cs{cal}}
19283 % \begin{macrocode}
19284 \if@memoldfont
19285 \def\@mem@calwarn{%
19286 \@memwarn{The \protect\cal\space font command is deprecated.
19287 \MessageBreak Try to use \protect\mathcal\space instead}}
19288 \DeclareRobustCommand*\cal{\@mem@calwarn\gdef\@mem@calwarn{}%
19289 \@fontswitch\relax\mathcal}
19290 \else
19291 \def\cal{%
19292 \@memerror{Font command \protect\cal\space is not supported}{%
19293 Use \protect\mathcal, or the oldfontcommands option}}
19294 \fi
19295
19296 % \end{macrocode}
19297 % \end{macro}
19298 % \end{macro}
19299 %
19300 % \begin{macro}{\@mem@mitwarn}
19301 % \begin{macro}{\mit}
19302 % The old math italic font command.
19303 % \changes{v1.0a}{2002/01/29}{Added definition of \cs{mit}}
19304 % \begin{macrocode}
19305 \if@memoldfont
19306 \def\@mem@mitwarn{%
19307 \@memwarn{The \protect\mit\space font command is deprecated.
19308 \MessageBreak Try to use \protect\mathnormal\space instead}}
19309 \DeclareRobustCommand*\mit{\@mem@mitwarn\gdef\@mem@mitwarn{}%
19310 \@fontswitch\relax\mathnormal}
19311 \else
19312 \def\mit{%
19313 \@memerror{Font command \protect\mit\space is not supported}{%
19314 Use \protect\mathnormal, or the oldfontcommands option}}
19315 \fi
19316
19317 % \end{macrocode}
19318 % \end{macro}
19319 % \end{macro}
19320 %
19321 %
19322 % \changes{v3.8.4}{2025/09/23}{Code about \cs{em} and
19323 % \cs{eminnershape} removed as it is already in the kernel in a better
19324 % version}
19325 %
19326 %
19327 % \section{Cross Referencing} \label{sec:xref}
19328 %
19329 % \subsection{Label referencing}
19330 %
19331 % \begin{macro}{\fref}
19332 % \begin{macro}{\tref}
19333 % \begin{macro}{\pref}
19334 % \begin{macro}{\Aref}
19335 % \begin{macro}{\Bref}
19336 % \begin{macro}{\Pref}
19337 % \begin{macro}{\Cref}
19338 % \begin{macro}{\Sref}
19339 % These are named references to labeled figures, tables and pages.
19340 % I find these useful to ensure consistency throughout the document
19341 % --- I don't have to remember whether it is `see Figure ...' or
19342 % `figure' or `Fig.' or \ldots.
19343 %
19344 % These are named references to labeled Part, Chapter and Sectional
19345 % divisions.
19346 %
19347 % In hindsight, it is not a good idea for a class to provide these
19348 % as user preferences differ. It is better for users to define
19349 % these. From July 2025 we defined them at document start if they
19350 % aren't already defined. They will give a warning with a suggestion
19351 % on how to define your own version
19352 % \changes{v1.2}{2002/07/27}{Added \cs{Pref}, \cs{Cref} and \cs{Sref}}
19353 % \changes{v1.61803}{2008/01/30}{Added \cs{Bref} (mempatch v4.9+)}
19354 % \changes{v1.61803}{2008/05/17}{Added \cs{Aref}}
19355 % \changes{v3.8.4}{2025/07/30}{Move tilde here instead as part of \cs{..refname}}
19356 % \changes{v3.8.4}{2025/07/30}{Mark deprecated and delay definition}
19357 % \changes{v3.8.4}{2025/08/04}{Fixed a few typos, inclusing \cs{pref} not using \cs{pageref}}
19358 % \begin{macrocode}
19359 \ExplSyntaxOn
19360 % helper function
19361 \cs_new_protected:Npn \memoir_make_deprecated_ref_cmds:nNNN #1#2#3#4#5
19362 {% #1 = starred (adds nobreakspace if not); #2: macro name; #3: ref macro; #4: macro name recommended in comment; #5: macro name we actually use
19363 \cs_if_exist:NF #2
19364 {
19365 \newcommand#2[1]{%
19366 \MarkDeprecated{#2}{from~memoir~in~2026.\MessageBreak%
19367 Define~your~own~version~in~the~preamble.~E.g.~via\MessageBreak%
19368 \string\newcommand\string#2[1]{\string#4\c_tilde_str\string#3{\c_hash_str1}}%
19369 \MessageBreak}%
19370 \IfBooleanTF{#1}
19371 {#5\ref{##1}}
19372 {#5\nobreakspace\ref{##1}}
19373 }
19374 }
19375 }
19376 \NewDocumentCommand\memoir@setup@deprecated@macros{smmm}{
19377 \memoir_make_deprecated_ref_cmds:nNNN {#1}#2#3#4
19378 }
19379 \ExplSyntaxOff
19380
19381 \AtBeginDocument{
19382 \memoir@setup@deprecated@macros\fref\ref\figurename\figurerefname
19383 \memoir@setup@deprecated@macros\tref\ref\tablename\tablerefname
19384 \memoir@setup@deprecated@macros\pref\pageref\pagename\pagerefname
19385 \memoir@setup@deprecated@macros\Aref\ref\appendixname\appendixrefname
19386 \memoir@setup@deprecated@macros\Bref\ref\bookname\bookrefname
19387 \memoir@setup@deprecated@macros\Pref\ref\partname\partrefname
19388 \memoir@setup@deprecated@macros\Cref\ref\chaptername\chapterrefname
19389 \memoir@setup@deprecated@macros*\Sref\ref\sectionname\sectionrefname
19390 }
19391
19392 % \newcommand*{\fref}[1]{\figurerefname~\ref{#1}}
19393 % \newcommand*{\tref}[1]{\tablerefname~\ref{#1}}
19394 % \newcommand*{\pref}[1]{\pagerefname~\pageref{#1}}
19395 % \newcommand*{\Aref}[1]{\appendixrefname~\ref{#1}}
19396 % \newcommand*{\Bref}[1]{\bookrefname~\ref{#1}}
19397 % \newcommand*{\Pref}[1]{\partrefname~\ref{#1}}
19398 % \newcommand*{\Cref}[1]{\chapterrefname~\ref{#1}}
19399 % \newcommand*{\Sref}[1]{\sectionrefname\ref{#1}}
19400
19401 % \end{macrocode}
19402 % \end{macro}
19403 % \end{macro}
19404 % \end{macro}
19405 % \end{macro}
19406 % \end{macro}
19407 % \end{macro}
19408 % \end{macro}
19409 % \end{macro}
19410 %
19411 % \subsection{Title referencing}
19412 %
19413 % \changes{v3.8}{2023/07/25}{Entire section rewritten}
19414 % As of Summer 2023 this has been redone by directly loading the
19415 % \Lpack{nameref} package instead. It is loaded without changing the
19416 % sectional macros, which are in turn updated to set
19417 % \cs{@currentlabelname} for the new kernel label system to
19418 % pickup. The new kernel label system also requires us not to modify
19419 % \cs{label} so the switch was required.
19420 %
19421 % \begin{macro}{\titleref}
19422 % Instead of defining our own macro we now let \cs{titleref} be an
19423 % alias for \cs{nameref}. Do remember that it also have a starred
19424 % version.
19425 % \begin{macrocode}
19426 % disable nameref sectional patches (the macro just needs to be defined)
19427 \def\NR@nopatch@sectioning{set}
19428 \def\NR@nopatch@caption{set}
19429 \RequirePackage{nameref}
19430 \newcommand\titleref{\nameref}
19431
19432 % \end{macrocode}
19433 % \end{macro}
19434 % \begin{macro}{\mem@set@cln}
19435 % We'll need to set \cs{@currentlabelname} in various places. The
19436 % title may need to be cleaned. \Lpack{nameref} provides
19437 % \cs{NR@gettitle} and we just use our own name for it.
19438 % \begin{macrocode}
19439 \def\mem@set@cln{\NR@gettitle}
19440 % \end{macrocode}
19441 % \end{macro}
19442 %
19443 % \begin{macro}{\M@gettitle}
19444 % All the sectional macros in memoir has been using \cs{M@gettitle}
19445 % for years to access the title to use for \cs{titleref}. We simply
19446 % change its definition to use our simpler case. Do remember that if
19447 % the argument for \cs{M@gettitle} is a macro, it needs to be
19448 % expanded once.
19449 % \begin{macrocode}
19450 \newcommand\M@gettitle[1]{\mem@set@cln{#1}}
19451 % \end{macrocode}
19452 % \end{macro}
19453 %
19454 % In the sectional macros the title we will be giving to
19455 % \cs{@currentlabelname} will be the title for the toc or if requested
19456 % (and avaiable) the title for the header. That is
19457 % \begin{verbatim}
19458 % \chapter{title} % sends title to toc and header, so use title
19459 % \chapter[toc]{title} % sends toc to toc and header, so use toc
19460 % \chapter[toc][header]{title} % data depends on \headnameref and
19461 % % \tocnameref (default)
19462 % \end{verbatim}
19463 % \changes{v1.4}{2003/11/16}{Added title referencing (from patch v1.4)}
19464 %
19465 % \begin{macro}{\ifheadnameref}
19466 % \begin{macro}{\headnameref}
19467 % \begin{macro}{\tocnameref}
19468 % \cs{ifheadnameref}: FALSE use ToC entry, TRUE use header entry. Used
19469 % inside the sectional macros that support two optional arguments.
19470 % \changes{v1.61803}{2008/01/30}{Added \cs{headnameref} and \cs{tocnameref}}
19471 % \begin{macrocode}
19472 \newif\ifheadnameref
19473 \newcommand*{\headnameref}{\headnamereftrue}
19474 \newcommand*{\tocnameref}{\headnamereffalse}
19475 \tocnameref
19476 % \end{macrocode}
19477 % \end{macro}
19478 % \end{macro}
19479 % \end{macro}
19480 %
19481 % Following the 2023 reimplementation of \cmd{\titleref} the following
19482 % public macros are no longer used and are redefined to either do
19483 % nothing or give an error.
19484 % \begin{macro}{\namerefon}
19485 % \begin{macro}{\namerefoff}
19486 % Was used to enable (default) or disable support for
19487 % \cmd{\titleref}. Now does nothing.
19488 % \begin{macrocode}
19489 \providecommand\namerefon{\@memwarn{\protect\namerefon\space no longer does anything}}
19490 \providecommand\namerefoff{\@memwarn{\protect\namerefoff\space no longer does anything}}
19491 % \end{macrocode}
19492 % \end{macro}
19493 % \end{macro}
19494 % \begin{macro}{\currenttitle}
19495 % \cmd{\currenttitle} was advertised to give the most recent
19496 % sectional title. It is better to be more specific and use a label
19497 % and \cmd{\titleref}. Now defined to give an error.
19498 % \begin{macrocode}
19499 \providecommand\currenttitle{%
19500 \@memerror{The \protect\currenttitle\space command is no longer\MessageBreak
19501 available}{%
19502 Place a label and use \protect\titleref{label} instead
19503 }
19504 }
19505 % \end{macrocode}
19506 % \end{macro}
19507 % \begin{macro}{\theTitleReference}
19508 % Was used to define the output of \cmd{\titleref}. Now just gives a
19509 % warning.
19510 % \begin{macrocode}
19511 \providecommand\theTitleReference[2]{%
19512 \@memwarn{\protect\theTitleReference\space is no longer available}
19513 }
19514 % \end{macrocode}
19515 % \end{macro}
19516 % \begin{macro}{\M@TitleReference}
19517 % This was used in the old implementation as a part of the data inside
19518 % \verb|\newlabel| in the \verb|.aux|-files. Deleting it will cause
19519 % the first compilation after a memoir update to fail. We'll
19520 % just define it to gobble two args.
19521 % \begin{macrocode}
19522 \let\M@TitleReference\@gobbletwo
19523 % \end{macrocode}
19524 % \end{macro}
19525 %
19526 %
19527 % \section{Table of Contents, etc.}
19528 %
19529 % A \cs{section} command writes a
19530 % \verb?\contentsline{section}?\marg{title}\marg{page}\verb!{}! command
19531 % on the \file{.toc} file, where \meta{title} contains the
19532 % contents of the entry and \meta{page} is the page number. If
19533 % sections are being numbered, then \meta{title} will be of the
19534 % form \cs{numberline}\marg{num}\marg{heading} where
19535 % \meta{num} is the number produced by \cs{thesection}. Other
19536 % sectioning commands work similarly.
19537 %
19538 % A \cs{caption} command in a `figure' environment writes \\
19539 % \verb?\contentsline{figure}{?\cs{numberline}\marg{num}\marg{caption}\verb?}?\marg{page}\verb!{}! \\
19540 % on the \file{.lof} file, where \meta{num} is the number produced
19541 % by \cs{thefigure} and \meta{caption} is the figure caption. It
19542 % works similarly for a `table' environment.
19543 %
19544 % The command \cs{contentsline}\marg{name} expands to
19545 % \cs{l@}\meta{name}. So, to specify the table of contents, we must
19546 % define \cs{l@chapter}, \cs{l@section}, \cs{l@subsection}, \ldots ; to
19547 % specify the list of figures, we must define \cs{l@figure}; and so
19548 % on. Most of these can be defined with the \cs{@dottedtocline}
19549 % command, which works as follows. \\
19550 % \cs{@dottedtocline}\marg{level}\marg{indent}\marg{numwidth}\marg{title}\marg{page}
19551 %
19552 % \begin{description}
19553 % \item[\meta{level}] An entry is produced only if\meta{level}
19554 % $<=$ value of the \Lcount{tocdepth} counter. Note,
19555 % \cs{chapter} is level 0, \cs{section} is level 1, etc.
19556 % \item[\meta{indent}] The indentation from the outer left margin
19557 % of the start of the contents line.
19558 % \item[\meta{numwidth}] The width of a box in which the section
19559 % number is to go, if \meta{title} includes a \cs{numberline}
19560 % command.
19561 % \end{description}
19562 %
19563 % \begin{macro}{\@pnumwidth}
19564 % \begin{macro}{\@tocrmarg}
19565 % \begin{macro}{\@dotsep}
19566 % This command uses the following three parameters, which are set
19567 % with a \cs{newcommand} (so em's can be used to make them depend upon
19568 % the font).
19569 % \begin{description}
19570 % \item[\texttt{\bslash @pnumwidth}] The width of a box in which the
19571 % page number is put.
19572 % \item[\texttt{\bslash @tocrmarg}] The right margin for multiple
19573 % line entries. One wants \cs{@tocrmarg} $\ge$ \cs{@pnumwidth}
19574 % \item[\texttt{\bslash @dotsep}] Separation between dots, in mu
19575 % units. Should be defined as a number like 2 or 1.7
19576 % \end{description}
19577 %
19578 % \begin{macrocode}
19579 \newcommand{\@pnumwidth}{1.55em}
19580 \newcommand{\@tocrmarg} {2.55em}
19581 \newcommand{\@dotsep}{4.5}
19582 % \end{macrocode}
19583 % \end{macro}
19584 % \end{macro}
19585 % \end{macro}
19586 %
19587 % \begin{macro}{\tocentryskip}
19588 % \begin{macro}{\tocbaseline}
19589 % \begin{macro}{\tocskip}
19590 % We define two lengths and a utility command.
19591 % \begin{macrocode}
19592 \newlength{\tocentryskip} \setlength{\tocentryskip}{1em}
19593 \newlength{\tocbaseline} \setlength{\tocbaseline}{20pt}
19594 \newcommand{\tocskip}[1]{%
19595 \addtocontents{toc}{\protect\vspace{#1}}}
19596 % \end{macrocode}
19597 % \end{macro}
19598 % \end{macro}
19599 % \end{macro}
19600 %
19601 % \subsection{New List of \ldots}
19602 %
19603 % It is apparent that users want to do at least two things that are not
19604 % readily provided by the standard classes: (a) change the appearance
19605 % of the Table of Contents, etc., headings, and (b) create new List of\ldots.
19606 % This class provides a means of creating new Lists whose headings are
19607 % parameterized, thereby killing two birds with one stone.
19608 %
19609 % In the standard classes the tables of contents, figures etc. are always
19610 % set in single-column style. In this class you can choose one- or two-column
19611 % ToCs, etc.
19612 % The titles are added to the ToC, unless the starred versions of the
19613 % commands are used.
19614 % \changes{v1.6180339f}{2009/03/16}{Enabled two-column ToC, etc}
19615 %
19616 % \begin{macro}{\ensureonecol}
19617 % \begin{macro}{\restorefromonecol}
19618 % These two
19619 % macros cooperate to switch from two-columns to one column, and back again.
19620 % \changes{v1.0a}{2002/01/24}{Deleted \cs{ensuretwocol} and
19621 % \cs{restorefromtwocol} as they were unused. BUT later reinstated them.}
19622 % \begin{macro}{\onecoltocetc}
19623 % \begin{macro}{\twocoltocetc}
19624 % \begin{macro}{\doccoltocetc}
19625 % These macros define \cs{ensureonecol} and \cs{restorefromonecol} such that
19626 % \begin{itemize}
19627 % \item \cs{onecoltocetc} ToCs, etc., will be set in one column (the default)
19628 % \item \cs{twocoltocetc} ToCs, etc., will be set in two columns
19629 % \item \cs{doccoltocetc} ToCs, etc., will be set in column(s) corresponding
19630 % to the document's (onecolumn/twocolumn) option.
19631 % \end{itemize}
19632 % \changes{v1.6180339f}{2009/03/16}{Added \cs{onecoltocetc}, \cs{twocoltocetc}
19633 % and \cs{doccoltocetc}}
19634 % \begin{macrocode}
19635 \newcommand*{\onecoltocetc}{%
19636 \def\ensureonecol{%
19637 \if@twocolumn
19638 \@restonecoltrue\onecolumn
19639 \else
19640 \@restonecolfalse
19641 \fi}%
19642 \def\restorefromonecol{\if@restonecol\twocolumn\fi}}
19643 \newcommand*{\twocoltocetc}{%
19644 \def\ensureonecol{%
19645 \if@twocolumn
19646 \@restonecoltrue
19647 \else
19648 \@restonecolfalse\twocolumn
19649 \fi}%
19650 \def\restorefromonecol{\if@restonecol\else\onecolumn\fi}}
19651 \newcommand*{\doccoltocetc}{%
19652 \let\ensureonecol\relax
19653 \let\restorefromonecol\relax}
19654 % \end{macrocode}
19655 % Set the default
19656 % \begin{macrocode}
19657 \onecoltocetc
19658
19659 % \end{macrocode}
19660 % \end{macro}
19661 % \end{macro}
19662 % \end{macro}
19663 % \end{macro}
19664 % \end{macro}
19665 %
19666 %
19667 % \begin{macro}{\cftparskip}
19668 % The \cs{parskip} local to the ToC, etc, is set to the length \cs{cftparskip}.
19669 % \begin{macrocode}
19670 \newlength{\cftparskip}
19671 \setlength{\cftparskip}{0pt}
19672
19673 % \end{macrocode}
19674 % \end{macro}
19675 %
19676 % \begin{macro}{\newlistof}
19677 % \cs{newlistof}\marg{listofcmmd}\marg{ext}\marg{listofname}
19678 % creates the command \cs{listofcmmd} to typeset a new List of, where the
19679 % external file has the extension \file{.ext} and the heading title is
19680 % \meta{listofname}. The code for this is a heavily modified part
19681 % of the \Lpack{tocloft} package.
19682 %
19683 % \begin{macrocode}
19684 \newcommand{\newlistof}[3]{%
19685 % \end{macrocode}
19686 %
19687 % In the following, \texttt{X} stands for the value of \meta{listofcmmd} and
19688 % \texttt{Z} stands for the value of \meta{ext}.
19689 %
19690 % \begin{macro}{\ext@Z}
19691 % \begin{macro}{\Zdepth}
19692 % The file extension and listing depth, which is set to level~1.
19693 % \begin{macrocode}
19694 \@namedef{ext@#2}{#2}
19695 \@ifundefined{c@#2depth}{\newcounter{#2depth}}{}
19696 \setcounter{#2depth}{1}
19697 % \end{macrocode}
19698 % \end{macro}
19699 % \end{macro}
19700 %
19701 % \begin{macro}{\Zmark}
19702 % The heading marks for the listing.
19703 % \changes{v1.1}{2002/03/10}{Changed \cs{@mkboth} to \cs{markboth} in \cs{Zmark}}
19704 % \begin{macrocode}
19705 \@namedef{#2mark}{\markboth{#3}{#3}}
19706 % \end{macrocode}
19707 % \end{macro}
19708 %
19709 % \begin{macro}{\X}
19710 % Typeset the listing title and entries,
19711 % with both a normal and starred version.
19712 % \changes{v1.61803398}{2009/08/08}{changed such that it only use one
19713 % internal macro}
19714 % \changes{v1.61803398}{2009/08/09}{chose a better name for the
19715 % internal macro}
19716 % \begin{macrocode}
19717 \@namedef{#1}{\@ifstar{\@nameuse{mem@#1}{01}}{\@nameuse{mem@#1}{00}}}
19718 % \end{macrocode}
19719 % \end{macro}
19720 %
19721 % \begin{macro}{\mem@X}
19722 % \begin{macro}{\cftZbeforelisthook}
19723 % \begin{macro}{\cftZafterlisthook}
19724 % \changes{v1.61803398}{2009/08/08}{introduced \cs{mem@X} to replace
19725 % \cs{@starZ} and \cs{@plainZ}}
19726 % In earlier version of the class, we used two macros \cs{@starZ}
19727 % and \cs{@plainZ}, to reduce code we now only use one, the argument
19728 % of it takes care of differentiating between the stuff that are
19729 % different. Two hooks is added just before and after importing the
19730 % list file contents. Additionally we have added a hook before the
19731 % title is being executed, it comes after \cs{phantomsection} but
19732 % before any \cs{addcontentsline}
19733 % \changes{v1.61803398d}{2010/02/14}{added the before and after hooks}
19734 % \changes{v3.7i}{2019/10/25}{moved the @\#2maketitle until after the
19735 % \cs{addcontentsline}, that way the hyperref anchor is above the
19736 % title, not below it. }
19737 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget}}
19738 % \begin{macrocode}
19739 \@namedef{cft#2beforelisthook}{}%
19740 \@namedef{cft#2afterlisthook}{}%
19741 \@namedef{mem@#1}##1{%
19742 \ensureonecol
19743 \par
19744 \begingroup
19745 % \phantomsection
19746 \MakeLinkTarget[chapter]{}%
19747 \if##1
19748 \ifmem@em@starred@listof\else
19749 \addcontentsline{toc}{chapter}{#3}
19750 \fi
19751 \fi
19752 \@nameuse{@#2maketitle}
19753 \parskip\cftparskip
19754 \@nameuse{cft#2beforelisthook}%
19755 \@starttoc{#2}%
19756 \@nameuse{cft#2afterlisthook}%
19757 \endgroup
19758 \restorefromonecol}
19759 % \end{macrocode}
19760 %
19761 % \end{macro}
19762 % \end{macro}
19763 % \end{macro}
19764 %
19765 % \begin{macro}{\@Zmaketitle}
19766 % This macro typesets the title.
19767 % \changes{v1.3}{2002/10/10}{Added \cs{printZnonum} to \cs{@Zmaketitle}}
19768 % \changes{v1.61803}{2008/01/30}{Slight changes to \cs{@Zmaketitle}
19769 % (mempatch v4.6)}
19770 % \changes{v3.6j}{2011/03/01}{Made sure \cs{parskip} is zero in the
19771 % title, otherwise a non-zero \cs{parskip} might cause it to be placed
19772 % incorrectly}
19773 % \begin{macrocode}
19774 \@namedef{@#2maketitle}{%
19775 \@nameuse{#2headstart}
19776 {\parindent\z@
19777 \parskip\z@
19778 %%%% \parskip\cftparskip
19779 \interlinepenalty\@M
19780 % \end{macrocode}
19781 % \changes{v1.3}{2002/11/14}{Added printZnonum to \cs{newlistof}}
19782 % \begin{macrocode}
19783 \@nameuse{print#2nonum}%
19784 \@nameuse{print#2title}{#3}%
19785 \@nameuse{#2mark}%
19786 \thispagestyle{chapter}%
19787 \@nameuse{after#2title}
19788 }
19789 \@afterheading}
19790 % \end{macrocode}
19791 % \end{macro}
19792 %
19793 % \begin{macro}{\Zheadstart}
19794 % \begin{macro}{\afterZtitle}
19795 % The macros \cs{Zheadstart} and \cs{afterZtitle}
19796 % control what goes before and after the title. They
19797 % default to the corresponding macros for chapters.
19798 % \begin{macrocode}
19799 \@namedef{#2headstart}{\chapterheadstart}
19800 \@namedef{after#2title}{\afterchaptertitle}
19801 % \end{macrocode}
19802 % \end{macro}
19803 % \end{macro}
19804 %
19805 % \begin{macro}{\printZnonum}
19806 % This typesets something before the title and defaults
19807 % to \cs{printchapternonum}.
19808 % \changes{v1.3}{2002/10/10}{Added \cs{printZnonum} macro}
19809 % \begin{macrocode}
19810 \@namedef{print#2nonum}{\printchapternonum}
19811 % \end{macrocode}
19812 % \end{macro}
19813 %
19814 % \begin{macro}{\printZtitle}
19815 % The title is typeset by the macro \cs{printZtitle}\marg{title}
19816 % which defaults to \cs{printchaptertitle}.
19817 % \begin{macrocode}
19818 \@namedef{print#2title}##1{\printchaptertitle{##1}}
19819 % \end{macrocode}
19820 % \end{macro}
19821 %
19822 % This is the end of the definition of \cs{newlistof}.
19823 % \begin{macrocode}
19824 } % end \newlistof
19825
19826 % \end{macrocode}
19827 % \end{macro}
19828 %
19829 % \begin{macro}{\ifmem@em@starred@listof}
19830 % \begin{macro}{\KeepFromToc}
19831 % The class handles the created `new lists' a little different than
19832 % other classes. We automatically add it to the main table of
19833 % contents. This us usually what one wants. If not, one can always
19834 % use the starred version. But in some cases other packages will use
19835 % \cs{tableofcontents} to typeset their own `list of\dots', in which
19836 % case it becomes a little hard to add a star. Therefore we add a
19837 % switch that can be used to emulate the starred list of. After the
19838 % macro \cs{KeepFromToc} the memoir created (non-starred) `list of'
19839 % will behave as their starred counterpart.
19840 % \changes{v1.61803398}{2009/08/08}{LM: added \cs{KeepFromToc}}
19841 % \begin{macrocode}
19842 \newif\ifmem@em@starred@listof
19843 \newcommand\KeepFromToc{\mem@em@starred@listoftrue}
19844 % \end{macrocode}
19845 % Tip: use \cs{KeepFromToc} as an environment, i.e.
19846 % \begin{verbatim}
19847 % \begin{KeepFromToc}
19848 % \listoffigures
19849 % \end{KeepFromToc}
19850 % \end{verbatim}
19851 % to locally remove a list from the TOC.
19852 % \end{macro}
19853 % \end{macro}
19854 %
19855 %
19856 % \begin{macro}{\@starttoc}
19857 % A list of macro calls \cs{@starttoc} to read the appropriate file. I have
19858 % changed the kernel definition to allow a file to be read multiple times
19859 % by delaying killing the file until the end of the document.
19860 % \changes{v1.3}{2002/11/14}{Changed \cs{@starttoc}}
19861 % \changes{v1.61803398d}{2009/11/23}{Removed infelicity in \cs{@starttoc}}
19862 % \begin{macrocode}
19863 \renewcommand{\@starttoc}[1]{%
19864 \begingroup\makeatletter
19865 \@input{\jobname.#1}%
19866 \if@filesw
19867 \AtEndDocument{%
19868 % \end{macrocode}
19869 % If a ToC, or other ListOf, is called more than once then we have to stop
19870 % opening yet another, redundant, output file. The check against \cs{relax}
19871 % seems to meet the requirement.
19872 % \begin{macrocode}
19873 \expandafter\ifx\csname tf@#1\endcsname\relax
19874 \expandafter\newwrite\csname tf@#1\endcsname
19875 \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
19876 \fi
19877 }%
19878 \fi
19879 \@nobreakfalse
19880 \endgroup}
19881
19882 % \end{macrocode}
19883 % \end{macro}
19884 %
19885 %
19886 % \subsection{Table of Contents}
19887 %
19888 % \begin{macro}{\tableofcontents}
19889 % \begin{macro}{\tableofcontents*}
19890 % These macros request that \LaTeX{} produces a table of
19891 % contents. The ToC heading is added to the ToC unless the starred
19892 % version is used.
19893 %
19894 % \begin{macrocode}
19895 \newlistof{tableofcontents}{toc}{\contentsname}
19896 % \end{macrocode}
19897 % \end{macro}
19898 % \end{macro}
19899 %
19900 % The List of Figures and List of Tables are defined later.
19901 %
19902 %
19903 %
19904 % \subsection{List entries}
19905 %
19906 % Each command in the body of the text that makes an entry in the ToC,
19907 % or LoF or LoT needs an addtional macro to format the entry, as described
19908 % above. Users often want to change the formatting of the entries but
19909 % it is not immediately obvious how to do that.
19910 %
19911 % I have borrowed and modified more of the code from the \Lpack{tocloft}
19912 % package to enable easy creation and modification the formatting of the
19913 % entries.
19914 %
19915 %
19916 % \begin{macro}{\setpnumwidth}
19917 % \begin{macro}{\setrmarg}
19918 % User commands for setting \cs{@pnumwidth} and \cs{@tocrmarg}.
19919 % \begin{macrocode}
19920 \newcommand*{\setpnumwidth}[1]{\renewcommand{\@pnumwidth}{#1}}
19921 \newcommand*{\setrmarg}[1]{\renewcommand{\@tocrmarg}{#1}}
19922 % \end{macrocode}
19923 % \end{macro}
19924 % \end{macro}
19925 %
19926 % \begin{macro}{\cftdot}
19927 % \begin{macro}{\cftdotfill}
19928 % In the default ToC, a dotted line can be used to provide a leader between
19929 % a title and the page number. The definition of this leader is buried
19930 % in the \cs{@dottedtocline} command. The \cs{cftdotfill}\marg{sep}
19931 % command provides a parameterised version of the leader code, where
19932 % \meta{sep} is the separation between the dots in mu units.
19933 % The symbol used for the `dots' in the leader is given by the value
19934 % of \cs{cftdot}.
19935 % \begin{macrocode}
19936 \providecommand{\cftdot}{.}
19937 \providecommand{\cftdotfill}[1]{%
19938 \leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill}
19939 % \end{macrocode}
19940 % \end{macro}
19941 % \end{macro}
19942 %
19943 % \begin{macro}{\cftdotsep}
19944 % \begin{macro}{\cftnodots}
19945 % \cs{cftdotsep} holds the default dot separation.
19946 % If the kerns in \cs{cftdotfill} are large enough, then no dots will
19947 % be printed. \cs{cftnodots} should be `large enough'.
19948 % \changes{v1.2}{2002/07/07}{Changed \cs{cftnodots} from 10,000 to 2,000 for
19949 % 17pt option and pdflatex}
19950 % \begin{macrocode}
19951 \providecommand{\cftdotsep}{4.5}
19952 \newcommand{\cftnodots}{2000}
19953 % \end{macrocode}
19954 % \end{macro}
19955 % \end{macro}
19956 %
19957 % Now for the trickier bits regarding the typesetting of the ToC
19958 % entries.
19959 %
19960 % A \file{.toc} (also \file{.lof} and \file{.lot}) file consists
19961 % of a list of \\
19962 % \cs{contentsline}\marg{kind}\marg{title}\marg{page} \\
19963 % commands, where \meta{kind} is the kind of heading (e.g., \texttt{part} or
19964 % \texttt{section} or \texttt{figure}), \meta{title} is the title text
19965 % (including the number),
19966 % and \meta{page} is the page number. The entries are inserted into the
19967 % file by calling the \\
19968 % \cs{addcontentsline}\marg{file}\marg{kind}\marg{title} \\
19969 % command, where \meta{file} is the file extension (e.g., \texttt{toc}, \texttt{lot})
19970 % and the other arguments are the same as for the \cs{contentsline}
19971 % command. (Arbitrary stuff may also be put into the file via the
19972 % \cs{addtocontents}\marg{file}\marg{text} command).
19973 % The typesetting of the \cs{contentsline} entries is performed by
19974 % commands of the form \cs{l@kind}. The sectioning and captioning commands
19975 % call \cs{addcontentsline} to insert their titles into the \file{.toc}
19976 % etc., files.
19977 %
19978 % For the purposes at hand it is generally impossible to treat
19979 % the typesetting
19980 % of a title and its number separately, as both are bundled into the
19981 % \meta{title} argument within \cs{contentsline}. They could be handled
19982 % separately if the \cs{contentsline} command was suitably modified. If
19983 % this was done, then the \cs{addtocontentsline} command would also need
19984 % to be changed which would then require the sectioning and captioning
19985 % commands to be modified as well. This is certainly possible, but would
19986 % cause problems if any other package also modified the sectioning or
19987 % captioning commands, and there are several packages which do this.
19988 %
19989 % I provide modified versions of the \cs{l@kind} commands.
19990 % Essentially, my new definitions
19991 % consist of inlined versions of the code for \cs{@dottedtocline}.
19992 %
19993 %
19994 % \begin{macro}{\cftparfillskip}
19995 % The \cs{l@kind} commands modify (locally) the value of \cs{parfillskip}.
19996 % \cs{cftparfillskip} is a copy of the default \theTeXbook{}
19997 % \cs{parfillskip} definition.
19998 % \begin{macrocode}
19999 \newcommand*{\cftparfillskip}{\parfillskip=0pt plus1fil}
20000 % \end{macrocode}
20001 % \end{macro}
20002 %
20003 % \begin{macro}{\@cftn@me}
20004 % Lars Madsen suggested that macros like \cs{cftfigurename} be added
20005 % to entries in the LoF, and so on.
20006 % \changes{v1.61803}{2008/01/30}{Added \cs{@cftn@me} (Lars Madsen mempatch v4.5)}
20007 % \begin{macrocode}
20008 \newcommand*{\@cftn@me}{}
20009
20010 % \end{macrocode}
20011 % \end{macro}
20012 %
20013 % \begin{macro}{\mem@cft@hb@xt@}
20014 % \begin{macro}{\numberlinebox}
20015 % \begin{macro}{\partnumberlinebox}
20016 % \begin{macro}{\chapternumberlinebox}
20017 % \begin{macro}{\booknumberlinebox}
20018 % \changes{v3.6k}{2012/07/22}{Added four \cs{Xnumberlinebox} macros}
20019 % Each of the four \cs{Xnumberline} macros (part, chapter, book and
20020 % regular) typeset their contents inside a box of a certain width. In
20021 % order to make this a little more flexible we provide a default box
20022 % macro. Note that the box left aligned by default. The default
20023 % \cs{Xnumberlinebox} macros are then let equal to this default.
20024 % \begin{macrocode}
20025 \newcommand\mem@cft@hb@xt@[2]{\hb@xt@#1{#2\hfil}}
20026 \let\numberlinebox\mem@cft@hb@xt@
20027 \let\partnumberlinebox\mem@cft@hb@xt@
20028 \let\chapternumberlinebox\mem@cft@hb@xt@
20029 \let\booknumberlinebox\mem@cft@hb@xt@
20030
20031 % \end{macrocode}
20032 %
20033 % \end{macro}
20034 % \end{macro}
20035 % \end{macro}
20036 % \end{macro}
20037 % \end{macro}
20038 %
20039 %
20040 % \begin{macro}{\numberline}
20041 % \begin{macro}{\numberlinehook}
20042 % The purpose of the \cs{numberline}\marg{secnum} command is to typeset
20043 % \meta{secnum} left justified in a box of width \cs{@tempdima}. I redefine
20044 % it to add three additional parameters, namely \cs{@cftbsnum},
20045 % \cs{@cftasnum} and \cs{@cftasnumb}
20046 % (see \file{ltsect.dtx} for the original
20047 % definition).
20048 % \changes{v1.61803398d}{2010/02/13}{added \cs{numberlinehook}}
20049 % We also add a hook, that initially does nothing, but
20050 % might be redefined to record say withs of \meta{secnum}s. In order
20051 % to tell the owner of the \cs{numberline}'s apart, check the value of
20052 % \cs{cftwhatismyname}.
20053 % \changes{v3.6k}{2012/07/22}{Factored out the box part into a
20054 % separate macro}
20055 % \begin{macrocode}
20056 \newcommand*\numberlinehook[1]{}
20057 \renewcommand*{\numberline}[1]{%
20058 \numberlinehook{#1}%
20059 %\hb@xt@\@tempdima{\@cftn@me\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
20060 \numberlinebox\@tempdima{\@cftn@me\@cftbsnum #1\@cftasnum}\@cftasnumb}
20061 % \end{macrocode}
20062 % \end{macro}
20063 % \end{macro}
20064 %
20065 % \begin{macro}{\@cftbsnum}
20066 % \begin{macro}{\@cftasnum}
20067 % \begin{macro}{\@cftasnumb}
20068 % \begin{macrocode}
20069 \newcommand{\@cftbsnum}{}
20070 \newcommand{\@cftasnum}{}
20071 \newcommand{\@cftasnumb}{}
20072 % \end{macrocode}
20073 % \end{macro}
20074 % \end{macro}
20075 % \end{macro}
20076 %
20077 % \begin{macro}{\setcftvspacecmd}
20078 % \begin{macro}{\mem@cft@vspace@cmd}
20079 % The entries in the ToC adds \cs{cftbeforeXskip} above each
20080 % entry. Traditionally the class have always used \cs{vskip}
20081 % here,\footnote{We do not know why.} whereas the standard classes
20082 % used \cs{addvspace}. It has only been 20 years (2025) before a
20083 % user complained that fx the space above the first entry does not
20084 % disappear. Since changing the \cs{vskip} to \cs{addvspace} will
20085 % change thousands of documents, we instead make it configurable,
20086 % then the user can choose what suits them best.
20087 % \changes{v3.8.3}{2025/03/03}{Added \cs{setcftvspacecmd}}
20088 % \begin{macrocode}
20089 \newcommand\setcftvspacecmd[1]{\def\mem@cft@vspace@cmd{#1}}
20090 \setcftvspacecmd{\vskip}
20091 % \end{macrocode}
20092 % \end{macro}
20093 % \end{macro}
20094 %
20095 %
20096 % \begin{macro}{\newlistentry}
20097 % \cs{newlistentry}\oarg{within}\marg{counter}\marg{ext}\marg{level-1}
20098 % creates a set of commands for typesetting a new kind of entry in a List of.
20099 % \meta{counter} is the name of the counter for the entry and must be
20100 % the same as the name
20101 % of the entry (e.g., \texttt{subsection}). The optional \meta{within} is the
20102 % name of a counter within which \texttt{counter} is defined. The file extension
20103 % for the List of is \meta{ext} and \meta{level-1} is one less than the
20104 % level of the entry in the List of.
20105 % \changes{v1.61803}{2008/01/30}{Added \cs{cftXname} to \cs{newlistentry}
20106 % (mempatch v4.5)}
20107 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{newlistentry}}
20108 % \begin{macrocode}
20109 \newcommand{\newlistentry}[4][\@empty]{%
20110 % \end{macrocode}
20111 %
20112 % In the following, \texttt{X} is used as the value of \meta{counter} and
20113 % \texttt{Z} as the value of \meta{ext}.
20114 %
20115 % \begin{macro}{\c@X}
20116 % \begin{macro}{\theX}
20117 % Check if \meta{within} and \meta{counter} have been defined. It is
20118 % an error if \meta{within} has not been defined. \meta{counter}
20119 % will be created if it has not been previously defined.
20120 % Set the default counter values.
20121 % \begin{macrocode}
20122 \@ifundefined{c@#2}{% check & set the counter
20123 \ifx \@empty#1\relax
20124 \newcounter{#2}
20125 \else
20126 \newcounter{#2}[#1]%
20127 \expandafter\edef\csname the#2\endcsname{%
20128 \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
20129 \fi}{}
20130 \setcounter{#2}{0}
20131 % \end{macrocode}
20132 % \end{macro}
20133 % \end{macro}
20134 %
20135 % That finishes off the error checking. No matter what the result, the
20136 % rest of the new commands are defined.
20137 %
20138 % \begin{macro}{\l@X}
20139 % \cs{l@X}\marg{title}\marg{page} typesets the entry.
20140 % \begin{macrocode}
20141 \@namedef{l@#2}##1##2{%
20142 % \end{macrocode}
20143 % Only typeset if the \cs{Zdepth} is greater than \meta{level-1}.
20144 % \begin{macrocode}
20145 \ifnum \@nameuse{c@#3depth} > #4\relax
20146 % \end{macrocode}
20147 % Add some vertical space.
20148 % \changes{v3.8.3}{2025/03/03}{factoring the vertical space cmd}
20149 % \changes{v3.8.3b}{2025/03/10}{This contained a bug, better to not use \cs{@nameuse}}
20150 % \begin{macrocode}
20151 % \vskip \@nameuse{cftbefore#2skip}
20152 % \mem@cft@vspace@cmd \@nameuse{cftbefore#2skip}
20153 \ExpandArgs{c}\mem@cft@vspace@cmd{cftbefore#2skip}
20154 % \end{macrocode}
20155 % Start a group to keep paragraphing changes local. Set the \cs{leftskip}
20156 % to the entry's indentation.
20157 % \begin{macro}{\cftwhatismyname}
20158 % \changes{v1.61803398d}{2010/02/13}{added \cs{cftwhatismyname}}
20159 % \cs{cftwhatismyname} locally stores the type of toc entry. Useful
20160 % for hooks into general macros like \verb?\numberline?.
20161 % \begin{macrocode}
20162 {%\leftskip \@nameuse{cft#2indent}\relax
20163 \newcommand*\cftwhatismyname{#2}%
20164 \memRTLleftskip \@nameuse{cft#2indent}\relax
20165 % \end{macrocode}
20166 % \end{macro}
20167 % Set the \cs{rightskip} to \cs{@tocrmarg} to leave room for the page number.
20168 % \begin{macrocode}
20169 %%% \rightskip \@tocrmarg
20170 \memRTLrightskip \@tocrmarg
20171 % \end{macrocode}
20172 % Ensure that the last line of an entry will be filled. Setting \cs{parfillskip}
20173 % to a negative value prevents `overfull box' messages.
20174 % \begin{macrocode}
20175 %%% \parfillskip -\rightskip
20176 \parfillskip -\memRTLrightskip
20177 % \end{macrocode}
20178 % Set the paragraph's indentation to the entry's indentation.
20179 % \begin{macrocode}
20180 \parindent \@nameuse{cft#2indent}\relax\@afterindenttrue
20181 % \end{macrocode}
20182 % Try and prevent breaks between lines in a multiline entry.
20183 % \begin{macrocode}
20184 \interlinepenalty\@M
20185 % \end{macrocode}
20186 % Make sure we have left vertical mode.
20187 % \begin{macrocode}
20188 \leavevmode
20189 % \end{macrocode}
20190 % Our version of \cs{numberline} expects that the width of the number box
20191 % is in \cs{@tempdima}, and that the three macros \cs{@cftbsnum},
20192 % \cs{@cftaqsnum}, and \cs{@cftasnumb} are defined. We set all these to
20193 % the values for this entry.
20194 % \changes{v3.6k}{2012/07/30}{Added brace pair around
20195 % \cs{nameuse\{cft#2name\}}, then
20196 % \cs{cftXfont} can end with say \cs{MakeUppercase}}
20197 % \begin{macrocode}
20198 \settowidth{\@tempdima}{\@nameuse{cft#2font}{\@nameuse{cft#2name}}}%
20199 \addtolength{\@tempdima}{\@nameuse{cft#2numwidth}}%
20200 \expandafter\let\expandafter\@cftbsnum\csname cft#2presnum\endcsname
20201 \expandafter\let\expandafter\@cftasnum\csname cft#2aftersnum\endcsname
20202 \expandafter\let\expandafter\@cftasnumb\csname cft#2aftersnumb\endcsname
20203 \expandafter\let\expandafter\@cftn@me\csname cft#2name\endcsname
20204 % \end{macrocode}
20205 % Arrange that the (entry number and) first line of the title is set at
20206 % the current indent, and that any subsequent lines will be further
20207 % indented.
20208 % \begin{macrocode}
20209 %%% \advance\leftskip\@tempdima \null\nobreak\hskip -\leftskip
20210 \advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
20211 % \end{macrocode}
20212 % Print the (number and) title, prohibiting any breaking.
20213 % \changes{v3.6k}{2012/07/29}{Added brace pair around \#\#1, then
20214 % \cs{cftXfont} can end with say \cs{MakeUppercase}}
20215 % \begin{macrocode}
20216 {\@nameuse{cft#2font}{##1}}\nobreak
20217 % \end{macrocode}
20218 % Print the leader and the page number, and then close the group.
20219 % \begin{macrocode}
20220 \@nameuse{cft#2fillnum}{##2}}
20221 \fi
20222 }% end of \l@#2
20223
20224 % \end{macrocode}
20225 % \end{macro}
20226 %
20227 % Now define all the layout commands used by \cs{l@X}. The default
20228 % values of these print the entry in a normal font with a dotted
20229 % line between the title and the page number.
20230 % \begin{macro}{\cftbeforeXskip}
20231 % The skip before the title.
20232 % \begin{macrocode}
20233 \expandafter\newlength\csname cftbefore#2skip\endcsname
20234 \setlength{\@nameuse{cftbefore#2skip}}{\z@ \@plus .2\p@}
20235 % \end{macrocode}
20236 % \end{macro}
20237 % \begin{macro}{\cftXindent}
20238 % \begin{macro}{\cftXnumwidth}
20239 % The indent and width for the number.
20240 % \begin{macrocode}
20241 \expandafter\newlength\csname cft#2indent\endcsname
20242 \expandafter\newlength\csname cft#2numwidth\endcsname
20243 % \end{macrocode}
20244 % Set the default values for the indent and numwidth depending on
20245 % the entry's level. A level of 1 corresponds to a figure entry
20246 % (no indent, and space for a number like N.N).
20247 % \begin{macrocode}
20248 \ifcase #4\relax % 0 (level 1)
20249 \setlength{\@nameuse{cft#2indent}}{0em}
20250 \setlength{\@nameuse{cft#2numwidth}}{2.3em}
20251 \or % 1 (level 2)
20252 \setlength{\@nameuse{cft#2indent}}{2.3em}
20253 \setlength{\@nameuse{cft#2numwidth}}{3.2em}
20254 \or % 2 (level 3)
20255 \setlength{\@nameuse{cft#2indent}}{5.5em}
20256 \setlength{\@nameuse{cft#2numwidth}}{4.1em}
20257 \or % 3 (level 4)
20258 \setlength{\@nameuse{cft#2indent}}{8.5em}
20259 \setlength{\@nameuse{cft#2numwidth}}{5.0em}
20260 \else % anything else
20261 \setlength{\@nameuse{cft#2indent}}{10.5em}
20262 \setlength{\@nameuse{cft#2numwidth}}{6.0em}
20263 \fi
20264 % \end{macrocode}
20265 % \end{macro}
20266 % \end{macro}
20267 % \begin{macro}{\cftXfont}
20268 % \begin{macro}{\cftXname}
20269 % \begin{macro}{\cftXpresnum}
20270 % \begin{macro}{\cftXaftersnum}
20271 % \begin{macro}{\cftXaftersnumb}
20272 % \begin{macro}{\cftXdotsep}
20273 % \begin{macro}{\cftXleader}
20274 % \begin{macro}{\cftXpagefont}
20275 % \begin{macro}{\cftXafterpnum}
20276 % And the remaining commands; the only ones that are not null are for the
20277 % dotsep, the font and the leader
20278 % \begin{macrocode}
20279 \@namedef{cft#2font}{\normalfont}
20280 \@namedef{cft#2name}{}
20281 \@namedef{cft#2presnum}{}
20282 \@namedef{cft#2aftersnum}{}
20283 \@namedef{cft#2aftersnumb}{}
20284 \@namedef{cft#2dotsep}{\cftdotsep}
20285 \@namedef{cft#2leader}{\normalfont\cftdotfill{\@nameuse{cft#2dotsep}}}
20286 \@namedef{cft#2pagefont}{\normalfont}
20287 \@namedef{cft#2afterpnum}{}
20288 % \end{macrocode}
20289 % \end{macro}
20290 % \end{macro}
20291 % \end{macro}
20292 % \end{macro}
20293 % \end{macro}
20294 % \end{macro}
20295 % \end{macro}
20296 % \end{macro}
20297 % \end{macro}
20298 %
20299 % \begin{macro}{\toclevel@X}
20300 % The hyperref package needs a command \cs{toclevel@X}, holding
20301 % the \meta{level-1} value.
20302 % \begin{macrocode}
20303 \@namedef{toclevel@#2}{#4}
20304 % \end{macrocode}
20305 % \end{macro}
20306 %
20307 % \begin{macro}{\cftXformatpnum}
20308 % \begin{macro}{\cftXformatpnumhook}
20309 % \begin{macro}{\cftXfillnum}
20310 % Typeset the leader and page number. We add a hook into the formating
20311 % of the page number. This might later be used to record the widths of
20312 % the numbers used. It will be given the page number as its
20313 % argument. Does nothing by default.
20314 % \changes{v1.61803}{2008/01/30}{Added \cs{cftXformatpnum} (Dan Leucking
20315 % mempatch v4.9)}
20316 % \changes{v1.61803398d}{2010/02/13}{added hook into page number formatter}
20317 % \begin{macrocode}
20318 \@namedef{cft#2formatpnumhook}##1{}
20319 \@namedef{cft#2formatpnum}##1{%
20320 \@nameuse{cft#2formatpnumhook}{##1}%
20321 \hb@xt@\@pnumwidth{\hfil\@nameuse{cft#2pagefont}##1}}
20322 \@namedef{cft#2fillnum}##1{%
20323 {\@nameuse{cft#2leader}}\nobreak
20324 %%% \hb@xt@\@pnumwidth{%
20325 %%% \hfil\@nameuse{cft#2pagefont}##1}
20326 \@nameuse{cft#2formatpnum}{##1}%
20327 \@nameuse{cft#2afterpnum}\par}
20328 % \end{macrocode}
20329 % \end{macro}
20330 % \end{macro}
20331 % \end{macro}
20332 % This ends the definition of \cs{newlistentry}.
20333 % \begin{macrocode}
20334 } % end \newlistentry
20335
20336 % \end{macrocode}
20337 % \end{macro}
20338 %
20339 %
20340 % \begin{macro}{\cftsetindents}
20341 % \cs{cftsetindents}\marg{entry}\marg{indent}\marg{numwidth} sets
20342 % the \textit{indent} and \textit{numwidth} for entry \meta{entry}.
20343 % \begin{macrocode}
20344 \newcommand*{\cftsetindents}[3]{%
20345 \setlength{\@nameuse{cft#1indent}}{#2}
20346 \setlength{\@nameuse{cft#1numwidth}}{#3}}
20347
20348 % \end{macrocode}
20349 % \end{macro}
20350 %
20351 % \begin{macro}{\cftbookname}
20352 % If you want a book entry in the ToC like: \\
20353 % BOOK I Title ... \\
20354 % then \verb?\renewcommand*{\cftbookname}{BOOK~}? \\
20355 % \begin{macrocode}
20356 \newcommand*{\cftbookname}{}
20357
20358 % \end{macrocode}
20359 % \end{macro}
20360 %
20361 % \begin{macro}{\cftbookbreak}
20362 % \begin{macro}{\l@book}
20363 % \begin{macro}{\booknumberline}
20364 % \begin{macro}{\booknumberlinehook}
20365 % Now for the ToC entry.
20366 % \changes{v1.61803}{2008/01/30}{Added \cs{l@book} and supports (mempatch v4.4)}
20367 % \changes{v1.6180339}{2008/07/23}{Deleted \cs{space} from \cs{booknumberline}
20368 % and \cs{partnumberline}
20369 % (per Lars Henrik Gam Madsen mempatch v5.1)}
20370 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@book}}
20371 % \changes{v1.61803398d}{2010/02/13}{added hook into the book numberline}
20372 % \changes{v3.6k}{2012/07/22}{Factored the general box out of \cs{booknumberline}}
20373 % \changes{v3.8.3}{2025/03/06}{Factored out the penalty}
20374 % \changes{v3.8.4}{2025/08/15}{Fixed typo, need \cs{cftbeforebookpenalty} not \cs{cftbeforepartpenalty}, even if they have the same value }
20375 % \begin{macrocode}
20376 \newcommand*{\cftbookbreak}{%
20377 \addpenalty{\cftbeforebookpenalty}%
20378 \addvspace{\cftbeforebookskip}%
20379 }
20380 \newcommand*{\l@book}[2]{%
20381 \ifnum\c@tocdepth >-3\relax
20382 \cftbookbreak
20383 \begingroup
20384 {%\leftskip \cftbookindent\relax
20385 \memRTLleftskip \cftbookindent\relax
20386 %%% \rightskip \@tocrmarg
20387 \memRTLrightskip \@tocrmarg
20388 %%% \parfillskip -\rightskip
20389 \parfillskip -\memRTLrightskip
20390 \parindent \cftbookindent\relax\@afterindenttrue
20391 \interlinepenalty\@M
20392 \leavevmode
20393 \settowidth{\@tempdima}{\cftbookfont\cftbookname}%
20394 \addtolength{\@tempdima}{\cftbooknumwidth}%
20395 \let\@cftbsnum \cftbookpresnum
20396 \let\@cftasnum \cftbookaftersnum
20397 \let\@cftasnumb \cftbookaftersnumb
20398 %%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
20399 \advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
20400 % \end{macrocode}
20401 % \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
20402 % \cs{cftbookfont} can end with say \cs{MakeUppercase}}
20403 % \begin{macrocode}
20404 {\cftbookfont {#1}}%
20405 \cftbookfillnum{#2}}
20406 \nobreak
20407 \global\@nobreaktrue
20408 \everypar{\global\@nobreakfalse\everypar{}}%
20409 \endgroup
20410 \fi}
20411 \newcommand*\booknumberlinehook[1]{}
20412 \newcommand{\booknumberline}[1]{%
20413 \booknumberlinehook{#1}%
20414 % \hb@xt@\@tempdima{%
20415 % \cftbookname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
20416 \booknumberlinebox\@tempdima{%
20417 \cftbookname\@cftbsnum #1\@cftasnum}\@cftasnumb}%%\space}
20418
20419 % \end{macrocode}
20420 % \end{macro}
20421 % \end{macro}
20422 % \end{macro}
20423 % \end{macro}
20424 %
20425 % \newpage
20426 %
20427 % \begin{macro}{\cftbeforebookskip}
20428 % \begin{macro}{\cftbeforebookpenalty}
20429 % \begin{macro}{\cftbookindent}
20430 % \begin{macro}{\cftbooknumwidth}
20431 % \begin{macro}{\cftbookfont}
20432 % \begin{macro}{\cftbookpresnum}
20433 % \begin{macro}{\cftbookaftersnum}
20434 % \begin{macro}{\cftbookaftersnumb}
20435 % \begin{macro}{\cftbookleader}
20436 % \begin{macro}{\cftbookdotsep}
20437 % \begin{macro}{\cftbookpagefont}
20438 % \begin{macro}{\cftbookafterpnum}
20439 % \begin{macro}{\cftbookfillnum}
20440 % \begin{macro}{\cftbookformatpnum}
20441 % \begin{macro}{\cftbookformatpnumhook}
20442 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftbookformatpnum}}
20443 % \changes{v3.8.3}{2025/03/06}{added \cs{cftbeforebookpenalty}}
20444 % \begin{macrocode}
20445 \newlength{\cftbeforebookskip}
20446 \setlength{\cftbeforebookskip}{2.25em \@plus\p@}
20447 \newcommand\cftbeforebookpenalty{-\@highpenalty}
20448 \newdimen\cftbookindent
20449 \setlength{\cftbookindent}{0em}
20450 \newdimen\cftbooknumwidth
20451 \setlength{\cftbooknumwidth}{1.5em}
20452 \newcommand*{\cftbookfont}{\large\bfseries}
20453 \newcommand*{\cftbookpresnum}{}
20454 \newcommand*{\cftbookaftersnum}{}
20455 \newcommand*{\cftbookaftersnumb}{}
20456 \newcommand*{\cftbookleader}{%
20457 \large\bfseries\cftdotfill{\cftbookdotsep}}
20458 \newcommand*{\cftbookdotsep}{\cftnodots}
20459 \newcommand*{\cftbookpagefont}{\large\bfseries}
20460 \newcommand{\cftbookafterpnum}{}
20461 \newcommand{\cftbookfillnum}[1]{%
20462 {\cftbookleader}%
20463 %%%% {\hb@xt@\@pnumwidth{\hss {\cftbookpagefont #1}}}%
20464 \cftbookformatpnum{#1}%
20465 \cftbookafterpnum\par}
20466 \newcommand{\cftbookformatpnumhook}[1]{}
20467 \newcommand{\cftbookformatpnum}[1]{%
20468 \cftbookformatpnumhook{#1}%
20469 \hb@xt@\@pnumwidth{\hss {\cftbookpagefont #1}}}
20470
20471 % \end{macrocode}
20472 % \end{macro}
20473 % \end{macro}
20474 % \end{macro}
20475 % \end{macro}
20476 % \end{macro}
20477 % \end{macro}
20478 % \end{macro}
20479 % \end{macro}
20480 % \end{macro}
20481 % \end{macro}
20482 % \end{macro}
20483 % \end{macro}
20484 % \end{macro}
20485 % \end{macro}
20486 % \end{macro}
20487 %
20488 %
20489 %
20490 % \begin{macro}{\cftpartname}
20491 % If you want a part entry in the ToC like: \\
20492 % PART I Title ... \\
20493 % then \verb?\renewcommand*{\cftpartname}{PART~}? \\
20494 % \changes{v1.618}{2005/09/03}{Added \cs{cftpartname}, courtesy Danie Els (mempatch v3.12)}
20495 % \begin{macrocode}
20496 \newcommand*{\cftpartname}{}
20497
20498 % \end{macrocode}
20499 % \end{macro}
20500 %
20501 % \begin{macro}{\cftpartbreak}
20502 % \begin{macro}{\l@part}
20503 % Can't use \cs{newlistentry} for \cs{l@part} because of the initial penalty
20504 % and the final \cs{nobreak} code.
20505 % \changes{v1.61803}{2008/01/30}{Added \cs{cftpartbreak}}
20506 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@part}}
20507 % \changes{v3.8.3}{2025/03/06}{Factored out the penalty part}
20508 % \begin{macrocode}
20509 \newcommand*{\cftpartbreak}{%
20510 \addpenalty{\cftbeforepartpenalty}%
20511 \addvspace{\cftbeforepartskip}%
20512 }
20513 \newcommand*{\l@part}[2]{%
20514 \ifnum \c@tocdepth >-2\relax
20515 \cftpartbreak
20516 \begingroup
20517 {%\leftskip \cftpartindent\relax
20518 \memRTLleftskip \cftpartindent\relax
20519 %%% \rightskip \@tocrmarg
20520 \memRTLrightskip \@tocrmarg
20521 %%% \parfillskip -\rightskip
20522 \parfillskip -\memRTLrightskip
20523 \parindent \cftpartindent\relax\@afterindenttrue
20524 \interlinepenalty\@M
20525 \leavevmode
20526 \settowidth{\@tempdima}{\cftpartfont\cftpartname}%
20527 \addtolength{\@tempdima}{\cftpartnumwidth}%
20528 \let\@cftbsnum \cftpartpresnum
20529 \let\@cftasnum \cftpartaftersnum
20530 \let\@cftasnumb \cftpartaftersnumb
20531 %%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
20532 \advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
20533 % \end{macrocode}
20534 % \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
20535 % \cs{cftpartkfont} can end with say \cs{MakeUppercase}}
20536 % \begin{macrocode}
20537 {\cftpartfont {#1}}%
20538 \cftpartfillnum{#2}}
20539 \nobreak
20540 \global\@nobreaktrue
20541 \everypar{\global\@nobreakfalse\everypar{}}%
20542 \endgroup
20543 \fi}
20544
20545 % \end{macrocode}
20546 % \end{macro}
20547 % \end{macro}
20548 %
20549 % \begin{macro}{\toclevel@part}
20550 % Needed if the \Lpack{hyperref} package is used.
20551 % \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@part} (mempatch v4.9)}
20552 % \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@part} definition to
20553 % \cs{def} for better compability with future hyperref}
20554 % \begin{macrocode}
20555 \def\toclevel@part{-1}
20556
20557 % \end{macrocode}
20558 % \end{macro}
20559 %
20560 % \begin{macro}{\partnumberline}
20561 % \begin{macro}{\partnumberlinehook}
20562 % \cs{partnumberline} is a special version of \cs{numberline} output by \cs{part}.
20563 % Its default definition is identical to \cs{numberline}.
20564 % \changes{v1.3}{2002/11/14}{Added \cs{partnumberline}}
20565 % \changes{v1.61803}{2008/01/30}{Added a space after the number in
20566 % \cs{partnumberline} (mempatch v4.4)}
20567 % \changes{v1.61803398d}{2010/02/13}{added hook into part numberline}
20568 % \changes{v3.6k}{2012/07/22}{Factored out the box command}
20569 % \begin{macrocode}
20570 \newcommand*\partnumberlinehook[1]{}
20571 \newcommand{\partnumberline}[1]{%
20572 \partnumberlinehook{#1}%
20573 % \hb@xt@\@tempdima{%
20574 % \cftpartname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
20575 \partnumberlinebox\@tempdima{%
20576 \cftpartname\@cftbsnum #1\@cftasnum}\@cftasnumb}%%\space}
20577
20578
20579 % \end{macrocode}
20580 % \end{macro}
20581 % \end{macro}
20582 %
20583 % \begin{macro}{\cftbeforepartskip}
20584 % \begin{macro}{\cftbeforepartpenalty}
20585 % \begin{macro}{\cftpartnumwidth}
20586 % \begin{macro}{\cftpartfont}
20587 % \begin{macro}{\cftpartpresnum}
20588 % \begin{macro}{\cftpartaftersnum}
20589 % \begin{macro}{\cftpartaftersnumb}
20590 % \begin{macro}{\cftpartleader}
20591 % \begin{macro}{\cftpartdotsep}
20592 % \begin{macro}{\cftpartpagefont}
20593 % \begin{macro}{\cftpartafterpnum}
20594 % \begin{macro}{\cftpartindent}
20595 % \begin{macro}{\cftpartformatpnum}
20596 % \begin{macro}{\cftpartformatpnumhook}
20597 % \begin{macro}{\cftpartfillnum}
20598 % These are the user commands to control the typesetting of Part entries.
20599 % They are initialised to give the standard appearance.
20600 % \changes{v1.3}{2002/10/10}{Changed \cs{cftpartnumwidth} to cater for
20601 % use of \cs{numberline} in the ToC}
20602 % \changes{v1.61803}{2008/01/30}{Added \cs{cftpartformatpnum} (mempatch v4.9)}
20603 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftpartformatpnum}}
20604 % \changes{v3.8.3}{2025/03/06}{Added \cs{cftbeforepartpenalty}}
20605 % \begin{macrocode}
20606 \newlength{\cftbeforepartskip}
20607 \setlength{\cftbeforepartskip}{2.25em \@plus\p@}
20608 \newcommand\cftbeforepartpenalty{-\@highpenalty}
20609 \newlength{\cftpartindent}
20610 \setlength{\cftpartindent}{0em}
20611 \newlength{\cftpartnumwidth}
20612 \setlength{\cftpartnumwidth}{1.5em}
20613 \newcommand{\cftpartfont}{\large\bfseries}
20614 \newcommand{\cftpartpresnum}{}
20615 \newcommand{\cftpartaftersnum}{}
20616 \newcommand{\cftpartaftersnumb}{}
20617 \newcommand{\cftpartleader}{%
20618 \large\bfseries\cftdotfill{\cftpartdotsep}}
20619 \newcommand{\cftpartdotsep}{\cftnodots}
20620 \newcommand{\cftpartpagefont}{\large\bfseries}
20621 \newcommand{\cftpartafterpnum}{}
20622 \newcommand{\cftpartformatpnumhook}[1]{}
20623 \newcommand*{\cftpartformatpnum}[1]{%
20624 \cftpartformatpnumhook{#1}%
20625 \hb@xt@\@pnumwidth{\hss {\cftpartpagefont #1}}}
20626 \newcommand{\cftpartfillnum}[1]{%
20627 {\cftpartleader}%
20628 {\cftpartformatpnum{#1}}%
20629 \cftpartafterpnum\par}
20630
20631 % \end{macrocode}
20632 % \end{macro}
20633 % \end{macro}
20634 % \end{macro}
20635 % \end{macro}
20636 % \end{macro}
20637 % \end{macro}
20638 % \end{macro}
20639 % \end{macro}
20640 % \end{macro}
20641 % \end{macro}
20642 % \end{macro}
20643 % \end{macro}
20644 % \end{macro}
20645 % \end{macro}
20646 % \end{macro}
20647 %
20648 %
20649 % \begin{macro}{\cftchaptername}
20650 % If you want a chapter entry in the ToC like: \\
20651 % Chapter 1. A title ... \\
20652 % then \verb?\renewcommand*{\cftchaptername}{\chaptername~}? \\
20653 % \verb?\renewcommand*{\cftchapteraftersnum}{.}? \\
20654 %
20655 % \changes{v1.618}{2005/09/03}{Added \cs{cftchaptername}, courtesy Danie Els (mempatch v3.12)}
20656 % \begin{macrocode}
20657 \newcommand*{\cftchaptername}{}
20658
20659 % \end{macrocode}
20660 % \end{macro}
20661 %
20662 % \begin{macro}{\l@chapapp}
20663 % Generic chapter/appendix ToC entry typesetting.
20664 % \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak} to
20665 % \cs{l@chapter} (Peter probably meant \cs{l@chapapp} here, and thus
20666 % the remark was moved here, /dlf 2025/03/03)}
20667 % \changes{v1.618}{2005/09/03}{Added \cs{l@chapapp}, courtesy Danie Els (mempatch v3.12)}
20668 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@chapapp}}
20669 % \begin{macrocode}
20670 \newcommand*{\l@chapapp}[3]{%
20671 \ifnum \c@tocdepth >\m@ne
20672 % \end{macrocode}
20673 % 2025/03/03: Factored the vertical skip part into \cs{cftchapterbreak} to mimic \cs{part} and \cs{book}
20674 % \begin{macrocode}
20675 \cftchapterbreak
20676 % \vskip \cftbeforechapterskip
20677 {%\leftskip \cftchapterindent\relax
20678 \memRTLleftskip \cftchapterindent\relax
20679 %%% \rightskip \@tocrmarg
20680 \memRTLrightskip \@tocrmarg
20681 %%% \parfillskip -\rightskip
20682 \parfillskip -\memRTLrightskip
20683 \parindent \cftchapterindent\relax
20684 \@afterindenttrue
20685 \interlinepenalty\@M
20686 \leavevmode
20687 \let\@cftbsnum \cftchapterpresnum
20688 \let\@cftasnum \cftchapteraftersnum
20689 \let\@cftasnumb \cftchapteraftersnumb
20690 \def\@chapapp@head{#3}%
20691 \settowidth{\@tempdima}{\cftchapterfont\@chapapp@head}%
20692 \addtolength{\@tempdima}{\cftchapternumwidth}%
20693 %%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
20694 \advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
20695 % \end{macrocode}
20696 % \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
20697 % \cs{cftchapterfont} can end with say \cs{MakeUppercase}}
20698 % \begin{macrocode}
20699 {\cftchapterfont {#1}}\nobreak
20700 \cftchapterfillnum{#2}}
20701 \fi}
20702
20703 % \end{macrocode}
20704 % \end{macro}
20705 %
20706 % \begin{macro}{\l@chapter}
20707 % \cs{l@chapter}\marg{title}\marg{page} typesets the ToC entry for
20708 % a \texttt{chapter} heading. It is a parameterised copy of the default
20709 % \cs{l@chapter}
20710 % (see \file{classes.dtx} for the original definition). Can't use
20711 % \cs{newlistentry} for this because of the intial penalty.
20712 % \changes{v1.618}{2005/09/03}{Defined \cs{l@chapter} in terms of \cs{l@chapapp} (mempatch v3.12)}
20713 % \begin{macrocode}
20714 \newcommand*{\l@chapter}[2]{%
20715 \l@chapapp{#1}{#2}{\cftchaptername}}
20716
20717 % \end{macrocode}
20718 % \end{macro}
20719 %
20720 % \begin{macro}{\toclevel@chapter}
20721 % Needed if the \Lpack{hyperref} package is used.
20722 % \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@chapter} (mempatch v4.9)}
20723 % \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@chapter} definitions to
20724 % \cs{def} for better compability with future hyperref}
20725 % \begin{macrocode}
20726 \def\toclevel@chapter{0}
20727
20728 % \end{macrocode}
20729 % \end{macro}
20730 %
20731 % \begin{macro}{\cftappendixname}
20732 % If you want a appendixed chapter entry in the ToC like: \\
20733 % Appendix A A title ... \\
20734 % then \verb?\renewcommand*{\cftappendixname}{\appendixname~}? \\
20735 %
20736 % \changes{v1.618}{2005/09/03}{Added \cs{cftappendixname}, courtesy Danie Els (mempatch v3.12)}
20737 % \begin{macrocode}
20738 \newcommand*{\cftappendixname}{}
20739
20740 % \end{macrocode}
20741 % \end{macro}
20742 %
20743 % \begin{macro}{\l@appendix}
20744 % \begin{macro}{\toclevel@appendix}
20745 % Similar to \cs{l@chapter} but for an appendix.
20746 % \changes{v1.618}{2005/09/03}{Added \cs{l@apendix} (mempatch v3.12)}
20747 % \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@appendix} definitions to
20748 % \cs{def} for better compability with future hyperref}
20749 % \begin{macrocode}
20750 \newcommand*{\l@appendix}[2]{%
20751 \l@chapapp{#1}{#2}{\cftappendixname}}
20752 \def\toclevel@appendix{0}
20753
20754 % \end{macrocode}
20755 % \end{macro}
20756 % \end{macro}
20757 %
20758 % \begin{macro}{\chapternumberline}
20759 % \begin{macro}{\chapternumberlinehook}
20760 % \cs{chapternumberline} is a special version of \cs{numberline} output by
20761 % \cs{chapter}.
20762 % It's default definition is identical to \cs{numberline}.
20763 % \changes{v1.3}{2002/11/14}{Added \cs{chapternumberline}}
20764 % \changes{v1.618}{2005/09/03}{Added \cs{@chapapp@head} to \cs{chapternumberline} (mempatch v3.12)}
20765 % \changes{v1.61803398d}{2010/02/13}{added hook into chapter numberline}
20766 % \changes{v3.6k}{2012/07/22}{Factored out the box command}
20767 % \begin{macrocode}
20768 \newcommand*\chapternumberlinehook[1]{}
20769 \newcommand{\chapternumberline}[1]{%
20770 \chapternumberlinehook{#1}%
20771 % \hb@xt@\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum\hfil}%
20772 % \@cftasnumb}
20773 \chapternumberlinebox\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum}%
20774 \@cftasnumb}
20775
20776 % \end{macrocode}
20777 % \end{macro}
20778 % \end{macro}
20779 %
20780 % \begin{macro}{\cftbeforechapterskip}
20781 % \begin{macro}{\cftbeforechapterpenalty}
20782 % \begin{macro}{\cftchapterindent}
20783 % \begin{macro}{\cftchapternumwidth}
20784 % \begin{macro}{\cftchapterfont}
20785 % \begin{macro}{\cftchapterpresnum}
20786 % \begin{macro}{\cftchapteraftersnum}
20787 % \begin{macro}{\cftchapteraftersnumb}
20788 % \begin{macro}{\cftchapterleader}
20789 % \begin{macro}{\cftchapterdotsep}
20790 % \begin{macro}{\cftchapterpagefont}
20791 % \begin{macro}{\cftchapterafterpnum}
20792 % \begin{macro}{\cftchapterformatpnum}
20793 % \begin{macro}{\cftchapterformatpnumhook}
20794 % \begin{macro}{\cftchapterfillnum}
20795 % These are the user commands to control the typesetting of Chapter entries.
20796 % They are initialised to give the standard appearance.
20797 % \changes{v1.61803}{2008/01/30}{Added \cs{cftchapterformatpnum} (mempatch v4.9)}
20798 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftchapterformatpnum}}
20799 % \changes{v3.8.3}{2025/03/06}{Added \cs{cftbeforechapterpenalty}}
20800 % \begin{macrocode}
20801 \newlength{\cftbeforechapterskip}
20802 \setlength{\cftbeforechapterskip}{1.0em \@plus\p@}
20803 \newcommand\cftbeforechapterpenalty{-\@highpenalty}
20804 \newlength{\cftchapterindent}
20805 \setlength{\cftchapterindent}{0em}
20806 \newlength{\cftchapternumwidth}
20807 \setlength{\cftchapternumwidth}{1.5em}
20808 \newcommand{\cftchapterfont}{\bfseries}
20809 \newcommand{\cftchapterpresnum}{}
20810 \newcommand{\cftchapteraftersnum}{}
20811 \newcommand{\cftchapteraftersnumb}{}
20812 \newcommand{\cftchapterleader}{%
20813 \bfseries\cftdotfill{\cftchapterdotsep}}
20814 \newcommand{\cftchapterdotsep}{\cftnodots}
20815 \newcommand{\cftchapterpagefont}{\bfseries}
20816 \newcommand{\cftchapterafterpnum}{}
20817 \newcommand{\cftchapterformatpnumhook}[1]{}
20818 \newcommand*{\cftchapterformatpnum}[1]{%
20819 \cftchapterformatpnumhook{#1}%
20820 \hb@xt@\@pnumwidth{\hfil\cftchapterpagefont #1}}
20821 \newcommand*{\cftchapterfillnum}[1]{%
20822 {\cftchapterleader}\nobreak
20823 \cftchapterformatpnum{#1}%
20824 \cftchapterafterpnum\par}
20825 % \end{macrocode}
20826 % \end{macro}
20827 % \end{macro}
20828 % \end{macro}
20829 % \end{macro}
20830 % \end{macro}
20831 % \end{macro}
20832 % \end{macro}
20833 % \end{macro}
20834 % \end{macro}
20835 % \end{macro}
20836 % \end{macro}
20837 % \end{macro}
20838 % \end{macro}
20839 % \end{macro}
20840 % \end{macro}
20841 %
20842 % \begin{macro}{\cftchapterbreak}
20843 % Another parameter for \cs{l@chapter}.
20844 % \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak}}
20845 % \changes{v3.8.3}{2025/03/03}{Moved the vertical skip part into \cs{cftchapterbreak}}
20846 % \changes{v3.8.3}{2025/03/06}{Factored the penalty into its own macro}
20847 % \begin{macrocode}
20848 \newcommand{\cftchapterbreak}{%
20849 \addpenalty{\cftbeforechapterpenalty}%
20850 \mem@cft@vspace@cmd \cftbeforechapterskip%
20851 }
20852
20853 % \end{macrocode}
20854 % \end{macro}
20855 %
20856 % \begin{macro}{\l@section}
20857 % \begin{macro}{\l@subsection}
20858 % \begin{macro}{\l@subsubsection}
20859 % \begin{macro}{\l@paragraph}
20860 % \begin{macro}{\l@subparagraph}
20861 % \cs{l@section}\marg{title}\marg{page} typesets the ToC entry for
20862 % a \cs{section} heading. Similarly \cs{l@subsection} and \cs{l@subsubsection}
20863 % for \cs{subsection} and \cs{subsubsection} entries, and so on.
20864 % \changes{v1.4}{2003/11/22}{Used \cs{newlistentry} for pararaph and
20865 % subparagraph (from patch v1.7)}
20866 % \changes{v1.618}{2005/09/02}{Corrected (sub)paragraph ToC indents (mempatch v2.3)}
20867 % \begin{macrocode}
20868 \newlistentry[chapter]{section}{toc}{0}
20869 \cftsetindents{section}{1.5em}{2.3em}
20870 \newlistentry[section]{subsection}{toc}{1}
20871 \cftsetindents{subsection}{3.8em}{3.2em}
20872 \newlistentry[subsection]{subsubsection}{toc}{2}
20873 \cftsetindents{subsubsection}{7.0em}{4.1em}
20874 \newlistentry[subsubsection]{paragraph}{toc}{3}
20875 \cftsetindents{paragraph}{10.0em}{5.0em}
20876 \newlistentry[paragraph]{subparagraph}{toc}{4}
20877 \cftsetindents{subparagraph}{12.0em}{6.0em}
20878
20879 % \end{macrocode}
20880 % \end{macro}
20881 % \end{macro}
20882 % \end{macro}
20883 % \end{macro}
20884 % \end{macro}
20885 %
20886 % The typesetting for Figures and Tables is defined later.
20887 %
20888 %
20889 %
20890 % \subsection{Support for the \Lpack{subfigure} package}
20891 %
20892 % The code for supporting the \Lpack{subfigure} package is, in all
20893 % essentials, the same as that for the figure and table captions; only the
20894 % names are changed. However, the code need only be executed if the
20895 % \Lpack{subfigure} package is actually loaded.
20896 %
20897 % \begin{macro}{\@cftl@subfigtab}
20898 % This command redefines the \cs{l@subfigure} and \cs{l@subtable} commands.
20899 % \changes{v1.61803}{2008/01/30}{Made \cs{@cftl@subfigtab} a no-op (mempatch v4.6)}
20900 % \begin{macrocode}
20901 \newcommand*{\@cftl@subfigtab}{
20902 % \end{macrocode}
20903 % \begin{macro}{\l@subfigure}
20904 % \begin{macro}{\l@subtable}
20905 % \cs{l@subfigure}\marg{title}\marg{page} typesets the LoF entry for
20906 % a subfigure caption heading, and \cs{l@subtable} does the same for subtables.
20907 % \begin{macrocode}
20908 \newlistentry[figure]{subfigure}{lof}{1}
20909 \cftsetindents{subfigure}{2.3em}{2.5em}
20910 \newlistentry[table]{subtable}{lot}{1}
20911 \cftsetindents{subtable}{2.3em}{2.5em}}
20912 \renewcommand*{\@cftl@subfigtab}{}
20913
20914 % \end{macrocode}
20915 % \end{macro}
20916 % \end{macro}
20917 % \end{macro}
20918 %
20919 %
20920 % Call the \Lpack{subfigure} package setup code only if the
20921 % \Lopt{subfigure} package has been used.
20922 % \begin{macrocode}
20923 \AtBeginDocument{\@ifpackageloaded{subfigure}{\@cftl@subfigtab}{}}
20924
20925 % \end{macrocode}
20926 %
20927 %
20928 % \subsection{Switching page numbering}
20929 %
20930 % It can, at times, be useful to be able to have ToC entries that have
20931 % no printed page numbers.
20932 %
20933 % \begin{macro}{\cftpagenumbersoff}
20934 % The user level command for switching off page numbers is
20935 % \cs{cftpagenumbersoff}\marg{entry} where \meta{entry} is the
20936 % name of the entry.
20937 % The macro redefines the \cs{cftXfillnum} command so that there is no leader
20938 % and the page number is ignored.
20939 % \begin{macrocode}
20940 \DeclareRobustCommand{\cftpagenumbersoff}[1]{%
20941 \@namedef{cft#1fillnum}##1{%
20942 \cftparfillskip\@nameuse{cft#1afterpnum}\par}}
20943
20944 % \end{macrocode}
20945 % \end{macro}
20946 %
20947 % \begin{macro}{\cftpagenumberson}
20948 % \cs{cftpagenumberson}\marg{entry} is the user level command for
20949 % reversing the corresponding \cs{cftpagenumbersoff}.
20950 % The macro defines the \cs{cftXfillnum} command to correspond to
20951 % the default definition.
20952 % \changes{v1.61803}{2008/01/30}{Modified \cs{cftpagenumberson} to use \cs{cftXformatpnum}
20953 % (mempatch v4.9)}
20954 % \begin{macrocode}
20955 \DeclareRobustCommand{\cftpagenumberson}[1]{%
20956 \@namedef{cft#1fillnum}##1{%
20957 \@nameuse{cft#1leader}\nobreak
20958 \@nameuse{cft#1formatpnum}{##1}%
20959 \@nameuse{cft#1afterpnum}\par}}
20960
20961 % \end{macrocode}
20962 % \end{macro}
20963 %
20964 %
20965 % \subsection{Chapter precis}
20966 %
20967 % \begin{macro}{\chapterprecis}
20968 % The command \cs{chapterprecis}\marg{text} typesets
20969 % \meta{text} at the point where it is called, and also adds \meta{text}
20970 % to the \file{.toc} file. It is expects to be called immediately after
20971 % a \cs{chapter} command.
20972 % \begin{macrocode}
20973 \newcommand{\chapterprecis}[1]{%
20974 \chapterprecishere{#1}
20975 \chapterprecistoc{#1}}
20976 % \end{macrocode}
20977 % \end{macro}
20978 %
20979 % \begin{macro}{\chapterprecishere}
20980 % \cs{chapterprecishere}\marg{text} typesets \meta{text}. It expects
20981 % to be called immediately after a \cs{chapter} command.
20982 % \changes{v1.3}{2002/11/14}{Parameterised \cs{chapterprecishere}}
20983 % \begin{macrocode}
20984 \newcommand{\chapterprecishere}[1]{%
20985 \prechapterprecis #1\postchapterprecis}
20986 % \end{macrocode}
20987 % \end{macro}
20988 %
20989 % \begin{macro}{\prechapterprecis}
20990 % \begin{macro}{\prechapterprecisshift}
20991 % \begin{macro}{\precisfont}
20992 % \begin{macro}{\postchapterprecis}
20993 % The \cs{pre...} and \cs{post...} macros put code before and after
20994 % \cs{chapterprecishere} text. By
20995 % default \cs{prechapterprecis} adds some (negative) space (defined by
20996 % \cs{prechapterprecisshift} whose value depends on whether or not the
20997 % \Lopt{article} option is used, as discovered by Lars Madsen) and starts a
20998 % quote environment using the \cs{precisfont}. \cs{postchapterprecis} ends
20999 % the quote environment.
21000 % \changes{v1.3}{2002/11/14}{Added \cs{prechapterprecis} and
21001 % \cs{postchapterprecis}}
21002 % \changes{v1.61803}{2008/01/30}{Added \cs{prechapterprecisshift} and
21003 % \cs{precisfont} (mempatch v4.9)}
21004 % \begin{macrocode}
21005 \newdimen\prechapterprecisshift
21006 \ifartopt
21007 \prechapterprecisshift=0pt
21008 \else
21009 \prechapterprecisshift=-2\baselineskip
21010 \fi
21011 \newcommand*{\precisfont}{\normalfont\itshape}
21012 \newcommand{\prechapterprecis}{%
21013 \vspace*{\prechapterprecisshift}%
21014 \begin{quote}\precisfont}
21015 % \end{macrocode}
21016 % \changes{v3.6k}{2013/04/24}{We are missing the after heading
21017 % stuff. Otherwise text will indent after \cs{chapterprecis}}
21018 % \begin{macrocode}
21019 \newcommand*{\postchapterprecis}{%
21020 \end{quote}%
21021 \par\m@mindentafterchapter%
21022 \@afterheading}
21023
21024 % \end{macrocode}
21025 % \end{macro}
21026 % \end{macro}
21027 % \end{macro}
21028 % \end{macro}
21029 %
21030 % \begin{macro}{\precistocfont}
21031 % Font for typesetting chapter precis in the ToC.
21032 % \changes{v1.3}{2002/11/14}{Added \cs{precistocfont}}
21033 % \begin{macrocode}
21034 \newcommand{\precistocfont}{\normalfont\itshape}
21035 % \end{macrocode}
21036 % \end{macro}
21037 % \begin{macro}{\precistocformat}
21038 % Macro for adding extra formatting to the precis toc text, formatting
21039 % that has nothiing to do with font. The default is \cs{noindent}.
21040 % \changes{v3.6d}{2010/06/09}{Added \cs{precistocformat}}
21041 % \begin{macrocode}
21042 \newcommand{\precistocformat}{\noindent}
21043 % \end{macrocode}
21044 % \end{macro}
21045 %
21046 % \begin{macro}{\chapterprecistoc}
21047 % \begin{macro}{\precistoctext}
21048 % \cs{chapterprecistoc}\marg{text} effectively adds \meta{text} to
21049 % the \file{.toc}
21050 % file. The \meta{text} will be typeset within the same margins as the
21051 % the title text of a \cs{chapter} heading, using the \cs{precistocfont} font.
21052 % \changes{v1.3}{2002/11/14}{Added \cs{precistoctext}}
21053 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{precistoctext}}
21054 % \begin{macrocode}
21055 \newcommand{\chapterprecistoc}[1]{%
21056 \addtocontents{toc}{\precistoctext{#1}}}
21057 \DeclareRobustCommand{\precistoctext}[1]{%
21058 % \end{macrocode}
21059 % Start a group to localize changes to the paragraphing. Set the
21060 % left margin to the chapter indent plus the chapter number width.
21061 % \changes{v1.6180339c}{2009/01/20}{Added a \cs{nopagebreak}, though
21062 % this only disencourage a page break}
21063 % \begin{macrocode}
21064 {%\nopagebreak\leftskip \cftchapterindent\relax
21065 \nopagebreak\memRTLleftskip \cftchapterindent\relax
21066 %%% \advance\leftskip \cftchapternumwidth\relax
21067 \advance\memRTLleftskip \cftchapternumwidth\relax
21068 % \end{macrocode}
21069 % Set the right hand margin to \cs{@tocrmarg}.
21070 % \begin{macrocode}
21071 %%% \rightskip \@tocrmarg\relax
21072 \memRTLrightskip \@tocrmarg\relax
21073 % \end{macrocode}
21074 % Typeset \meta{text} using an italic font, then ensure that the paragraph
21075 % is finished (to use the local skips). Finally close the group and we
21076 % are done.
21077 % \changes{v3.6d}{2010/06/09}{Added \cs{precistocformat}}
21078 % \begin{macrocode}
21079 \precistocformat\precistocfont #1\par}}
21080 % \end{macrocode}
21081 % \end{macro}
21082 % \end{macro}
21083 %
21084 % \subsection{Adding things to the ToC}
21085 %
21086 % \begin{macro}{\cftlocalchange}
21087 % \cs{cftmakelocalchange}\marg{file}\marg{pnumwidth}\marg{tocrmarg}
21088 % makes an entry into \meta{file} to change the \cs{@pnumwidth} and
21089 % the \cs{@tocrmarg} values.
21090 % \begin{macrocode}
21091 \newcommand{\cftlocalchange}[3]{%
21092 \addtocontents{#1}{\protect\setpnumwidth{#2} \protect\setrmarg{#3}}}
21093 % \end{macrocode}
21094 % \end{macro}
21095 %
21096 % \begin{macro}{\cftaddtitleline}
21097 % \cs{cftaddtitleline}\marg{file}\marg{kind}\marg{title}\marg{page}
21098 % adds a \cs{contentsline} entry to \meta{file} with the given information.
21099 % \changes{v3.8.4}{2025/09/18}{Missing a \texttt{\{\}}}
21100 % \begin{macrocode}
21101 \newcommand{\cftaddtitleline}[4]{%
21102 \addtocontents{#1}{\protect\contentsline{#2}{#3}{#4}{}}}
21103 % \end{macrocode}
21104 % \end{macro}
21105 %
21106 % \begin{macro}{\cftaddnumtitleline}
21107 % \cs{cftaddnumtitleline}\marg{file}\marg{kind}\marg{num}\marg{title}\marg{page}
21108 % adds a \cs{contentsline} entry to \meta{file} with the given information.
21109 % \changes{v3.8.4}{2025/09/18}{Missing a \texttt{\{\}}}
21110 % \begin{macrocode}
21111 \newcommand{\cftaddnumtitleline}[5]{%
21112 \addtocontents{#1}%
21113 {\protect\contentsline{#2}{\protect\numberline{#3}%
21114 {\protect\ignorespaces #4}}{#5}{}}}
21115 % \end{macrocode}
21116 % \end{macro}
21117 %
21118 %
21119 % \begin{macro}{\cftinsertcode}
21120 % \begin{macro}{\cftinserthook}
21121 % \begin{macro}{\cftinsert}
21122 % This is a generalisation of a suggestion by Lars Madsen (private email,
21123 % 2007/12/14).
21124 %
21125 % \cs{cftinsertcode}\marg{id}\marg{code} creates a hook to be executed in
21126 % a `List of'. Since we use \cs{@nameuse} it does not matter if the hook
21127 % does not exist
21128 %
21129 % \cs{cftinserthook}\marg{list}\marg{id} inserts the hook \meta{id} into the
21130 % \meta{list} `List of' file (in the form of \cs{cftinsert}\marg{id}).
21131 %
21132 % Use like this:
21133 % \begin{verbatim}
21134 % \cftinsertcode{A}{%
21135 % \renewcommand*{\cftchapterfont}{\normalfont\scshape}
21136 % ...
21137 % }
21138 % \cftinsertcode{F}{...}
21139 % \cftinsertcode{G}{...}
21140 % ...
21141 % \frontmatter
21142 % \tableofcontents
21143 % \cftinserthook{lof}{G}
21144 % \listoffigures
21145 % \chapter{...}
21146 % ...
21147 % \mainmatter
21148 % \cftinserthook{lof}{F}
21149 % \cftinserthook{toc}{A}
21150 % \chapter{...}
21151 % ...
21152 % \end{verbatim}
21153 %
21154 % \changes{v1.61803}{2008/01/30}{Added \cs{cftinsert} and friends (mempatch v4.9)}
21155 % \changes{v3.8.3}{2024/02/14}{Better implementation for \cs{cftinserthook}}
21156 % \begin{macrocode}
21157 \newcommand*{\cftinsert}[1]{\@nameuse{cftinsert#1}}
21158 \newcommand{\cftinsertcode}[2]{\@namedef{cftinsert#1}{#2}}
21159 \NewDocumentCommand\cftinserthook{smm}{
21160 \IfBooleanTF{#1}{
21161 \ifdim\pagetotal>\z@
21162 \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}
21163 \clearpage
21164 \else
21165 \immediateaddtocontents{#2}{\noexpand\cftinsert{#3}}
21166 \fi
21167 }{%
21168 \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}%
21169 }%
21170 }
21171
21172
21173
21174 % \end{macrocode}
21175 % \end{macro}
21176 % \end{macro}
21177 % \end{macro}
21178 % \paragraph{Caveat:} In certain cases an immediate verson of
21179 % \cs{cftinserthook} might be needed due to race conditions. We might
21180 % add such a version at some point.
21181 %
21182 %
21183 % \subsection{ToC and divisional numbering}
21184 %
21185 % Commands are provided, based on the \Lpack{tocvsec2} package, for changing
21186 % the section numbering level and the ToC entry level.
21187 %
21188 % \begin{macro}{\@setclcnt}
21189 % Helper macro to set a sectioning-related counter. Use as
21190 % \cs{@setclcnt}\marg{sec}\marg{counter} to set \Lcount{counter}
21191 % to the level of \meta{sec}.
21192 % \changes{v1.61803}{2008/01/30}{Added book to \cs{@setclcnt} and friends
21193 % (mempatch v4.4)}
21194 % \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if@tempswa} with
21195 % \cs{@setclcntok} in \cs{@setclcnt} to avoid bad clashes with other uses}
21196 % \changes{v3.8.3}{2024/02/13}{Reimplemented using expl3}
21197 % \begin{macrocode}
21198 \ExplSyntaxOn
21199 \newcommand*{\@setclcnt}[2]{%
21200 \str_case_e:nnF{#1}{
21201 {none}{ \setcounter{#2}{-10}}
21202 {book}{ \setcounter{#2}{-2} }
21203 {part}{ \setcounter{#2}{-1} }
21204 {chapter}{ \setcounter{#2}{0} }
21205 {section}{ \setcounter{#2}{1} }
21206 {subsection}{ \setcounter{#2}{2} }
21207 {subsubsection}{ \setcounter{#2}{3} }
21208 {paragraph}{ \setcounter{#2}{4} }
21209 {subparagraph}{ \setcounter{#2}{5} }
21210 {all}{ \setcounter{#2}{50} }
21211 }{
21212 \@memerror{%
21213 Unknown~document~division~name~(#1)
21214 }{%
21215 I'll~ignore~it.~
21216 Type~<return>~and~I'll~continue.\MessageBreak
21217 If~you~haven't~mistyped~the~name~then~ use~
21218 \protect\setcounter~instead.}%
21219 }
21220 }
21221 \ExplSyntaxOff
21222 % \newcommand*{\@setclcnt}[2]{%
21223 % \def\@setclcntok{0}% = false
21224 % \nametest{#1}{none}%
21225 % \ifsamename
21226 % \setcounter{#2}{-10}%
21227 % \def\@setclcntok{1}% = true
21228 % \fi
21229 % \nametest{#1}{book}%
21230 % \ifsamename
21231 % \setcounter{#2}{-2}%
21232 % \def\@setclcntok{1}%
21233 % \fi
21234 % \nametest{#1}{part}%
21235 % \ifsamename
21236 % \setcounter{#2}{-1}%
21237 % \def\@setclcntok{1}%
21238 % \fi
21239 % \nametest{#1}{chapter}%
21240 % \ifsamename
21241 % \setcounter{#2}{0}%
21242 % \def\@setclcntok{1}%
21243 % \fi
21244 % \nametest{#1}{section}%
21245 % \ifsamename
21246 % \setcounter{#2}{1}%
21247 % \def\@setclcntok{1}%
21248 % \fi
21249 % \nametest{#1}{subsection}%
21250 % \ifsamename
21251 % \setcounter{#2}{2}%
21252 % \def\@setclcntok{1}%
21253 % \fi
21254 % \nametest{#1}{subsubsection}%
21255 % \ifsamename
21256 % \setcounter{#2}{3}%
21257 % \def\@setclcntok{1}%
21258 % \fi
21259 % \nametest{#1}{paragraph}%
21260 % \ifsamename
21261 % \setcounter{#2}{4}%
21262 % \def\@setclcntok{1}%
21263 % \fi
21264 % \nametest{#1}{subparagraph}%
21265 % \ifsamename
21266 % \setcounter{#2}{5}%
21267 % \def\@setclcntok{1}%
21268 % \fi
21269 % \nametest{#1}{all}%
21270 % \ifsamename
21271 % \setcounter{#2}{50}%
21272 % \def\@setclcntok{1}%
21273 % \fi
21274 % %% \if@tempswa\else
21275 % \ifnum \@setclcntok = 0\relax
21276 % \@memerror{%
21277 % Unknown document division name (#1)
21278 % }{%
21279 % I'll ignore it.
21280 % Type \space <return> and I'll continue.\MessageBreak
21281 % If you haven't mistyped the name then use
21282 % \protect\setcounter\space instead.}%
21283 % \fi}
21284 %
21285 % \end{macrocode}
21286 % \end{macro}
21287 %
21288 %
21289 % \begin{macro}{\settocdepth@}
21290 % \cs{settocdepth@}\marg{macro}\marg{sec}\\
21291 % This is a utility macro to fuel \cs{settocdepth}, and a
21292 % variant. Instead of a \cs{nametest} stack it is implemented using
21293 % the expl3 \verb|\str_case_e:nnTF| function. Here \meta{macro} is
21294 % the macro to use to write to the toc file.
21295 % \changes{v3.8.3}{2024/02/13}{Added simpler implementation}
21296 % \begin{macrocode}
21297 \ExplSyntaxOn
21298 \newcommand*{\settocdepth@}[2]{%
21299 \str_case_e:nnTF{#2}{
21300 {none}{ #1{toc}{\changetocdepth{-10}}}
21301 {book}{ #1{toc}{\changetocdepth{-2}} }
21302 {part}{ #1{toc}{\changetocdepth{-1}} }
21303 {chapter}{ #1{toc}{\changetocdepth{0}} }
21304 {section}{ #1{toc}{\changetocdepth{1}} }
21305 {subsection}{ #1{toc}{\changetocdepth{2}} }
21306 {subsubsection}{ #1{toc}{\changetocdepth{3}} }
21307 {paragraph}{ #1{toc}{\changetocdepth{4}} }
21308 {subparagraph}{ #1{toc}{\changetocdepth{5}} }
21309 {all}{ #1{toc}{\changetocdepth{50}} }
21310 }{
21311 \@ifundefined{toclevel@#2}{%
21312 \@memwarn{Unknown~toclevel~for~#2}%
21313 }{%
21314 \setcounter{tocdepth}{\@nameuse{toclevel@#2}}%
21315 }
21316 }{
21317 \@memerror{%
21318 Unknown~document~division~name~(#2)
21319 }{%
21320 I'll~ignore~ it.~
21321 Type~<return>~and~I'll~continue.}%
21322 }
21323 }
21324 \ExplSyntaxOff
21325 % \end{macrocode}
21326 % \begin{macro}{\settocdepth}
21327 % \begin{macro}{\immediatesettocdepth}
21328 % \cs{settocdepth}\marg{sec} is the user command for setting
21329 % \Lcount{tocdepth} in the \file{.toc} file to the value corresponding to
21330 % \meta{sec}. Also added an immediate version, which is rather dangerous,
21331 % so not mentioned in the manual for now.
21332 % \changes{v1.3}{2002/11/14}{Changed \cs{settocdepth} to use \cs{changetocdepth}}
21333 % \changes{v1.61803}{2008/01/30}{Added book to ToC depth setting (mempatch v4.4)}.
21334 % \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if@tempswa} with
21335 % \cs{@chtocdok} in \cs{settocdepth} to avoid bad clashes with other uses}
21336 % \changes{v3.8.3}{2024/02/13}{Reimplemented using simpler code}
21337 % \begin{macrocode}
21338 % \newcommand*{\settocdepth}[1]{\settocdepth@{\addtocontents}{#1}}
21339 % \newcommand*{\immediatesettocdepth}[1]{\settocdepth@{\immediateaddtocontents}{#1}}
21340 \NewDocumentCommand\settocdepth{sm}{%
21341 \IfBooleanTF{#1}{%
21342 \ifdim\pagetotal>\z@%
21343 \settocdepth@{\addtocontents}{#2}%
21344 \clearpage%
21345 \else%
21346 \settocdepth@{\immediateaddtocontents}{#2}%
21347 \fi%
21348 }{%
21349 \settocdepth@{\addtocontents}{#2}%
21350 }%
21351 }
21352
21353
21354
21355
21356 % \def\@chtodok{0}% false
21357 % \nametest{#1}{none}%
21358 % \ifsamename
21359 % \addtocontents{toc}{\changetocdepth{-10}}%
21360 % \def\@chtodok{1}% true
21361 % \fi
21362 % \nametest{#1}{book}%
21363 % \ifsamename
21364 % \addtocontents{toc}{\changetocdepth{-2}}%
21365 % \def\@chtodok{1}%
21366 % \fi
21367 % \nametest{#1}{part}%
21368 % \ifsamename
21369 % \addtocontents{toc}{\changetocdepth{-1}}%
21370 % \def\@chtocdok{1}%
21371 % \fi
21372 % \nametest{#1}{chapter}%
21373 % \ifsamename
21374 % \addtocontents{toc}{\changetocdepth{0}}%
21375 % \def\@chtocdok{1}%
21376 % \fi
21377 % \nametest{#1}{section}%
21378 % \ifsamename
21379 % \addtocontents{toc}{\changetocdepth{1}}%
21380 % \def\@chtocdok{1}%
21381 % \fi
21382 % \nametest{#1}{subsection}%
21383 % \ifsamename
21384 % \addtocontents{toc}{\changetocdepth{2}}%
21385 % \def\@chtocdok{1}%
21386 % \fi
21387 % \nametest{#1}{subsubsection}%
21388 % \ifsamename
21389 % \addtocontents{toc}{\changetocdepth{3}}%
21390 % \def\@chtocdok{1}%
21391 % \fi
21392 % \nametest{#1}{paragraph}%
21393 % \ifsamename
21394 % \addtocontents{toc}{\changetocdepth{4}}%
21395 % \def\@chtocdok{1}%
21396 % \fi
21397 % \nametest{#1}{subparagraph}%
21398 % \ifsamename
21399 % \addtocontents{toc}{\changetocdepth{5}}%
21400 % \def\@chtocdok{1}%
21401 % \fi
21402 % \nametest{#1}{all}%
21403 % \ifsamename
21404 % \addtocontents{toc}{\changetocdepth{50}}%
21405 % \def\@chtocdok{1}%
21406 % \fi
21407 % \ifnum\@chtocdok=1\relax
21408 % \@ifundefined{toclevel@#1}{%
21409 % \@memwarn{Unknown toclevel for #1}%
21410 % }{%
21411 % \setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
21412 % }
21413 % \else
21414 % \@memerror{%
21415 % Unknown document division name (#1)
21416 % }{%
21417 % I'll ignore it.
21418 % Type \space <return> and I'll continue.}%
21419 % \fi}
21420
21421 % \end{macrocode}
21422 % \end{macro}
21423 % \end{macro}
21424 % \end{macro}
21425 %
21426 % \begin{macro}{\toclevel@none}
21427 % \begin{macro}{\toclevel@all}
21428 % Couple of extras for hypperef to cater for \texttt{all} and \texttt{none}
21429 % as `division levels'.
21430 % \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@none} and \cs{toclevel@all}
21431 % (mempatch v4.4)}
21432 % \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@...} definitions to
21433 % \cs{def} for better compability with future hyperref}
21434 % \begin{macrocode}
21435 \def\toclevel@none{-10}
21436 \def\toclevel@all{50}
21437
21438 % \end{macrocode}
21439 % \end{macro}
21440 % \end{macro}
21441 %
21442 % \begin{macro}{\changetocdepth}
21443 % Changes the \texttt{tocdepth} counter. Make it robust as it will be written
21444 % to the *.toc file.
21445 % \changes{v1.3}{2002/11/14}{Added \cs{changetocdepth}}
21446 % \begin{macrocode}
21447 \DeclareRobustCommand{\changetocdepth}[1]{\setcounter{tocdepth}{#1}}
21448
21449 % \end{macrocode}
21450 % \end{macro}
21451 %
21452 % \begin{macro}{\maxtocdepth}
21453 % \cs{maxtocdepth}\marg{sec} can be used to initialise \Lcount{tocdepth}
21454 % to the value corresponding to \meta{sec}. This can only be used
21455 % between the end of the preamble and the \cs{tableofcontents} command.
21456 % \begin{macrocode}
21457 \newcommand{\maxtocdepth}[1]{%
21458 \@setclcnt{#1}{tocdepth}}
21459 % \end{macrocode}
21460 % \end{macro}
21461 %
21462 % \begin{macro}{\maxsecnumdepth}
21463 % \cs{maxsecnumdepth}\marg{sec} can be used to initialise
21464 % \Lcount{secnumdepth}
21465 % to the value corresponding to \meta{sec}.
21466 % \changes{v1.1}{2002/03/10}{Added maxsecnumdepth counter and modified \cs{maxsecnumdepth}}
21467 % \begin{macrocode}
21468 \newcounter{maxsecnumdepth}
21469 \newcommand{\maxsecnumdepth}[1]{%
21470 \@setclcnt{#1}{secnumdepth}\@setclcnt{#1}{maxsecnumdepth}}
21471
21472 % \end{macrocode}
21473 % \end{macro}
21474 %
21475 % \begin{macro}{\setsecnumdepth}
21476 % \cs{setsecnumdepth}\marg{sec} is the user command for setting
21477 % \Lcount{secnumdepth} to the value for \meta{sec}. In the preamble it sets
21478 % both the \Lcount{secnumdepth} and \Lcount{maxsecnumdepth} to \meta{sec}
21479 % while in the body it only sets \Lcount{secnumdepth}.
21480 % \changes{v1.61803}{2008/01/30}{Extended \cs{setsecnumdepth} to make it more
21481 % intuitive (mempatch v4.9)}
21482 % \begin{macrocode}
21483 \newcommand{\setsecnumdepth}[1]{%
21484 \ifx\@nodocument\relax% after the preamble
21485 \@setclcnt{#1}{secnumdepth}%
21486 \else
21487 \@setclcnt{#1}{secnumdepth}%
21488 \@setclcnt{#1}{maxsecnumdepth}%
21489 \fi}
21490 \setsecnumdepth{section}
21491
21492 % \end{macrocode}
21493 % \end{macro}
21494 %
21495 %
21496 %
21497 %
21498 % \section{Bibliography}
21499 %
21500 %
21501 % \begin{macro}{\bibindent}
21502 % The \Lopt{open} bibliography uses an indentation of \cs{bibindent}.
21503 % \begin{macrocode}
21504 \newdimen\bibindent
21505 \setlength\bibindent{1.5em}
21506 % \end{macrocode}
21507 % \end{macro}
21508 %
21509 % \begin{macro}{\bibitemsep}
21510 % The vertical separation between items in the bibliography list.
21511 % \changes{v1.4}{2003/11/22}{Added \cs{bibitemsep} (from patch v1.7)}
21512 % \begin{macrocode}
21513 \newlength{\bibitemsep}
21514 \setlength{\bibitemsep}{\itemsep}
21515 % \end{macrocode}
21516 % \end{macro}
21517 %
21518 % \begin{macro}{\biblistextra}
21519 % A hook into the \texttt{bibitemlist}.
21520 % \changes{v1.4}{2003/11/22}{Added \cs{biblistextra} (from patch v1.7)}
21521 % \begin{macrocode}
21522 \newcommand{\biblistextra}{\itemsep=\bibitemsep}
21523
21524 % \end{macrocode}
21525 % \end{macro}
21526 %
21527 % \begin{environment}{bibitemlist}
21528 % The \texttt{thebibliography} environment starts a new document division.
21529 % Internally it tweaks some typesetting aspects; principally it
21530 % uses \cs{sloppy} because good linebreaking is hard in a bibliography,
21531 % and \verb?\sfcode`\.=1000\relax? causes a full stop not to produce an
21532 % end-of-sentence space. The implementation of the environment is
21533 % based on the generic \texttt{list} environment, and uses the \cs{c@enumiv}
21534 % count for the labels. The following code is extracted from the
21535 % \Lpack{book} class, plus some additions.
21536 % \changes{v1.4}{2003/11/22}{Added \cs{biblistextra} to bibitemlist (from patch v1.7)}
21537 % \begin{macrocode}
21538 \newenvironment{bibitemlist}[1]{%
21539 \typeout{bibitemlist}
21540 \list{\@biblabel{\@arabic\c@enumiv}}%
21541 {\settowidth\labelwidth{\@biblabel{#1}}%
21542 \leftmargin\labelwidth
21543 \advance\leftmargin\labelsep
21544 \@openbib@code
21545 \usecounter{enumiv}%
21546 \let\p@enumiv\@empty
21547 \renewcommand\theenumiv{\@arabic\c@enumiv}%
21548 \biblistextra}%
21549 \sloppy
21550 \clubpenalty4000
21551 \@clubpenalty \clubpenalty
21552 \widowpenalty4000%
21553 \sfcode`\.\@m}%
21554 {\def\@noitemerr
21555 {\@latex@warning{Empty `thebibliography' environment}}%
21556 \endlist}
21557
21558 % \end{macrocode}
21559 % \end{environment}
21560 %
21561 % \begin{macro}{\newblock}
21562 % The default is for \cs{newblock} to provide a small space.
21563 % \begin{macrocode}
21564 \newcommand{\newblock}{\hskip .11em\@plus.33em\@minus.07em}
21565 % \end{macrocode}
21566 % \end{macro}
21567 %
21568 % \begin{macro}{\@openbib@code}
21569 % This a an empty hook. It will be modified if the \Lopt{openbib}
21570 % option is used.
21571 % \begin{macrocode}
21572 \let\@openbib@code\@empty
21573 % \end{macrocode}
21574 % \end{macro}
21575 %
21576 % \begin{macro}{\setbiblabel}
21577 % \begin{macro}{\@biblabel}
21578 % This is the user command for setting the label for a \cs{bibitem}.
21579 % The following sets the default definition.
21580 % \begin{macrocode}
21581 \newcommand*{\setbiblabel}[1]{%
21582 \renewcommand*{\@biblabel}[1]{#1}}
21583 \setbiblabel{[#1]\hfill}
21584 % \end{macrocode}
21585 % \end{macro}
21586 % \end{macro}
21587 %
21588 % \begin{macro}{\@memb@bchap}
21589 % \begin{macro}{\@memb@bsec}
21590 % In a \ctt{} thread \textit{memoir, natbib, and chapterbib} in January 2003
21591 % there was a discussion on how to get all three to work together.
21592 % Donald Arseneau suggested that \cs{bibsection} be used as a `standard'
21593 % way of controlling the sectioning command of a bibliography. Here is
21594 % an implementation of that idea.
21595 %
21596 % \cs{@memb@bchap} is a copy of memoir's original code for the start
21597 % of the \texttt{thebibliography} environment which used a \cs{chapter*}
21598 % title. \cs{@memb@bsec} is the much simpler version for a \cs{section} title.
21599 % \changes{v1.4}{2003/02/27}{Added support code for implementing \cs{bibsection}
21600 % (patch 1.3)}
21601 % \changes{v3.7g}{2018/02/28}{Removeded \cs{phantomsection} before
21602 % \cs{addcontentsline} as it is no longer needed, and causes the
21603 % hyperlink target to the bibligraphy to be below the title, reported
21604 % via \texttt{https://tex.stackexchange.com/a/396303/3929}}
21605 % \begin{macrocode}
21606 \newcommand{\@memb@bchap}{%
21607 \chapter*{\bibname}%
21608 \bibmark
21609 \ifnobibintoc\else
21610 % \phantomsection
21611 \addcontentsline{toc}{chapter}{\bibname}%
21612 \fi
21613 \prebibhook}
21614 \newcommand{\@memb@bsec}{\section{\bibname}\prebibhook}
21615 % \end{macrocode}
21616 % \end{macro}
21617 % \end{macro}
21618 %
21619 % \begin{macro}{\bibsection}
21620 % Normally treat the bibliography heading as a chapter.
21621 % \changes{v1.4}{2003/02/27}{Added \cs{bibsection} to replace memoir's
21622 % original code for the bibliography (patch 1.3)}
21623 % \begin{macrocode}
21624 \newcommand{\bibsection}{\@memb@bchap}
21625
21626 % \end{macrocode}
21627 % \end{macro}
21628 %
21629 % \begin{environment}{thebibliography}
21630 % The definition of the \texttt{thebibliography} environment in this class is not
21631 % quite the same as in the standard classes!
21632 %
21633 % \changes{v0.2}{2001/06/03}{Deleted starred version of thebibliography}
21634 % \changes{v1.4}{2003/02/27}{Replaced initial code in the bibliography
21635 % environment by \cs{bibsection} (patch 1.3)}
21636 % \begin{macrocode}
21637 \newenvironment{thebibliography}[1]{%
21638 \bibsection
21639 \begin{bibitemlist}{#1}}{\end{bibitemlist}\postbibhook}
21640 % \end{macrocode}
21641 % \end{environment}
21642 %
21643 % \begin{macro}{\ifnobibintoc}
21644 % \begin{macro}{\bibintoc}
21645 % \begin{macro}{\nobibintoc}
21646 % Flag to control whether or not to add the bibliography title to the ToC,
21647 % and declarations to set the flag.
21648 % Default is to put the title into the ToC.
21649 % \changes{v0.2}{2001/06/03}{Added \cs{ifnobibintoc}, etc.}
21650 % \begin{macrocode}
21651 \newif\ifnobibintoc
21652 \newcommand*{\bibintoc}{\nobibintocfalse}
21653 \newcommand*{\nobibintoc}{\nobibintoctrue}
21654 \bibintoc
21655
21656 % \end{macrocode}
21657 % \end{macro}
21658 % \end{macro}
21659 % \end{macro}
21660 %
21661 % \begin{macro}{\prebibhook}
21662 % \begin{macro}{\postbibhook}
21663 % These two macros are called just before starting the bib items and just
21664 % after finishing them. By default they do nothing but can be changed
21665 % by the user to give, say, some introductory information.
21666 % \begin{macrocode}
21667 \newcommand{\prebibhook}{}
21668 \newcommand{\postbibhook}{}
21669
21670 % \end{macrocode}
21671 % \end{macro}
21672 % \end{macro}
21673 %
21674 %
21675 % \begin{macro}{\@cite}
21676 % The output of the \cs{cite} command is produced by this macro. The default
21677 % is used. The \Lpack{cite} package is a good way of changing this.
21678 % \begin{macrocode}
21679 % \renewcommand*{\@cite}[1]{[#1]}
21680 % \end{macrocode}
21681 % \end{macro}
21682 %
21683 % \subsection{Use with the \Lpack{natbib} and \Lpack{chapterbib} packages}
21684 %
21685 % The \Lpack{natbib} package~\cite{NATBIB} uses its own definition for
21686 % the \texttt{thebibliography} environment, which knows nothing about adding
21687 % the Bibliography to the ToC. The following makes appropriate changes
21688 % to \Lpack{natbib} code to support the class.
21689 %
21690 % The \Lpack{chapterbib} package by Donald Arseneau also may make changes
21691 % to the \texttt{thebibliography} environment --- perhaps memoir's version
21692 % or natbib's version.
21693 %
21694 % As packages get loaded after classes, I have to try and patch any
21695 % non-memoir modifications at begin document time.
21696 % The fixes have to be firstly for \Lpack{natbib}
21697 % and only after those can \Lpack{chapterbib} be considered.
21698 %
21699 % \changes{v1.1}{2002/03/10}{Added internal support for the natbib package}
21700 % \changes{v1.4}{2003/02/27}{Changed code supporting natbib (patch 1.3)}
21701 % \changes{v1.4}{2003/02/27}{Added code supporting chapterbib (patch 1.3)}
21702 % \begin{macro}{\bibsection}
21703 % \begin{macro}{\endthebibliography}
21704 % Natbib provides \cs{bibsection} for titling the bibliography. I also have
21705 % to extend the end of the \texttt{thebibliography} environment to cater for
21706 % \cs{postbibhook}.
21707 % \begin{macrocode}
21708 \AtBeginDocument{%
21709 \@ifpackageloaded{natbib}{% natbib is loaded
21710 % \end{macrocode}
21711 % As \Lpack{natbib} is used, change \cs{endthebibliography} to the class
21712 % definition.
21713 % \begin{macrocode}
21714 \addtodef{\endthebibliography}{}{\vskip-\lastskip\postbibhook}
21715 \@ifpackagewith{natbib}{sectionbib}{% with sectionbib option
21716 % \end{macrocode}
21717 % \Lpack{natbib}'s \Lopt{sectionbib} option is used,
21718 % \begin{macrocode}
21719 \renewcommand{\bibsection}{\@memb@bsec}}%
21720 % \end{macrocode}
21721 % The \Lopt{sectionbib} option is not used, so we have a chapter title.
21722 % \begin{macrocode}
21723 {\renewcommand{\bibsection}{\@memb@bchap}}}%
21724 % \end{macrocode}
21725 % Finished with any \Lpack{natbib} related changes.
21726 % \begin{macrocode}
21727 {}
21728 % \end{macrocode}
21729 %
21730 % Now deal with \Lpack{chapterbib} if necessary.
21731 % \begin{macrocode}
21732 \@ifpackagewith{chapterbib}{sectionbib}{%
21733 % \end{macrocode}
21734 % \Lpack{chapterbib} is used with its \Lopt{sectionbib} option. This is the
21735 % only case to worry about. Kill \Lpack{chapterbib}'s \cs{sectionbib} macro
21736 % which it calls at begin document to do its patch, then make sure
21737 % the class definition is used.
21738 % \begin{macrocode}
21739 \renewcommand{\sectionbib}[2]{}
21740 \renewcommand{\bibsection}{\@memb@bsec}}{}
21741 % \end{macrocode}
21742 % And we've finished with this bunch of \cs{AtBeginDocument} code.
21743 % \begin{macrocode}
21744 }
21745
21746 % \end{macrocode}
21747 % \end{macro}
21748 % \end{macro}
21749 %
21750 %
21751 %
21752 % \section{The index}
21753 %
21754 % I allow for a single column index as well as the default double column.
21755 %
21756 % \begin{macro}{\ifonecolindex}
21757 % TRUE for a one column index.
21758 % \changes{v1.3}{2002/10/10}{Added one column index}
21759 % \begin{macrocode}
21760 \newif\ifonecolindex
21761 \onecolindexfalse
21762
21763 % \end{macrocode}
21764 % \end{macro}
21765 %
21766 % \begin{macro}{\onecolindex}
21767 % \begin{macro}{\twocolindex}
21768 % \changes{v1.61803}{2008/01/30}{Added \cs{onecolindex} and \cs{twocolindex}}
21769 % \begin{macrocode}
21770 \newcommand*{\onecolindex}{\onecolindextrue}
21771 \newcommand*{\twocolindex}{\onecolindexfalse}
21772
21773 % \end{macrocode}
21774 % \end{macro}
21775 % \end{macro}
21776 %
21777 % \begin{environment}{theindex}
21778 % The environment \texttt{theindex} can be used for indices. It makes an
21779 % index with two columns, with each entry a separate paragraph. At
21780 % the user level the commands \cs{item}, \cs{subitem} and \cs{subsubitem}
21781 % are used to produce index entries of various levels. When a new
21782 % letter of the alphabet is encountered an amount of \cs{indexspace}
21783 % white space can be added.
21784 %
21785 %
21786 % \changes{v0.2}{2001/06/03}{Deleted starred version of theindex}
21787 % \changes{v0.2}{2001/06/03}{Changed Index pagestyle to chapter}
21788 % \changes{v1.618}{2005/09/03}{Make \cs{indexcolsep} work, courtesy of hazydirk (mempatch v3.11)}
21789 % \changes{v1.61803}{2008/01/30}{Added \cs{clearforchapter} to theindex
21790 % environment (Erik Quaeghebeur, mempatch v4.4)}
21791 % \changes{v1.61803}{2008/01/30}{Added an indextitlepagestyle (Lars Madsen
21792 % mempatch v4.6)}
21793 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} by \cs{MakeLinkTarget} and moved it}
21794 % \begin{macrocode}
21795 \newenvironment{theindex}{%
21796 \clearforchapter
21797 \if@twocolumn
21798 \@restonecolfalse
21799 \else
21800 \@restonecoltrue
21801 \fi
21802 \ifonecolindex
21803 \onecolumn
21804 \chapter*{\indexname}
21805 \preindexhook
21806 \else
21807 \setlength{\columnseprule}{\indexrule}%
21808 \setlength{\columnsep}{\indexcolsep}%
21809 \MakeLinkTarget[chapter]{}% <-- new 2025
21810 \twocolumn[%
21811 \@makeschapterhead{\indexname}
21812 \preindexhook]%
21813 \fi
21814 \indexmark
21815 \ifnoindexintoc\else
21816 %\phantomsection
21817 \addcontentsline{toc}{chapter}{\indexname}%
21818 \fi
21819 \thispagestyle{indextitlepagestyle}\parindent\z@
21820 \parskip\z@ \@plus .3\p@\relax
21821 \let\item\@idxitem}%
21822 {\if@restonecol\onecolumn\else\twocolumn\fi}
21823
21824 % \end{macrocode}
21825 % \end{environment}
21826 %
21827 % \begin{macro}{\ps@indextitlepagestyle}
21828 % \begin{macrocode}
21829 \aliaspagestyle{indextitlepagestyle}{chapter}
21830
21831 % \end{macrocode}
21832 % \end{macro}
21833 %
21834 % \begin{macro}{\ifnoindexintoc}
21835 % \begin{macro}{\indexintoc}
21836 % \begin{macro}{\noindexintoc}
21837 % Flag to control whether or not to add the index title to the ToC,
21838 % and declarations to set the flag.
21839 % Default is to put the title into the ToC.
21840 % \changes{v0.2}{2001/06/03}{Added \cs{ifnoindexintoc}, etc.}
21841 % \begin{macrocode}
21842 \newif\ifnoindexintoc
21843 \newcommand*{\indexintoc}{\noindexintocfalse}
21844 \newcommand*{\noindexintoc}{\noindexintoctrue}
21845 \indexintoc
21846
21847 % \end{macrocode}
21848 % \end{macro}
21849 % \end{macro}
21850 % \end{macro}
21851 %
21852 % \begin{macro}{\indexcolsep}
21853 % \begin{macro}{\indexrule}
21854 % These two lengths control the column separation and the thickness
21855 % of the inter-column rule.
21856 % \changes{v0.2}{2001/06/03}{Added \cs{indexcolsep} and \cs{indexrule}}
21857 % \begin{macrocode}
21858 \newlength{\indexcolsep} \setlength{\indexcolsep}{35pt}
21859 \newlength{\indexrule} \setlength{\indexrule}{0pt}
21860
21861 % \end{macrocode}
21862 % \end{macro}
21863 % \end{macro}
21864 %
21865 % \begin{macro}{\preindexhook}
21866 % A macro that is called between the index heading and the start of the
21867 % two columns. The user can modify it to add something.
21868 % \begin{macrocode}
21869 \newcommand{\preindexhook}{}
21870 % \end{macrocode}
21871 % \end{macro}
21872 %
21873 % \begin{macro}{\l@index}
21874 % Format the index entry in the table of contents.
21875 % \begin{macrocode}
21876 \newcommand{\l@index}{\@dottedtocline{1}{0em}{0pt}}
21877 % \end{macrocode}
21878 % \end{macro}
21879 %
21880 % \begin{macro}{\@idxitem}
21881 % \begin{macro}{\subitem}
21882 % \begin{macro}{\subsubitem}
21883 % Thsee macros are used to format the entries in the index.
21884 % \begin{macrocode}
21885 \newcommand{\@idxitem} {\par\hangindent 40\p@}
21886 \newcommand{\subitem} {\par\hangindent 40\p@ \hspace*{20\p@}}
21887 \newcommand{\subsubitem}{\par\hangindent 40\p@ \hspace*{30\p@}}
21888 % \end{macrocode}
21889 % \end{macro}
21890 % \end{macro}
21891 % \end{macro}
21892 %
21893 % \begin{macro}{\indexspace}
21894 % The amount of white space that is inserted between `letter
21895 % blocks' in the index.
21896 % \begin{macrocode}
21897 \newcommand{\indexspace}{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
21898
21899 % \end{macrocode}
21900 % \end{macro}
21901 %
21902 % \begin{macro}{\makeindex}
21903 % \begin{macro}{\index}
21904 % \begin{macro}{\specialindex}
21905 % \begin{macro}{\makememindexhook}
21906 % This is a modified version of the kernel \cs{makeindex} to allow for
21907 % multiple indexes. It also defines \cs{index} (which is a modified version
21908 % of the standard \cs{index}) and \cs{specialindex}.
21909 %
21910 % \cs{makememindexhook} is a null op but can be redefined to add extra code
21911 % into \cs{makeindex}. For example, to incorporate \Lpack{ledmac}'s
21912 % \cs{edindex} into the scheme:
21913 % \begin{verbatim}
21914 % \renewcommand*{\makememindexhook}{%
21915 % \def\edindex{\@bsphack%
21916 % \@ifnextchar [{\l@d@index}{\l@d@index[\jobname]}}}
21917 % \end{verbatim}
21918 % \changes{v1.3}{2002/11/14}{Indexing macros completely redone and extended}
21919 % \changes{v1.61}{2004/03/12}{Added the \cs{makememindexhook} to \cs{makeindex}}
21920 % \changes{v1.618}{2005/09/02}{Modified \cs{makeindex} for \cs{nofiles}}
21921 % \begin{macrocode}
21922 \newcommand*{\makememindexhook}{}
21923 % \end{macrocode}
21924 % \begin{macrocode}
21925 \providecommand*{\makeindex}{}
21926 \renewcommand*{\makeindex}[1][\jobname]{%
21927 \if@filesw
21928 \def\index{\@bsphack%
21929 \@ifnextchar [{\@index}{\@index[\jobname]}}
21930 \def\specialindex{\@bsphack\@spindex}%
21931 \makememindexhook
21932 \expandafter\newwrite\csname #1@idxfile\endcsname
21933 \expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
21934 \typeout{Writing index file #1.idx }%
21935 \fi}
21936
21937 % \end{macrocode}
21938 % Initially define, but emasculate, \cs{index} and \cs{specialindex} which are
21939 % defined properly by the user calling \cs{makeindex}.
21940 % \begin{macrocode}
21941 \renewcommand{\index}[2][\jobname]{\@bsphack\@esphack}
21942 \newcommand{\specialindex}[3]{\@bsphack\@esphack}
21943
21944 % \end{macrocode}
21945 % \end{macro}
21946 % \end{macro}
21947 % \end{macro}
21948 % \end{macro}
21949 %
21950 % \begin{macro}{\printindex}
21951 % The command to read an \file{ind} file.
21952 % \begin{macrocode}
21953 \newcommand{\printindex}[1][\jobname]{\@input@{#1.ind}}
21954
21955 % \end{macrocode}
21956 % \end{macro}
21957 %
21958 % \begin{macro}{\ifreportnoidxfile}
21959 % \begin{macro}{\reportnoidxfile}
21960 % \begin{macro}{\ignorenoidxfile}
21961 % \begin{macro}{\ifshowindexmark}
21962 % \begin{macro}{\showindexmarks}
21963 % \begin{macro}{\hideindexmarks}
21964 % Two booleans to control reporting on unknown \file{idx} files and
21965 % displaying indexed items in the margin.
21966 % \begin{macrocode}
21967 \newif\ifreportnoidxfile
21968 \newcommand*{\reportnoidxfile}{\reportnoidxfiletrue}
21969 \newcommand*{\ignorenoidxfile}{\reportnoidxfilefalse}
21970 \ignorenoidxfile
21971 \newif\ifshowindexmark
21972 \newcommand*{\showindexmarks}{\showindexmarktrue}
21973 \newcommand*{\hideindexmarks}{\showindexmarkfalse}
21974 \hideindexmarks
21975
21976 % \end{macrocode}
21977 % \end{macro}
21978 % \end{macro}
21979 % \end{macro}
21980 % \end{macro}
21981 % \end{macro}
21982 % \end{macro}
21983 %
21984 % \begin{macro}{\@index}
21985 % \verb?\@index[file]? is first stage of \cs{index}, handling the \file{idx} file.
21986 % \begin{macrocode}
21987 \def\@index[#1]{%
21988 \@ifundefined{#1@idxfile}%
21989 {\ifreportnoidxfile
21990 \@memwarn{Undefined index file #1}%
21991 \fi
21992 \begingroup
21993 \@sanitize
21994 \@nowrindex}%
21995 {\def\@idxfile{#1}%
21996 \begingroup
21997 \@sanitize
21998 \@wrindexm@m}}
21999 % \end{macrocode}
22000 % \end{macro}
22001 %
22002 % \begin{macro}{\@nowrindex}
22003 % Called when there is no \file{idx} file to throw away the indexed item.
22004 % \begin{macrocode}
22005 \newcommand{\@nowrindex}[1]{%
22006 \ifshowindexmark\@showidx{#1}\fi\endgroup\@esphack}
22007
22008 % \end{macrocode}
22009 % \end{macro}
22010 %
22011 % \begin{macro}{\@wrindexm@m}
22012 % \begin{macro}{\@@wrindexhyp}
22013 % The next stage in index processing is \verb?\@wrindexm@m{item}?,
22014 % which writes the \file{idx} file name
22015 % and indexed item to the \file{aux} file. The \cs{@@wrindexhyp} macro
22016 % provides hyperlinks in case the \Lpack{hyperref} package is used.
22017 % \begin{macrocode}
22018 \newcommand{\@wrindexm@m}[1]{\@@wrindexhyp#1||\\}
22019 \def\@@wrindexhyp#1|#2|#3\\{%
22020 \ifshowindexmark\@showidx{#1}\fi
22021 \ifx\\#2\\%
22022 \protected@write\@auxout{}%
22023 {\string\@@wrindexm@m{\@idxfile}{#1|hyperpage}{\thepage}}%
22024 \else
22025 \def\Hy@temp@A{#2}%
22026 \ifx\Hy@temp@A\HyInd@ParenLeft
22027 \protected@write\@auxout{}%
22028 {\string\@@wrindexm@m{\@idxfile}{#1|#2hyperpage}{\thepage}}%
22029 \else
22030 % \end{macrocode}
22031 % Add a corresponding test on \verb+|)+ to add \verb|hyperpage|. This
22032 % is needed by the \verb|xindy| indexing programme. The standard
22033 % \verb|makeindex| programme does not seem to mind.
22034 % \changes{v3.7g}{2018/04/04}{Added test for \texttt{|)} and adding
22035 % \texttt{hyperpage} accordingly.}
22036 % \begin{macrocode}
22037 \ifx\Hy@temp@A\HyInd@ParenRight
22038 \protected@write\@auxout{}%
22039 {\string\@@wrindexm@m{\@idxfile}{#1|#2hyperpage}{\thepage}}%
22040 \else
22041 \protected@write\@auxout{}%
22042 {\string\@@wrindexm@m{\@idxfile}{#1|#2}{\thepage}}%
22043 \fi
22044 \fi
22045 \fi
22046 \endgroup
22047 \@esphack}
22048 % \end{macrocode}
22049 % \end{macro}
22050 % \end{macro}
22051 %
22052 % \begin{macro}{\hyperpage}
22053 % \begin{macro}{\hyperlink}
22054 % These are defined in the \Lpack{hyperref} package but we need them.
22055 % Other hyperstuff is only used if the package itself is used.
22056 % \begin{macrocode}
22057 \newcommand{\hyperpage}[1]{#1}
22058 \newcommand{\hyperlink}[2]{#2}
22059
22060 % \end{macrocode}
22061 % \end{macro}
22062 % \end{macro}
22063 %
22064 % \begin{macro}{\@@wrindexm@m}
22065 % The macro \verb?\@@wrindexm@m{file}{item}{page}? has been written into
22066 % the \file{aux} file. It is normally defined so that it calls
22067 % \verb?\@@@wrindexm@m{item}{page}? to finally write to the \file{idx} file.
22068 % \begin{macrocode}
22069 \newcommand{\@@wrindexm@m}[1]{\begingroup
22070 \def\@idxfile{\@nameuse{#1@idxfile}}
22071 \@sanitize
22072 \@@@wrindexm@m}
22073
22074 % \end{macrocode}
22075 % \end{macro}
22076 %
22077 % \begin{macro}{\@@@wrindexm@m}
22078 % \cs{@@@wrindexm@m}\marg{item}\marg{page} writes the \cs{indexentry} to
22079 % the \file{idx} file. This file is read both at the beginning and end of
22080 % a document so \cs{@@@wrindexm@m} must be disabled for one of these reads
22081 % otherwise the index entries will be doubled up. Initially I disabled it
22082 % after the first read. It eventually dawned on me that this meant two
22083 % LaTeX runs to update the \file{idx}. Enabling it for the second read
22084 % means that the \file{idx} file is updated at the end of each run.
22085 % \changes{v1.618}{2005/09/02}{Made \cs{@@@wrindexm@m} obey \cs{nofiles}}
22086 % \changes{v1.618}{2005/09/25}{\cs{@@@wrindexm@m} now reads the aux
22087 % file at the end of the document}
22088 % \changes{v3.7i}{2019/11/15}{Changed the writing to protected}
22089 % \begin{macrocode}
22090 \newcommand{\@@@wrindexm@m}[2]{\endgroup}
22091 \AtBeginDocument{%
22092 \def\@@@wrindexm@m#1#2{%
22093 \if@filesw
22094 %\immediate\write \@idxfile{\string\indexentry{#1}{#2}}%
22095 \immediate@protected@write\@idxfile{}{\string\indexentry{#1}{#2}}%
22096 \fi
22097 \endgroup}%
22098 }
22099 % \end{macrocode}
22100 % \end{macro}
22101 %
22102 % \begin{macro}{\@spindex}
22103 % Now do similar things for \cs{specialindex}.
22104 % \begin{macrocode}
22105 \newcommand{\@spindex}[2]{%
22106 \@ifundefined{#1@idxfile}%
22107 {\ifreportnoidxfile
22108 \@memwarn{Undefined index file #1}%
22109 \fi
22110 \begingroup
22111 \@sanitize
22112 \@nowrindex}%
22113 {\def\@idxfile{#1}%
22114 \def\@sptheidx{#2}%
22115 \begingroup
22116 \@sanitize
22117 \@wrspindex}}
22118
22119 % \end{macrocode}
22120 % \end{macro}
22121 %
22122 % \begin{macro}{\@wrspindex}
22123 % \begin{macro}{\@@wrspindexhyp}
22124 % \begin{macrocode}
22125 \newcommand{\@wrspindex}[1]{\@@wrspindexhyp#1||\\}
22126 \def\@@wrspindexhyp#1|#2|#3\\{%
22127 \ifshowindexmark\@showidx{#1}\fi
22128 \ifx\\#2\\%
22129 \protected@write\@auxout{}%
22130 {\string\@@wrindexm@m{\@idxfile}%
22131 {#1|hyperspindexpage(\thepage)}%
22132 {\@nameuse{the\@sptheidx}}}%
22133 \else
22134 \def\Hy@temp@A{#2}%
22135 \ifx\Hy@temp@A\HyInd@ParenLeft
22136 \protected@write\@auxout{}%
22137 {\string\@@wrindexm@m{\@idxfile}%
22138 {#1|#2hyperspindexpage(\thepage)}%
22139 {\@nameuse{the\@sptheidx}}}%
22140 \else
22141 \protected@write\@auxout{}%
22142 {\string\@@wrindexm@m{\@idxfile}{#1|#2}%
22143 {\@nameuse{the\@sptheidx}}}%
22144 \fi
22145 \fi
22146 \endgroup
22147 \@esphack}
22148 % \end{macrocode}
22149 % \end{macro}
22150 % \end{macro}
22151 %
22152 % \begin{macro}{\hyperspindexpage}
22153 % \begin{macrocode}
22154 \def\hyperspindexpage(#1)#2{\hyperlink{page.#1}{#2}}
22155
22156 % \end{macrocode}
22157 % \end{macro}
22158 %
22159 % \begin{macro}{\ifmemhyperindex}
22160 % \begin{macro}{\memhyperindextrue}
22161 % \begin{macro}{\memhyperindexfalse}
22162 % Flag to turn off \cs{hyperindexfalse} hyperrefing the index (apparently
22163 % \Lpack{xindy} can't cope with this. Email from Frederic Connes, 2005/07/13:
22164 % \begin{verbatim}
22165 % ...You use |hyperspindex(\thepage) which xindy doesn't
22166 % recognise as a valid markup-locref. And I don't know how
22167 % to add it because xindy only accepts one argument in
22168 % markup-locref (if the number is not a page number, it will
22169 % still point to a page with that number) so replacing it
22170 % with |hyperpage won't work. ...
22171 % \end{verbatim}
22172 %
22173 %
22174 % The default is \cs{memhyperindextrue}. Setting \cs{memhyperindexfalse}
22175 % prohibits a hyper index --- setting whatever option in \Lpack{hyperref}
22176 % to disable hyper indexing will (probably) not work as far as \Lpack{xindy}
22177 % is concerned.
22178 % \changes{v1.618}{2005/09/04}{Added \cs{ifmemhyperindex}}
22179 % \begin{macrocode}
22180 \newif\ifmemhyperindex
22181 \memhyperindextrue
22182
22183 % \end{macrocode}
22184 % \end{macro}
22185 % \end{macro}
22186 % \end{macro}
22187 %
22188 % \begin{macro}{\ifm@mxindy}
22189 % \begin{macro}{\m@mxindytrue}
22190 % \begin{macro}{\m@mxindyfalse}
22191 % \begin{macro}{\xindyindex}
22192 % \begin{macro}{\@@wrspindexhyp}
22193 % Use \cs{xindyindex} when you are going to use the xindy program
22194 % rather than makeindex. hyperrefed entries won't work with xindy.
22195 % The code was supplied by Frederic Connes in an email to me on
22196 % 2006/01/08.
22197 % \changes{v1.61803}{2008/01/30}{Added \cs{xindyindex} (Frederic Connes
22198 % mempatch v4.4)}
22199 % \begin{macrocode}
22200 \newif\ifm@mxindy
22201 \m@mxindyfalse
22202 \newcommand*{\xindyindex}{\m@mxindytrue}
22203 \def\@@wrspindexhyp#1|#2|#3\\{%
22204 \ifshowindexmark\@showidx{#1}\fi
22205 \ifx\\#2\\%
22206 \protected@write\@auxout{}%
22207 {\string\@@wrindexm@m{\@idxfile}%
22208 \ifm@mxindy{#1}\else{#1|hyperspindexpage(\thepage)}\fi
22209 {\@nameuse{the\@sptheidx}}}%
22210 \else
22211 \def\Hy@temp@A{#2}%
22212 \ifx\Hy@temp@A\HyInd@ParenLeft
22213 \protected@write\@auxout{}%
22214 {\string\@@wrindexm@m{\@idxfile}%
22215 \ifm@mxindy{#1|#2}\else{#1|#2hyperspindexpage(\thepage)}\fi
22216 {\@nameuse{the\@sptheidx}}}%
22217 \else
22218 \protected@write\@auxout{}%
22219 {\string\@@wrindexm@m{\@idxfile}{#1|#2}%
22220 {\@nameuse{the\@sptheidx}}}%
22221 \fi
22222 \fi
22223 \endgroup
22224 \@esphack}
22225
22226 % \end{macrocode}
22227 % \end{macro}
22228 % \end{macro}
22229 % \end{macro}
22230 % \end{macro}
22231 % \end{macro}
22232 %
22233 %
22234 %
22235 % \begin{macro}{\@@wrindexhyp}
22236 % \begin{macro}{\@@wrspindexhyp}
22237 % If the \Lpack{hyperref} package is not being used, or \cs{ifmemhyperindex}
22238 % is false, there is no need
22239 % to clutter up the index files.
22240 % \changes{v1.61}{2004/03/28}{Declutter index files if hyperref is not used}
22241 % \changes{v1.618}{2005/09/02}{Fixed spaces in non-hyperref index files (mempatch v2.3).
22242 % Reported by Michael W. Daniels.}
22243 % \begin{macrocode}
22244 \AtBeginDocument{%
22245 \@ifpackageloaded{hyperref}{}{\memhyperindexfalse}%
22246 % \end{macrocode}
22247 % If the \Lpack{hyperref} package is not being used, or a hyperindex
22248 % is not required, simplify!
22249 % \begin{macrocode}
22250 \ifmemhyperindex\else
22251 \def\@@wrindexhyp#1||\\{%
22252 \ifshowindexmark\@showidx{#1}\fi
22253 \protected@write\@auxout{}%
22254 {\string\@@wrindexm@m{\@idxfile}{#1}{\thepage}}%
22255 \endgroup
22256 \@esphack}%
22257 \def\@@wrspindexhyp#1||\\{%
22258 \ifshowindexmark\@showidx{#1}\fi
22259 \protected@write\@auxout{}%
22260 {\string\@@wrindexm@m{\@idxfile}{#1}{\@nameuse{the\@sptheidx}}}%
22261 \endgroup
22262 \@esphack}%
22263 \fi
22264 }
22265
22266 % \end{macrocode}
22267 % \end{macro}
22268 % \end{macro}
22269 %
22270 % \begin{macro}{\see}
22271 % \begin{macro}{\seename}
22272 % \begin{macro}{\seealso}
22273 % \begin{macro}{\alsoname}
22274 % These definitions are taken from the \Lpack{makeidx} package.
22275 % \begin{macrocode}
22276 \newcommand*{\see}[2]{\emph{\seename} #1}
22277 \newcommand*{\seename}{see}
22278 \newcommand*{\seealso}[2]{\emph{\alsoname} #1}
22279 \newcommand*{\alsoname}{see also}
22280
22281 % \end{macrocode}
22282 % \end{macro}
22283 % \end{macro}
22284 % \end{macro}
22285 % \end{macro}
22286 %
22287 % \begin{macro}{\citeindexfile}
22288 % For the \Lpack{natbib} package, and possibly other packages that do
22289 % some special indexing.
22290 % \begin{macrocode}
22291 \newcommand{\citeindexfile}{\jobname}
22292 \AtBeginDocument{\@ifpackageloaded{natbib}{%
22293 \def\NAT@index{\index[\citeindexfile]{\NAT@idxtxt}}}{}}
22294
22295 % \end{macrocode}
22296 % \end{macro}
22297 %
22298 % The next part of the code is essentially the \Lpack{showidx} package.
22299 % I tried putting index entries into marginpars but too many on a page
22300 % led to the `too many floats' problem.
22301 %
22302 % \begin{macro}{\indexmarkstyle}
22303 % \begin{macro}{\@indexbox}
22304 % \begin{macrocode}
22305 \newtoks\indexmarkstyle
22306 \indexmarkstyle{\normalfont\footnotesize\ttfamily}
22307 \newinsert\@indexbox
22308 \dimen\@indexbox\maxdimen
22309
22310 % \end{macrocode}
22311 % \end{macro}
22312 % \end{macro}
22313 %
22314 % \begin{macrocode}
22315 \begingroup
22316 \catcode`\@\active
22317 \expandafter\gdef\csname\string @sanitizeat\endcsname
22318 {\def @{\char`\@}}
22319 \endgroup
22320
22321 % \end{macrocode}
22322 %
22323 % \begin{macro}{\@showidx}
22324 % \begin{macrocode}
22325 \newcommand{\@showidx}[1]{%
22326 \insert\@indexbox{%
22327 \@sanitizeat
22328 \the\indexmarkstyle
22329 \hsize\marginparwidth
22330 \hangindent\marginparsep \parindent\z@
22331 \everypar{}\let\par\@@par \parfillskip\@flushglue
22332 \lineskip\normallineskip
22333 \baselineskip .8\normalbaselineskip\sloppy
22334 \raggedright \leavevmode
22335 \vrule \@height .7\normalbaselineskip \@width \z@\relax
22336 #1\relax
22337 \vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@\relax
22338 }%
22339 \ifhmode\penalty\@M \hskip\z@skip\fi}
22340
22341 % \end{macrocode}
22342 % \end{macro}
22343 %
22344 % \begin{macro}{\@leftidx}
22345 % \begin{macro}{\@rightidx}
22346 % \begin{macrocode}
22347 \newcommand{\@leftidx}{\hskip-\marginparsep \hskip-\marginparwidth}
22348 \newcommand{\@rightidx}{\hskip\columnwidth \hskip\marginparsep}
22349
22350 % \end{macrocode}
22351 % \end{macro}
22352 % \end{macro}
22353 %
22354 % \begin{macro}{\@mkidx}
22355 % \begin{macrocode}
22356 \newcommand{\@mkidx}{\vbox to \z@{%
22357 \rlap{%
22358 \if@twocolumn
22359 \if@firstcolumn \@leftidx \else \@rightidx \fi
22360 \else
22361 \if@twoside
22362 \ifodd\c@page \@rightidx \else \@leftidx \fi
22363 \else
22364 \@rightidx
22365 \fi
22366 \fi
22367 \box\@indexbox
22368 }%
22369 \vss}}
22370
22371 % \end{macrocode}
22372 % \end{macro}
22373 %
22374 % \section{Page bottom}
22375 %
22376 % \begin{macro}{\raggedbottom}
22377 % \begin{macro}{\flushbottom}
22378 % \begin{macro}{\@texttop}
22379 % \begin{macro}{\mem@flshbot}
22380 % These kernel macros need changing because of the new \cs{@indexbox}
22381 % marginal insert.
22382 % \changes{v3.7d}{2015/04/21}{It makes more sense to explicitly call
22383 % \cs{flushbottom} than just let \cs{@texttop}. We also add a switch
22384 % macro to see if \cs{flushbottom} is active. \cs{raggedbottom} and
22385 % \cs{sloppybottom} sets the switch to false}
22386 % \changes{v3.8}{2023/08/08}{The kernel defined these as robust, we'd
22387 % better too}
22388 % \begin{macrocode}
22389 \DeclareRobustCommand{\raggedbottom}{%
22390 \def\mem@flshbot{01}%
22391 \def\@textbottom{\vskip\z@ plus.0001fil}%
22392 \let\@texttop\@mkidx}
22393 \DeclareRobustCommand{\flushbottom}{%
22394 \def\mem@flshbot{00}%
22395 \let\@textbottom\relax
22396 \let\@texttop\@mkidx}
22397 \let\@texttop\@mkidx
22398 \flushbottom
22399
22400 % \end{macrocode}
22401 % \end{macro}
22402 % \end{macro}
22403 % \end{macro}
22404 % \end{macro}
22405 %
22406 % \subsection{Widows and sloppybottom}
22407 %
22408 % There was a discussion \textit{widow handling?} on CTT in
22409 % May 2006. Ivowel wrote
22410 % \begin{quote}
22411 % in experimenting with raggedbottom, widowpenalty, and clubpenalty,
22412 % I think that I have not found a solution that strikes me as
22413 % particularly desirable. I think what I would really like is that
22414 % widows (i.e., left-over single lines that begin on the following
22415 % page) are resolved not by pushing one extra line from the same
22416 % paragraph also onto the next page, but by stretching the
22417 % \cs{textheight} to allow this one extra at the bottom of the
22418 % same page.
22419 % \end{quote}
22420 % Donald Arseneau, as he so often does, came up with a solution he
22421 % termed \cs{sloppybottom}. Here is a generalised version.
22422 %
22423 % \begin{macro}{\sloppybottom}
22424 % \cs{sloppybottom} allows an extra line on a page to save a widow.
22425 % You must increase the \cs{topskip} (by 60 percent is reasonable) and this
22426 % will push the text lower on the page. Run \cs{checkandfixthelayout}
22427 % after the change. For example:
22428 % \begin{verbatim}
22429 % \setlength{\topskip}{1.6\topskip}
22430 % \checkandfixthelayout
22431 % \sloppybottom
22432 % ...
22433 % \end{verbatim}
22434 % \changes{v1.61803}{2008/01/30}{Added \cs{sloppybottom} (mempatch v4.6)}
22435 % \changes{v3.7d}{2015/04/21}{Added flush bottom switch}
22436 % \begin{macrocode}
22437 \newcommand*{\sloppybottom}{%
22438 \def\mem@flshbot{01}%
22439 \def\@textbottom{\vskip \z@ \@plus.0001fil \@minus .95\topskip}%
22440 \topskip=1\topskip \@plus 0.625\topskip \@minus .95\topskip
22441 \def\@texttop{\vskip \z@ \@plus -0.625\topskip \@minus -0.95\topskip}}
22442
22443 % \end{macrocode}
22444 % \end{macro}
22445 %
22446 %
22447 %
22448 %
22449 % \section{Glossaries}
22450 %
22451 % Standard LaTeX provides little and insufficient support for
22452 % glossaries, just a \cs{makeglossary} and \cs{glossary} commands.
22453 % This class does somewhat better. The code follows along the lines
22454 % of that for indexes.
22455 % \changes{v1.618}{2005/09/25}{Added glossary code}
22456 %
22457 %
22458 % \begin{macro}{\ifonecolglossary}
22459 % \begin{macro}{\onecolglossarytrue}
22460 % \begin{macro}{\onecolglossaryfalse}
22461 % TRUE for a one column glossary, otherwise its two column.
22462 % \begin{macrocode}
22463 \newif\ifonecolglossary
22464 \onecolglossarytrue
22465 % \end{macrocode}
22466 % \end{macro}
22467 % \end{macro}
22468 % \end{macro}
22469 %
22470 % \begin{macro}{\onecolglossary}
22471 % \begin{macro}{\twocolglossary}
22472 % \changes{v1.61803}{2008/01/30}{Added \cs{onecolglossary} and \cs{twocolglossary}}
22473 % \begin{macrocode}
22474 \newcommand*{\onecolglossary}{\onecolglossarytrue}
22475 \newcommand*{\twocolglossary}{\onecolglossaryfalse}
22476
22477 % \end{macrocode}
22478 % \end{macro}
22479 % \end{macro}
22480 %
22481 %
22482 % \begin{environment}{theglossary}
22483 % The environment \texttt{theglossary} is used for glossaries.
22484 % It makes a glossary with one or two columns, headed by a chapter-like
22485 % title.
22486 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} with \cs{MakeLinkTarget} and moved it}
22487 % \begin{macrocode}
22488 \newenvironment{theglossary}{%
22489 \if@twocolumn
22490 \@restonecolfalse
22491 \else
22492 \@restonecoltrue
22493 \fi
22494 \ifonecolglossary
22495 \onecolumn
22496 \chapter*{\glossaryname}
22497 \preglossaryhook
22498 \else
22499 \setlength{\columnseprule}{\glossaryrule}
22500 \setlength{\columnsep}{\glossarycolsep}
22501 \MakeLinkTarget[chapter]{}%
22502 \twocolumn[%
22503 \@makeschapterhead{\glossaryname}
22504 \preglossaryhook
22505 ]%
22506 \fi
22507 \glossarymark
22508 \ifnoglossaryintoc\else
22509 %\phantomsection
22510 \addcontentsline{toc}{chapter}{\glossaryname}
22511 \fi
22512 \thispagestyle{chapter}\parindent\z@
22513 \parskip\z@ \@plus .3\p@\relax
22514 \begintheglossaryhook}%
22515 {\atendtheglossaryhook\if@restonecol\onecolumn\else\twocolumn\fi}
22516
22517 % \end{macrocode}
22518 % \end{environment}
22519 %
22520 % \begin{macro}{\begintheglossaryhook}
22521 % \begin{macro}{\atendtheglossaryhook}
22522 % Two vacuous macros called as the last thing by \verb?\begin{theglossary}?
22523 % and the first thing by \verb?\end{theglossary}? These could be used,
22524 % for example, to insert another kind of environment.
22525 % \begin{macrocode}
22526 \newcommand*{\begintheglossaryhook}{}
22527 \newcommand*{\atendtheglossaryhook}{}
22528 % \end{macrocode}
22529 % \end{macro}
22530 % \end{macro}
22531 %
22532 % \begin{macro}{\preglossaryhook}
22533 % A vacuous macro called after the title is set and before the listing
22534 % starts. The user can modify it to, for example, add some explanatory
22535 % text.
22536 % \begin{macrocode}
22537 \newcommand*{\preglossaryhook}{}
22538
22539 % \end{macrocode}
22540 % \end{macro}
22541 %
22542 % \begin{macro}{\ifnoglossaryintoc}
22543 % \begin{macro}{\glossaryintoc}
22544 % \begin{macro}{\noglossaryintoc}
22545 % Flag and declarations to control whether or not the glossary
22546 % title is added to the ToC. Default is to put the title
22547 % in the ToC.
22548 % \begin{macrocode}
22549 \newif\ifnoglossaryintoc
22550 \newcommand*{\glossaryintoc}{\noglossaryintocfalse}
22551 \newcommand*{\noglossaryintoc}{\noglossaryintoctrue}
22552 \glossaryintoc
22553
22554 % \end{macrocode}
22555 % \end{macro}
22556 % \end{macro}
22557 % \end{macro}
22558 %
22559 % \begin{macro}{\glossarycolsep}
22560 % \begin{macro}{\glossaryrule}
22561 % When the glossary is two column these lengths control the
22562 % column separation and the width of a rule between the columns.
22563 % \begin{macrocode}
22564 \newdimen\glossarycolsep \glossarycolsep=35\p@
22565 \newdimen\glossaryrule \glossaryrule=0\p@
22566 % \end{macrocode}
22567 % \end{macro}
22568 % \end{macro}
22569 %
22570 % \begin{macro}{\glossaryspace}
22571 % Vertical space between `letter blocks' in the glossary.
22572 % Note that this is a macro, not a length.
22573 % \begin{macrocode}
22574 \newcommand*{\glossaryspace}{%
22575 \par \vskip 1.0\onelineskip \@plus 5\p@ \@minus3\p@\relax}
22576
22577 % \end{macrocode}
22578 % \end{macro}
22579 %
22580 %
22581 % \begin{macro}{\makeglossary}
22582 % The preamble command to set up a glossary. Output is to the
22583 % \file{\#1.glo} file. We need the \cs{providecommand} in case \cs{nofiles}
22584 % has been called before the class. \cs{makeglossary} sets up several
22585 % file-specific macros.
22586 % \begin{macrocode}
22587 \providecommand*{\makeglossary}{}
22588 \renewcommand*{\makeglossary}[1][\jobname]{%
22589 \makememglossaryhook
22590 \@namedef{memglsact#1}{@}% actual
22591 \@namedef{memglsnx#1}{}% no ref
22592 \@namedef{memglsn#1}{\thepage}% num by page
22593 \@namedef{memglsnf#1}{|memjustarg}% no special number format | emacs
22594 \if@filesw \expandafter\newwrite\csname #1memglofile\endcsname
22595 \expandafter\immediate\openout \csname #1memglofile\endcsname #1.glo\relax
22596 \typeout{Writing glossary file #1.glo }%
22597 \fi}
22598
22599 % \end{macrocode}
22600 % \end{macro}
22601 %
22602 % \begin{macro}{\makememglossaryhook}
22603 % A vacuous macro called at the start of the \cs{makeglossary} code.
22604 % It is redefinable to do something useful.
22605 % \begin{macrocode}
22606 \newcommand*{\makememglossaryhook}{}
22607
22608 % \end{macrocode}
22609 % \end{macro}
22610 %
22611 % \begin{macro}{\glossary}
22612 % The user command for a raw glossary item. The full calling
22613 % sequence looks like: \\
22614 % \cs{glossary}\oarg{file}\parg{key}\marg{term}\marg{desc} \\
22615 % but most is accomplished by lower level macros. It calls
22616 % \cs{@glossary} to handle the first optional argument.
22617 % \begin{macrocode}
22618 \def\glossary{\@bsphack%
22619 \@ifnextchar [{\@glossary}{\@glossary[\jobname]}}%
22620 % \end{macrocode}
22621 % \end{macro}
22622 %
22623 % \begin{macro}{\@glossary}
22624 % \cs{@glossary}\oarg{file} handles the first of the \cs{glossary} optional
22625 % arguments, even though the calling sequence looks like: \\
22626 % \cs{@glossary}\oarg{file}\parg{key}\marg{term}\marg{desc}. \\
22627 % It calls \cs{@@glossary} to handle the second optional argument
22628 % and the rest.
22629 % \begin{macrocode}
22630 \def\@glossary[#1]{%
22631 \@ifnextchar ({\@@glossary[#1]}{\@@glossary[#1]()}}
22632 % \end{macrocode}
22633 % \end{macro}
22634 %
22635 % \begin{macro}{\@@glossary}
22636 % The base macro for \cs{glossary}. Its real calling sequence is: \\
22637 % \cs{@@glossary}\oarg{file}\parg{key}\marg{term}\marg{desc}. \\
22638 % Provided the glossary output file has been set up it calls
22639 % \cs{@wrglom@m} to write the data, otherwise it throws away its
22640 % arguments.
22641 % \begin{macrocode}
22642 \def\@@glossary[#1](#2)#3#4{%
22643 \@ifundefined{#1memglofile}{%
22644 \begingroup
22645 \@sanitize
22646 \endgroup
22647 \@esphack%
22648 }{%
22649 \def\memglofile{#1}%
22650 \begingroup
22651 \@sanitize
22652 % \end{macrocode}
22653 % Use the correct key, \meta{key} if given, otherwise \meta{term}.
22654 % \begin{macrocode}
22655 \ifx\@empty#2\@empty
22656 \@wrglom@m{#3}{#3}{#4}%
22657 \else
22658 \@wrglom@m{#2}{#3}{#4}%
22659 \fi}}
22660
22661 % \end{macrocode}
22662 % \end{macro}
22663 %
22664 % \begin{macro}{\@wrglom@m}
22665 % \cs{@wrglom@m}\marg{key}\marg{term}\marg{desc} writes its three arguments,
22666 % plus the \meta{ref} and the \meta{num} to the \file{aux} file as the
22667 % arguments to the \cs{@@wrglom@m} macro.
22668 % \begin{macrocode}
22669 \newcommand{\@wrglom@m}[3]{%
22670 \protected@write\@auxout{}%
22671 {\string\@@wrglom@m{\memglofile}{#1}{#2}{#3}{\@nameuse{memglsnx\memglofile}}{\@nameuse{memglsn\memglofile}}}%
22672 \endgroup
22673 \@esphack}
22674
22675 % \end{macrocode}
22676 % \end{macro}
22677 %
22678 % \begin{macro}{\@@wrglom@m}
22679 % The calling sequence looks like: \\
22680 % \cs{@@wrglom@m}\marg{file}\marg{key}\marg{term}\marg{desc}\marg{ref}\marg{num} \\
22681 % but is actually really only \\
22682 % \cs{@@wrglom@m}\marg{file} \\
22683 % It saves the output file identifier in \cs{memglofile} and
22684 % \meta{file} as \cs{m@mgf}, then calls \cs{memwritetoglo}
22685 % to handle the remaining `arguments'.
22686 % \begin{macrocode}
22687 \newcommand{\@@wrglom@m}[1]{\begingroup
22688 \def\memglofile{\@nameuse{#1memglofile}}%
22689 \def\m@mgf{#1}%
22690 \@sanitize
22691 \memwritetoglo}
22692
22693 % \end{macrocode}
22694 % \end{macro}
22695 %
22696 % \begin{macro}{\memwritetoglo}
22697 % \begin{macro}{\@ctualm@mwritetoglo}
22698 % \cs{memwritetoglo}\marg{key}\marg{name}\marg{desc}\marg{ref}\marg{num}
22699 % will, at an appropriate time write the raw glossary data to the
22700 % appropriate \file{glo} file.
22701 %
22702 % The \file{aux} file is read twice, once as one of the initial
22703 % actions at the start of the \texttt{document} environment, and again
22704 % at the end of the \texttt{document} environment. The raw glossary
22705 % data must only be written once from the \file{aux} to the \file{glo} file.
22706 % Initially \cs{memwritetoglo} is defined to do nothing, then, after the
22707 % \file{aux} file has been read at the beginning is redefined to do
22708 % its writing.
22709 %
22710 % The Makeindex program expects its input to be like: \\
22711 % \verb?\glosaryentry{key@data}{num}?
22712 % Very cunningly the raw data is fed to the \file{glo}
22713 % file looking like: \\
22714 % \verb?\glossaryentry{key@{\memgloterm{term} \memglodesc{desc} \memgloref{ref}}{num}? \\
22715 % which as far as Makeindex is concerned is simply: \\
22716 % \verb?\glosaryentry{key@{data}}{num}? \\
22717 % (note where all the braces are).
22718 %
22719 %
22720 % \changes{v3.7k}{2020/02/24}{Rewritten to use
22721 % \cs{immediate@protected@write} instead, otherwise UTF8 may get
22722 % written as latin1}
22723 % \begin{macrocode}
22724 \newcommand{\memwritetoglo}[5]{\endgroup}
22725 \newcommand{\@ctualm@mwritetoglo}[5]{%
22726 %\immediate\write \memglofile%
22727 \immediate@protected@write\memglofile{}%
22728 {\string\glossaryentry{#1\@nameuse{memglsact\m@mgf}
22729 {\string\memgloterm{#2}}{\string\memglodesc{#3}}
22730 {\string\memgloref{#4}}\@nameuse{memglsnf\m@mgf}}{#5}}%
22731 \endgroup}
22732 \AtBeginDocument{%
22733 \let\memwritetoglo\@ctualm@mwritetoglo}
22734
22735 % \end{macrocode}
22736 % \end{macro}
22737 % \end{macro}
22738 %
22739 %
22740 % \begin{macro}{\changeglossactual}
22741 % \begin{macro}{\changeglossref}
22742 % \begin{macro}{\changeglossnum}
22743 % \begin{macro}{\changeglossnumformat}
22744 % There are internal macros that are file-dependant, their names
22745 % being constructed from the file name plus a fixed name. The
22746 % \cs{makeglossary} command initializes these but the user may well need
22747 % to change them. In the macros below, \texttt{...actual} refers to the
22748 % actual character in a Makeindex configuration file (default \texttt{@}),
22749 % \texttt{...ref} to the \meta{ref} glossary argument, \texttt{...num}
22750 % to the meta{num} argument (default \cs{thepage}) and \texttt{...numformat}
22751 % to the Makeindex encapsulating command. Example uses are:
22752 % \begin{verbatim}
22753 % \changeglossactual[file]{?}
22754 % \changeglossref[file]{\thepage}
22755 % \changeglossnum[file]{\thesection}
22756 % \changeglossnumref[file]{|textbf}
22757 % \end{verbatim}
22758 % \begin{macrocode}
22759 \newcommand*{\changeglossactual}[2][\jobname]{%
22760 \@namedef{memglsact#1}{#2}}
22761 \newcommand*{\changeglossref}[2][\jobname]{%
22762 \@namedef{memglsnx#1}{#2}}
22763 \newcommand*{\changeglossnum}[2][\jobname]{%
22764 \@namedef{memglsn#1}{#2}}
22765 \newcommand*{\changeglossnumformat}[2][\jobname]{%
22766 \@namedef{memglsnf#1}{#2}}
22767
22768 % \end{macrocode}
22769 % \end{macro}
22770 % \end{macro}
22771 % \end{macro}
22772 % \end{macro}
22773 %
22774 % \begin{macro}{\glossitem}
22775 % The final sorted glossary data is in the form: \\
22776 % \cs{glossitem}\marg{term}\marg{desc}\marg{ref}\marg{num} \\
22777 % The definition here does little.
22778 % \begin{macrocode}
22779 \newcommand{\glossitem}[4]{#1 #2 #3 #4\par}
22780
22781 % \end{macrocode}
22782 % \end{macro}
22783 %
22784 % \begin{macro}{\memgloterm}
22785 % \begin{macro}{\memglodesc}
22786 % \begin{macro}{\memgloref}
22787 % \begin{macro}{\memglonum}
22788 % These are wrappers round the \meta{term}, \meta{desc}, \meta{ref} and
22789 % \meta{num} elements in the final data. They are vacuous to start with.
22790 % \begin{macrocode}
22791 \newcommand*{\memgloterm}[1]{#1}
22792 \newcommand*{\memglodesc}[1]{#1}
22793 \newcommand*{\memgloref}[1]{#1}
22794 \newcommand*{\memglonum}[1]{#1}
22795
22796 % \end{macrocode}
22797 % \end{macro}
22798 % \end{macro}
22799 % \end{macro}
22800 % \end{macro}
22801 %
22802 % \begin{macro}{\printglossary}
22803 % \cs{printglossary}\oarg{file} inputs the glossary \file{gst} file.
22804 % \begin{macrocode}
22805 \newcommand*{\printglossary}[1][\jobname]{\@input@{#1.gls}}
22806
22807 % \end{macrocode}
22808 % \end{macro}
22809 %
22810 %
22811 %
22812 %
22813 % \section{Notes/Marginalia}
22814 %
22815 %
22816 % \subsection{A simple interface for specifying locations}
22817 %
22818 % \changes{v1.61803398d}{2010/01/25}{added}
22819 %
22820 % The \Lpack{memoir} class as of December 2009 supports \cs{marginpar},
22821 % \cs{sidepar}, and \cs{sidebar} for placing information in a margin.
22822 % The means of specifying in which margin the information should be put
22823 % is different for each of these. Here a consistent location interface
22824 % is provided for all marginalia.
22825 %
22826 %
22827 % \begin{macro}{\m@msetm@argin}
22828 % \begin{macro}{\m@mm@argin}
22829 % A workhorse macro for setting a margin placement code. The argument
22830 % may be one of: left, right, outer, or inner, with \cs{m@mm@argin} defined
22831 % as the corresponding codes of 0, 1, 2, or 3. An unkown argument is coded
22832 % as a negative number.
22833 % \begin{macrocode}
22834 \newcommand*{\m@msetm@argin}[1]{%
22835 \def\@tempa{#1}\def\@tempb{left}%
22836 \ifx\@tempa\@tempb
22837 \def\m@mm@argin{0}%
22838 \else
22839 \def\@tempb{right}%
22840 \ifx\@tempa\@tempb
22841 \def\m@mm@argin{1}%
22842 \else
22843 \def\@tempb{outer}%
22844 \ifx\@tempa\@tempb
22845 \def\m@mm@argin{2}%
22846 \else
22847 \def\@tempb{inner}%
22848 \ifx\@tempa\@tempb
22849 \def\m@mm@argin{3}%
22850 \else
22851 \def\m@mm@argin{-1}%
22852 \fi
22853 \fi
22854 \fi
22855 \fi}
22856
22857 % \end{macrocode}
22858 % \end{macro}
22859 % \end{macro}
22860 %
22861 % \begin{macro}{\ifmemtortm}
22862 % \begin{macro}{\memtortmtrue}
22863 % \begin{macro}{\memtortmfalse}
22864 % A flag set TRUE if the marginalia is to be moved to the right of the text
22865 % and FALSE if it is to be moved to the left of the text.
22866 % \begin{macrocode}
22867 % MEM-TO-RighT-Margin
22868 \newif\ifmemtortm
22869 \memtortmtrue
22870 % \end{macrocode}
22871 % \end{macro}
22872 % \end{macro}
22873 % \end{macro}
22874 %
22875 % \begin{macro}{\m@mwhich@margin}
22876 % \cs{m@mwhich@margin}\marg{code} sets \cs{ifmemtortm} TRUE or FALSE depending
22877 % on the value of \meta{code} (0 to 3), and other factors.
22878 % \begin{description}
22879 % \item[Two column document] If the first column, to the left, otherwise
22880 % to the right, irrespective the document being
22881 % one- or two-side.
22882 % \item[One sided document] If code = 0 (left), to the left, otherwise
22883 % (code = 1 (right), 2 (outer), 3 (inner)) to the right.
22884 % \item[Two sided document] depends on whether a recto or verso page:
22885 % \begin{description}
22886 % \item[Recto (odd) page] right if code = 1 (right) or 2 (outer), otherwise
22887 % left.
22888 % \item[Verso (even) page] left if code = 0 (left) or 2 (outer), otherwise
22889 % right.
22890 % \end{description}
22891 % \end{description}
22892 %
22893 %
22894 % \begin{macrocode}
22895 \newcommand*{\m@mwhich@margin}[1]{%
22896 \memtortmtrue
22897 \if@twocolumn
22898 \if@firstcolumn% left
22899 \memtortmfalse
22900 \else% right
22901 \memtortmtrue
22902 \fi
22903 \else
22904 \if@twoside
22905 \checkoddpage
22906 \ifcase #1\relax% 0 left
22907 \memtortmfalse
22908 \or% 1 right
22909 \memtortmtrue
22910 \or% 2 outer
22911 \ifoddpage
22912 \memtortmtrue
22913 \else
22914 \memtortmfalse
22915 \fi
22916 \or% 3 inner
22917 \ifoddpage
22918 \memtortmfalse
22919 \else
22920 \memtortmtrue
22921 \fi
22922 \fi% end ifcase
22923 \else% oneside
22924 \ifnum #1=\z@% 0 left, all else right
22925 \memtortmfalse
22926 \else
22927 \memtortmtrue
22928 \fi
22929 \fi% end if@twoside
22930 \fi}
22931
22932 % \end{macrocode}
22933 % \end{macro}
22934 %
22935 %
22936 %
22937 % \subsection{Marginpars}
22938 %
22939 % A \cs{marginpar} is a kind of floating object --- you can't control
22940 % exactly where it will go. There is one problem with the kernel
22941 % definition of \cs{marginpar} in that sometimes a \cs{marginpar} may
22942 % end up on the wrong side of the page. The following is an attempt
22943 % to fix that using the odd/even page check provided as part of
22944 % the class.
22945 %
22946 % \begin{macro}{\@addmarginpar}
22947 % The part of the code for \cs{marginpar} that deals with deciding which
22948 % side of the page it should be printed on is \cs{@addmarginpar}, buried
22949 % away in the kernel's \texttt{output} routine. A couple of minor changes are made
22950 % to the kernel code. The first is at the beginning where I have added
22951 % the \cs{checkoddpage} page checking code.
22952 % \changes{v1.618033988d}{2010/02/26}{fixed twoside -> left marrgin
22953 % bug, reported by Frank Wikstr\"om, on private email}
22954 % In the new margin placement syntax, there is a new syntax: always
22955 % left, in twoside mode. This cannot be implemented using the normal
22956 % marginpar placement controls, so we have to add our own.
22957 % \begin{macrocode}
22958 \def\@addmarginpar{%
22959 \checkoddpage
22960 % \end{macrocode}
22961 % Continue with the kernel code. The twocolumn stuff in the new syntax
22962 % scheme is the same as in the kernel.
22963 % \begin{macrocode}
22964 \@next\@marbox\@currlist{\@cons\@freelist\@marbox
22965 \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
22966 \if@twocolumn
22967 \if@firstcolumn \@tempcnta\m@ne \fi
22968 \else
22969 % \end{macrocode}
22970 % \changes{v1.618033988d}{2010/02/26}{added as a part of the above
22971 % mentioned fix}
22972 % Here we add the new stuff. We make use of the fact that we have
22973 % hidden all the page checking in \verb?\m@mwhich@margin?, and we only
22974 % fire it of if we know \verb?\marginparmargin? have been used (via
22975 % \verb?\ifm@msetmp?).
22976 % \begin{macrocode}
22977 \ifm@msetmp%
22978 % \@tempcnta > 0 => right side of page
22979 % \@tempcnta < 0 => left side of page
22980 \m@mwhich@margin{\m@mmpar@margin}% set left or right margin
22981 \ifmemtortm%
22982 \@tempcnta\@ne\relax%
22983 \else%
22984 \@tempcnta\m@ne\relax%
22985 \fi%
22986 \else%
22987 \if@mparswitch
22988 % \end{macrocode}
22989 % The next line, reading \\
22990 % \verb?\ifodd\c@page \else\@tempcnta\m@ne \fi? \\
22991 % is where the odd/even page checking is done in the kernel code. I
22992 % replace it with my code, and then continue with the kernel.
22993 % \begin{macrocode}
22994 \ifoddpage \else \@tempcnta\m@ne \fi%
22995 \fi%
22996 \if@reversemargin \@tempcnta -\@tempcnta \fi%
22997 \fi%
22998 \fi%
22999 \ifnum\@tempcnta <\z@ \global\setbox\@marbox\box\@currbox \fi
23000 \@tempdima\@mparbottom
23001 \advance\@tempdima -\@pageht
23002 \advance\@tempdima\ht\@marbox
23003 \ifdim\@tempdima >\z@
23004 % \end{macrocode}
23005 % The next line in the kernel reads: \\
23006 % \verb?\@latex@warning@no@line {Marginpar on page \thepage\space moved}? \\
23007 % I have changed the warning message to give the user an indication
23008 % of the severity of the move. Then follow the kernel on to the end.
23009 % \begin{macrocode}
23010 \@latex@warning@no@line {Marginpar on page
23011 \thepage\space moved by \the\@tempdima}%
23012 \else
23013 \@tempdima\z@
23014 \fi
23015 \global\@mparbottom\@pageht
23016 \global\advance\@mparbottom\@tempdima
23017 \global\advance\@mparbottom\dp\@marbox
23018 \global\advance\@mparbottom\marginparpush
23019 \advance\@tempdima -\ht\@marbox
23020 \global\setbox \@marbox
23021 \vbox {\vskip \@tempdima
23022 \box \@marbox}%
23023 \global \ht\@marbox \z@
23024 \global \dp\@marbox \z@
23025 \kern -\@pagedp
23026 \nointerlineskip
23027 \hb@xt@\columnwidth
23028 {\ifnum \@tempcnta >\z@
23029 \hskip\columnwidth \hskip\marginparsep
23030 \else
23031 \hskip -\marginparsep \hskip -\marginparwidth
23032 \fi
23033 \box\@marbox \hss}%
23034 \nointerlineskip
23035 \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}%
23036 }
23037
23038 % \end{macrocode}
23039 % \end{macro}
23040 %
23041 % \subsubsection{Marginpar -- margin interface}
23042 %
23043 % The `standard' method of specifying the desired margin for a \cs{marginpar}
23044 % consists of the two macros \cs{normalmarginpar} and \cs{reversemarginpar},
23045 % whose effects depend on whether the document is one- or two-sided, whether
23046 % the page is recto or verso, and if it is set in one- or two-columns.
23047 %
23048 % \begin{macro}{\ifm@msetmp}
23049 % \begin{macro}{m@msetmptrue}
23050 % \begin{macro}{m@msetmpfalse}
23051 % TRUE if the macro \cs{marginparmargin} has been called.
23052 % \begin{macrocode}
23053 \newif\ifm@msetmp
23054 \m@msetmpfalse
23055 % \end{macrocode}
23056 % \end{macro}
23057 % \end{macro}
23058 % \end{macro}
23059 %
23060 % \begin{macro}{\marginparmargin}
23061 % \begin{macro}{\m@mmpar@margin}
23062 % The user command for specifying the desired margin for \cs{marginpar}s.
23063 % The code is stored as \cs{m@mmpar@margin}, and \cs{setmpbools} is called to
23064 % convert to the regular \cs{marginpar} booleans.
23065 % \begin{macrocode}
23066 \newcommand*{\marginparmargin}[1]{%
23067 \m@msetmptrue
23068 \m@msetm@argin{#1}%
23069 \ifnum\m@mm@argin<\z@
23070 \@memwarn{Bad \string\marginparmargin\space argument `#1'\MessageBreak
23071 set to `outer'}%
23072 \gdef\m@mmpar@margin{2}% set as outer
23073 \else
23074 \global\let\m@mmpar@margin\m@mm@argin
23075 \fi
23076 \setmpbools}
23077
23078 % \end{macrocode}
23079 % \changes{v3.6k}{2013/05/14}{Added default \cs{m@mmpar@margin}}
23080 % \begin{macrocode}
23081 \if@twocolumn\else
23082 \if@twoside
23083 \def\m@mmpar@margin{2}
23084 \else
23085 \def\m@mmpar@margin{1}
23086 \fi
23087 \fi
23088
23089 % \end{macrocode}
23090 %
23091 %
23092 % \end{macro}
23093 % \end{macro}
23094 %
23095 % \begin{macro}{\setmpbools}
23096 % Given \cs{m@mmpar@margin}, \cs{setmpbools} sets the corresponding
23097 % \cs{marginpar} location booleans.
23098 % \begin{macrocode}
23099 \newcommand*{\setmpbools}{%
23100 \if@twoside
23101 \@mparswitchtrue
23102 \else
23103 \@mparswitchfalse
23104 \fi
23105 \ifcase\m@mmpar@margin\relax% 0 left
23106 \@reversemargintrue% \sideparswitchfalse \reversesidepartrue
23107 \or% 1 right
23108 \@reversemarginfalse% \sideparswitchfalse \reversesideparfalse
23109 \or% 2 outer
23110 \@reversemarginfalse% \sideparswitchtrue \reversesideparfalse
23111 \or% 3 inner
23112 \@reversemargintrue% \sideparswitchtrue \reversesidepartrue
23113 \fi}
23114
23115 % \end{macrocode}
23116 % \end{macro}
23117 %
23118 % \begin{macrocode}
23119 \newcommand*{\m@msetmpcodes}{%
23120 \if@mparswitch% 2 sided
23121 \if@reversemargin% inner
23122 \def\m@mmpar@margin{3}%
23123 \else% outer
23124 \def\m@mmpar@margin{2}%
23125 \fi
23126 \else% 1 sided
23127 \if@reversemargin% left
23128 \def\m@mmpar@margin{0}%
23129 \else% right
23130 \def\m@mmpar@margin{1}%
23131 \fi
23132 \fi}
23133
23134 % \end{macrocode}
23135 %
23136 % \subsection{A fixed marginpar}
23137 %
23138 %
23139 % Introduce a non-floating marginpar.
23140 % \changes{v1.4}{2003/11/22}{Added \cs{sidepar} and supports for a fixed
23141 % marginpar (from patch v1.8)}
23142 %
23143 % \begin{macro}{\parnopar}
23144 % From \theTeXbook{} Exercise 14.15. It creates an `invisible' end/start paragraph,
23145 % and may be used for getting \TeX{} to try a pagebreak.
23146 %
23147 % Roman Eisle (email 2008/09/05) found a problem with the original
23148 % definition as its effects continued on: \\
23149 % \verb?\newcommand{\parnopar}{\parfillskip=0pt\par\parskip=0pt\noindent}? \\
23150 % and he supplied the fix used below.
23151 %
23152 % \changes{v1.6180339c}{2008/12/24}{Changed \cs{parnopar} to limit its effect
23153 % to a single instance}
23154 % \changes{v3.6e}{2010/08/17}{made \cs{parnopar} sit inside a group}
23155 % \begin{macrocode}
23156 \newcommand*{\parnopar}{{\parfillskip=0pt\par\parskip=0pt\noindent}}
23157
23158 % \end{macrocode}
23159 % \end{macro}
23160 %
23161 %
23162 % \begin{macro}{\ifreversesidepar}
23163 % \begin{macro}{\ifsideparswitch}
23164 % \changes{v1.61803398d}{2010/01/25}{Added footnote explaining the default}
23165 % Analogues of \cs{marginpar} controls.\footnote{Note that for some
23166 % now forgotten reason the default placement of the \cs{sidepar} is
23167 % reversed in comparison to say \cs{marginpar}. As not to change
23168 % existing documents, we have left the default like this.}
23169 % \begin{macrocode}
23170 \newif\ifreversesidepar
23171 % \reversesideparfalse
23172 \reversesidepartrue
23173 \newif\ifsideparswitch
23174 \sideparswitchfalse
23175 \if@twoside \sideparswitchtrue \fi
23176
23177 % \end{macrocode}
23178 % \end{macro}
23179 % \end{macro}
23180 %
23181 % \changes{v1.61803398d}{2010/01/25}{Added}
23182 % \begin{macro}{\ifm@msetsp}
23183 % \begin{macro}{\m@msetsptrue}
23184 % \begin{macro}{\m@msetspfalse}
23185 % \begin{macrocode}
23186 %% true if \sideparmargin used
23187 \newif\ifm@msetsp
23188 \m@msetspfalse
23189 % \end{macrocode}
23190 % \end{macro}
23191 % \end{macro}
23192 % \end{macro}
23193 % \changes{v1.61803398d}{2010/01/25}{Added}
23194 % \begin{macro}{\sideparmargin}
23195 % \begin{macro}{\m@mspar@margin}
23196 % User command for specifing the margin for \cs{sidepar}s.
23197 % The numeric code is stored in \cs{m@mspar@margin}.
23198 % \begin{macrocode}
23199 \newcommand*{\sideparmargin}[1]{%
23200 \m@msetsptrue
23201 \m@msetm@argin{#1}%
23202 \ifnum\m@mm@argin<\z@
23203 \@memwarn{Bad \string\sideparmargin\space argument `#1'\MessageBreak
23204 set to `outer'}%
23205 \gdef\m@mspar@margin{2}% set as outer
23206 \else
23207 \global\let\m@mspar@margin\m@mm@argin
23208 \fi}
23209
23210 % \end{macrocode}
23211 % \end{macro}
23212 % \end{macro}
23213 % \changes{v1.61803398d}{2010/01/25}{Added}
23214 % \begin{macro}{\m@msidepar@left}
23215 % \begin{macro}{\m@msidepar@right}
23216 % Move a \cs{sidepar} into the left/right margin.
23217 % \begin{macrocode}
23218 \newcommand*{\m@msidepar@left}{%
23219 \@tempdimc\marginparwidth
23220 \advance\@tempdimc\marginparsep
23221 \kern-\@tempdimc}
23222 \newcommand*{\m@msidepar@right}{%
23223 \@tempdimc\columnwidth
23224 \advance\@tempdimc\marginparsep
23225 \kern\@tempdimc}
23226
23227 % \end{macrocode}
23228 % \end{macro}
23229 % \end{macro}
23230 % \changes{v1.61803398d}{2010/01/25}{Added}
23231 % \begin{macro}{\setspbools}
23232 % Given the \cs{m@mspar@margin} code, calculates the corresponding
23233 % \cs{sidepar} location booleans.
23234 % \begin{macrocode}
23235 \newcommand*{\setspbools}{%
23236 \ifcase\m@mspar@margin\relax% 0 left
23237 \sideparswitchfalse \reversesidepartrue
23238 \or% 1 right
23239 \sideparswitchfalse \reversesideparfalse
23240 \or% 2 outer
23241 \sideparswitchtrue \reversesideparfalse
23242 \or% 3 inner
23243 \sideparswitchtrue \reversesidepartrue
23244 \fi}
23245
23246 % \end{macrocode}
23247 % \end{macro}
23248 % \changes{v1.61803398d}{2010/01/25}{Added}
23249 % \begin{macro}{\setspcode}
23250 % Given the \cs{sidepar} location booleans, sets up the corresponding
23251 % \cs{m@mspar@margin} numeric codes.
23252 % \begin{macrocode}
23253 \newcommand*{\setspcode}{%
23254 \ifsideparswitch
23255 \ifreversesidepar
23256 \def\m@mspar@margin{3}% inner
23257 \else
23258 \def\m@mspar@margin{2}% outer
23259 \fi
23260 \else
23261 \ifreversesidepar
23262 \def\m@mspar@margin{0}% left
23263 \else
23264 \def\m@mspar@margin{1}% right
23265 \fi
23266 \fi}
23267
23268 % \end{macrocode}
23269 % \end{macro}
23270 % \changes{v1.61803398d}{2010/01/25}{Added}
23271 % \begin{macro}{\sideparfont}
23272 % \begin{macro}{\sideparform}
23273 % The font to be used for \cs{sidepar}s and the alignment for it.
23274 % \changes{v1.61803398d}{2010/02/04}{Changed default font}
23275 % \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
23276 % The \cs{sideparform} holds code that will set the text flush against
23277 % the edge of the text.\footnote{One might consider redefining this
23278 % using the \cs{RaggedRight} and \cs{RaggedLeft} macros from the
23279 % ragged2e package.}
23280 % \begin{macrocode}
23281 \newcommand*{\sideparfont}{\normalfont\normalsize}
23282 \newcommand*{\sideparform}{\ifmemtortm\raggedright\else\raggedleft\fi}
23283 % \end{macrocode}
23284 % \end{macro}
23285 % \end{macro}
23286
23287 %
23288 % \begin{macro}{\sidepar}
23289 % \begin{macro}{\@sidepar}
23290 % \begin{macro}{\sideparvshift}
23291 % \cs{sidepar}\oarg{left}\marg{right} (per \cs{marginpar}).
23292 % Sidepars had a nasty habit of moving up or down depending on whether
23293 % characters in the sidepar and the main text line have ascenders and/or
23294 % descenders. The length \cs{sideparvshift} was provided to
23295 % enable adjustments. This is Dan Luecking's modified version of my
23296 % original code
23297 % (CTT \textit{Re: sidepars drift up a point}, 2006/04/11) which does a much
23298 % better job,
23299 % and the default for \cs{sideparvshift} is now 0pt.
23300 % \changes{v1.61803}{2008/01/30}{Fixed \cs{sidepars} from moving up and down
23301 % (mempatch v4.5)}
23302 % \changes{v1.61803}{2008/01/30}{Normalised font in \cs{@sidepar}
23303 % (mempatch v4.9)}
23304 % \changes{v1.61803398d}{2010/01/25}{\cs{@sidepar} changed to fit the
23305 % interface just added}
23306 % \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
23307 % \changes{v3.6h}{2010/10/29}{The inserted text should have the same
23308 % baseline stretch as the rest of the page notes.}
23309 % \begin{macrocode}
23310 \newcommand{\sidepar}{\@dblarg{\@sidepar}}
23311 \long\def\@sidepar[#1]#2{\leavevmode\@bsphack\strut\vadjust{%
23312 \checkoddpage
23313 \ifm@msetsp% \sideparmargin used
23314 %%%% \setspbools
23315 \else% \sideparmargin not used, set the \m@mspar@margin code
23316 \setspcode
23317 \fi
23318 \rlap{\kern-\parindent
23319 \m@mwhich@margin{\m@mspar@margin}% set left or right margin
23320 \ifmemtortm
23321 \m@msidepar@right
23322 \else
23323 \m@msidepar@left
23324 \fi
23325 \setbox0=\vtop to 0pt{%
23326 \begin{minipage}[t]{\marginparwidth}%
23327 \def\baselinestretch{\m@m@footnote@spacing}%
23328 \sideparform\sideparfont%
23329 \ifmemtortm #2\else #1\fi
23330 \end{minipage}%
23331 \vss}%
23332 \vtop to 0pt{\kern\sideparvshift% default should be 0pt
23333 \kern-\dp\strutbox
23334 \kern-\ht0
23335 \box0 \vss}}}%
23336 \@esphack}
23337
23338 % \end{macrocode}
23339 % \end{macro}
23340 % \end{macro}
23341 % Vertical shift for sidepar to align with text line
23342 % \begin{macrocode}
23343 \newlength{\sideparvshift}
23344 \setlength{\sideparvshift}{0pt}
23345 %%%% \setlength{\sideparvshift}{-2.08ex}% seems to work for all font sizes
23346
23347 % \end{macrocode}
23348 % \end{macro}
23349 %
23350 %
23351 % \subsection{Sidebars}
23352 %
23353 % \changes{v1.1}{2002/03/19}{Added experimental code for sidebars}
23354 %
23355 % On 2002/10/22 Donald Arseneau posted the following code to \ctt{} for adding
23356 % sidebars to plain TeX.
23357 % \begin{verbatim}
23358 % \newinsert\sideins
23359 % \skip\sideins=0pt
23360 % \count\sideins=0
23361 % \dimen\sideins=2in
23362 %
23363 % \def\sidebarvsep{25pt}
23364 % \def\sidebarhsep{15pt}
23365 %
23366 % \let\mainpagecontents\pagecontents
23367 %
23368 % \def\sidecontents{%
23369 % \ifvoid\sideins\else
23370 % {\advance\hsize\sidebarhsep
23371 % \moveright\hsize \vtop to0pt{%
23372 % \vskip-\sidebarvsep \vskip\topskip % offset by difference
23373 % \unvbox\sideins \vss}%
23374 % }\fi}
23375 % \def\pagecontents{\sidecontents\mainpagecontents}
23376 % \long\def\sidebar#1{
23377 % \insert\sideins{%
23378 % \splittopskip\sidebarvsep\relax
23379 % \hsize 1.5in \rightskip=0pt plus 20pt \it
23380 % \noindent \vbox to \sidebarvsep{}\ignorespaces #1%
23381 % \ifhmode \unskip\strut\fi \par
23382 % }%
23383 % }
23384 %
23385 % \end{verbatim}
23386 %
23387 % The following started off (2002/03/19) as my attempt to rewrite the above
23388 % into a form suitable for LaTeX, and this class in particular.
23389 %
23390 % Donald Arseneau came up with some improvements to my sidebar code.
23391 % The impetus
23392 % for this came from a CTT thread, \textit{whitespace after my command},
23393 % 2006/11/30 and earlier. In email to me on 2006/11/30 he said:
23394 % \begin{quotation}
23395 % For \Lpack{memoir} \cs{sidebar}, it seems the rules are expanding
23396 % to fill the space for the sidebar, so here is my suggested change
23397 % to \cs{sidecontents}.
23398 %
23399 % It occurs to me that a separate \cs{sidetsep} (or \cs{sidetopsep})
23400 % would be more valuable than having an explicit 1\cs{onelineskip}.
23401 %
23402 % I grouped common code into two macros, and altered \cs{sidebarform} too.
23403 % \end{quotation}
23404 %
23405 % Since then we have been going back and forth, with the result that
23406 % practically all the complex code is Donald's.
23407 % \changes{v1.61803}{2008/01/30}{Major rewrite of \cs{sidebar} code
23408 % (mempatch v4.6 and v4.9)}
23409 %
23410 %
23411 % \begin{macro}{\sideins}
23412 % Create a new insert called \cs{sideins}, which also creates a corresponding
23413 % skip, count, dimen, and box. \\
23414 % \verb?\skip\sideins? is the extra vertical space to allow on the page for
23415 % the insert, \\
23416 % \verb?\count\sideins? is the magnification factor for page breaking, \\
23417 % \verb?\dimen\sideins? is the maximum insertion size (height) per page, \\
23418 % and the inserted material will be in \verb?\box\sideins? when a page is output.
23419 % \begin{macrocode}
23420 \newinsert\sideins
23421 \skip\sideins=0pt
23422 \count\sideins=0
23423
23424 % \end{macrocode}
23425 % \end{macro}
23426 %
23427 % \begin{macro}{\sidebartopsep}
23428 % Separation at the top of a sidebar.
23429 % \begin{macrocode}
23430 \newlength{\sidebartopsep}
23431 \setlength{\sidebartopsep}{0pt}
23432 % \end{macrocode}
23433 % \end{macro}
23434 %
23435 %
23436 % \begin{macro}{\setsidebarheight}
23437 % The macro \cs{setsidebarheight}\marg{length} sets the total
23438 % height of sidebars on a page to \meta{length}.
23439 % This is an interface for controlling \verb?\dimen\sideins? properly,
23440 % taking account of \cs{topskip} and the sidebar font size (and therefore
23441 % should be invoked \emph{after} declaring \cs{sidebarfont}).
23442 %
23443 % Note that \cs{sidebartopsep} is \emph{not} included as part of the
23444 % allocated height.
23445 % \begin{macrocode}
23446 \newcommand{\setsidebarheight}[1]{%
23447 \setlength{\dimen\sideins}{#1}%
23448 \advance\dimen\sideins-\topskip
23449 \advance\dimen\sideins\ht\strutbox}
23450
23451 % \end{macrocode}
23452 % \end{macro}
23453 %
23454 % \begin{macro}{\sidebarhsep}
23455 % \begin{macro}{\sidebarvsep}
23456 % \begin{macro}{\sidebarwidth}
23457 % The length \cs{sidebarhsep} is the gap between the typeblock and the sidebar.
23458 % \cs{sidebarvsep} is the vertical gap between sidebars on a page.
23459 % The maximum number of sidebar lines on a page is
23460 % \verb?1 + (\dimen\sideins - \sidebarvsep)?, assuming \verb?\dimen\sideins?
23461 % is defined in terms of \cs{onelineskip}.
23462 % The width of the sidebar is \cs{sidebarwidth}.
23463 % \begin{macrocode}
23464 \newlength{\sidebarhsep}
23465 \newlength{\sidebarvsep}
23466 \newlength{\sidebarwidth}
23467 % \end{macrocode}
23468 % \end{macro}
23469 % \end{macro}
23470 % \end{macro}
23471 %
23472 % \begin{macro}{\sidebarfont}
23473 % The font for typesetting the contents of a sidebar.
23474 % \changes{v1.61803398d}{2010/02/05}{Added a default for \cs{sidebarfont}}
23475 % \begin{macrocode}
23476 \newcommand{\sidebarfont}{\normalfont\normalsize}
23477 % \end{macrocode}
23478 % \end{macro}
23479 %
23480 % \begin{macro}{\setsidebars}
23481 % \cs{setsidebars}\marg{hsep}\marg{width}\marg{vsep}\marg{topsep}\marg{font}\marg{height}
23482 % sets the main \cs{sidebar} parameters. A \verb?*? argument means leave the
23483 % setting as is.
23484 % \changes{v1.61803}{2008/01/30}{Added \cs{setsidebars} (mempatch v4.6)}
23485 % \begin{macrocode}
23486 \newcommand*{\setsidebars}[6]{%
23487 \nametest{#1}{*}\ifsamename\else
23488 \setlength{\sidebarhsep}{#1}\@memznegtest{\sidebarhsep}%
23489 \fi
23490 \nametest{#2}{*}\ifsamename\else
23491 \setlength{\sidebarwidth}{#2}\@memznegtest{\sidebarwidth}%
23492 \fi
23493 \nametest{#3}{*}\ifsamename\else
23494 \setlength{\sidebarvsep}{#3}\@memnegtest{\sidebarvsep}%
23495 \fi
23496 \nametest{#4}{*}\ifsamename\else
23497 \setlength{\sidebartopsep}{#4}%
23498 \fi
23499 \nametest{#5}{*}\ifsamename\else
23500 \def\sidebarfont{#5}%
23501 \fi
23502 \nametest{#6}{*}\ifsamename\else
23503 \setsidebarheight{#6}%
23504 \ifdim\dimen\sideins>\z@\else
23505 %%%% \@memerror{\protect\sidebarheight\space is zero or negative}{\@ehd}%
23506 \@memwarn{\protect\sidebarheight\space is zero or negative}%
23507 \fi
23508 \fi}
23509 \setsidebars{\marginparsep}% sidebarhsep
23510 {\marginparwidth}% sidebarwidth
23511 {\onelineskip}% sidebarvsep
23512 {0pt}% sidebartopsep
23513 {\normalsize\normalfont}% sidebarfont
23514 {\textheight}% sidebarheight
23515
23516 % \end{macrocode}
23517 % \end{macro}
23518 %
23519 %
23520 % \begin{macro}{\sidebarform}
23521 % \cs{sidebarform} sets the `raggedness' in a sidebar. The current definition
23522 % is less ragged than \cs{raggedright}. Examples:
23523 % \begin{verbatim}
23524 % for flushleftright \renewcommand{\sidebarform}{}
23525 % for raggedleft \renewcommand{\sidebarform}{\raggedleft}
23526 % \end{verbatim}
23527 % \changes{v1.4}{2003/11/22}{Added \cs{sidebarform} (from patch v1.5)}
23528 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{sidebarform}}
23529 % \changes{v1.61803398d}{2010/02/05}{changed to make the text flush
23530 % against the text}
23531 % \begin{macrocode}
23532 \newcommand{\sidebarform}{%\rightskip=\z@ \@plus 2em}
23533 %\memRTLrightskip=\z@ \@plus 2em
23534 \ifmemtortm\raggedright\else\raggedleft\fi%
23535 % \ifmemtortm\memRTLrightskip=\z@ \@plus 2em\else\memRTLleftskip=\z@ \@plus 2em\fi
23536 }
23537
23538 % \end{macrocode}
23539 % \end{macro}
23540 %
23541 % \begin{macro}{\ifsidebaroneside}
23542 % Flag for oneside.
23543 % \changes{v1.61}{2004/04/05}{Added \cs{ifsidebaroneside}}
23544 % \changes{v1.61803398d}{2010/02/07}{flaged as deprecated, the macro
23545 % is not used at all, kept just to ensure that documents does not
23546 % crash, TO BE DELETED}
23547 % \begin{macrocode}
23548 \newif\ifsidebaroneside
23549 \if@twoside\sidebaronesidefalse\else\sidebaronesidetrue\fi
23550
23551 % \end{macrocode}
23552 % \end{macro}
23553 %
23554 % \begin{macro}{\sidebarmargin}
23555 % \begin{macro}{\m@msidebar@margin}
23556 % \changes{v1.61803398d}{2010/02/07}{removed the mention of
23557 % \cs{sidebaroneside}, as it is deprecated}
23558 % \cs{sidebarmargin}\marg{side} sets the side where sidebars will be printed.
23559 % Valid arguments are: left, right, outer, or inner.
23560 %
23561 % \changes{v1.618}{2005/09/03}{Added \cs{sidebarmargin} (mempatch v3.2)}
23562 % \changes{v1.61803398d}{2010/01/25}{Changed to match new general interface}
23563 % \begin{macrocode}
23564 \newcommand*{\sidebarmargin}[1]{%
23565 \m@msetm@argin{#1}%
23566 \ifnum\m@mm@argin<\z@
23567 \@memwarn{Bad \string\sidebarmargin\space argument `#1'\MessageBreak
23568 set to `outer'}%
23569 \gdef\m@msidebar@margin{2}% set as outer
23570 \else
23571 \global\let\m@msidebar@margin\m@mm@argin
23572 \fi}
23573 %%%% default outer
23574 \gdef\m@msidebar@margin{2}
23575 % \end{macrocode}
23576 % \end{macro}
23577 % \end{macro}
23578 %
23579 % \begin{macro}{\m@sideb@left}
23580 % \begin{macro}{\m@sideb@right}
23581 % Code used later to put sidebars into the desired margin.
23582 % \changes{v1.61803}{2008/01/30}{Added \cs{m@sideb@left} and \cs{m@sideb@right}
23583 % (mempatch v4.6)}
23584 % \begin{macrocode}
23585 \newcommand*{\m@sideb@left}{%
23586 \@tempdimc \sidebarwidth
23587 \advance\@tempdimc\sidebarhsep
23588 \kern-\@tempdimc}
23589 \newcommand*{\m@sideb@right}{%
23590 \@tempdimc \columnwidth% or \hsize
23591 \advance\@tempdimc\sidebarhsep
23592 \kern\@tempdimc}
23593
23594 % \end{macrocode}
23595 % \end{macro}
23596 % \end{macro}
23597 %
23598 % \begin{macro}{\sidecontents}
23599 % This locates the horizontal position of a sidebar. On two column
23600 % pages it is put in the margin next to the column where \cs{sidebar}
23601 % is called, otherwise it is put in the outer (foredge) margin, except
23602 % for the oneside option when it is put into the right hand margin.
23603 % This can be separately controlled via \cs{ifsidebaroneside}.
23604 % Emanuele Vicentini (private email, 2004/04/05)
23605 % suggested to code for the oneside option.
23606 % \changes{v1.61}{2004/04/05}{Changed \cs{sidecontents} for oneside option}
23607 % \changes{v1.618}{2005/09/03}{Changed \cs{sidecontents} for \cs{sidebarmargin}}
23608 % \changes{v1.61803}{2008/01/30}{Modified \cs{sidecontents} (mempatch v4.6)}
23609 % \changes{v1.61803398d}{2010/01/15}{changed to use
23610 % \cs{m@mwhich@margin} for determining wheter to move right ot left}
23611 % \begin{macrocode}
23612 \newcommand{\sidecontents}{\hbox to \z@{%
23613 \m@mwhich@margin{\m@msidebar@margin}%
23614 \ifmemtortm
23615 \m@sideb@right
23616 \else
23617 \m@sideb@left
23618 \fi
23619 % \end{macrocode}
23620 % DA and I have gone to and fro on the next bit of code trying to get
23621 % the top alignment correct.
23622 % \begin{verbatim}
23623 % \vtop to0pt{%
23624 % \vskip\onelineskip
23625 % \unvbox\sideins \vss}%
23626 % \end{verbatim}
23627 % DA has the last word.
23628 % \begin{macrocode}
23629 \vtop to0pt{%
23630 \normalsize\normalfont\sidebarfont% select font so we know the strut size
23631 \vskip\topskip \vskip-\ht\strutbox
23632 \vskip\sidebartopsep% extra vertical shift
23633 \unvbox\sideins \vss}%
23634 \hss}}
23635
23636 % \end{macrocode}
23637 % \end{macro}
23638 %
23639 % \begin{macro}{\sidebar}
23640 % \cs{sidebar}\marg{text} puts \meta{text} into a sidebar.
23641 %
23642 % Florence Henry in the thread \textit{Of memoir, sidebar, and
23643 % justification}, 2003/04/02, pointed out that \texttt{itemize} in a
23644 % \cs{sidebar} could overflow. DA gave the solution hint.
23645 %
23646 % DA says that having stacked insertions position properly is difficult.
23647 % Here he uses the size of the strut to regulate both the height and the
23648 % depth of each insertion (much as for footnotes). The following is his
23649 % code and commentary.
23650 % \changes{v1.4}{2003/11/22}{Revised \cs{sidebar}}
23651 % \changes{v1.61803}{2008/01/30}{DA's rewrite of \cs{sidebar} (mempatch v4.6)}
23652 % \begin{macrocode}
23653 \newcommand{\sidebar}[1]{%
23654 \insert\sideins{%
23655 % \end{macrocode}
23656 % Begin the insertion with settings. The height of the strut box
23657 % (dependant on the font) will determine the top alignment both initially
23658 % and after a page break. The setting for maximum depth does not control
23659 % anything; see the code further on instead.
23660 % \changes{v1.61803398d}{2010/02/05}{removed
23661 % \cs{normalfont}\cs{normalsize}, as these are now in the \cs{sidebarfont}}
23662 % \changes{v3.6h}{2010/10/29}{the text should have the same baseline
23663 % stretch as the rest of the page notes.}
23664 % \begin{macrocode}
23665 \hsize\sidebarwidth
23666 \@parboxrestore
23667 \def\baselinestretch{\m@m@footnote@spacing}%
23668 % \end{macrocode}
23669 % \changes{v1.61803398d}{2010/02/05}{Added margin placement check
23670 % inside \cs{sidebar}}
23671 % Even though the margin placement is handled inside
23672 % \cs{sidecontents}, there are some timming issues such that
23673 % \cs{ifmemtortm} is executed too late for \cs{sidebar}s internals to
23674 % make use of it. Fixed by adding the margin check to \cs{sidebar} as well.
23675 % \begin{macrocode}
23676 \m@mwhich@margin{\m@msidebar@margin}%
23677 \sidebarform\sidebarfont
23678 \splittopskip=\ht\strutbox
23679 \splitmaxdepth=\dp\strutbox % doesn't do anything useful
23680 % \end{macrocode}
23681 % Allow a free split at the top (so this whole insertion moves
23682 % to the next page if it does not fit).
23683 % \begin{macrocode}
23684 \allowbreak
23685 % \end{macrocode}
23686 % Control the (vertical) positioning of non-split entries. Footnotes (and
23687 % previous versions of \cs{sidebar}) us a strut at the beginning of the text,
23688 % but we will allow a baseline-skip to perform the same function. This
23689 % method also introduces a \cs{parskip} when the paragraph begins, so we
23690 % counteract that. (The problem with an initial strut is that it messes'
23691 % up entries that begin with vertical space.)
23692 % \begin{macrocode}
23693 \prevdepth=\dp\strutbox % supersedes a "top-strut"
23694 \vskip-\parskip
23695 % \end{macrocode}
23696 % Now the user's sidebar entry:
23697 % \begin{macrocode}
23698 #1%
23699 % \end{macrocode}
23700 % If the entry ended still in a paragraph, take the chance to insert a
23701 % final strut; then end the paragraph.
23702 % \begin{macrocode}
23703 \ifvmode\else
23704 \unskip\@finalstrut\strutbox
23705 \fi\par
23706 % \end{macrocode}
23707 % Explicitly force the effect of \cs{maxdepth} (\cs{splitmaxdepth}),
23708 % but using the depth of the strut in the r\^{o}le of \cs{maxdepth}.
23709 % \begin{macrocode}
23710 \ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox \fi
23711 % \end{macrocode}
23712 % Now control how adjacent entries abut (whether or not a final strut got
23713 % inserted) and how an entry fits at the bottom of the page. Use \cs{vskip}s
23714 % to move from the text bottom to where a strut would bottom out,
23715 % but insert an allowed breakpoint at the baseline position
23716 % (so that the entry baseline may match the page's baseline). Finally
23717 % insert the extra separation between entries.
23718 % \begin{macrocode}
23719 \ifdim\prevdepth>99\p@
23720 \nobreak
23721 \vskip-\prevdepth
23722 \allowbreak
23723 \vskip\dp\strutbox
23724 \fi
23725 \vskip\sidebarvsep}}
23726
23727 % \end{macrocode}
23728 % \end{macro}
23729 %
23730 %
23731 % \subsection{Footnotes}
23732 %
23733 % For my reference, in case I want to fiddle with it even more
23734 % than I have already done so, here is the kernel code (from \file{ltfloat.dtx})
23735 % for footnotes.
23736 % \DescribeMacro{\footins}
23737 % The insert for footnotes.
23738 % \begin{verbatim}
23739 % \newinsert\footins
23740 % \skip\footins=\bigskipamount
23741 % \count\footins=1000
23742 % \dimen\footins=8in
23743 % \end{verbatim}
23744 %
23745 % \DescribeMacro{\footnoterule}
23746 % Draws the rule separating footnotes from the main text. It is executed
23747 % after a \cs{vspace} of \verb?\skip\footins? and should take no vertical
23748 % space.
23749 % \begin{verbatim}
23750 % \def\footnoterule{\kern-3\p@ \hrule \@width 2in \kern 2.6\p@}
23751 %
23752 % \@definecounter{footnote}
23753 % \def\thefootnote{\@arabic\c@footnote}
23754 % \@definecounter{mpfootnote}
23755 % \def\thempfootnote{\itshape\@alph\c@mpfootnote}
23756 % \end{verbatim}
23757 %
23758 % \DescribeMacro{\@makefnmark}
23759 % Generates the footnote marker from \cs{@thefnmark}.
23760 % \begin{verbatim}
23761 % \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
23762 %
23763 % \DeclareRobustCommand*\textsuperscript[1]{%
23764 % \@textsuperscript{\selectfont#1}}
23765 % \def\@textsuperscript#1{%
23766 % {\m@th\ensuremath{^{\mbox{\fontsize\sf@size\z@#1}}}}}
23767 %
23768 % \newdimen\footnotesep
23769 % \end{verbatim}
23770 %
23771 % \DescribeMacro{\footnote}
23772 % \cs{footnote}\oarg{num}\marg{text} is what the user uses for footnoting.
23773 % It defines \cs{@thefnmark} and calls \cs{@footnotemark} and
23774 % \cs{@footnotetext} to do the work.
23775 % \begin{verbatim}
23776 % \def\footnote{\@ifnextchar[\@xfootnote{\stepcounter\@mpfn
23777 % \protected@xdef\@thefnmark{\thempfn}%
23778 % \@footnotemark\@footnotetext}}
23779 % \end{verbatim}
23780 %
23781 % \DescribeMacro{\@xfootnote}
23782 % Handles the optional \meta{num} argument to \cs{footnote}.
23783 % It defines \cs{@thefnmark} and calls \cs{@footnotemark} and
23784 % \cs{@footnotetext} to do the work.
23785 % \begin{verbatim}
23786 % \def\@xfootnote[#1]{%
23787 % \begingroup
23788 % \csname c@\@mpfn\endcsname #1\relax
23789 % \unrestored@protected@xdef\@thefnmark{\thempfn}%
23790 % \endgroup
23791 % \@footnotemark\@footnotetext}
23792 % \end{verbatim}
23793 %
23794 % \DescribeMacro{\@footnotetext}
23795 % \cs{@footnotetext}\marg{text} sets up for typeseting the footnote
23796 % (at the bottom of the page). It calls \cs{@makefntext}\marg{text}
23797 % to actually do the typesetting (\cs{@makefntext} has to be supplied
23798 % by a class or package).
23799 % \begin{verbatim}
23800 % \long\def\@footnotetext#1{%
23801 % \insert\footins{%
23802 % \reset@font\footnotesize
23803 % \interlinepenalty\interfootnotelinepenalty
23804 % \splittopskip\footnotesep
23805 % \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
23806 % \hsize\columnwidth \@parboxrestore
23807 % \def\@currentcounter{footnote}% added later
23808 % \protected@edef\@currentlabel{%
23809 % \csname p@footnote\endcsname\@thefnmark}%
23810 % \color@begingroup
23811 % \@makefntext{%
23812 % \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
23813 % \color@endgroup}}
23814 % \end{verbatim}
23815 %
23816 % \DescribeMacro{\footnotemark}
23817 % \cs{footnotemark}\oarg{num} the user uses this to produce just a
23818 % footnote mark in the text.
23819 % \begin{verbatim}
23820 % \def\footnotemark{%
23821 % \@ifnextchar[\@xfootnotemark
23822 % {\stepcounter{footnote}%
23823 % \protected@xdef\@thefnmark{\thefootnote}%
23824 % \@footnotemark}}
23825 % \end{verbatim}
23826 %
23827 % \DescribeMacro{\@xfootnotemark}
23828 % Handles the optional \meta{num} argument to \cs{footnotemark}.
23829 % \begin{verbatim}
23830 % \def\@xfootnotemark[#1]{%
23831 % \begingroup
23832 % \c@footnote #1\relax
23833 % \unrestored@protected@xdef\@thefnmark{\thefootnote}%
23834 % \endgroup
23835 % \@footnotemark}
23836 % \end{verbatim}
23837 %
23838 % \DescribeMacro{\@footnotemark}
23839 % Typesets the mark in the main text, via \cs{@makefnmark}.
23840 % \begin{verbatim}
23841 % \def\@footnotemark{%
23842 % \leavevmode
23843 % \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
23844 % \@makefnmark
23845 % \ifhmode\spacefactor\@x@sf\fi
23846 % \relax}
23847 % \end{verbatim}
23848 %
23849 % \DescribeMacro{\footnotetext}
23850 % \cs{footnotetext}\oarg{num}\marg{text} is user view for creating a footnote
23851 % without a marker in the main text.
23852 % \begin{verbatim}
23853 % \def\footnotetext{%
23854 % \@ifnextchar [\@xfootnotenext
23855 % {\protected@xdef\@thefnmark{\thempfn}%
23856 % \@footnotetext}}
23857 % \end{verbatim}
23858 %
23859 % \DescribeMacro{\@xfootnotetext}
23860 % Handles the optional \meta{num} argument to \cs{footnotetext}.
23861 % \begin{verbatim}
23862 % \def\@xfootnotenext[#1]{%
23863 % \begingroup
23864 % \csname c@\@mpfn\endcsname #1\relax
23865 % \unrestored@protected@xdef\@thefnmark{\thempfn}%
23866 % \endgroup
23867 % \@footnotetext}
23868 % \end{verbatim}
23869 %
23870 % \DescribeMacro{\@mpfn}
23871 % \DescribeMacro{\thempfn}
23872 % \begin{verbatim}
23873 % \def\@mpfn{footnote}
23874 % \def\thempfn{\thefootnote}
23875 % \end{verbatim}
23876 %
23877 % And from \file{ltboxes.dtx} for the \texttt{minipage} environment.
23878 %
23879 % \DescribeMacro{\@mpfn}
23880 % \DescribeMacro{\thempfn}
23881 % \DescribeMacro{\@footnotetext}
23882 % When setting up
23883 % the environment, it includes:
23884 % \begin{verbatim}
23885 % \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
23886 % \let\@footnotetext\@mpfootnotetext
23887 % \end{verbatim}
23888 %
23889 % \DescribeMacro{\@mpfootnotetext}
23890 % Later it defines \cs{@mpfootnotetext}\marg{text} as the minipage version
23891 % of \cs{@footnotetext}.
23892 % \begin{verbatim}
23893 % \long\def\@mpfootnotetext#1{%
23894 % \global\setbox\@mpfootins\vbox{%
23895 % \unvbox\@mpfootins
23896 % \reset@font\footnotesize
23897 % \hsize\columnwidth
23898 % \@parboxrestore
23899 % \def\@currentcounter{mpfootnote}% forgotten
23900 % \protected@edef\@currentlabel{%
23901 % \csname p@mpfootnote\endcsname\@thefnmark}%
23902 % \color@begingroup
23903 % \@makefntext{%
23904 % \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
23905 % \color@endgroup}}
23906 % \end{verbatim}
23907 %
23908 % That completes the kernel extracts.
23909 %
23910 % \begin{macro}{\footnoterule}
23911 % Usually, footnotes are separated from the main body of the text
23912 % by a small rule. This rule is drawn by the macro \cs{footnoterule}.
23913 % We have to make sure that the rule takes no vertical space (see
23914 % \file{plain.tex}) so we compensate for the natural heigth of the
23915 % rule of 0.4pt by adding the right amount of vertical skip.
23916 %
23917 % To prevent the rule from colliding with the footnote we first add
23918 % a little negative vertical skip, then we put the rule and make
23919 % sure we end up at the same point where we begun this operation.
23920 % \changes{v3.6k}{2013/05/08}{Added \cs{normalcolor}, this seems to
23921 % fix a color leak into paragraph footnotes.}
23922 % \begin{macrocode}
23923 \renewcommand{\footnoterule}{%
23924 \kern-3\p@
23925 \normalcolor% added 2013/05/08
23926 \hrule width .4\columnwidth
23927 \kern 2.6\p@}
23928 % \end{macrocode}
23929 % And just to make sure that we are using memoir's font-dependent
23930 % skips:
23931 % \begin{macrocode}
23932 \skip\footins=\bigskipamount
23933 % \end{macrocode}
23934 % \end{macro}
23935 %
23936 % \begin{macro}{\c@footnote}
23937 % Footnotes are numbered per chapter. The counter is predefined.
23938 % \begin{macrocode}
23939 \@addtoreset{footnote}{chapter}
23940 % \end{macrocode}
23941 % \end{macro}
23942 %
23943 % The footnote mechanism of \LaTeX{} calls the macro \cs{@makefntext}
23944 % to produce the actual footnote. The macro gets the text of the
23945 % footnote as its argument and should use \cs{@thefnmark} as the mark
23946 % of the footnote. The macro \cs{@makefntext} is called when
23947 % effectively inside a \cs{parbox} of width \cs{columnwidth} (i.e.,
23948 % with \cs{hsize} = \cs{columnwidth}).
23949 %
23950 % An example of what can be achieved is given by the following piece
23951 % of \TeX{} code.
23952 % \begin{verbatim}
23953 % \long\def\@makefntext#1{%
23954 % \@setpar{\@@par
23955 % \@tempdima = \hsize
23956 % \advance\@tempdima-10pt
23957 % \parshape \@ne 10pt \@tempdima}%
23958 % \par
23959 % \parindent 1em\noindent
23960 % \hbox to \z@{\hss\@makefnmark}#1}
23961 % \end{verbatim}
23962 % The effect of this definition is that all lines of the footnote
23963 % are indented by 10pt, while the first line of a new paragraph is
23964 % indented by 1em. To change these dimensions, just substitute the
23965 % desired value for `10pt' (in both places) or `1em'. The mark is
23966 % flushright against the footnote.
23967 %
23968 % The standard classes use a simpler macro, in which the
23969 % footnote text is set like an ordinary text paragraph, with no
23970 % indentation except on the first line of a paragraph, and the
23971 % first line of the footnote. Thus, all the macro must do is set
23972 % \cs{parindent} to the appropriate value for succeeding paragraphs
23973 % and put the proper indentation before the mark.
23974 % \begin{verbatim}
23975 % \newcommand{\@makefntext}[1]{%
23976 % \parindent 1em%
23977 % \noindent
23978 % \hb@[email protected]{\hss\@makefnmark}#1}
23979 % \end{verbatim}
23980 %
23981 % This class provides a configurable specification.
23982 %
23983 % Normally, if two or more footnotes are sequentially applied: \\
23984 % \verb?...text\footnote{first}\footnote{second}...? \\
23985 % the markers in the text run together
23986 % (e.g., \ldots text\textsuperscript{12}).
23987 % The class provides a separator between the markers
23988 % (e.g., \ldots text\textsuperscript{1,2}).
23989 % The underlying ideas for this are from the \Lpack{ledmac}
23990 % package~\cite{LEDMAC},
23991 % which in turn got them from the \Lpack{footmisc} package~\cite{FOOTMISC}.
23992 % \changes{v1.4}{2003/11/22}{Added footnote separator (from patch v1.5)}
23993 %
23994 % \begin{macro}{\multfootsep}
23995 % The separator between multiple footnote markers.
23996 % \begin{macrocode}
23997 \newcommand*{\multfootsep}{\textsuperscript{\normalfont,}}
23998 % \end{macrocode}
23999 % \end{macro}
24000 %
24001 % \begin{macro}{\multiplefootnotemarker}
24002 % \begin{macro}{\m@mmf@prepare}
24003 % \cs{m@mmf@prepare} is a pair of self-cancelling kerns.
24004 % \begin{macrocode}
24005 \newcommand*{\multiplefootnotemarker}{3sp}
24006 \newcommand*{\m@mmf@prepare}{%
24007 \kern-\multiplefootnotemarker
24008 \kern\multiplefootnotemarker\relax}
24009 % \end{macrocode}
24010 % \end{macro}
24011 % \end{macro}
24012 %
24013 % \begin{macro}{\m@mmf@check}
24014 % If \cs{m@mmf@check} recognises the last kern as \cs{multiplefootnotemarker}
24015 % it typesets \cs{multfootsep}.
24016 % \begin{macrocode}
24017 \newcommand*{\m@mmf@check}{%
24018 \ifdim\lastkern=\multiplefootnotemarker\relax
24019 \edef\@x@sf{\the\spacefactor}%
24020 \unkern
24021 \multfootsep
24022 \spacefactor\@x@sf\relax
24023 \fi}
24024
24025 % \end{macrocode}
24026 % \end{macro}
24027 %
24028 % \begin{macro}{\@footnotemark}
24029 % We have to modify the kernel's % \cs{@footnotetext} and
24030 % \cs{@footnotemark}
24031 % to implement the separator.
24032 % \changes{v1.618}{2005/09/03}{Stop body font changes leaking into footnotes (mempatch v3.7)}
24033 % \changes{v1.61803}{2008/01/30}{Keep single spacing in footnotes (mempatch v4.6)}
24034 % \changes{v3.6g}{2010/09/19}{Made the 'single spacing' configurable.}
24035 % \changes{v3.6h}{2010/20/22}{\cs{@footnotetext} is redefined later
24036 % on, so the \cs{m@mold@footnotetext} needs to be moved, we also
24037 % remove this version of \cs{@footnotetext} such that people do
24038 % not mistake this for the `real' \cs{@footnotetext}}.
24039 % \begin{macrocode}
24040 \renewcommand*{\@footnotemark}{%
24041 \leavevmode
24042 \ifhmode
24043 \edef\@x@sf{\the\spacefactor}%
24044 \m@mmf@check
24045 \nobreak
24046 \fi
24047 \@makefnmark
24048 \m@mmf@prepare
24049 \ifhmode\spacefactor\@x@sf\fi
24050 \relax}
24051
24052 % \end{macrocode}
24053 % \end{macro}
24054 %
24055 % \begin{macro}{\mem@pn@multiple@marker}
24056 % This controls the multiple marker handling for successive page
24057 % notes, i.e., adding a comma between them.
24058 % \changes{v3.6k}{2013/05/16}{Added hooks, they are not intended for users}
24059 % \begin{macrocode}
24060 \newcommand{\mem@pn@multiple@marker}[1]{%
24061 \leavevmode
24062 \ifhmode
24063 \edef\@x@sf{\the\spacefactor}%
24064 \m@mmf@check
24065 \nobreak
24066 \fi
24067 \@nameuse{mem@pnmm@start@hook}%
24068 #1%
24069 \@nameuse{mem@pnmm@end@hook}%
24070 \m@mmf@prepare
24071 \ifhmode\spacefactor\@x@sf\fi
24072 \relax}
24073
24074 % \end{macrocode}
24075 %
24076 % \end{macro}
24077 % %
24078 % \begin{macro}{\footmarkwidth}
24079 % \begin{macro}{\footmarksep}
24080 % \begin{macro}{\footparindent}
24081 % The mark is typset right justified in a box with width \cs{footmarkwidth}.
24082 % Second and later lines of the text are offset \cs{footmarksep} from the
24083 % end of the box. Paragraphs in footnotes are indented by \cs{parindent}.
24084 % \begin{macrocode}
24085 \newlength{\footmarkwidth}
24086 \newlength{\footmarksep}
24087 \newlength{\footparindent}
24088 % \end{macrocode}
24089 % \end{macro}
24090 % \end{macro}
24091 % \end{macro}
24092 %
24093 % \begin{macro}{\footmarkstyle}
24094 % \begin{macro}{\footscript}
24095 % The marker is typeset according to \cs{footscript}\marg{marker}. This
24096 % can be specified by the user via \cs{footmarkstyle}.
24097 % \begin{macrocode}
24098 \newcommand*{\footmarkstyle}[1]{\def\footscript##1{#1}}
24099 % \end{macrocode}
24100 % \end{macro}
24101 % \end{macro}
24102 %
24103 % \begin{macro}{\makefootmarkhook}
24104 % A vacuous macro that the user can redefine to do something useful?
24105 % \begin{macrocode}
24106 \newcommand{\makefootmarkhook}{}
24107
24108 % \end{macrocode}
24109 % \end{macro}
24110 %
24111 % \begin{macro}{\footfootmark}
24112 % This macro typesets the footnote marker.
24113 % \begin{macrocode}
24114 \newcommand{\footfootmark}{%
24115 \ifdim\footmarkwidth < \z@
24116 % \end{macrocode}
24117 % Negative width, mark is in the margin.
24118 % \begin{macrocode}
24119 \llap{\hb@xt@ -\footmarkwidth{%
24120 \hss\normalfont\footscript{\@thefnmark}}%
24121 \hspace*{-\footmarkwidth}}%
24122 \else
24123 \ifdim\footmarkwidth = \z@
24124 % \end{macrocode}
24125 % Zero width, mark is at (inside) the margin.
24126 % \begin{macrocode}
24127 {\normalfont\footscript{\@thefnmark}}%
24128 \else
24129 % \end{macrocode}
24130 % Positive width.
24131 % \begin{macrocode}
24132 \hb@xt@\footmarkwidth{\hss\normalfont\footscript{\@thefnmark}}%
24133 \fi
24134 \fi}
24135
24136 % \end{macrocode}
24137 % \end{macro}
24138 %
24139 % \begin{macro}{\makefootmark}
24140 % \begin{macro}{\@makefntext}
24141 % The class version of \cs{@makefntext}.
24142 % \begin{macrocode}
24143 \newcommand{\makefootmark}[1]{%
24144 \leavevmode
24145 \parindent \footparindent\noindent
24146 \leftskip\footmarksep\relax
24147 \advance\leftskip \footmarkwidth \null\nobreak\hskip -\leftskip\relax
24148 \makefootmarkhook\relax
24149 \footfootmark #1}
24150 % \end{macrocode}
24151 % In the thread \textit{memoir and footnote.sty trouble}, 2003/04/02,
24152 % Patrik Nyman noted that in order
24153 % to stop \file{footnote.sty} (from \texttt{mdwtools}) barfing my original \\
24154 % \verb?\newcommand{\@makefntext}[1]{\makefootmark{#1}}? \\
24155 % had to be changed.
24156 % \changes{v1.4}{2004/11/22}{Revised \cs{@makefntext}}
24157 % \begin{macrocode}
24158 \newcommand{\@makefntext}[1]{\makefootmark #1}
24159 % \end{macrocode}
24160 % \end{macro}
24161 % \end{macro}
24162 %
24163 % All that now remains for the footer part is to set the defaults.
24164 % \begin{macrocode}
24165 \footmarkstyle{\textsuperscript{#1}}
24166 \setlength{\footmarkwidth}{1.8em}
24167 \setlength{\footmarksep}{-1.8em}
24168 \setlength{\footparindent}{1em}
24169
24170 % \end{macrocode}
24171 %
24172 % \begin{macro}{\@makefnmark}
24173 % The footnote markers that are printed in the text to point to the
24174 % footnotes should be produced by the macro \cs{@makefnmark}. We use
24175 % the default definition for it.
24176 % \begin{macrocode}
24177 %\renewcommand\@makefnmark{\hbox{\@textsuperscript{%
24178 % \normalfont\@thefnmark}}}
24179 % \end{macrocode}
24180 % \end{macro}
24181 %
24182 % \begin{macro}{\footref}
24183 % Sometimes it is desireable to reference a footnote more than
24184 % once.
24185 % If a footnote is labelled (e.g., \verb?\footnote{text\label{fn}}?) then
24186 % the macro \cs{footref}\marg{fn} will print the footnote marker.
24187 % The code is essentially a much simplified version of \cs{footnotemark}
24188 % from \file{ltfloat.dtx}.
24189 % \changes{v1.0}{2001/10/30}{Added \cs{footref}}
24190 % \begin{macrocode}
24191 % \changes{v3.7o}{2021/02/24}{in 2021/05 \cs{footref} will be in the
24192 % kernel, thus we make it provide}
24193 \providecommand{\footref}[1]{%
24194 \begingroup
24195 \unrestored@protected@xdef\@thefnmark{\ref{#1}}%
24196 \endgroup
24197 \@footnotemark}
24198
24199 % \end{macrocode}
24200 % \end{macro}
24201 %
24202 % The following code for footnotes that can include verbatims is based
24203 % on Jeremy Gibbons \textit{`Footnotes with verbatim material'}
24204 % in the column \textit{`Hey --- it works'} (edited by Jeremy Gibbons),
24205 % TeX and TUG NEWS, vol 2 no. 4, p 9, October 1993. I have updated
24206 % the basic code so that it works for LaTeX2e.
24207 %
24208 % \begin{macro}{\verbfootnote}
24209 % \begin{macro}{\@xverbfootnote}
24210 % \cs{verbfootnote} is just like \cs{footnote} except that it can contain
24211 % verbatim material.
24212 % \begin{macrocode}
24213 \def\verbfootnote{\@ifnextchar[\@xverbfootnote{\stepcounter\@mpfn
24214 \protected@xdef\@thefnmark{\thempfn}%
24215 \@footnotemark\@verbfootnotetext}}
24216
24217 \def\@xverbfootnote[#1]{%
24218 \begingroup
24219 \csname c@\@mpfn\endcsname #1\relax
24220 \unrestored@protected@xdef\@thefnmark{\thempfn}%
24221 \endgroup
24222 \@footnotemark\@verbfootnotetext}
24223
24224 % \end{macrocode}
24225 % \end{macro}
24226 % \end{macro}
24227 %
24228 % \begin{macro}{\@verbfootnotetext}
24229 % This is the secret ingredient. It is based on the \cs{footnote} macro
24230 % in \theTeXbook{} page 363, which somehow manages to read an argument
24231 % with verbatims. As Knuth says that it is subtle and involves trickery,
24232 % don't expect me to even try to explain anything.
24233 %
24234 % I'm not at all sure about the color bits, though!
24235 % \changes{v1.618}{2005/09/02}{Fixed colors in \cs{verbfootnote} (mempatch v2.3)}
24236 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
24237 % \changes{v3.8}{2023/07/27}{replaced hardcoded \cs{foornotesize}
24238 % by \cs{foottextfont}}
24239 % \begin{macrocode}
24240 \long\def\@verbfootnotetext{%
24241 \insert\footins\bgroup
24242 \foottextfont%
24243 \interlinepenalty\interfootnotelinepenalty
24244 \splittopskip\footnotesep
24245 \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
24246 \hsize\columnwidth \@parboxrestore
24247 \def\@currentcounter{footnote}%
24248 \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
24249 %%%% \color@begingroup
24250 \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
24251 \futurelet\next\fo@t
24252 }
24253 % \end{macrocode}
24254 % \end{macro}
24255 %
24256 % \begin{macro}{\fo@t}
24257 % \begin{macro}{\f@@t}
24258 % \begin{macro}{\f@t}
24259 % \begin{macro}{\@foot}
24260 % Guess what these do.
24261 % \changes{v1.61803}{2008/01/30}{Added \cs{m@mmf@prepare} to \cs{@foot} to
24262 % implement the multifootnotemark separator (noted by zarko, CTT 2005/01/15)}
24263 % \begin{macrocode}
24264 \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
24265 \else \let\next\f@t\fi \next}
24266 \def\f@@t{\bgroup\aftergroup\@foot\let\next}
24267 \def\f@t#1{%
24268 \color@begingroup
24269 #1\@foot
24270 \color@endgroup}
24271 \def\@foot{%
24272 \strut\egroup
24273 %%%% \color@endgroup
24274 \m@mmf@prepare
24275 }
24276
24277 % \end{macrocode}
24278 % \end{macro}
24279 % \end{macro}
24280 % \end{macro}
24281 % \end{macro}
24282 %
24283 % \begin{macro}{\@verbmpfootnotetext}
24284 % Footnotes in minipages are a little different, so another
24285 % version of \cs{...footnotetext}.
24286 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
24287 % \changes{v3.8}{2023/07/27}{replaced hardcoded \cs{foornotesize}
24288 % by \cs{foottextfont}}
24289 % \begin{macrocode}
24290 \long\def\@verbmpfootnotetext{%
24291 \global\setbox\@mpfootins\vbox{%
24292 \reset@font\foottextfont
24293 \unvbox\@mpfootins
24294 \bgroup
24295 \hsize\columnwidth
24296 \@parboxrestore
24297 \def\@currentcounter{mpfootnote}%
24298 \edef\@currentlabel{\csname p@mpfootnote\endcsname\@thefnmark}%
24299 \color@begingroup
24300 \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
24301 }
24302 \futurelet\next\fo@t
24303 }
24304
24305 % \end{macrocode}
24306 % \end{macro}
24307 %
24308 % \begin{macro}{\@minipagerestore}
24309 % To get the \cs{verbfootnote} to work in a \texttt{minipage} we have to use
24310 % \cs{@verbmpfootnotetext} instead of \cs{@verbfootnotetext}. There is
24311 % a nice hook in the kernel \texttt{minipage} code for this.
24312 %
24313 % As of version 1.61803 the following code is placed earlier. \\
24314 % \verb?\def\@minipagerestore{\let\@verbfootnotetext\@verbmpfootnotetext}?
24315 % \end{macro}
24316 %
24317 %
24318 % \subsection{Major extensions for footnotes}
24319 %
24320 % \begin{macrocode}
24321 %%%%%%%%%%%%%% major extension to footnoting
24322
24323 % \end{macrocode}
24324 %
24325 % This all requires modifications to the output routine's \cs{@makecol},
24326 % which will be done later.
24327 %
24328 % \begin{macro}{\setfootnoterule}
24329 % Per Starb\"{a}ck found (CTT \textit{feetbelowfloat in memoir}, 2006/11/24)
24330 % that \cs{feetbelowfloat} did not affect anything when \cs{raggedbottom}
24331 % is in effect.
24332 %
24333 % \cs{setfootnoterule}\oarg{vfill}\marg{uplift}\marg{width}\marg{thickness}
24334 % defines the \cs{footnoterule}. Memoir's default setting is \\
24335 % \verb?\setfootnoterule{3pt}{0.4\columnwidth}{\normalrulethickness}? \\
24336 % To force footnotes to the bottom after a \cs{raggedbottom} use \\
24337 % \verb?\setfootnoterule[\vfill]{3pt}{0.4\columnwidth}{\normalrulethickness}?
24338 % \changes{v1.61803}{2008/01/30}{Added \cs{setfootnoterule} (memptatch v4.6)}
24339 % \changes{v3.6k}{2013/05/08}{Added \cs{normalcolor}, this seems to
24340 % fix a color leak into paragraph footnotes.}
24341 % \begin{macrocode}
24342 \newcommand*{\setfootnoterule}[4][]{%
24343 \def\footnoterule{\kern -#2\relax #1\relax
24344 \normalcolor% added 2013/05/08
24345 \hrule width #3\relax
24346 \kern #2\kern-#4}}
24347 \setfootnoterule{3pt}{0.4\columnwidth}{\normalrulethickness}
24348
24349 % \end{macrocode}
24350 % \end{macro}
24351 %
24352 % All sorts of extra kinds of footnotes.
24353 %
24354 % \begin{macro}{\m@mdoextrafeet}
24355 % \begin{macro}{\extrafeetins}
24356 % \begin{macro}{\extrafeetinshook}
24357 % These macros are hooks into \cs{@makecol}.
24358 % \changes{v1.618}{2005/09/02}{Fixed memoir/listings spacing problem (from Cartsten Heinz, mempatch v2.3)}
24359 % \changes{v1.618}{2005/09/03}{Set \cs{boxmaxdepth} in \cs{extrafeetins} (mmempatch v3.1)}
24360 % \begin{macrocode}
24361 \newcommand{\m@mdoextrafeet}{\extrafeetins}
24362 \newcommand*{\extrafeetins}{%
24363 \setbox\@outputbox \vbox{%
24364 \boxmaxdepth \@maxdepth
24365 \unvbox\@outputbox
24366 \ifvoid\footinsv@r\else\@footstartv@r\@footgroupv@r\fi
24367 \extrafeetinshook}}
24368 \newcommand{\extrafeetinshook}{}
24369
24370 % \end{macrocode}
24371 % \end{macro}
24372 % \end{macro}
24373 % \end{macro}
24374 %
24375 % \begin{macro}{\m@mdodoreinextrafeet}
24376 % \begin{macro}{\extrafeetreinshook}
24377 % Hooks into \cs{@reinserts} for multiple footnote kinds.
24378 % \begin{macrocode}
24379 \newcommand{\m@mdodoreinextrafeet}{%
24380 \ifvoid\footinsv@r\else\insert\footinsv@r{\unvbox\footinsv@r}\fi
24381 \extrafeetreinshook}
24382 \newcommand{\extrafeetreinshook}{}
24383
24384 % \end{macrocode}
24385 % \end{macro}
24386 % \end{macro}
24387 %
24388 %
24389 %
24390 % \begin{macro}{\foottextfont}
24391 % \begin{macro}{\footinsdim}
24392 % \begin{macro}{\@preamfntext}
24393 % General macros.
24394 % \begin{macrocode}
24395 \newcommand{\foottextfont}{\footnotesize}
24396 \newlength{\footinsdim}
24397 \setlength{\footinsdim}{8in} % standard for \dimen\footins
24398 \newcommand{\@preamfntext}{%
24399 \interlinepenalty\interfootnotelinepenalty
24400 \floatingpenalty \@MM
24401 \splittopskip=\footnotesep
24402 \splitmaxdepth=\dp\strutbox
24403 \@parboxrestore}
24404
24405 % \end{macrocode}
24406 % \end{macro}
24407 % \end{macro}
24408 % \end{macro}
24409 %
24410 %
24411 % We are going to change some of the kernel footnote macros
24412 %
24413 % \begin{macro}{\@mpfootnotetext}
24414 % \begin{macro}{\@plainmpfootnotetext}
24415 % \changes{v1.6180}{2006/06/12}{Stop font changes leaking into footnotes.
24416 % The v1.618 change was too early}
24417 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable'}
24418 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
24419 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
24420 % \begin{macrocode}
24421 \renewcommand{\@mpfootnotetext}[1]{%
24422 \global\setbox\@mpfootins\vbox{%
24423 \unvbox\@mpfootins
24424 \def\baselinestretch{\m@m@footnote@spacing}%
24425 \foottextfont \hsize\columnwidth \@parboxrestore
24426 \def\@currentcounter{mpfootnote}%
24427 \protected@edef\@currentlabel{%
24428 \csname p@mpfootnote\endcsname\@thefnmark}%
24429 \color@begingroup
24430 \reset@font%
24431 \@makefntext{%
24432 \rule\z@\footnotesep\ignorespaces\foottextfont #1%
24433 \@finalstrut\strutbox}%
24434 \color@endgroup}}
24435
24436 % \end{macrocode}
24437 % Save our revised version of \cs{@mpfootnotetext}
24438 % \changes{v3.6h}{2010/10/22}{\cs{m@mold@mpfootnotetext} renamed to \cs{@plainmpfootnotetext}}
24439 % \begin{macrocode}
24440 \let\@plainmpfootnotetext\@mpfootnotetext
24441
24442 % \end{macrocode}
24443 % \end{macro}
24444 % \end{macro}
24445 %
24446 %
24447 % We also to patch the minipage environment. We can use
24448 % \cs{@minipagerestore} for the \texttt{begin} part (done earlier),
24449 % but have to
24450 % modify \cs{endminipage}
24451 %
24452 % \begin{macro}{\m@mdoextrafeetmini}
24453 % \begin{macro}{\extrafeetminihook}
24454 % \begin{macro}{\@minipagerestore}
24455 % \begin{macrocode}
24456 \newcommand{\m@mdoextrafeetmini}{%
24457 \extrafeetminihook}
24458 \newcommand{\extrafeetminihook}{}
24459 %%%%\renewcommand{\@minipagerestore}{\m@mdoextrafeetmini}
24460
24461 % \end{macrocode}
24462 % \end{macro}
24463 % \end{macro}
24464 % \end{macro}
24465 %
24466 % \begin{macro}{\extrafeetendmini}
24467 % \begin{macro}{\extrafeetendminihook}
24468 % \begin{macrocode}
24469 \newcommand{\extrafeetendmini}{%
24470 \ifvoid\@mpfootinsv@r\else
24471 \vskip\skip\@mpfootins
24472 \normalcolor\footnoterule\mp@footgroupv@r
24473 \fi
24474 \extrafeetendminihook}
24475 \newcommand{\extrafeetendminihook}{}
24476
24477 % \end{macrocode}
24478 % \end{macro}
24479 % \end{macro}
24480 %
24481 % \begin{macro}{\m@mdoextrafeetendmini}
24482 % \begin{macro}{\endminipage}
24483 % This is our patched version of \cs{endminipage}.
24484 % \begin{macrocode}
24485 \newcommand{\m@mdoextrafeetendmini}{\extrafeetendmini}
24486 \def\endminipage{%
24487 \par
24488 \unskip
24489 \ifvoid\@mpfootins\else
24490 \vskip\skip\@mpfootins
24491 \normalcolor
24492 \footnoterule
24493 \unvbox\@mpfootins
24494 \fi
24495 \m@mdoextrafeetendmini
24496 \@minipagefalse
24497 \color@endgroup
24498 \egroup
24499 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}}
24500
24501 % \end{macrocode}
24502 % \end{macro}
24503 % \end{macro}
24504 %
24505 % \begin{macro}{\plainfootnotes}
24506 % The declaration for standard footnotes; easy, just use the saved
24507 % versions of \cs{@footnotetext} and \cs{@mpfootnotetext}.
24508 % \changes{v3.6h}{2010/10/22}{\cs{m@mold@footnotetext} renamed
24509 % \cs{@plainfootnotetext} and \cs{m@mold@mpfootnotetext} as \cs{@plainmpfootnotetext}}
24510 % \begin{macrocode}
24511 \newcommand{\plainfootnotes}{%
24512 \let\@footnotetext\@plainfootnotetext
24513 \let\@mpfootnotetext\@plainmpfootnotetext}
24514
24515 % \end{macrocode}
24516 % \end{macro}
24517 %
24518 % Now for lots of somewhat tedious code, interspersed with complex
24519 % `Dirty Tricks' type things.
24520 %
24521 % Robert Schlicht (Private email, 2004/03/12) [RS] has provided
24522 % valuable help in tuning up the code.
24523 %
24524 %
24525 % \begin{macro}{\newfootnoteseries}
24526 % \cs{newfootnoteseries}\marg{series} creates the set of macros required
24527 % for footnote code (see the kernel code presented earlier).
24528 % The created macros have \meta{series} appended to their name.
24529 % \changes{v1.61}{2004/03/14}{Added skip setup to \cs{newfootnoteseries}}
24530 % \changes{v1.61}{2004/03/24}{Use \cs{newcounter} instead of \cs{newcount}
24531 % in \cs{newfootnoteseries}}
24532 % \begin{macrocode}
24533 \newcommand{\newfootnoteseries}[1]{%
24534 \expandafter\newinsert\csname footins#1\endcsname% -> \footins#1
24535 \expandafter\skip\csname footins#1\endcsname \bigskipamount%
24536 %%% - > \skip\footins#1 % [RS]
24537 \newcounter{footnote#1}% -> \c@footnote#1
24538 \@nameuse{c@footnote#1} \z@% -> \c@footnote#1=0
24539 \global\@namelet{p@footnote#1} \@empty% -> \p@footnote#1
24540 \@namedef{thefootnote#1}{\arabic{footnote#1}}% -> \thefootnote#1
24541 \@namedef{foottextfont#1}{\foottextfont}% -> \foottextfont#1
24542 \m@makefootnote{#1}% -> \footnote#1
24543 \m@make@xfootnote{#1}% -> \@xfootnote#1
24544 \m@make@footnotetext{#1}% -> \@footnotetext#1
24545 \m@makefootnotemark{#1}% -> \footnotemark#1
24546 \m@make@xfootnotemark{#1}% -> \@xfootnotemark#1
24547 \m@make@footnotemark{#1}% -> \@footnotemark#1
24548 \m@makefootnotetext{#1}% -> \footnotetext#1
24549 \m@make@xfootnotenext{#1}% -> \@xfootnotenext#1
24550 \m@make@mpfn{#1}% -> \@mpfn#1
24551 \m@makethempfn{#1}% -> \thempfn#1
24552 \m@make@makefnmark{#1}% -> \@makefnmark#1
24553 \m@makefootref{#1}% -> \footref#1
24554 \m@makefootfootmark{#1}% -> \footfootmark#1
24555 \m@makemakefootmark{#1}% -> \makefootmark#1
24556 \m@makefootmarkstyle{#1}% -> \footmarkstyle#1
24557 % \end{macrocode}
24558 % \changes{3.7i}{2019/05/24}{@makefntext\#1 should of course be
24559 % long. Reported on TSE by meide, https://tex.stackexchange.com/q/491303/3929}
24560 % \begin{macrocode}
24561 \@namelongdef{@makefntext#1}##1{\@nameuse{makefootmark#1} ##1}%
24562 \m@make@footstart{#1}% -> \@footstart#1
24563 \m@make@footgroup{#1}% -> \@footgroup#1
24564 \expandafter\newinsert\csname @mpfootins#1\endcsname% -> \@mpfootins#1
24565 \newcounter{mpfootnote#1}% -> \c@mpfootnote#1
24566 \global\@namelet{p@mpfootnote#1}\@empty
24567 \@namedef{thempfootnote#1}{\itshape\alph{mpfootnote#1}}%
24568 \m@make@mpfootnotetext{#1}% -> \@mpfootnotetext#1
24569 % \end{macrocode}
24570 % Reset the counter per chapter, except for articles.
24571 % \changes{v1.6}{2004/03/14}{Added chapter reset for footnote series [RS]}
24572 % \begin{macrocode}
24573 \ifartopt\else% [RS]
24574 \expandafter\@cons\csname cl@chapter\endcsname {{footnote#1}}%
24575 \fi
24576 % \end{macrocode}
24577 % Add the footnote to the (re)insert hooks.
24578 % \begin{macrocode}
24579 \g@addto@macro{\extrafeetinshook}{%
24580 \ifvoid\@nameuse{footins#1}\else
24581 \@nameuse{@footstart#1}\@nameuse{@footgroup#1}\fi}
24582 \g@addto@macro{\extrafeetreinshook}{%
24583 \ifvoid\@nameuse{footins#1}\else
24584 \insert\@nameuse{footins#1}{\unvbox\@nameuse{footins#1}}\fi}
24585 \g@addto@macro{\extrafeetendminihook}{%
24586 \ifvoid\@nameuse{@mpfootins#1}\else
24587 \vskip\skip\@mpfootins
24588 \normalcolor\footnoterule\@nameuse{mp@footgroup#1}\fi}
24589 \g@addto@macro{\extrafeetminihook}{%
24590 \@namedef{@mpfn#1}{mpfootnote#1}
24591 \@namedef{thempfn#1}{\@nameuse{thempfootnote#1}}
24592 \csname c@mpfootnote#1\endcsname\z@
24593 \expandafter\let\expandafter\@t@mp \csname @mpfootnotetext#1\endcsname
24594 \expandafter\let \csname @footnotetext#1\endcsname \@t@mp}
24595 \g@addto@macro{\@mem@extranofeet}{% % [RS]
24596 \ifvoid\@nameuse{footins#1}\else\@mem@nofootfalse\fi}
24597 \plainfootstyle{#1}%
24598 }
24599
24600 % \end{macrocode}
24601 % \end{macro}
24602 %
24603 % \begin{macro}{\m@makefootnote}
24604 % \cs{m@makefootnote}\marg{series} creates \cs{footnote<series>}
24605 % \changes{v1.4}{2004/01/21}{In \cs{m@makefootnote} changed \cs{advance}
24606 % to \cs{stepcounter} to make change global}
24607 % \begin{macrocode}
24608 \newcommand{\m@makefootnote}[1]{
24609 \@namedef{footnote#1}{\@ifnextchar[
24610 {\@nameuse{@xfootnote#1}}{%\advance \@nameuse{c@\@mpfn#1} by \@ne
24611 \stepcounter{\@mpfn#1}%
24612 \@name@p@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
24613 \@nameuse{@footnotemark#1}\@nameuse{@footnotetext#1}}}}
24614
24615 % \end{macrocode}
24616 % \end{macro}
24617 %
24618 % \begin{macro}{\m@make@xfootnote}
24619 % \cs{m@make@xfootnote}\marg{series} creates \cs{@xfootnote<series>}
24620 % \begin{macrocode}
24621 \newcommand{\m@make@xfootnote}[1]{
24622 \@namedef{@xfootnote#1}[##1]{%
24623 \begingroup
24624 \csname c@\@mpfn#1\endcsname ##1\relax
24625 \@name@unresp@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
24626 \endgroup
24627 \@nameuse{@footnotemark#1}\@nameuse{@footnotetext#1}}}
24628
24629 % \end{macrocode}
24630 % \end{macro}
24631 %
24632 % \begin{macro}{\m@make@footnotetext}
24633 % \cs{m@make@footnotetext}\marg{series} creates \cs{@footnotetext<series>}
24634 % \changes{v1.6180339a}{2008/08/07}{Removed a space from
24635 % \cs{m@make@footnotetext} and \cs{m@make@mpfootnotetext}
24636 % (courtesy David Wilson)}
24637 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
24638 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
24639 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
24640 % \begin{macrocode}
24641 \newcommand{\m@make@footnotetext}[1]{%
24642 \@namelongdef{@footnotetext#1}##1{%
24643 \insert\@nameuse{footins#1}{%
24644 \def\baselinestretch{\m@m@footnote@spacing}%
24645 \reset@font\@nameuse{foottextfont#1}%
24646 \@preamfntext
24647 \hsize\columnwidth
24648 \def\@currentcounter{footnote}%
24649 \protected@edef\@currentlabel{%
24650 \csname p@footnote#1\endcsname\@nameuse{@thefnmark#1}}%
24651 \color@begingroup
24652 \@nameuse{@makefntext#1}{%
24653 % \end{macrocode}
24654 % \changes{v3.8.2}{2024/01/03}{Bug: \#\#1 needs to be outside of \cs{@nameuse}, reported in \url{https://tex.stackexchange.com/questions/706033/footnotes-defined-with-newfootnoteseries-dont-work/}}
24655 % \begin{macrocode}
24656 \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1}##1%
24657 \@finalstrut\strutbox}%
24658 \color@endgroup}%
24659 \m@mmf@prepare}%
24660 }
24661
24662 % \end{macrocode}
24663 % \end{macro}
24664 %
24665 % \begin{macro}{\m@make@mpfootnotetext}
24666 % \cs{m@make@mpfootnotetext}\marg{series} creates \cs{@mpfootnotetext<series>}
24667 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
24668 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
24669 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
24670 % \begin{macrocode}
24671 \newcommand{\m@make@mpfootnotetext}[1]{%
24672 \@namelongdef{@mpfootnotetext#1}##1{%
24673 \global\setbox\@nameuse{@mpfootins#1}\vbox{%
24674 \unvbox\@nameuse{@mpfootins#1}%
24675 \def\baselinestretch{\m@m@footnote@spacing}%
24676 \reset@font\@nameuse{foottextfont#1}%
24677 \hsize\columnwidth \@parboxrestore
24678 \def\@currentcounter{mpfootnote}%
24679 \protected@edef\@currentlabel{%
24680 \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
24681 \color@begingroup
24682 \@nameuse{@makefntext#1}{%
24683 \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1}##1%
24684 \@finalstrut\strutbox}%
24685 \color@endgroup}%
24686 \m@mmf@prepare}}
24687
24688 % \end{macrocode}
24689 % \end{macro}
24690 %
24691 % \begin{macro}{\m@makefootnotemark}
24692 % \changes{v1.61}{2004/03/24}{Changed \cs{advance} to \cs{stepcounter}
24693 % in \cs{m@makefootnotemark}}
24694 % \cs{m@makefootnotemark}\marg{series} creates \cs{footnotemark<series>}
24695 % \begin{macrocode}
24696 \newcommand{\m@makefootnotemark}[1]{
24697 \@namedef{footnotemark#1}{%
24698 \@ifnextchar[ {\@nameuse{@xfootnotemark#1}}
24699 {%\advance\@nameuse{c@footnote#1} by \@ne%
24700 \stepcounter{footnote#1}%
24701 \@name@p@xdef{@thefnmark#1}{\@nameuse{thefootnote#1}}%
24702 \@nameuse{@footnotemark#1}}}}
24703
24704 % \end{macrocode}
24705 % \end{macro}
24706 %
24707 % \begin{macro}{\m@make@xfootnotemark}
24708 % \cs{m@make@xfootnotemark}\marg{series} creates \cs{@xfootnotemark<series>}
24709 % \begin{macrocode}
24710 \newcommand{\m@make@xfootnotemark}[1]{%
24711 \@namedef{@xfootnotemark#1}[##1]{%
24712 \begingroup
24713 \@nameuse{c@footnote#1} ##1\relax
24714 \@name@unresp@xdef{@thefnmark#1}{\@nameuse{thefootnote#1}}%
24715 \endgroup
24716 \@nameuse{@footnotemark#1}}}
24717
24718 % \end{macrocode}
24719 % \end{macro}
24720 %
24721 % \begin{macro}{\m@make@footnotemark}
24722 % \cs{m@make@footnotemark}\marg{series} creates \cs{@footnotemark<series>}
24723 % \begin{macrocode}
24724 \newcommand{\m@make@footnotemark}[1]{%
24725 \@namedef{@footnotemark#1}{%
24726 \leavevmode
24727 \ifhmode
24728 \edef\@x@sf{\the\spacefactor}%
24729 \m@mmf@check
24730 \nobreak
24731 \fi
24732 \@nameuse{@makefnmark#1}%
24733 \m@mmf@prepare
24734 \ifhmode\spacefactor\@x@sf\fi
24735 \relax}}
24736
24737 % \end{macrocode}
24738 % \end{macro}
24739 %
24740 % \begin{macro}{\m@makefootmarkstyle}
24741 % \cs{m@makefootmarkstyle}\marg{series} creates \cs{footmarkstyle<series>}
24742 % \begin{macrocode}
24743 \newcommand{\m@makefootmarkstyle}[1]{%
24744 \@namedef{footmarkstyle#1}##1{%
24745 \@namedef{footscript#1}####1{##1}}}
24746
24747 % \end{macrocode}
24748 % \end{macro}
24749 %
24750 % \begin{macro}{\m@makefootnotetext}
24751 % \cs{m@makefootnotetext}\marg{series} creates \cs{footnotetext<series>}
24752 % \begin{macrocode}
24753 \newcommand{\m@makefootnotetext}[1]{%
24754 \@namedef{footnotetext#1}{%
24755 \@ifnextchar[ {\@nameuse{@xfootnotenext#1}}%
24756 {\@name@p@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
24757 \@nameuse{@footnotetext#1}}}}
24758
24759 % \end{macrocode}
24760 % \end{macro}
24761 %
24762 % \begin{macro}{\m@make@xfootnotenext}
24763 % \cs{m@make@xfootnotenext}\marg{series} creates \cs{@xfootnotenext<series>}
24764 % \begin{macrocode}
24765 \newcommand{\m@make@xfootnotenext}[1]{
24766 \@namedef{@xfootnotenext#1}[##1]{%
24767 \begingroup
24768 \csname c@\@mpfn#1\endcsname ##1\relax
24769 \@name@unresp@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
24770 \endgroup
24771 \@nameuse{@footnotetext#1}}}
24772
24773 % \end{macrocode}
24774 % \end{macro}
24775 %
24776 % \begin{macro}{\m@make@mpfn}
24777 % \cs{m@make@mpfn}\marg{series} creates \cs{@mpfn<series>}
24778 % \begin{macrocode}
24779 \newcommand{\m@make@mpfn}[1]{%
24780 \@namedef{@mpfn#1}{\@nameuse{footnote#1}}}
24781
24782 % \end{macrocode}
24783 % \end{macro}
24784 %
24785 % \begin{macro}{\m@makethempfn}
24786 % \cs{m@makethempfn}\marg{series} creates \cs{thempfn<series>}
24787 % \begin{macrocode}
24788 \newcommand{\m@makethempfn}[1]{%
24789 \@namedef{thempfn#1}{\@nameuse{thefootnote#1}}}
24790
24791 % \end{macrocode}
24792 % \end{macro}
24793 %
24794 % \begin{macro}{\m@make@makefnmark}
24795 % \cs{m@make@makefnmark}\marg{series} creates \cs{@makefnmark<series>}
24796 % \begin{macrocode}
24797 \newcommand{\m@make@makefnmark}[1]{%
24798 \@namedef{@makefnmark#1}{%
24799 \hbox{\@textsuperscript{\normalfont\@nameuse{@thefnmark#1}}}}}
24800
24801 % \end{macrocode}
24802 % \end{macro}
24803 %
24804 % \begin{macro}{\m@makefootref}
24805 % \cs{m@makefootref}\marg{series} creates \cs{footref<series>}
24806 % \begin{macrocode}
24807 \newcommand{\m@makefootref}[1]{%
24808 \@namedef{footref#1}##1{%
24809 \begingroup
24810 \@name@unresp@xdef{@thefnmark#1}{\ref{##1}}%
24811 \endgroup
24812 \@nameuse{@footnotemark#1}}}
24813
24814 % \end{macrocode}
24815 % \end{macro}
24816 %
24817 % \begin{macro}{\m@makefootfootmark}
24818 % \cs{m@makefootfootmark}\marg{series} creates \cs{footfootmark<series>}
24819 % \begin{macrocode}
24820 \newcommand{\m@makefootfootmark}[1]{%
24821 \@namedef{footfootmark#1}{%
24822 \ifdim\footmarkwidth < \z@
24823 \llap{\hb@xt@ -\footmarkwidth{%
24824 \hss\normalfont\@nameuse{footscript#1}%
24825 {\@nameuse{@thefnmark#1}}}%
24826 \hspace*{-\footmarkwidth}}%
24827 \else
24828 \ifdim\footmarkwidth = \z@
24829 {\normalfont\@nameuse{footscript#1}{\@nameuse{@thefnmark#1}}}%
24830 \else
24831 \hb@xt@\footmarkwidth{%
24832 \hss\normalfont\@nameuse{footscript#1}%
24833 {\@nameuse{@thefnmark#1}}}%
24834 \fi
24835 \fi}}
24836
24837 % \end{macrocode}
24838 % \end{macro}
24839 %
24840 % \begin{macro}{\m@makemakefootmark}
24841 % \changes{v1.61}{2004/03/23}{Removed extraneous space from \cs{m@makemakefootmark}}
24842 % \cs{m@makemakefootmark}\marg{series} creates \cs{makefootmark<series>}
24843 % \begin{macrocode}
24844 \newcommand{\m@makemakefootmark}[1]{%
24845 \@namedef{makefootmark#1}##1{%
24846 \leavevmode
24847 \parindent \footparindent\noindent
24848 \leftskip\footmarksep\relax
24849 \advance\leftskip \footmarkwidth
24850 \null\nobreak\hskip -\leftskip\relax
24851 \makefootmarkhook\relax
24852 \@nameuse{footfootmark#1}##1}}
24853
24854 % \end{macrocode}
24855 % \end{macro}
24856 %
24857 % \begin{macro}{\m@make@footgroup}
24858 % \cs{m@make@footgroup}\marg{series} creates \cs{@footgroup<series>}
24859 % \begin{macrocode}
24860 \newcommand{\m@make@footgroup}[1]{%
24861 \@namedef{@footgroup#1}{\unvbox\@nameuse{footins#1}}}
24862
24863 % \end{macrocode}
24864 % \end{macro}
24865 %
24866 % \begin{macro}{\m@makemp@footgroup}
24867 % \cs{m@makemp@footgroup}\marg{series} creates \cs{mp@footgroup<series>}
24868 % \begin{macrocode}
24869 \newcommand{\m@makemp@footgroup}[1]{%
24870 \@namedef{mp@footgroup#1}{\unvbox\@nameuse{@mpfootins#1}}}
24871
24872 % \end{macrocode}
24873 % \end{macro}
24874 %
24875 % \begin{macro}{\m@make@footstart}
24876 % \cs{m@make@footstart}\marg{series} creates \cs{@footstart<series>}.
24877 %
24878 % The footnote series should of course use
24879 % the skip associated with that series not just
24880 % \cs{vskip}\cs{bigskipamount}.
24881 % \changes{v3.7d}{2015/04/22}{Changed the \cs{vskip}}
24882 % \changes{v3.7d}{2015/04/22}{Added the feet at bottom part}
24883 % \begin{macrocode}
24884 \newcommand{\m@make@footstart}[1]{%
24885 \@namedef{@footstart#1}{%
24886 %\vskip\bigskipamount
24887 \mem@if@flushbottomF\m@mopfn@bottom
24888 \vskip\skip\csname footins#1\endcsname
24889 \leftskip=\z@
24890 \rightskip=\z@
24891 \footnoterule}}
24892
24893 % \end{macrocode}
24894 % \end{macro}
24895 %
24896 % \begin{macro}{\plainfootstyle}
24897 % \cs{plainfootstyle}\marg{series} specifies a plain (normal) footnote
24898 % style for \meta{series}.
24899 % \begin{macrocode}
24900 \newcommand{\plainfootstyle}[1]{%
24901 \m@make@footnotetext{#1}%
24902 \m@make@footgroup{#1}%
24903 \m@make@footstart{#1}%
24904 \m@make@mpfootnotetext{#1}%
24905 \m@makemp@footgroup{#1}%
24906 \@nameuse{footmarkstyle#1}{\textsuperscript{##1}}
24907 \expandafter\dimen\csname footins#1\endcsname=\footinsdim
24908 \expandafter\count\csname footins#1\endcsname=1000\relax}
24909
24910 % \end{macrocode}
24911 % \end{macro}
24912 %
24913 % Now the basic code for footnote declarations (we will be
24914 % using \texttt{footnotev@r} instead of the regular \texttt{footnote}).
24915 %
24916 % \begin{macro}{\footinsv@r}
24917 % Define the new \cs{footinsv@r} insert.
24918 % \begin{macrocode}
24919 \newinsert\footinsv@r
24920 \skip\footinsv@r\bigskipamount
24921 \count\footinsv@r=1000 % no magnifcation
24922 \dimen\footinsv@r=\footinsdim
24923 % \end{macrocode}
24924 % \end{macro}
24925 % Create a new \verb?v@r? footnote series.
24926 % \begin{macrocode}
24927 \m@make@footstart{v@r}
24928 % \end{macrocode}
24929 %
24930 % \begin{macro}{\@footgroupv@r}
24931 % Initialise the \texttt{footgroup} for the series to do nothing.
24932 % \begin{macrocode}
24933 \newcommand{\@footgroupv@r}{}
24934
24935 % \end{macrocode}
24936 % \end{macro}
24937 %
24938 % And also for minipages:
24939 % \begin{macro}{\@mpfootinsv@r}
24940 % \begin{macro}{\mp@footgroupv@r}
24941 % \begin{macrocode}
24942 \newinsert\@mpfootinsv@r
24943 \newcommand{\mp@footgroupv@r}{}
24944
24945 % \end{macrocode}
24946 % \end{macro}
24947 % \end{macro}
24948 %
24949 %
24950 % \Lpack{ledmac} package style footnotes (see \file{ledmac.dtx} for
24951 % more detailed explanations).
24952 %
24953 % The two- and three-column notes use a macro \cs{m@mrigidbalance}
24954 % to split text into a number of columns. This is based on \theTeXbook,
24955 % page 397.
24956 % \begin{macro}{\m@m@k}
24957 % \begin{macro}{\m@m@h}
24958 % \begin{macrocode}
24959 \newcount\m@m@k \newdimen\m@m@h
24960 % \end{macrocode}
24961 % \end{macro}
24962 % \end{macro}
24963 %
24964 % \begin{macro}{\m@mrigidbalance}
24965 % \begin{macro}{\m@mdosplits}
24966 % \begin{macro}{\m@msplitoff}
24967 % \cs{m@mrigidbalance}\marg{box}\marg{num}\marg{length} splits a
24968 % \meta{box} (of text) into \meta{num} columns with \meta{length}
24969 % space between the top baseline and the top of the \cs{vbox}.
24970 % \begin{macrocode}
24971 \newcommand*{\m@mrigidbalance}[3]{\setbox0=\box#1 \m@m@k=#2 \m@m@h=#3
24972 \@@line{\splittopskip=\m@m@h \vbadness=\@M \hfilneg
24973 \valign{##\vfill\cr\m@mdosplits}}}
24974 \newcommand*{\m@mdosplits}{\ifnum\m@m@k>0 \noalign{\hfil}\m@msplitoff
24975 \global\advance\m@m@k-1\cr\m@mdosplits\fi}
24976 \newcommand*{\m@msplitoff}{\dimen0=\ht0
24977 \divide\dimen0 by\m@m@k \advance\dimen0 by\m@m@h
24978 \setbox2 \vsplit0 to \dimen0
24979 \unvbox2 }
24980
24981 % \end{macrocode}
24982 % \end{macro}
24983 % \end{macro}
24984 % \end{macro}
24985 %
24986 %
24987 % \subsubsection{Two column footnotes}
24988 %
24989 % \begin{macro}{\twocolumnfootnotes}
24990 % Declaration for two column footnotes. This causes the standard
24991 % \cs{footnote} and friends to internally use the \verb?v@r? series,
24992 % which here produces two column footnotes.
24993 % \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{twocolumnfootnotes}}
24994 % \begin{macrocode}
24995 \newcommand{\twocolumnfootnotes}{%
24996 \@namedef{foottextfontv@r}{\foottextfont}% % [RS]
24997 \let\@footnotetext\@twocolfootnotetext
24998 \dimen\footinsv@r=2\footinsdim
24999 \count\footinsv@r=500\relax
25000 \m@make@twocol@footgroup{v@r}%
25001 \let\@footgroupv@r\@twocol@footgroupv@r
25002 \let\@mpfootnotetext\@mptwocolfootnotetext
25003 \m@make@mptwocol@footgroup{v@r}%
25004 \let\mp@footgroupv@r\@mptwocol@footgroupv@r}
25005
25006 % \end{macrocode}
25007 % \end{macro}
25008 %
25009 % \begin{macro}{\@twocolfootnotetext}
25010 % \cs{@twocolfootnotetext}\marg{text} is the two column version of
25011 % \cs{@footnotetext} for the \verb?v@r? series.
25012 % \changes{v1.618}{2005/09/03}{Added missing percent to \cs{@twocolfootnotetext} (mempatch v3.1)}
25013 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25014 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25015 % \begin{macrocode}
25016 \newcommand{\@twocolfootnotetext}[1]{\insert\footinsv@r{%
25017 \def\baselinestretch{\m@m@footnote@spacing}%
25018 \reset@font\foottextfont
25019 \@preamfntext
25020 \def\@currentcounter{footnote}%
25021 \protected@edef\@currentlabel{%
25022 \csname p@footnote\endcsname\@thefnmark}%
25023 \color@begingroup
25024 \@twocolfootfmt{#1}%
25025 \color@endgroup}%
25026 \m@mmf@prepare}
25027
25028 % \end{macrocode}
25029 % \end{macro}
25030 %
25031 % \begin{macro}{\@preamtwofmt}
25032 % Give each column 0.45 of the textwidth.
25033 % \begin{macrocode}
25034 \newcommand{\@preamtwofmt}{%
25035 \hsize .45\hsize
25036 \parindent=\z@
25037 \tolerance=5000\relax
25038 \raggedright
25039 \leavevmode}
25040
25041 % \end{macrocode}
25042 % \end{macro}
25043 %
25044 % \begin{macro}{\@twocolfootfmt}
25045 % \cs{@twocolfootfmt}
25046 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
25047 % \begin{macrocode}
25048 \newcommand{\@twocolfootfmt}[1]{%
25049 \@preamtwofmt
25050 {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
25051
25052 % \end{macrocode}
25053 % \end{macro}
25054 %
25055 % \begin{macro}{\@mptwocolfootnotetext}
25056 % \cs{@mptwocolfootnotetext}\marg{text} is the two column version
25057 % of \cs{@mpfootnotetext} for the \verb?v@r? series for minipages.
25058 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25059 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25060 % \begin{macrocode}
25061 \newcommand{\@mptwocolfootnotetext}[1]{%
25062 \global\setbox\@mpfootinsv@r\vbox{%
25063 \unvbox\@mpfootinsv@r
25064 \def\baselinestretch{\m@m@footnote@spacing}%
25065 \reset@font\foottextfont
25066 \hsize\columnwidth \@parboxrestore
25067 \def\@currentcounter{mpfootnote}%
25068 \protected@edef\@currentlabel{%
25069 \csname p@mpfootnote\endcsname\@thefnmark}%
25070 \color@begingroup
25071 \@twocolfootfmt{#1}%
25072 \color@endgroup}%
25073 \m@mmf@prepare}
25074
25075 % \end{macrocode}
25076 % \end{macro}
25077 %
25078 % \begin{macro}{\twocolumnfootstyle}
25079 % \cs{twocolumnfootstyle}\marg{series} specifies a two column footnote
25080 % style for \meta{series}.
25081 % \begin{macrocode}
25082 \newcommand{\twocolumnfootstyle}[1]{%
25083 \m@make@twocolfootnotetext{#1}%
25084 \m@make@mptwocolfootnotetext{#1}%
25085 \m@make@twocolfootfmt{#1}%
25086 \m@make@twocol@footgroup{#1}%
25087 \m@make@mptwocol@footgroup{#1}%
25088 \m@make@footstart{#1}%
25089 \@namelongdef{@footnotetext#1}##1{%
25090 \@nameuse{@twocolfootnotetext#1}{##1}}%
25091 \@namelongdef{@mpfootnotetext#1}##1{%
25092 \@nameuse{@mptwocolfootnotetext#1}{##1}}%
25093 \@namedef{@footgroup#1}{\@nameuse{@twocol@footgroup#1}}%
25094 \@namedef{mp@footgroup#1}{\@nameuse{@mptwocol@footgroup#1}}%
25095 \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
25096 \expandafter\count\csname footins#1\endcsname=500\relax}
25097
25098 % \end{macrocode}
25099 % \end{macro}
25100 %
25101 % \begin{macro}{\m@make@twocolfootnotetext}
25102 % \cs{m@make@twocolfootnotetext}\marg{series} creates
25103 % \cs{@twocolfootnotetext}\meta{series}
25104 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25105 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25106 % \begin{macrocode}
25107 \newcommand{\m@make@twocolfootnotetext}[1]{%
25108 \@namelongdef{@twocolfootnotetext#1}##1{%
25109 \insert\@nameuse{footins#1}{%
25110 \def\baselinestretch{\m@m@footnote@spacing}%
25111 \reset@font\@nameuse{foottextfont#1}%
25112 \@preamfntext
25113 \def\@currentcounter{footnote}%
25114 \protected@edef\@currentlabel{%
25115 \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
25116 \color@begingroup
25117 \@nameuse{@twocolfootfmt#1}{##1}%
25118 \color@endgroup}%
25119 \m@mmf@prepare}}
25120
25121 % \end{macrocode}
25122 % \end{macro}
25123 %
25124 % \begin{macro}{\m@make@mptwocolfootnotetext}
25125 % \cs{m@make@mptwocolfootnotetext}\marg{series} creates
25126 % \cs{@mptwocolfootnotetext}\meta{series}
25127 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25128 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25129 % \begin{macrocode}
25130 \newcommand{\m@make@mptwocolfootnotetext}[1]{%
25131 \@namelongdef{@mptwocolfootnotetext#1}##1{%
25132 \global\setbox\@nameuse{@mpfootins#1}\vbox{%
25133 \unvbox\@nameuse{@mpfootins#1}
25134 \def\baselinestretch{\m@m@footnote@spacing}%
25135 \reset@font\@nameuse{foottextfont#1}%
25136 \hsize\columnwidth \@parboxrestore
25137 \def\@currentcounter{mpfootnote}%
25138 \protected@edef\@currentlabel{%
25139 \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
25140 \color@begingroup
25141 \@nameuse{@twocolfootfmt#1}{##1}%
25142 \color@endgroup}\m@mmf@prepare}}
25143
25144 % \end{macrocode}
25145 % \end{macro}
25146 %
25147 % \begin{macro}{\m@make@twocolfootfmt}
25148 % \cs{m@make@twocolfootfmt}\marg{series} creates
25149 % \cs{@twocolfootfmt}\meta{series}
25150 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@twocolfootfmt} [RS]}
25151 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
25152 % \begin{macrocode}
25153 \newcommand{\m@make@twocolfootfmt}[1]{%
25154 \@namedef{@twocolfootfmt#1}##1{%
25155 \@preamtwofmt
25156 {\@nameuse{footfootmark#1}\strut
25157 \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
25158
25159 % \end{macrocode}
25160 % \end{macro}
25161 %
25162 % \begin{macro}{\m@make@twocol@footgroup}
25163 % \cs{m@make@twocol@footgroup}\marg{series} creates
25164 % \cs{@twocol@footgroup}\meta{series}
25165 % \begin{macrocode}
25166 \newcommand{\m@make@twocol@footgroup}[1]{%
25167 \@namedef{@twocol@footgroup#1}{{%
25168 \@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
25169 \m@mrigidbalance{\@nameuse{footins#1}}{\tw@}{\splittopskip}}}}
25170
25171 % \end{macrocode}
25172 % \end{macro}
25173 %
25174 % \begin{macro}{\m@make@mptwocol@footgroup}
25175 % \cs{m@make@mptwocol@footgroup}\marg{series} creates
25176 % \cs{@mptwocol@footgroup}\meta{series}
25177 % \begin{macrocode}
25178 \newcommand{\m@make@mptwocol@footgroup}[1]{%
25179 \@namedef{@mptwocol@footgroup#1}{{%
25180 \@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
25181 \m@mrigidbalance{\@nameuse{@mpfootins#1}}{\tw@}{\splittopskip}}}}
25182
25183 % \end{macrocode}
25184 % \end{macro}
25185 %
25186 %
25187 % \subsubsection{Three column footnotes}
25188 %
25189 % \begin{macro}{\threecolumnfootnotes}
25190 % Declaration for three column footnotres.
25191 % \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{threecolumnfootnotes}}
25192 % \begin{macrocode}
25193 \newcommand{\threecolumnfootnotes}{%
25194 \@namedef{foottextfontv@r}{\foottextfont}% % [RS]
25195 \let\@footnotetext\@threecolfootnotetext
25196 \dimen\footinsv@r=3\footinsdim
25197 \count\footinsv@r=333\relax
25198 \m@make@threecol@footgroup{v@r}%
25199 \let\@footgroupv@r\@threecol@footgroupv@r
25200 \let\@mpfootnotetext\@mpthreecolfootnotetext
25201 \m@make@mpthreecol@footgroup{v@r}%
25202 \let\mp@footgroupv@r\@mpthreecol@footgroupv@r}
25203
25204 % \end{macrocode}
25205 % \end{macro}
25206 %
25207 % \begin{macro}{\@threecolfootnotetext}
25208 % \cs{@threecolfootnotetext}\marg{text} is the three column version of
25209 % \cs{@footnotetext}
25210 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25211 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25212 % \begin{macrocode}
25213 \newcommand{\@threecolfootnotetext}[1]{\insert\footinsv@r{%
25214 \def\baselinestretch{\m@m@footnote@spacing}%
25215 \reset@font\foottextfont
25216 \@preamfntext
25217 \def\@currentcounter{footnote}%
25218 \protected@edef\@currentlabel{%
25219 \csname p@footnote\endcsname\@thefnmark}%
25220 \color@begingroup
25221 \@threecolfootfmt{#1}%
25222 \color@endgroup}\m@mmf@prepare}
25223
25224 % \end{macrocode}
25225 % \end{macro}
25226 %
25227 % \begin{macro}{\@preamthreefmt}
25228 % Give each column 0.3 of the text width.
25229 % \begin{macrocode}
25230 \newcommand{\@preamthreefmt}{%
25231 \hsize .3\hsize
25232 \parindent=\z@
25233 \tolerance=5000\relax
25234 \raggedright
25235 \leavevmode}
25236
25237 % \end{macrocode}
25238 % \end{macro}
25239 %
25240 % \begin{macro}{\@threecolfootfmt}
25241 %
25242 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
25243 % \begin{macrocode}
25244 \newcommand{\@threecolfootfmt}[1]{%
25245 \@preamthreefmt
25246 {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
25247
25248 % \end{macrocode}
25249 % \end{macro}
25250 %
25251 % \begin{macro}{\@mpthreecolfootnotetext}
25252 % \cs{@mpthreecolfootnotetext}\marg{text} is the three column version of
25253 % \cs{@mpfootnotetext}
25254 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25255 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25256 % \begin{macrocode}
25257 \newcommand{\@mpthreecolfootnotetext}[1]{%
25258 \global\setbox\@mpfootinsv@r\vbox{%
25259 \unvbox\@mpfootinsv@r
25260 \def\baselinestretch{\m@m@footnote@spacing}%
25261 \reset@font\foottextfont
25262 \hsize\columnwidth \@parboxrestore
25263 \def\@currentcounter{mpfootnote}%
25264 \protected@edef\@currentlabel{%
25265 \csname p@mpfootnote\endcsname\@thefnmark}%
25266 \color@begingroup
25267 \@threecolfootfmt{#1}%
25268 \color@endgroup}\m@mmf@prepare}
25269
25270 % \end{macrocode}
25271 % \end{macro}
25272 %
25273 %
25274 %
25275 % \begin{macro}{\threecolumnfootstyle}
25276 % \cs{threecolumnfootstyle}\marg{series} specifies three column footnote style
25277 % for \meta{series}
25278 % \begin{macrocode}
25279 \newcommand{\threecolumnfootstyle}[1]{%
25280 \m@make@threecolfootnotetext{#1}%
25281 \m@make@mpthreecolfootnotetext{#1}%
25282 \m@make@threecolfootfmt{#1}%
25283 \m@make@threecol@footgroup{#1}%
25284 \m@make@mpthreecol@footgroup{#1}%
25285 \m@make@footstart{#1}%
25286 \@namelongdef{@footnotetext#1}##1{%
25287 \@nameuse{@threecolfootnotetext#1}{##1}}%
25288 \@namelongdef{@mpfootnotetext#1}##1{%
25289 \@nameuse{@mpthreecolfootnotetext#1}{##1}}%
25290 \@namedef{@footgroup#1}{\@nameuse{@threecol@footgroup#1}}%
25291 \@namedef{mp@footgroup#1}{\@nameuse{@mpthreecol@footgroup#1}}%
25292 \expandafter\dimen\csname footins#1\endcsname=3\footinsdim
25293 \expandafter\count\csname footins#1\endcsname=333\relax}
25294
25295 % \end{macrocode}
25296 % \end{macro}
25297 %
25298 % \begin{macro}{\m@make@threecolfootnotetext}
25299 % \cs{m@make@threecolfootnotetext}\marg{series} creates
25300 % \cs{@threecolfootnotetext}\meta{series}
25301 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25302 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25303 % \begin{macrocode}
25304 \newcommand{\m@make@threecolfootnotetext}[1]{%
25305 \@namelongdef{@threecolfootnotetext#1}##1{%
25306 \insert\@nameuse{footins#1}{%
25307 \def\baselinestretch{\m@m@footnote@spacing}%
25308 \reset@font\@nameuse{foottextfont#1}%
25309 \@preamfntext
25310 \def\@currentcounter{footnote}%
25311 \protected@edef\@currentlabel{%
25312 \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
25313 \color@begingroup
25314 \@nameuse{@threecolfootfmt#1}{##1}%
25315 \color@endgroup}\m@mmf@prepare}}
25316
25317 % \end{macrocode}
25318 % \end{macro}
25319 %
25320 % \begin{macro}{\m@make@mpthreecolfootnotetext}
25321 % \cs{m@make@mpthreecolfootnotetext}\marg{series} creates
25322 % \cs{@mpthreecolfootnotetext}\meta{series}
25323 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25324 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25325 % \begin{macrocode}
25326 \newcommand{\m@make@mpthreecolfootnotetext}[1]{%
25327 \@namelongdef{@mpthreecolfootnotetext#1}##1{%
25328 \global\setbox\@nameuse{@mpfootins#1}\vbox{%
25329 \unvbox\@nameuse{@mpfootins#1}
25330 \def\baselinestretch{\m@m@footnote@spacing}%
25331 \reset@font\@nameuse{foottextfont#1}%
25332 \hsize\columnwidth \@parboxrestore
25333 \def\@currentcounter{mpfootnote}%
25334 \protected@edef\@currentlabel{%
25335 \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
25336 \color@begingroup
25337 \@nameuse{@threecolfootfmt#1}{##1}%
25338 \color@endgroup}\m@mmf@prepare}}
25339
25340 % \end{macrocode}
25341 % \end{macro}
25342 %
25343 % \begin{macro}{\m@make@threecolfootfmt}
25344 % \cs{m@make@threecolfootfmt}\marg{series} creates
25345 % \cs{@threecolfootfmt}\meta{series}
25346 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@threecolfootfmt} [RS]}
25347 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
25348 % \begin{macrocode}
25349 \newcommand{\m@make@threecolfootfmt}[1]{%
25350 \@namelongdef{@threecolfootfmt#1}##1{%
25351 \@preamthreefmt
25352 {\@nameuse{footfootmark#1}\strut
25353 \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
25354
25355 % \end{macrocode}
25356 % \end{macro}
25357 %
25358 % \begin{macro}{\m@make@threecol@footgroup}
25359 % \cs{m@make@threecol@footgroup}\marg{series} creates
25360 % \cs{@threecol@footgroup}\meta{series}
25361 % \begin{macrocode}
25362 \newcommand{\m@make@threecol@footgroup}[1]{%
25363 \@namedef{@threecol@footgroup#1}{{%
25364 \@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
25365 \m@mrigidbalance{\@nameuse{footins#1}}{\thr@@}{\splittopskip}}}}
25366
25367 % \end{macrocode}
25368 % \end{macro}
25369 %
25370 % \begin{macro}{\m@make@mpthreecol@footgroup}
25371 % \cs{m@make@mpthreecol@footgroup}\marg{series} creates
25372 % \cs{@mpthreecol@footgroup}\meta{series}
25373 % \begin{macrocode}
25374 \newcommand{\m@make@mpthreecol@footgroup}[1]{%
25375 \@namedef{@mpthreecol@footgroup#1}{{%
25376 \@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
25377 \m@mrigidbalance{\@nameuse{@mpfootins#1}}{\thr@@}{\splittopskip}}}}
25378
25379 % \end{macrocode}
25380 % \end{macro}
25381 %
25382 %
25383 % \subsubsection{Paragraphed footnotes}
25384 %
25385 % Paragraphed footnotes are based on \theTeXbook, page 398ff, in the
25386 % Dirty Tricks appendix. It does a lot of box manipulations.
25387 %
25388 % \begin{macro}{\m@munvxh}
25389 % \cs{m@munvxh}\marg{vbox}: unvbox, extract the last line, and unhbox it.
25390 % \begin{macrocode}
25391 \newcommand{\m@munvxh}[1]{%
25392 \setbox0=\vbox{\unvbox#1%
25393 \global\setbox1=\lastbox}%
25394 \unhbox1
25395 \unskip
25396 \unskip
25397 \unpenalty
25398 \hskip\m@mipn@skip}
25399
25400 % \end{macrocode}
25401 % \end{macro}
25402 %
25403 % \begin{macro}{\m@mungebox}
25404 %
25405 % \begin{macrocode}
25406 \newcommand{\m@mungebox}{%
25407 \setbox0=\hbox{\m@munvxh0}%
25408 \dp0=\z@
25409 \ht0=\footfudgefactor\wd0
25410 \box0
25411 \penalty0}
25412
25413 % \end{macrocode}
25414 % \end{macro}
25415 %
25416 % \begin{macro}{\m@mipn@skip}
25417 % \begin{macro}{\m@minterparanoteglue}
25418 % These are `inter-para-note-skip' and `inter-parafootnote' glue, for
25419 % paragraphed footnotes.
25420 % \begin{macrocode}
25421 \newskip\m@mipn@skip
25422 \newcommand*{\m@minterparanoteglue}[1]{%
25423 {\foottextfont\global\m@mipn@skip=#1\relax}}
25424 \m@minterparanoteglue{1em plus.4em minus.4em}
25425
25426 % \end{macrocode}
25427 % \end{macro}
25428 % \end{macro}
25429 %
25430 % \begin{macro}{\m@mmakehboxofhboxes}
25431 % Make an hbox of hboxes.
25432 % \begin{macrocode}
25433 \newcommand*{\m@mmakehboxofhboxes}{\setbox0=\hbox{}%
25434 \loop
25435 \unpenalty
25436 \setbox2=\lastbox
25437 \ifhbox2
25438 \setbox0=\hbox{\box2\unhbox0}
25439 \repeat}
25440
25441 % \end{macrocode}
25442 % \end{macro}
25443 %
25444 % \begin{macro}{\m@mremovehboxes}
25445 % \begin{macrocode}
25446 \newcommand*{\m@mremovehboxes}{\setbox0=\lastbox
25447 \ifhbox0{\m@mremovehboxes}\unhbox0 \fi}
25448
25449 % \end{macrocode}
25450 % \end{macro}
25451 %
25452 % \begin{macro}{\footfudgefiddle}
25453 % TeX uses \verb?\footfufgefactor? to estimate the space required for
25454 % paragraphed footnotes. If it underestimates then the notes approach,
25455 % or cover, the footer. \verb?\footfudgefiddle? can be changed (upward) from
25456 % its default to improve matters.
25457 % \begin{macrocode}
25458 \newcommand*{\footfudgefiddle}{64}
25459
25460 % \end{macrocode}
25461 % \end{macro}
25462 %
25463 % \begin{macro}{\paragraphfootnotes}
25464 % Declaration for paragraphed footnotes.
25465 % \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{paragraphfootnotes}}
25466 % \begin{macrocode}
25467 \newcommand{\paragraphfootnotes}{%
25468 \@namedef{foottextfontv@r}{\foottextfont}% % [RS]
25469 \let\@footnotetext\@parafootnotetext
25470 \dimen\footinsv@r=\footinsdim
25471 \count\footinsv@r=1000\relax
25472 \m@make@para@footgroup{v@r}%
25473 \let\@footgroupv@r\@para@footgroupv@r
25474 \let\@mpfootnotetext\@mpparafootnotetext
25475 \m@make@mppara@footgroup{v@r}%
25476 \let\mp@footgroupv@r\@mppara@footgroupv@r
25477 {\foottextfont
25478 \dimen0=\baselineskip
25479 % \end{macrocode}
25480 % Multiplying \cs{dimen0} by 1024 can lead to arithmetic overflow if
25481 % \cs{baselineskip} is too large, for example under
25482 % \cs{DoubleSpacing}. Instead we only multiply by 256 and then
25483 % multiply again by 4 after the division by \cs{hsize}.
25484 % \changes{v3.7r}{2022/07/28}{Changed calculation}
25485 % \begin{macrocode}
25486 %\multiply\dimen0 by 1024
25487 \multiply\dimen0 by 256
25488 \divide\dimen0 by \hsize
25489 \multiply\dimen0 by 4
25490 \multiply\dimen0 by \footfudgefiddle
25491 \xdef\footfudgefactor{\expandafter\strip@pt\dimen0 }}}
25492
25493 % \end{macrocode}
25494 % \end{macro}
25495 %
25496 % \begin{macro}{\@parafootnotetext}
25497 % \cs{@parafootnotetext}\marg{text} is a paragraph version of
25498 % \cs{@footnotetext}
25499 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25500 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25501 % \begin{macrocode}
25502 \newcommand{\@parafootnotetext}[1]{\insert\footinsv@r{
25503 \def\baselinestretch{\m@m@footnote@spacing}%
25504 \reset@font\foottextfont
25505 \@preamfntext
25506 \def\@currentcounter{footnote}%
25507 \protected@edef\@currentlabel{%
25508 \csname p@footnote\endcsname\@thefnmark}%
25509 \setbox0=\vbox{\hsize=\maxdimen
25510 \color@begingroup
25511 \noindent \@parafootfmt{#1}%
25512 \color@endgroup}%
25513 \m@mungebox}\m@mmf@prepare}
25514
25515 % \end{macrocode}
25516 % \end{macro}
25517 %
25518 % \begin{macro}{\@parafootfmt}
25519 % \cs{@parafootfmt}\marg{text} is a paragraph version of
25520 % \cs{@footfmt}
25521 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
25522 % \begin{macrocode}
25523 \newcommand{\@parafootfmt}[1]{%
25524 \parindent=\z@
25525 \parfillskip=0pt \@plus 1fil
25526 {\footfootmark\strut \foottextfont #1\penalty-10}}
25527
25528 % \end{macrocode}
25529 % \end{macro}
25530 %
25531 % \begin{macro}{\@mpparafootnotetext}
25532 % \cs{@mpparafootnotetext}\marg{text} is a paragraph version of
25533 % \cs{@mpfootnotetext}
25534 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25535 % \changes{v3.8}{2023/07/26}{adding the missing \cs{@currentcounter}}
25536 % \begin{macrocode}
25537 \newcommand{\@mpparafootnotetext}[1]{%
25538 \global\setbox\@mpfootinsv@r\vbox{%
25539 \unvbox\@mpfootinsv@r
25540 \def\baselinestretch{\m@m@footnote@spacing}%
25541 \reset@font\foottextfont
25542 \hsize\columnwidth \@parboxrestore
25543 \def\@currentcounter{mpfootnote}%
25544 \protected@edef\@currentlabel{%
25545 \csname p@mpfootnote\endcsname\@thefnmark}%
25546 \setbox0=\vbox{\hsize=\maxdimen
25547 \color@begingroup
25548 \noindent \@parafootfmt{#1}%
25549 \color@endgroup}%
25550 \m@mungebox}\m@mmf@prepare}
25551
25552 % \end{macrocode}
25553 % \end{macro}
25554 %
25555 % \begin{macro}{\paragraphfootstyle}
25556 % \cs{paragraphfootstyle}\marg{series} specifies paragraphed footnote style
25557 % for \meta{series}.
25558 % \begin{macrocode}
25559 \newcommand{\paragraphfootstyle}[1]{%
25560 \m@make@parafootnotetext{#1}%
25561 \m@make@mpparafootnotetext{#1}%
25562 \m@make@parafootfmt{#1}%
25563 \m@make@para@footgroup{#1}%
25564 \m@make@mppara@footgroup{#1}%
25565 \m@make@para@footstart{#1}%
25566 \@namelongdef{@footnotetext#1}##1{%
25567 \@nameuse{@parafootnotetext#1}{##1}}%
25568 \@namelongdef{@mpfootnotetext#1}##1{%
25569 \@nameuse{@mpparafootnotetext#1}{##1}}%
25570 \@namedef{@footgroup#1}{\@nameuse{@para@footgroup#1}}%
25571 \@namedef{mp@footgroup#1}{\@nameuse{@mppara@footgroup#1}}%
25572 \@namedef{@footstart#1}{\@nameuse{@para@footstart#1}}%
25573 \expandafter\dimen\csname footins#1\endcsname=\footinsdim
25574 \expandafter\count\csname footins#1\endcsname=1000\relax
25575 {\@nameuse{foottextfont#1}%
25576 \dimen0=\baselineskip
25577 % \end{macrocode}
25578 % Similar issue with arithmetic overflow as mentioned with \cs{paragraphfootnotes}.
25579 % \changes{v3.7r}{2022/07/28}{Changed calculation}
25580 % \begin{macrocode}
25581 %\multiply\dimen0 by 1024
25582 \multiply\dimen0 by 256
25583 \divide\dimen0 by \hsize
25584 \multiply\dimen0 by 4
25585 % \end{macrocode}
25586 % \changes{v3.7r}{2022/07/28}{Changed 64 to \cs{footfudgefiddle}}
25587 % \begin{macrocode}
25588 \multiply\dimen0 by \footfudgefiddle
25589 \xdef\footfudgefactor{\expandafter\strip@pt\dimen0 }}}
25590
25591 % \end{macrocode}
25592 % \end{macro}
25593 %
25594 % \begin{macro}{\m@make@parafootnotetext}
25595 % \cs{m@make@parafootnotetext}\marg{series} creates
25596 % \cs{@parafootnotetext}\meta{series}
25597 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25598 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25599 % \begin{macrocode}
25600 \newcommand{\m@make@parafootnotetext}[1]{%
25601 \@namelongdef{@parafootnotetext#1}##1{%
25602 \insert\@nameuse{footins#1}{
25603 \def\baselinestretch{\m@m@footnote@spacing}%
25604 \reset@font\@nameuse{foottextfont#1}%
25605 \@preamfntext
25606 \def\@currentcounter{footnote}%
25607 \protected@edef\@currentlabel{%
25608 \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
25609 \setbox0=\vbox{\hsize=\maxdimen
25610 \color@begingroup
25611 \noindent \@nameuse{@parafootfmt#1}{##1}%
25612 \color@endgroup}%
25613 \m@mungebox}\m@mmf@prepare}}
25614
25615 % \end{macrocode}
25616 % \end{macro}
25617 %
25618 % \begin{macro}{\m@make@mpparafootnotetext}
25619 % \cs{m@make@mpparafootnotetext}\marg{series} creates
25620 % \cs{@mpparafootnotetext}\meta{series}
25621 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
25622 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
25623 % \begin{macrocode}
25624 \newcommand{\m@make@mpparafootnotetext}[1]{%
25625 \@namelongdef{@mpparafootnotetext#1}##1{%
25626 \global\setbox\@nameuse{@mpfootins#1}\vbox{%
25627 \unvbox\@nameuse{@mpfootins#1}
25628 \def\baselinestretch{\m@m@footnote@spacing}%
25629 \reset@font\@nameuse{foottextfont#1}%
25630 \hsize\columnwidth \@parboxrestore
25631 \def\@currentcounter{mpfootnote}%
25632 \protected@edef\@currentlabel{%
25633 \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
25634 \setbox0=\vbox{\hsize=\maxdimen
25635 \color@begingroup
25636 \noindent \@nameuse{@parafootfmt#1}{##1}%
25637 \color@endgroup}%
25638 \m@mungebox}\m@mmf@prepare}}
25639
25640 % \end{macrocode}
25641 % \end{macro}
25642 %
25643 % \begin{macro}{\m@make@parafootfmt}
25644 % \cs{m@make@parafootfmt}\marg{series} creates
25645 % \cs{@parafootfmt}\meta{series}
25646 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@parafootfmt} [RS]}
25647 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
25648 % \begin{macrocode}
25649 \newcommand{\m@make@parafootfmt}[1]{%
25650 \@namelongdef{@parafootfmt#1}##1{%
25651 \parindent=\z@
25652 \parfillskip=0pt \@plus 1fil
25653 {\@nameuse{footfootmark#1}\strut
25654 \@nameuse{foottextfont#1}##1\penalty-10}}}
25655
25656 % \end{macrocode}
25657 % \end{macro}
25658 %
25659 % \begin{macro}{\m@make@para@footgroup}\marg{series} creates
25660 % \cs{@para@footgroup}\meta{series}
25661 % \begin{macrocode}
25662 \newcommand{\m@make@para@footgroup}[1]{%
25663 \@namedef{@para@footgroup#1}{%
25664 \unvbox\@nameuse{footins#1}
25665 \m@mmakehboxofhboxes
25666 \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
25667 \@nameuse{foottextfont#1}%
25668 \noindent\unhbox0\par}}
25669
25670 % \end{macrocode}
25671 % \end{macro}
25672 %
25673 % \begin{macro}{\m@make@mppara@footgroup}
25674 % \cs{m@make@mppara@footgroup}\marg{series} creates
25675 % \cs{@mppara@footgroup}\meta{series}
25676 % \begin{macrocode}
25677 \newcommand{\m@make@mppara@footgroup}[1]{%
25678 \@namedef{@mppara@footgroup#1}{%
25679 \unvbox\@nameuse{@mpfootins#1}
25680 \m@mmakehboxofhboxes
25681 \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
25682 \@nameuse{foottextfont#1}%
25683 \noindent\unhbox0\par}}
25684
25685 % \end{macrocode}
25686 % \end{macro}
25687 %
25688 % \begin{macro}{\m@make@para@footstart}
25689 % \cs{m@make@para@footstart}\marg{series} creates
25690 % \cs{@para@footstart}\meta{series}
25691 % \begin{macrocode}
25692 \newcommand{\m@make@para@footstart}[1]{%
25693 \@namedef{@para@footstart#1}{%
25694 \vskip\bigskipamount
25695 \leftskip=\z@
25696 \rightskip=\z@
25697 \parindent=\z@
25698 \vskip\skip\@nameuse{footins#1}%
25699 \footnoterule}}
25700
25701 % \end{macrocode}
25702 % \end{macro}
25703 %
25704 % \subsection{Nasty insert bits}
25705 % \changes{v1.61803}{2008/01/30}{Put \cs{@makecol} and associated code
25706 % into new section `Nasty insert bits' (mempatch various)}
25707 %
25708 % \cs{sidebar} is implemented as a new kind of \cs{insert} and the
25709 % extended footnotes are also implemented via new kinds of \cs{insert}s.
25710 % New \cs{insert}s mean that the kernel's \cs{@makecol} must be revised
25711 % to cater for them. As this is part of the output process it is nasty to
25712 % do.
25713 %
25714 % Before v1.61803 \cs{@makecol} got (re)defined at several points in the
25715 % code. Here is what I hope is the final version od \cs{@makecol} and
25716 % associated code after having resolved and combined all the changes.
25717 %
25718 %
25719 % \begin{macro}{\if@mem@nofoot}
25720 % \begin{macro}{\@mem@testifnofoot}
25721 % \begin{macro}{\@mem@extranofoot}
25722 % These are from [RS] as \cs{@doclearpage} should check for more than
25723 % just \cs{footins} being void. Note that this covers all current
25724 % class defined inserts, including sidebars.
25725 % \changes{v1.61}{2004/03/14}{Added \cs{if@mem@nofoot},
25726 % \cs{@mem@testifnofoot}, and
25727 % \cs{@mem@extranofoot}}
25728 % \begin{macrocode}
25729 \newif\if@mem@nofoot
25730 \newcommand*{\@mem@testifnofoot}{%
25731 \@mem@nofoottrue
25732 \ifvoid\footins\else\@mem@nofootfalse\fi
25733 \ifvoid\footinsv@r\else\@mem@nofootfalse\fi
25734 \ifvoid\sideins\else\@mem@nofootfalse\fi
25735 \@mem@extranofeet}
25736 \newcommand*{\@mem@extranofeet}{}
25737
25738 % \end{macrocode}
25739 % \end{macro}
25740 % \end{macro}
25741 % \end{macro}
25742 %
25743 % \begin{macro}{\memold@doclearpage}
25744 % \begin{macro}{\mem@doclearpage}
25745 % \begin{macro}{\@doclearpage}
25746 % I thought that I could get away with using the kernel's
25747 % \cs{@doclearpage} but [RS] discovered that I couldn't.
25748 % \changes{v1.62}{2004/03/14}{Redid \cs{@doclearpage} using [RS] code}
25749 % \changes{v3.7d}{2015/04/23}{Opdated \cs{mem@doclearpage} to match
25750 % \Lpack{fixltx2e} v1.1s (which will be the base of the ltx kernel for
25751 % TL15)}
25752 % \begin{macrocode}
25753 \let\memold@doclearpage\@doclearpage
25754 \newcommand{\mem@doclearpage}{%
25755 \@mem@testifnofoot
25756 \if@mem@nofoot
25757 \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
25758 \setbox\@tempboxa\box\@cclv
25759 \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
25760 \global \let \@toplist \@empty
25761 \global \let \@botlist \@empty
25762 \global \@colroom \@colht
25763 \ifx \@currlist\@empty
25764 \else
25765 \@latexerr{Float(s) lost}\@ehb
25766 \global \let \@currlist \@empty
25767 \fi
25768 \@makefcolumn\@deferlist
25769 \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
25770 \if@twocolumn
25771 \if@firstcolumn
25772 \xdef\@deferlist{\@dbltoplist\@deferlist}%
25773 \global \let \@dbltoplist \@empty
25774 \global \@colht \textheight
25775 \begingroup
25776 \@dblfloatplacement
25777 \@makefcolumn\@deferlist
25778 \@whilesw\if@fcolmade \fi{\@outputpage
25779 \@makefcolumn\@deferlist}%
25780 \endgroup
25781 \else
25782 \vbox{}\clearpage
25783 \fi
25784 \fi
25785 \ifx\@deferlist\@empty \else\clearpage \fi
25786 \else
25787 \setbox\@cclv\vbox{\box\@cclv\vfil}%
25788 \@makecol\@opcol
25789 \clearpage
25790 \fi
25791 % older version
25792 % \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
25793 % \setbox\@tempboxa\box\@cclv
25794 % \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
25795 % \global\let\@toplist\@empty
25796 % \global\let\@botlist\@empty
25797 % \global\@colroom\@colht
25798 % \ifx \@currlist\@empty
25799 % \else
25800 % \@latexerr{Float(s) lost}\@ehb
25801 % \global\let\@currlist\@empty
25802 % \fi
25803 % \@makefcolumn\@deferlist
25804 % \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
25805 % \if@twocolumn
25806 % \if@firstcolumn
25807 % \xdef\@dbldeferlist{\@dbltoplist\@dbldeferlist}%
25808 % \global\let\@dbltoplist\@empty
25809 % \global\@colht\textheight
25810 % \begingroup
25811 % \@dblfloatplacement
25812 % \@makefcolumn\@dbldeferlist
25813 % \@whilesw\if@fcolmade \fi{\@outputpage
25814 % \@makefcolumn\@dbldeferlist}%
25815 % \endgroup
25816 % \else
25817 % \vbox{}\clearpage
25818 % \fi
25819 % \fi
25820 % \else
25821 % \setbox\@cclv\vbox{\box\@cclv\vfil}%
25822 % \@makecol\@opcol
25823 % \clearpage
25824 % \fi
25825 }
25826 % \end{macrocode}
25827 % Replace the kernel's \cs{@doclearpage}.
25828 % \begin{macrocode}
25829 \gdef\@doclearpage{\mem@doclearpage}
25830
25831 % \end{macrocode}
25832 % \end{macro}
25833 % \end{macro}
25834 % \end{macro}
25835 %
25836 %
25837 % \begin{macro}{\m@m@makecolfloats}
25838 % \begin{macro}{\m@m@makecoltext}
25839 % These two macros contain code common to versions of \cs{@makecol}
25840 % \changes{v3.7q}{2022/02/20}{Added the \cs{@elt} line from the kernel}
25841 % \begin{macrocode}
25842 \newcommand*{\m@m@makecolfloats}{%
25843 \let\@elt\relax%
25844 \xdef\@freelist{\@freelist\@midlist}%
25845 \global\let\@midlist\@empty
25846 \@combinefloats}
25847 % \end{macrocode}
25848 % \changes{v3.8c}{2025/07/14}{Fixed typo in first branch. BTW: is this even different from the kernel version?}
25849 % \begin{macrocode}
25850 \newcommand*{\m@m@makecoltext}{%
25851 \ifvbox\@kludgeins
25852 \@make@specialcolbox
25853 \else
25854 \setbox\@outputbox \vbox to\@colht{%
25855 \@texttop
25856 \dimen@ \dp\@outputbox
25857 \unvbox \@outputbox
25858 \vskip -\dimen@
25859 \@textbottom}%
25860 \fi}
25861
25862 % \end{macrocode}
25863 % \end{macro}
25864 % \end{macro}
25865 %
25866 % \begin{macro}{\m@m@makecolintro}
25867 % A hook into the revised \cs{@makecol}
25868 % \begin{macrocode}
25869 \newcommand*{\m@m@makecolintro}{}
25870
25871 % \end{macrocode}
25872 % \end{macro}
25873 %
25874 % \begin{macro}{\m@mopfootnote}
25875 % (footnote) code for possible use in \cs{@makecol}.
25876 % \changes{v3.7d}{2015/04/21}{Added feature to force footnotes to the
25877 % bottom of the page in a ragged context}
25878 % \begin{macrocode}
25879 \newcommand*{\m@mopfootnote}{\setbox\@outputbox \vbox{%
25880 \boxmaxdepth\@maxdepth
25881 \@tempdima\dp\@cclv
25882 \unvbox\@cclv
25883 \vskip-\@tempdima
25884 % \end{macrocode}
25885 % We then add a macro call that is only activated if we are not using
25886 % \cs{flushbottom}. If \cs{feetatbottom} is active, then a
25887 % \cs{vfill} is added. Solution inspired by \Lpack{footmisc}.
25888 % \begin{macrocode}
25889 \mem@if@flushbottomF\m@mopfn@bottom
25890 \vskip \skip\footins
25891 \color@begingroup
25892 \normalcolor
25893 \footnoterule
25894 \unvbox \footins
25895 \color@endgroup}}
25896
25897 % \end{macrocode}
25898 % \end{macro}
25899 %
25900 % \begin{macro}{\m@mopfootnotebf}
25901 % (footnote) code in support of footnotes below floats. Problem
25902 % with original code noted by J{\o}rgen Larsen on
25903 % 2008/05/24. Updated 2015.
25904 % \changes{v1.618033}{2008/06/02}{Added \cs{m@mopfootnotebf}}
25905 % \changes{v3.7d}{2015/04/21}{Added feature to force footnotes to the
25906 % bottom of the page in a ragged context}
25907 % \begin{macrocode}
25908 \newcommand*{\m@mopfootnotebf}{%
25909 \setbox\@outputbox \vbox{%
25910 \boxmaxdepth\@maxdepth
25911 \unvbox\@outputbox
25912 % \end{macrocode}
25913 % We then add a macro call as above.
25914 % \begin{macrocode}
25915 \mem@if@flushbottomF\m@mopfn@bottom
25916 \vskip\skip\footins
25917 \color@begingroup
25918 \normalcolor
25919 \footnoterule
25920 \unvbox \footins
25921 \color@endgroup}}
25922
25923 % \end{macrocode}
25924 % \end{macro}
25925 %
25926 % \begin{macro}{\m@mopsidebar}
25927 % (sidebar) code for possible use in \cs{@makecol}.
25928 % From DA's latest sidebar fixes.
25929 % \begin{macrocode}
25930 \newcommand*{\m@mopsidebar}{%
25931 \ifvoid\sideins\else
25932 \setbox\@outputbox \vbox{%
25933 \sidecontents
25934 \unvbox\@outputbox}
25935 \fi}
25936
25937 % \end{macrocode}
25938 % \end{macro}
25939 %
25940 % \begin{macro}{\mem@makecol}
25941 % DA's latest version of \cs{@makecol} (giving the standard
25942 % footnote order (bottom floats after footnotes)) putting the sidebar
25943 % insert after the others (from mempatch v4.9). The code is renewed on
25944 % page~\pageref{makecol} onwards.
25945 % \begin{macrocode}
25946 % \gdef\mem@makecol{%
25947 % \m@m@makecolintro
25948 % \ifvoid\footins
25949 % \setbox\@outputbox \box\@cclv
25950 % \else
25951 % \m@mopfootnote
25952 % \fi
25953 % \m@mdoextrafeet
25954 % \m@m@makecolfloats
25955 % \m@mopsidebar
25956 % \m@m@makecoltext
25957 % \global \maxdepth \@maxdepth}
25958
25959 % \end{macrocode}
25960 % \end{macro}
25961 %
25962 % \begin{macro}{\mem@makecolbf}
25963 % A version of \cs{@makecol} which puts footnotes at the bottom of the page
25964 % (after any bottom floats). The code is renewed on
25965 % page~\pageref{makecol} onwards.
25966 % \changes{v1.618033}{2008/06/02}{Used \cs{m@mopfootnotebf} instead of
25967 % \cs{m@mopfootnote} in \cs{mem@makecolbf}}
25968 % \begin{macrocode}
25969 % \gdef\mem@makecolbf{%
25970 % \m@m@makecolintro
25971 % \setbox\@outputbox \box\@cclv
25972 % \m@m@makecolfloats
25973 % \ifvoid\footins\else
25974 % \m@mopfootnotebf
25975 % \fi
25976 % \m@mdoextrafeet
25977 % \m@mopsidebar
25978 % \m@m@makecoltext
25979 % \global\maxdepth \@maxdepth}
25980
25981 % \end{macrocode}
25982 % \end{macro}
25983 %
25984 % \begin{macro}{\mem@makecoldblf}
25985 % A version of \cs{@makecol} which is a placeholder to fix the doublefloat
25986 % problem.
25987 % TODO: remove this code it is not used
25988 % \begin{macrocode}
25989 \gdef\mem@makecoldblf{%
25990 \m@m@makecolintro
25991 \setbox\@outputbox \box\@cclv
25992 \m@m@makecolfloats
25993 \m@mopsidebar% <- added
25994 \ifvoid\footins
25995 \else
25996 \m@mopfootnote
25997 \fi
25998 \m@mdoextrafeet
25999 \m@m@makecoltext
26000 \global \maxdepth \@maxdepth}
26001
26002 % \end{macrocode}
26003 % \end{macro}
26004 %
26005 % \begin{macro}{\feetabovefloat}
26006 % \begin{macro}{\feetbelowfloat}
26007 % \begin{macro}{\@makecol}
26008 % declarations to put footnotes above bottom floats (standard \LaTeX)
26009 % or at the bottom of the page
26010 % \begin{macrocode}
26011 \newcommand{\feetabovefloat}{\gdef\@makecol{\mem@makecol}}
26012 \newcommand{\feetbelowfloat}{\gdef\@makecol{\mem@makecolbf}}
26013 \feetabovefloat
26014
26015 % \end{macrocode}
26016 % \end{macro}
26017 % \end{macro}
26018 % \end{macro}
26019 %
26020 % \begin{macro}{\feetatbottom}
26021 % \begin{macro}{\feetbelowragged}
26022 % \begin{macro}{\m@mopfn@bottom}
26023 % \begin{macro}{\mem@if@flushbottomF}
26024 % If a page is typeset with a ragged bottom then any footnotes are
26025 % added directly under the text. It may look better if the footnotes
26026 % are added to the text block from the bottom up.
26027 % \begin{macrocode}
26028 \newcommand\feetatbottom{\def\m@mopfn@bottom{\vfill\relax}}
26029 \newcommand\feetbelowragged{\let\m@mopfn@bottom\relax}
26030 \feetbelowragged
26031 % \end{macrocode}
26032 % Next we add a test to see if \cs{flushbottom} is active. This macro
26033 % is used within \cs{m@mopfootnote} and \cs{m@mopfootnotebf} to
26034 % force the footnotes to the bottom \emph{only} when \cs{flushbottom}
26035 % is \emph{not} active, hince the \texttt{F} in the name.
26036 % \begin{macrocode}
26037 \newcommand\mem@if@flushbottomF[1]{%
26038 \if\mem@flshbot\else#1\fi%
26039 }
26040
26041 % \end{macrocode}
26042 % \end{macro}
26043 % \end{macro}
26044 % \end{macro}
26045 % \end{macro}
26046 %
26047 % \begin{macro}{\@reinserts}
26048 % DA's final version from last patch.
26049 % \changes{v3.6d}{2010/06/30}{THere is a newer version further down
26050 % the code}
26051 % \begin{macrocode}
26052 % \gdef\@reinserts{%
26053 % \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
26054 % \m@mdodoreinextrafeet
26055 % \ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi
26056 % \ifvoid\sideins\else\insert\sideins{\unvbox\sideins}\fi}
26057
26058 % \end{macrocode}
26059 % \end{macro}
26060 %
26061 % \changes{v1.61803398d}{2010/01/25}{Added section about side footnotes}
26062 % \subsection{Side footnotes} \label{sec:sidefootnotes}
26063 %
26064 %
26065 % \subsubsection{Extension to the regular footnote}
26066 %
26067 % The code here enables the regular \cs{footnote} to be set in the
26068 % margin. It is based on Robin Fairbairns' \Lpack{footmisc} package.
26069 %
26070 % \begin{macro}{\ifm@mfnmargin}
26071 % \begin{macro}{\footnotesatfoot}
26072 % \begin{macro}{\footnotesinmargin}
26073 % Declarations for regular footnotes to be set as normal at the foot
26074 % of the page, or in the margin.
26075 % \begin{macrocode}
26076 \newif\ifm@mfnmargin
26077 \newcommand*{\footnotesatfoot}{\m@mfnmarginfalse}
26078 \newcommand*{\footnotesinmargin}{\m@mfnmargintrue}
26079 \footnotesatfoot
26080
26081 % \end{macrocode}
26082 % \end{macro}
26083 % \end{macro}
26084 % \end{macro}
26085 % \changes{v1.61803398d}{2010/01/25}{Remember that we actually have
26086 % several \cs{@footnotetext} in memoir, might be an idea to clean this
26087 % up at some point/daleif}
26088 % \begin{macro}{\@footnotetext}
26089 % \begin{macro}{\m@mold@footnotetext}
26090 % Change \cs{@footnotetext} to enable footnotes to be put into the margin
26091 % by using \cs{marginpar}.
26092 % \begin{macrocode}
26093 \renewcommand{\@footnotetext}[1]{%
26094 \ifm@mfnmargin% use marginpar
26095 % \end{macrocode}
26096 % Use \cs{marginpar} for placing the footnote.
26097 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
26098 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
26099 % \begin{macrocode}
26100 \marginpar{%
26101 \def\baselinestretch{\m@m@footnote@spacing}%
26102 \reset@font
26103 \foottextfont
26104 \def\@currentcounter{footnote}%
26105 \protected@edef\@currentlabel{%
26106 \csname p@footnote\endcsname\@thefnmark}%
26107 \color@begingroup
26108 \@makefntext{\ignorespaces#1}%
26109 \color@endgroup}%
26110 \else% regular feet
26111 % \end{macrocode}
26112 % This is the original code for \cs{@footnotetext}.
26113 % \changes{v1.618033988c}{2010/02/20}{sporadic spaces removed, error
26114 % reported on texlive mailinglist}
26115 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
26116 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
26117 % \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
26118 % \begin{macrocode}
26119 \insert\footins{%
26120 \def\baselinestretch{\m@m@footnote@spacing}%
26121 \reset@font
26122 \foottextfont
26123 \@preamfntext
26124 \hsize\columnwidth
26125 \def\@currentcounter{footnote}%
26126 \protected@edef\@currentlabel{%
26127 \csname p@footnote\endcsname\@thefnmark}%
26128 \color@begingroup
26129 \@makefntext{%
26130 \rule\z@\footnotesep\ignorespaces\foottextfont #1%
26131 \@finalstrut\strutbox}%
26132 \color@endgroup}%
26133 \fi%
26134 \m@mmf@prepare}
26135 % \end{macrocode}
26136 % Need to save this version of \cs{@footnotetext}, it is
26137 % used within \cs{plainfootnotes}.
26138 % \changes{v3.6h}{2010/10/22}{Moved \cs{m@mold@footnotetext} to this
26139 % location, and renamed it to \cs{@plainfootnotetext}}
26140 % \begin{macrocode}
26141 \let\@plainfootnotetext\@footnotetext
26142
26143 % \end{macrocode}
26144 % \end{macro}
26145 % \end{macro}
26146 %
26147 % \subsection{Bottom aligned side footnotes}
26148 %
26149 % The code for the bottom aligned marginal footnotes is based partly on
26150 % the \cs{sidebar} code and code from David Salomon, 'Output Routines:
26151 % Examples and Techniques. Part III: Insertions', \textit{TUGboat},
26152 % 11, 4, pp 588--605, Nov 1990.
26153 %
26154 % \begin{macro}{\sidefootmargin}
26155 % \begin{macro}{\m@msidefoot@margin}
26156 % \cs{sidefootmargin} is the user command for setting the side for
26157 % side footnotes (stored as \cs{m@msidefoot@margin}). The default
26158 % is \texttt{outer}.
26159 % \begin{macrocode}
26160 \newcommand*{\sidefootmargin}[1]{%
26161 \m@msetm@argin{#1}%
26162 \ifnum\m@mm@argin<\z@
26163 \@memwarn{Bad \string\sidefootmargin\space argument `#1'\MessageBreak
26164 set to `outer'}%
26165 \gdef\m@msidefoot@margin{2}% set as outer
26166 \else
26167 \global\let\m@msidefoot@margin\m@mm@argin
26168 \fi}
26169 \sidefootmargin{outer}
26170
26171 % \end{macrocode}
26172 % \end{macro}
26173 % \end{macro}
26174 %
26175 %
26176 % \begin{macro}{\sidefootins}
26177 % As for any non-main text matter we need an insert.
26178 % \begin{macrocode}
26179 \newinsert\sidefootins
26180 \skip\sidefootins=0pt
26181 \count\sidefootins=0\relax
26182
26183 % \end{macrocode}
26184 % \end{macro}
26185 %
26186 % \begin{macro}{\sidefootadjust}
26187 % \begin{macro}{\sidefootheight}
26188 % \begin{macro}{\setsidefootheight}
26189 % The length \cs{sidefootadjust} can be used for fine control over the
26190 % vertivcal position of the base of the column of side footnotes.
26191 % The length \cs{sidefootheight}
26192 % is the height of the column and is best set by the \cs{setsidefootheight}
26193 % macro, which takes the desired height as its argument and sets the height
26194 % of the \cs{sidefootins} \cs{insert}. The height is
26195 % initially set to the \cs{textheight}.
26196 % \begin{macrocode}
26197 \newlength{\sidefootadjust}
26198 \setlength{\sidefootadjust}{0pt}
26199 \newlength{\sidefootheight}
26200 \newcommand*{\setsidefootheight}[1]{%
26201 \setlength{\dimen\sidefootins}{#1}%
26202 \advance\dimen\sidefootins -\topskip
26203 \advance\dimen\sidefootins \ht\strutbox
26204 \setlength{\sidefootheight}{\dimen\sidefootins}}
26205 \setsidefootheight{\textheight}
26206
26207 % \end{macrocode}
26208 % \end{macro}
26209 % \end{macro}
26210 % \end{macro}
26211 %
26212 % \begin{macro}{\sidefoothsep}
26213 % \begin{macro}{\sidefootwidth}
26214 % \begin{macro}{\sidefootvsep}
26215 % The horizontal space between the text block and side footnotes
26216 % (\cs{sidefoothsep}),
26217 % the width of the column of notes (\cs{sidefootwidth}),
26218 % and the vertical space between consecutive side footnotes
26219 % (\cs{sidefootvsep}).
26220 % \changes{v1.61803398d}{2010/02/05}{removed \cs{sidefootfont}}
26221 % \begin{macrocode}
26222 \newlength{\sidefoothsep}
26223 \newlength{\sidefootvsep}
26224 \newlength{\sidefootwidth}
26225
26226 % \end{macrocode}
26227 % \end{macro}
26228 % \end{macro}
26229 % \end{macro}
26230 %
26231 % \begin{macro}{\setsidefeet}
26232 % The macro \cs{setsidefeet}\marg{hsep}\marg{width}\marg{vsep}\marg{adj}\marg{font}\marg{height}
26233 % sets the specifications for the side footnotes. An `*' means `use
26234 % the current
26235 % value'.
26236 % \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont} to
26237 % \cs{sidefoottextfont}}
26238 %
26239 % \begin{macrocode}
26240 \newcommand*{\setsidefeet}[6]{%
26241 \nametest{#1}{*}\ifsamename\else
26242 \setlength{\sidefoothsep}{#1}\@memznegtest{\sidefoothsep}%
26243 \fi
26244 \nametest{#2}{*}\ifsamename\else
26245 \setlength{\sidefootwidth}{#2}\@memznegtest{\sidefootwidth}%
26246 \fi
26247 \nametest{#3}{*}\ifsamename\else
26248 \setlength{\sidefootvsep}{#3}\@memznegtest{\sidefootvsep}%
26249 \fi
26250 \nametest{#4}{*}\ifsamename\else
26251 \setlength{\sidefootadjust}{#4}%
26252 \fi
26253 \nametest{#5}{*}\ifsamename\else
26254 \def\sidefoottextfont{#5}%
26255 \fi
26256 \nametest{#6}{*}\ifsamename\else
26257 \setsidefootheight{#6}%
26258 \ifdim\dimen\sidefootins>\z@\else
26259 \@memerror{\protect\sidefootheight\space is zero or negative}{\@ehd}%
26260 \fi
26261 \fi}
26262 \setsidefeet{\marginparsep}{\marginparwidth}%
26263 {\onelineskip}{0pt}%
26264 {\normalfont\footnotesize}{\textheight}%
26265
26266 % \end{macrocode}
26267 % \end{macro}
26268 %
26269 %
26270 % \begin{macro}{\sidefootform}
26271 % Set the sidefootnotes raggedy right
26272 % \begin{macrocode}
26273 \newcommand*{\sidefootform}{\rightskip=\z@ \@plus 2em}
26274
26275 % \end{macrocode}
26276 % \end{macro}
26277 %
26278 %
26279 % \begin{macro}{\m@sideft@left}
26280 % \begin{macro}{\m@sideft@right}
26281 % Macros placing the sidefootnotes at the left and the right respectively.
26282 % \begin{macrocode}
26283 \newcommand*{\m@sideft@left}{%
26284 \@tempdimc \sidefootwidth
26285 \advance\@tempdimc\sidefoothsep
26286 \kern-\@tempdimc}
26287 \newcommand*{\m@sideft@right}{%
26288 \@tempdimc \columnwidth% or \hsize
26289 \advance\@tempdimc\sidefoothsep
26290 \kern\@tempdimc}
26291
26292 % \end{macrocode}
26293 % \end{macro}
26294 % \end{macro}
26295 %
26296 % \begin{macro}{\m@mdownsf}
26297 % A length used in the vertical positioning of sidefootnotes.
26298 % (Perhaps one of the \cs{@tempdim} lengths could be used instead?)
26299 % \begin{macrocode}
26300 \newlength{\m@mdownsf}
26301
26302 % \end{macrocode}
26303 % \end{macro}
26304 %
26305 % \begin{macro}{\sidefootcontents}
26306 % The essence of the sidefootnote task. This first positions the column
26307 % to the left or the right and then tries to make the bottom of the
26308 % column align with the bottom of the textblock.
26309 % \begin{macrocode}
26310 \newcommand*{\sidefootcontents}{\hbox to \z@{%
26311 \m@mwhich@margin{\m@msidefoot@margin}%
26312 \ifmemtortm
26313 \m@sideft@right
26314 \else
26315 \m@sideft@left
26316 \fi
26317 % \end{macrocode}
26318 % Now the fun part. The general idea is to measure the height of the insert's
26319 % contents, subtract this from the specified height of the insert,
26320 % and move the contents down by that amount.
26321 % The code below seems to work except when sidefootnotes
26322 % spill over to the following page; also, like \cs{sidebar},
26323 % they are out of vertical alignment when on a \cs{chapter} page.
26324 % I haven't found a way to automatically
26325 % adjust for these, which is why the \cs{sidefootadjust} length is
26326 % there to enable manual adjustment.
26327 % \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
26328 % to \cs{sidefoottextfont}}
26329 % \begin{macrocode}
26330 \vtop to 0pt{% original
26331 \normalsize\normalfont\sidefoottextfont
26332 \vskip\topskip \vskip-\ht\strutbox
26333 \vskip\sidefootadjust% use this for minor vertical adjustment
26334 \m@mdownsf=\dimen\sidefootins
26335 \advance\m@mdownsf-\ht\sidefootins
26336 \advance\m@mdownsf-\dp\sidefootins
26337 % \end{macrocode}
26338 % Here's where the fiddling occurs, arrived at by a mixture of theory and
26339 % experiment.
26340 % \begin{macrocode}
26341 \ifdim\m@mdownsf>\sidefootvsep
26342 \advance\m@mdownsf\sidefootvsep
26343 \advance\m@mdownsf 0.5\ht\strutbox
26344 \fi
26345 \vskip\m@mdownsf% --- basically works
26346 \unvbox\sidefootins%
26347 \vss}%
26348 \hss}}
26349
26350 % \end{macrocode}
26351 % \end{macro}
26352 %
26353 % \begin{macro}{\m@mopsidefoot}
26354 % If there are any sidefeet then add them to the output.
26355 % \begin{macrocode}
26356 \newcommand*{\m@mopsidefoot}{%
26357 \ifvoid\sidefootins\else
26358 \setbox\@outputbox \vbox{%
26359 \sidefootcontents
26360 \unvbox\@outputbox}
26361 \fi}
26362
26363 % \end{macrocode}
26364 % \end{macro}
26365 %
26366 % \begin{macro}{\mem@makecol}
26367 % \begin{macro}{\mem@makecolbf}
26368 % \begin{macro}{\@reinserts}
26369 % \begin{macro}{\@mem@extranofeet}
26370 % \begin{macro}{@mem@testifnofoot}
26371 % Revise these to cater for the new sidefoot insert.\label{makecol}
26372 % \changes{v3.7c}{2013/11/28}{Spurious space}
26373 % \begin{macrocode}
26374 \gdef\mem@makecol{%
26375 \m@m@makecolintro
26376 \ifvoid\footins
26377 \setbox\@outputbox \box\@cclv
26378 \else
26379 \m@mopfootnote
26380 \fi
26381 \m@mdoextrafeet
26382 \m@m@makecolfloats
26383 \m@mopsidebar
26384 \m@mopsidefoot
26385 \m@m@makecoltext
26386 \global \maxdepth \@maxdepth}
26387
26388 % \end{macrocode}
26389 %
26390 % If the \Lpack{footmisc} package is loaded all of our additions of
26391 % extra footnotes, side footnotes, sidebar are lost. So we add them to
26392 % their collection macro. This is especially important when
26393 % \Lpack{footmisc} \emph{and} \Lpack{reledmac} are loaded with
26394 % memoir. To play nice, we use the command hooks introduced in june 2021.
26395 % \changes{v3.7q}{2022/02/17}{Added this fix for \Lpack{footmisc}}
26396 % \changes{v3.8.4}{2025/09/24}{Removed format check as we use format of at least 2023/06/01}
26397 % \begin{macrocode}
26398 % adding to "hook" in footmisc
26399 \AddToHook{cmd/@makecol@appendblocks/after}{\m@mdoextrafeet\m@mopsidefoot\m@mopsidebar}
26400
26401 % \end{macrocode}
26402 %
26403 % \changes{v1.618033988b}{2010/02/17}{a bf was missing in \cs{m@mopfootnotebf}}
26404 % \changes{v3.7c}{2013/11/28}{Spurious space}
26405 % \begin{macrocode}
26406 \gdef\mem@makecolbf{%
26407 \m@m@makecolintro
26408 \setbox\@outputbox \box\@cclv
26409 \m@m@makecolfloats
26410 \ifvoid\footins
26411 \else
26412 \m@mopfootnotebf
26413 \fi
26414 \m@mdoextrafeet
26415 \m@mopsidebar
26416 \m@mopsidefoot
26417 \m@m@makecoltext
26418 \global \maxdepth \@maxdepth}
26419
26420 % \end{macrocode}
26421 % \changes{v3.6d}{2010/06/30}{There should not be an \cs{else} on the
26422 % kludge line}
26423 % \changes{v3.6f}{2010/08/22}{There should not be an \cs{else} on the
26424 % kludge line, then remember to remove it}
26425 % \begin{macrocode}
26426 \gdef\@reinserts{%
26427 \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
26428 \m@mdodoreinextrafeet
26429 \ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi
26430 \ifvoid\sideins\else\insert\sideins{\unvbox\sideins}\fi
26431 \ifvoid\sidefootins\else\insert\sidefootins{\unvbox\sidefootins}\fi}
26432
26433 % \end{macrocode}
26434 %
26435 % The easy way of extending the \cs{clearpage} code is by:
26436 % \begin{verbatim}
26437 % \renewcommand*{\@mem@extranofeet}{%
26438 % \ifvoid\sidefootins\else\@mem@nofootfalse\fi}
26439 % \end{verbatim}
26440 % but as so many other changes have to be made it's probably better to
26441 % leave that alone and change \cs{@mem@testifnofoot} directly.
26442 % \begin{macrocode}
26443 \renewcommand*{\@mem@testifnofoot}{%
26444 \@mem@nofoottrue
26445 \ifvoid\footins\else\@mem@nofootfalse\fi
26446 \ifvoid\footinsv@r\else\@mem@nofootfalse\fi
26447 \ifvoid\sideins\else\@mem@nofootfalse\fi
26448 \ifvoid\sidefootins\else\@mem@nofootfalse\fi
26449 \@mem@extranofeet}
26450
26451 % \end{macrocode}
26452 % \end{macro}
26453 % \end{macro}
26454 % \end{macro}
26455 % \end{macro}
26456 % \end{macro}
26457 %
26458 % \subsubsection{The sidefootnote macros}
26459 %
26460 % The macros here are essentially a copy of the ones for \cs{footnote}.
26461 % I have not done anything about sidefootnotes in minipages, as I can't
26462 % imagine a use for them while simultaneously making the final appearance
26463 % looking good.
26464 %
26465 % The usual counter.
26466 % \begin{macrocode}
26467 \newcounter{sidefootnote}
26468 \renewcommand{\thesidefootnote}{\@arabic\c@sidefootnote}
26469 \@addtoreset{sidefootnote}{chapter}
26470
26471 % \end{macrocode}
26472 %
26473 % By using: \\
26474 % \verb?\letcountercounter{sidefootnote}{footnote}? \\
26475 % the same counter will be used for both footnotes and sidefootnotes.
26476 % This can be reverted to separate counters by; \\
26477 % \verb?\unletcounter{sidefootnote}?
26478 %
26479 % \begin{macro}{\sidefoottextfont}
26480 % The font for the sidefootnotes.
26481 % \changes{v1.61803398d}{2010/02/06}{\cs{sidefoottextfont} is already
26482 % defined by the initial issuing of \cs{setsidefeet}}
26483 % \begin{macrocode}
26484 %\newcommand*{\sidefoottextfont}{\normalfont\footnotesize}
26485
26486 % \end{macrocode}
26487 % \end{macro}
26488 %
26489 % The remainder of the code is a copied from that for \cs{footnote}
26490 % but with the appropriate variables for \cs{sidefootnote}s
26491 %
26492 % \begin{macro}{\@sidempfn}
26493 % \begin{macro}{\thesidempfn}
26494 % \begin{macrocode}
26495 \newcommand*{\@sidempfn}{sidefootnote}
26496 \newcommand*{\thesidempfn}{\thesidefootnote}
26497
26498 % \end{macrocode}
26499 % \end{macro}
26500 % \end{macro}
26501 %
26502 % \begin{macro}{\@makesidefnmark}
26503 % \begin{macrocode}
26504 \newcommand*{\@makesidefnmark}{\hbox{\@textsuperscript{%
26505 \normalfont\@thesidefnmark}}}
26506
26507 % \end{macrocode}
26508 % \end{macro}
26509 %
26510 % \begin{macro}{\@preamsidefntext}
26511 % \begin{macrocode}
26512 \newcommand{\@preamsidefntext}{%
26513 \interlinepenalty\interfootnotelinepenalty
26514 \floatingpenalty \@MM
26515 \splittopskip=\footnotesep
26516 \splitmaxdepth=\dp\strutbox
26517 \@parboxrestore}
26518
26519 % \end{macrocode}
26520 % \end{macro}
26521 %
26522 % \begin{macro}{\@sidefootnotetext}
26523 % \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
26524 % to \cs{sidefoottextfont}}
26525 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
26526 % \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
26527 % \begin{macrocode}
26528 \newcommand{\@sidefootnotetext}[1]{\insert\sidefootins{%
26529 \hsize\sidefootwidth
26530 \@parboxrestore
26531 \def\baselinestretch{\m@m@footnote@spacing}%
26532 \sidefootform \normalsize\normalfont\sidefoottextfont
26533 \splittopskip=\ht\strutbox
26534 \splitmaxdepth=\dp\strutbox
26535 \allowbreak
26536 \prevdepth=\dp\strutbox
26537 \vskip-\parskip
26538 \def\@currentcounter{sidefootnote}%
26539 \protected@edef\@currentlabel{%
26540 \csname p@sidefootnote\endcsname\@thesidefnmark}%
26541 \color@begingroup
26542 \@makesidefntext{{\sidefoottextfont #1}}%
26543 \color@endgroup
26544 \ifvmode\else
26545 \unskip\@finalstrut\strutbox
26546 \fi
26547 \par
26548 \ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox\fi
26549 \ifdim\prevdepth>99\p@
26550 \nobreak
26551 \vskip-\prevdepth
26552 \allowbreak
26553 \vskip\dp\strutbox
26554 \fi
26555 \vskip\sidefootvsep}%
26556 \m@mmf@prepare}
26557
26558 % \end{macrocode}
26559 % \end{macro}
26560 %
26561 % \begin{macro}{\@sidefootnotemark}
26562 % \begin{macrocode}
26563 \newcommand*{\@sidefootnotemark}{%
26564 \leavevmode
26565 \ifhmode
26566 \edef\@x@sf{\the\spacefactor}%
26567 \m@mmf@check
26568 \nobreak
26569 \fi
26570 \@makesidefnmark
26571 \m@mmf@prepare
26572 \ifhmode\spacefactor\@x@sf\fi
26573 \relax}
26574
26575 % \end{macrocode}
26576 % \end{macro}
26577 %
26578 % \begin{macro}{\sidefootnote}
26579 % \begin{macrocode}
26580 \newcommand*{\sidefootnote}{\@ifnextchar[
26581 \@xsidefootnote{\stepcounter\@sidempfn
26582 \protected@xdef\@thesidefnmark{\thesidempfn}%
26583 \@sidefootnotemark\@sidefootnotetext}}
26584 % \end{macrocode}
26585 % \end{macro}
26586 %
26587 % \begin{macro}{\@xsidefootnote}
26588 % \begin{macrocode}
26589 \def\@xsidefootnote[#1]{%
26590 \begingroup
26591 \csname c@\@sidempfn\endcsname #1\relax
26592 \unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
26593 \endgroup
26594 \@sidefootnotemark\@sidefootnotetext}
26595
26596 % \end{macrocode}
26597 % \end{macro}
26598 %
26599 % \begin{macro}{\sidefootnotemark}
26600 % \begin{macrocode}
26601 \newcommand{\sidefootnotemark}{%
26602 \@ifnextchar[
26603 \@xsidefootnotemark
26604 {\stepcounter{sidefootnote}%
26605 \protected@xdef\@thesidefnmark{\thesidefootnote}%
26606 \@sidefootnotemark}}
26607 % \end{macrocode}
26608 % \end{macro}
26609 %
26610 % \begin{macro}{\@xsidefootnotemark}
26611 % \begin{macrocode}
26612 \def\@xsidefootnotemark[#1]{%
26613 \begingroup
26614 \c@sidefootnote #1\relax
26615 \unrestored@protected@xdef\@thesidefnmark{\thesidefootnote}%
26616 \endgroup
26617 \@sidefootnotemark}
26618
26619 % \end{macrocode}
26620 % \end{macro}
26621 %
26622 % \begin{macro}{\sidefootnotetext}
26623 % \begin{macrocode}
26624 \newcommand*{\sidefootnotetext}{%
26625 \@ifnextchar[
26626 \@xsidefootnotetext
26627 {\protected@xdef\@thesidefnmark{\thesidempfn}%
26628 \@sidefootnotetext}}
26629 % \end{macrocode}
26630 % \end{macro}
26631 %
26632 % \begin{macro}{\@xsidefootnotetext}
26633 % \begin{macrocode}
26634 \def\@xsidefootnotetext[#1]{%
26635 \begingroup
26636 \csname c@\@sidempfn\endcsname #1\relax
26637 \unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
26638 \endgroup
26639 \@sidefootnotetext}
26640
26641 % \end{macrocode}
26642 % \end{macro}
26643 %
26644 % \begin{macro}{\sidefootmarkstyle}
26645 % \begin{macro}{\sidefootscript}
26646 % \begin{macro}{\makesidefootmarkhook}
26647 % \begin{macro}{\sidefootfootmark}
26648 % \begin{macrocode}
26649 \newcommand*{\sidefootmarkstyle}[1]{\def\sidefootscript##1{#1}}
26650 \newcommand*{\makesidefootmarkhook}{}
26651 \newcommand*{\sidefootfootmark}{%
26652 \ifdim\sidefootmarkwidth < \z@
26653 \llap{\hb@xt@ -\sidefootmarkwidth{%
26654 \hss\normalfont\sidefootscript{\@thesidefnmark}}%
26655 \hspace*{-\sidefootmarkwidth}}%
26656 \else
26657 \ifdim\sidefootmarkwidth = \z@
26658 {\normalfont\sidefootscript{\@thesidefnmark}}%
26659 \else
26660 \hb@xt@\sidefootmarkwidth{\hss\normalfont\sidefootscript{\@thesidefnmark}}%
26661 \fi
26662 \fi}
26663
26664 % \end{macrocode}
26665 % \end{macro}
26666 % \end{macro}
26667 % \end{macro}
26668 % \end{macro}
26669 %
26670 % \begin{macro}{\makesidefootmark}
26671 % \changes{v1.61803398d}{2010/02/04}{Made \cs{makesidefootmark} long
26672 % as the similar \cs{footnote} command, otherwise one cannot make side
26673 % footnotes containign several paragraphs}
26674 % \begin{macrocode}
26675 \newcommand{\makesidefootmark}[1]{%
26676 \leavevmode
26677 \parindent \sidefootparindent\noindent
26678 \leftskip\sidefootmarksep\relax
26679 \advance\leftskip \sidefootmarkwidth \null\nobreak\hskip -\leftskip\relax
26680 \makesidefootmarkhook\relax
26681 \sidefootfootmark #1}
26682
26683 % \end{macrocode}
26684 % \end{macro}
26685 %
26686 % \begin{macro}{\@makesidefntext}
26687 % \begin{macrocode}
26688 \newcommand{\@makesidefntext}[1]{\makesidefootmark #1}
26689
26690 % \end{macrocode}
26691 % \end{macro}
26692 %
26693 % Final layout.
26694 % \begin{macro}{\sidefootmarkwidth}
26695 % \begin{macro}{\sidefootmarksep}
26696 % \begin{macro}{\sidefootparindent}
26697 % \changes{v1.61803398d}{2010/02/04}{changed the defaults for
26698 % \cs{sidefootmarkwidth} and \cs{sidefootmarksep} to zero, from 1em
26699 % and -1em, looks better with the narrow margins}
26700 % \begin{macrocode}
26701 \newlength{\sidefootmarkwidth}
26702 \setlength{\sidefootmarkwidth}{0em}
26703 \newlength{\sidefootmarksep}
26704 \setlength{\sidefootmarksep}{0em}
26705 \newlength{\sidefootparindent}
26706 \setlength{\sidefootparindent}{1em}
26707 \sidefootmarkstyle{\textsuperscript{#1}}
26708
26709 % \end{macrocode}
26710 % \end{macro}
26711 % \end{macro}
26712 % \end{macro}
26713 %
26714 %
26715 % \subsection{End notes}
26716 %
26717 % \changes{v3.6h}{2011/01/19+}{Reimplemented page notes}
26718 % This used to be a copy of the \Lpack{pagenote} package, with minor
26719 % amendments. But it turned out that the implementation used by
26720 % \Lpack{pagenote} at that time, had a few serious flaws. In this
26721 % implementation we will instead turn to the trick used by the
26722 % \Lpack{endnotes} package to overcome the same problem.
26723 % For the sake of history, let us summarise what the actual problem
26724 % was. Basically the command \cs{pagenote}\marg{text} would write an
26725 % entry to an external file in the following format
26726 % \begin{verbatim}
26727 % \noteentry{nom}{id}{text}{pagenum}
26728 % \end{verbatim}
26729 % and when typesetting the page notes, this file would be read into
26730 % the document and \cs{noteentry} would typeset each page note. The
26731 % main problem here is \verb|{text}| which is written verbatimly to
26732 % the external file, but it is written on a single line!, thus an
26733 % input like this
26734 % \begin{verbatim}
26735 % \pagenote{Test%
26736 % test}
26737 % \end{verbatim}
26738 % would give us the entry
26739 % \begin{verbatim}
26740 % \noteentry{num}{id}{Test%test}{pagenum}
26741 % \end{verbatim}
26742 % oops! This is what we will solve using inspiration from
26743 % \Lpack{endnotes}, kudos to John Lavagnino.
26744 %
26745 %
26746 % \begin{macro}{\ifm@mpnpageopt}
26747 % \begin{macro}{\ifm@mpncontopt}
26748 % We need two flags for the options.
26749 % \cs{m@mpnpageoptfalse} means that page numbers are not available and
26750 % \cs{m@mpncontopt} means that note numbers are reset at each \cs{chapter}.
26751 % \begin{macrocode}
26752 \newif\ifm@mpnpageopt
26753 \m@mpnpageoptfalse
26754 \newif\ifm@mpncontopt
26755 \m@mpncontoptfalse
26756 % \end{macrocode}
26757 % \end{macro}
26758 % \end{macro}
26759 %
26760 % \begin{macro}{\c@pagenote}
26761 % \begin{macro}{\thepagenote}
26762 % We need a counter for the notes. This is the default definition.
26763 % \begin{macrocode}
26764 \newcounter{pagenote}[chapter]
26765 \renewcommand{\thepagenote}{\arabic{pagenote}}
26766 \setcounter{pagenote}{0}
26767
26768 % \end{macrocode}
26769 % \end{macro}
26770 % \end{macro}
26771 %
26772 % \begin{macro}{\notepageref}
26773 % \begin{macro}{\continuousnotenums}
26774 % \changes{v3.6h}{2011/01/19}{Removed references to pagenote package}
26775 % Let the user change the default options. \cs{notepageref} makes
26776 % page numbers available in the typeset list of page note and
26777 % \cs{continuousnotenums} means that notes will be numbered
26778 % continuously throughout the document.
26779 % \begin{macrocode}
26780 \newcommand*{\notepageref}{\m@mpnpageopttrue}
26781 \@onlypreamble\notepageref
26782 \newcommand*{\continuousnotenums}{%
26783 \counterwithout{pagenote}{chapter}
26784 \renewcommand{\thepagenote}{\arabic{pagenote}}}
26785 \@onlypreamble\continuousnotenums
26786
26787 % \end{macrocode}
26788 % \end{macro}
26789 % \end{macro}
26790 %
26791 %
26792 % \begin{macro}{\ifmempagenotes}
26793 % Need to check if notes are required.
26794 % \begin{macrocode}
26795 \newif\ifmempagenotes
26796 \mempagenotesfalse
26797
26798 % \end{macrocode}
26799 % \end{macro}
26800 %
26801 % \begin{macro}{\makepagenote}
26802 % This sets up the note file. At the end it emasculates itself so it can only
26803 % be used once.
26804 % \begin{macrocode}
26805 \newcommand*{\makepagenote}{%
26806 \newwrite\@notefile
26807 \immediate\openout\@notefile=\jobname.ent
26808 \mempagenotestrue
26809 % \end{macrocode}
26810 % \begin{macro}{\pagenote}
26811 % Make sure that this has a useful definition.
26812 % \changes{v3.6h}{2011/01/19}{Made \cs{pagenote} robust}
26813 % \changes{v3.6j}{2011/03/01}{Removed \cs{@sanitize}}
26814 % \changes{v3.6k}{2011/03/08}{Actually need \cs{@sanitize} for the
26815 % optional argument. But we need to remove spaces from this}
26816 % \begin{macrocode}
26817 \DeclareRobustCommand\pagenote{\@bsphack\begingroup
26818 \rem@special{\ }% <--- added
26819 \@sanitize
26820 \m@m@wrpnote}%
26821 % \end{macrocode}
26822 % \end{macro}
26823 % \changes{v3.6h}{2011/01/19}{Added the redefinition of \cs{mem@footto@pagenote}}
26824 % \begin{macro}{\mem@footto@pagenote}
26825 % The same as for \cs{pagenote} but here we use a special version of
26826 % the writing macro that will ignore the optional argument. This will
26827 % internally be used when the user ask for foot notes to be turned
26828 % into page notes.
26829 % \changes{v3.6j}{2011/03/01}{Removed \cs{@sanitize}}
26830 % \changes{v3.6k}{2011/03/08}{Actually need \cs{@sanitize} for the
26831 % optional argument. But we need to remove spaces from this}
26832 % \begin{macrocode}
26833 \DeclareRobustCommand\mem@footto@pagenote{\@bsphack\begingroup
26834 \rem@special{\ }% <--- added
26835 \@sanitize
26836 \def\mem@pn@step{01}%
26837 \m@m@wrpnote}%
26838 % \end{macrocode}
26839 % \end{macro}
26840 % At the end we make sure \cs{makepagenote} can only do something once.
26841 % \begin{macrocode}
26842 \typeout{Writing note file \jobname.ent}%
26843 \let\makepagenote\@empty}
26844
26845 % \end{macrocode}
26846 % \end{macro}
26847 %
26848 % \begin{macro}{\immediate@protected@write}
26849 % We might have to do some immediate writes. This is an immediate
26850 % version of the kernel \cs{protected@write}.
26851 % \changes{v3.7i}{2019/11/15}{changed to \cs{providecommand} and
26852 % removed the \cs{if@nobreak} line, also removed the edef part,
26853 % suggested by Davis Carlisle}
26854 % \begin{macrocode}
26855 \providecommand{\immediate@protected@write}[3]{%
26856 \begingroup
26857 #2%
26858 \let\protect\@unexpandable@protect
26859 %\edef\reserved@a{\immediate\write#1{#3}}%
26860 %\reserved@a
26861 \immediate\write#1{#3}%
26862 \endgroup
26863 %\if@nobreak\ifvmode\nobreak\fi\fi%
26864 }
26865
26866 % \end{macrocode}
26867 %
26868 % \end{macro}
26869 %
26870 % \begin{macro}{\immediateaddtocontents}
26871 % This is a rather risky macro, that sometimes is needed in
26872 % documents with \cs{include} as things can get out of sequence. The
26873 % macro is \emph{not} documented in the manual, as it can be
26874 % dangerous. If a \cs{clearpage} is executed right after, then it
26875 % should be save to use. Instead of just copying code and edit, we
26876 % use a \cs{NewCommandCopy} and patch it. Note that we define
26877 % \cs{thepage} to do nothing here.
26878 % \begin{macrocode}
26879 % \long\def\immediateaddtocontents#1#2{%
26880 % \immediate@protected@write\@auxout%
26881 % {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble \let\thepage\relax}%
26882 % {\string\@writefile{#1}{#2}}}
26883 \NewCommandCopy\immediateaddtocontents\addtocontents
26884 \patchcmd{\immediateaddtocontents}
26885 {\protected@write}%
26886 {\immediate@protected@write}%
26887 {}%
26888 {\typeout{patch 1 for \string\immediateaddtocontents\space failed}}
26889 % \end{macrocode}
26890 % In 2025 \cs{addtocontents} was changed a bit and is now using
26891 % alternative \cs{@gobble} macro. Since we still support older
26892 % installations we support both variants.
26893 % \changes{v3.8.4}{2025/06/10}{Added support for \cs{@gobble@om}}
26894 % \begin{macrocode}
26895 \@ifundefined{@gobble@om}{
26896 \patchcmd{\immediateaddtocontents}%
26897 {\let\glossary\@gobble}%
26898 {\let\glossary\@gobble\let\thepage\relax}%
26899 {}%
26900 {\typeout{patch 2 for \string\immediateaddtocontents\space failed}}
26901 }{
26902 \patchcmd{\immediateaddtocontents}%
26903 {\let\glossary\@gobble@om}%
26904 {\let\glossary\@gobble\let\thepage\relax}%
26905 {}%
26906 {\typeout{patch 2 for \string\immediateaddtocontents\space failed}}
26907 }
26908 % \end{macrocode}
26909 % \end{macro}
26910 %
26911 % \begin{macro}{\m@m@pnwrite}
26912 % \begin{macro}{\m@m@pnwrited}
26913 % In the old implementation we used \cs{immediate@protected@write}
26914 % unless the user asked for page numbers in the notes, the new
26915 % implementation use the same writing method for all cases, for easy
26916 % of notation we collect it in a macro. Seems UTF8 is an interesting
26917 % beast, \cs{immediate@protected@write} can write it to disk, but
26918 % \cs{m@m@pnwrite} cannot. To get past this we also include a version
26919 % that has an embedded \cs{detokenize} (thanks to Heiko Oberdiek for
26920 % that hint). We also add a \% at the end of the \cs{m@m@pnwrited}
26921 % process (don't think \cs{m@m@pnwrite} needs it). This is handy in
26922 % those cases where the user is using a design which rely on there not
26923 % being any spaces after the note text.
26924 % \changes{v3.6k}{2011/04/06}{Added the version with \cs{detokenize}}
26925 % \begin{macrocode}
26926 % \changes{v3.7i}{2019/06/07}{Added \cs{@percentchar} to
26927 % \cs{m@m@pnwrited}}
26928 \newcommand{\m@m@pnwrite}[3]{\immediate\write#1{#3}}
26929 \newcommand{\m@m@pnwrited}[3]{\immediate\write#1{\detokenize{#3}\@percentchar}}
26930
26931 % \end{macrocode}
26932 % \end{macro}
26933 % \end{macro}
26934 %
26935 % \begin{macro}{\pnchap}
26936 % \begin{macro}{\pnschap}
26937 % Redefine these for different subheadings in the notes list.
26938 % \begin{macrocode}
26939 \newcommand*{\pnchap}{\f@rtoc}
26940 \newcommand*{\pnschap}{\f@rbdy}
26941
26942 % \end{macrocode}
26943 % \end{macro}
26944 % \end{macro}
26945 % \begin{macro}{\c@pagenoteshadow}
26946 % \begin{macro}{\mem@pn@step}
26947 % \begin{macro}{\mem@pn@lastkern}
26948 % Utilities, a counter to provide us with a unique name for each page
26949 % note, a toggle macro and a length to hold a lastkern (because
26950 % someone may hide it from us).
26951 % \begin{macrocode}
26952 \newcounter{pagenoteshadow}
26953 \setcounter{pagenoteshadow}{0}
26954 \newcommand\mem@pn@step{00} % i.e. true
26955 \newlength\mem@pn@lastkern
26956 % \end{macrocode}
26957 %
26958 % \end{macro}
26959 % \end{macro}
26960 % \end{macro}
26961 %
26962 % \begin{macro}{\m@m@wrpnote}
26963 % This writes the note information to the note file. If the optional argument
26964 % is empty it increments the
26965 % note counter and calls \cs{notenumintext} to handle its appearance in
26966 % the body text. We write an entry of the following design
26967 % \begin{verbatim}
26968 % \startnoteentry{notenumber}{id}{auto label key}{hyperref}
26969 % macro:->text
26970 % \endnoteentry
26971 % \end{verbatim}
26972 %
26973 % \begin{macro}{\m@m@pnwrite@fourtharg}
26974 % \begin{macro}{\m@m@pnwrite@fourtharg@hyperref}
26975 % In order for us to add \Lpack{hyperref} support we will need to
26976 % record the hyperref anchor label into the page note data. We do this
26977 % though \verb|\m@m@pnwrite@fourtharg|, which by default just adds
26978 % \verb|{}| to the page note data. \Lpack{memhfixc} makes it point
26979 % toward \verb|\m@m@pnwrite@fourtharg@hyperref| instead. We make sure
26980 % to pass it the optional argument from \verb?\pagenote?, if this is
26981 % precent a hyper anchor is not passed on.
26982 % \changes{v3.6k}{2013/05/17}{Macro needs to test an argument}
26983 % \begin{macrocode}
26984 \newcommand\m@m@pnwrite@fourtharg[1]{\m@m@pnwrited\@notefile{}{{}}}
26985 \newcommand\m@m@pnwrite@fourtharg@hyperref[1]{%
26986 \@ifmtarg{#1}{%
26987 \m@m@pnwrite\@notefile{}{{\Hy@pagenote@currentHref}}%
26988 }{%
26989 \m@m@pnwrited\@notefile{}{{}}%
26990 }}
26991
26992 % \end{macrocode}
26993 % \end{macro}
26994 % % \end{macro}
26995 %
26996 % \changes{v1.61803}{2008/05/25}{Made \cs{m@m@wrpnote} match the effect
26997 % described in memman regarding the optional argument.}
26998 % \changes{v3.6h}{2011/01/19}{Changed the internal implementation}
26999 % \begin{macrocode}
27000 \newcommand{\m@m@wrpnote}[2][]{%
27001 % \end{macrocode}
27002 % If \Lpack{hyperref} is loaded it issues a whatisit and thus
27003 % hide/reset the last kern, which is needed for the algorithm used for
27004 % the multiple notes in a row feature (adding commas). So we start by
27005 % storing the last kern, and refstep a shadow counter such that we
27006 % can generate more or less unique label keys.
27007 % \begin{macrocode}
27008 \mem@pn@lastkern=\lastkern%
27009 \refstepcounter{pagenoteshadow}%
27010 % \end{macrocode}
27011 % If the user asks for it enable page back refs, we use labels and
27012 % references for this (bonus: automatic support for hyperlinks if
27013 % \Lpack{hyperref} is available).
27014 % \changes{v3.8.4}{2025/09/16}{There is no need for a \cs{phantomsection} herem as there is a \cs{refstepcounter} just above}
27015 % \begin{macrocode}
27016 \ifm@mpnpageopt%
27017 %\phantomsection%
27018 \label{pagenote\thepagenoteshadow-\thesheetsequence}%
27019 \fi%
27020 % \end{macrocode}
27021 % Next we want to be able to reuse this macro just for writing the
27022 % entry to disk, no writing a marker in the text (think replacement
27023 % for \cs{footnotetext}), we use the toggle for this and also remember
27024 % to re-insert the code needed for comma separated multiple markers
27025 % \begin{macrocode}
27026 \if\mem@pn@step%
27027 \@ifmtarg{#1}{%
27028 \refstepcounter{pagenote}%
27029 % this enables the ^{1,2} feature
27030 \ifdim\mem@pn@lastkern=\multiplefootnotemarker%
27031 \m@mmf@prepare% rerun
27032 \fi%
27033 \mem@pn@multiple@marker{\notenumintext{\thepagenote}}%
27034 % \end{macrocode}
27035 % \changes{3.7i}{2019/05/28}{Added the special kern also if the
27036 % optional arg is empty. Otherwise the multiple marker might not work
27037 % under hyperref. Reported in private email}
27038 % \begin{macrocode}
27039 }{\m@mmf@prepare}%
27040 \fi%
27041 % \end{macrocode}
27042 % Check if this is the first note in a division, and if so indicate this
27043 % in the file.
27044 % \changes{v3.6h}{2011/01/25}{Added \cs{pagenotesubheadstarred}}
27045 % \begin{macrocode}
27046 \ifm@mpn@new@chap%
27047 \global\m@mpn@new@chapfalse%
27048 \addtonotes{\string\pagenotesubhead{\@chapapp}{\thechapter}{\pnchap}}%
27049 \fi%
27050 \ifm@mpn@new@schap%
27051 \global\m@mpn@new@schapfalse%
27052 \addtonotes{\string\pagenotesubheadstarred{\@chapapp}{}{\pnschap}}%
27053 \fi%
27054 % \end{macrocode}
27055 % Next we write to the notes file. Instead of writing everything as a
27056 % macro with arguments, we will use three writes. One to start a new
27057 % entry with a few (non-text) arguments, then the text itself, and
27058 % finally an end of entry marker macro. There is a slight complication
27059 % here. The \verb|#1| may be UTF8 so it has to be written unexpanded
27060 % to disk, but macros like \verb|\thepagenote| need to be
27061 % expanded. Luckily \TeX\ eats up spaces when reading arguments, so we
27062 % simply writte several lines using two different writing methods.
27063 % \changes{v3.6k}{2011/04/06}{Rewritten to use a different writing method}
27064 % \begin{macrocode}
27065 \m@m@pnwrite\@notefile{}%
27066 {\string\startnoteentry{\thepagenote}}%
27067 \m@m@pnwrited\@notefile{}{{#1}}%
27068 \m@m@pnwrite\@notefile{}%
27069 {{pagenote\thepagenoteshadow-\thesheetsequence}}%
27070 % \end{macrocode}
27071 % Add the fourth argument.
27072 % \changes{v3.6k}{2013/05/16}{Added fourth argument for the note data}
27073 % \changes{v3.6k}{2013/05/17}{Fourth arg, should depend on \#1}
27074 % \begin{macrocode}
27075 \m@m@pnwrite@fourtharg{#1}%
27076 % \end{macrocode}
27077 % Getting the newline stuff to work require
27078 % \verb|\immediate\write| which we defined earlier. We then write the
27079 % text `verbatimly' using the detokenized macro.
27080 % \changes{v3.6k}{2011/04/06}{No longer any need for the \cs{meaning} construction.}
27081 % \begin{macrocode}
27082 \begingroup%
27083 \newlinechar='40%
27084 \m@m@pnwrited\@notefile{}{#2}%
27085 \endgroup%
27086 % \end{macrocode}
27087 % Remember to also write a marker that ends the entry.
27088 % \begin{macrocode}
27089 \m@m@pnwrite\@notefile{}%
27090 {\string\endnoteentry}%
27091 \endgroup%
27092 \@esphack}
27093
27094 % \end{macrocode}
27095 % \end{macro}
27096 %
27097 % \begin{macro}{\pagenote}
27098 % \begin{macro}{\mem@footto@pagenote}
27099 % The user command to generate a note. It is given substance
27100 % by \cs{makepagenote}. Supplied with a special version used if the
27101 % user asks for all footnotes to be turned into page notes.
27102 % \changes{v3.6h}{2011/01/19}{Added \cs{mem@footto@pagenote}}
27103 % \begin{macrocode}
27104 \def\pagenote{\@bsphack\begingroup \@sanitize\m@m@pagenote}
27105 \let\mem@footto@pagenote\pagenote
27106 % \end{macrocode}
27107 % \end{macro}
27108 % \end{macro}
27109 %
27110 % \begin{macro}{\m@m@pagenote}
27111 % \begin{macrocode}
27112 \newcommand{\m@m@pagenote}[2][]{\endgroup\@esphack}
27113
27114 % \end{macrocode}
27115 % \end{macro}
27116 %
27117 % \begin{macro}{\pagetofootnote}
27118 % \begin{macro}{\foottopagenote}
27119 % \begin{macro}{\memsavefootnote}
27120 % \begin{macro}{\memsavepagenote}
27121 % Let the user change pagenotes to footnotes, or vice-versa. In either
27122 % case the optional argument is ignored.
27123 % \changes{v3.6h}{2010/12/07}{\cs{footnote} should be long}
27124 % \changes{v3.6h}{2010/12/09}{because of the way
27125 % \cs{pagenote} is defined, we cannot redefine \cs{footnote} to have
27126 % any arguments, we need to go another route}
27127 % \changes{v3.6h}{2010/12/09}{Added a check for the race condition}
27128 % We have a race condition, if both \cs{pagetofootnote} and
27129 % \cs{makepagenote} is issued in the same document,
27130 % \cs{pagetofootnote} need to come last.
27131 % \begin{macrocode}
27132 \newcommand*{\pagetofootnote}{%
27133 \let\memsavepagenote\pagenote
27134 \renewcommand{\pagenote}[2][]{\footnote{##2}}
27135 % \end{macrocode}
27136 % Basic idea is, if pagenotes mode is on when \cs{pagetofootnote} is
27137 % issued, everything is fine. Else we test at end document (because
27138 % \cs{makepagenote} can go anywhere).
27139 % \begin{macrocode}
27140 \ifmempagenotes\else%
27141 \AtEndDocument{%
27142 \ifmempagenotes%
27143 \@memerror{The use of \string\pagetofootnote\space before
27144 \string\makepagenote\space^^Jdoes not make
27145 sense. \string\makepagenote\space make some redefinitions that
27146 are not picked up if \string\pagetofootnote\space is issued
27147 before \string\makepagenote
27148 }{}
27149 \fi
27150 }
27151 \fi
27152 }
27153 % \end{macrocode}
27154 % Next the more challenging one. We make the footnote counter act as
27155 % the page note counter, this ensure that \cs{footnotemark} still work
27156 % when the user ask to have footnotes converted into page
27157 % notes. \cs{footnotetext} is the same as the page note writer macro,
27158 % but without writing the marker, here we use the special page note macro.
27159 % \begin{macrocode}
27160 \newcommand*{\foottopagenote}{%
27161 \let\memsavefootnote\footnote
27162 % \end{macrocode}
27163 % \changes{v3.6k}{2013/05/02}{Remember to remove footnote counter from
27164 % chapter reset}
27165 % Since we alias the footnote counter to the pagenote counter, we need
27166 % to rewmove the footnote counter from the chapter reset, otherwise
27167 % \cs{continuousnotenums} will be wrong.
27168 % \begin{macrocode}
27169 \counterwithout{footnote}{chapter}
27170 \letcountercounter{footnote}{pagenote}
27171 \renewcommand\footnotetext[2][]{\mem@footto@pagenote{##2}}
27172 \renewcommand{\footnote}[2][]{\pagenote{##2}}
27173 }
27174
27175 % \end{macrocode}
27176 % \end{macro}
27177 % \end{macro}
27178 % \end{macro}
27179 % \end{macro}
27180 %
27181 % \begin{macro}{\addtonotes}
27182 % \cs{addtonotes}\marg{text} puts \meta{text} into the notes file.
27183 % \changes{v3.6i}{2011/02/18}{\cs{addtonotes} need \cs{immediate@protected@write}}
27184 % \begin{macrocode}
27185 \newcommand{\addtonotes}[1]{\ifmempagenotes
27186 \IfFileExists{\jobname.ent}{\immediate@protected@write\@notefile{}{#1}}{\mempnofilewarn}%
27187 \fi}
27188
27189 % \end{macrocode}
27190 % \end{macro}
27191 %
27192 % \begin{macro}{\notenumintext}
27193 % \begin{macro}{\notenuminnotes}
27194 % \cs{notenumintext}\marg{notenum} typesets \meta{notenum} (in the
27195 % body text).
27196 % \begin{macrocode}
27197 \newcommand{\notenumintext}[1]{%
27198 \textsuperscript{#1}}
27199 % \end{macrocode}
27200 % \cs{notenuminnotes}\marg{notenum} typesets \meta{notenum} (i.e. the
27201 % very first item when typesetting a note).
27202 % \begin{macrocode}
27203 \newcommand{\notenuminnotes}[1]{%
27204 {\normalfont #1.}\space}
27205 % \end{macrocode}
27206 % \end{macro}
27207 % \end{macro}
27208 %
27209 % \begin{macro}{\noteentry}
27210 % \changes{v3.6}{2010/12/14}{explanation was wrong}
27211 % \changes{v3.6h}{2011/01/19}{removed}
27212 % \cs{noteentry}\marg{notenum}\marg{id}\marg{text}\marg{pagenum}
27213 % typesets a note. This macro is not used anymore.
27214 % \begin{macrocode}
27215 %\newcommand{\noteentry}[4]{} % not used any more!
27216
27217 % \end{macrocode}
27218 % \end{macro}
27219 %
27220 % \begin{macro}{\idtextinnotes}
27221 % \cs{idtextinnotes}\marg{id text} typesets the note's \meta{id text}.
27222 % \begin{macrocode}
27223 \newcommand{\idtextinnotes}[1]{%
27224 [#1]\space}
27225 % \end{macrocode}
27226 % \end{macro}
27227 %
27228 % \begin{macro}{\noteidinnotes}
27229 % \cs{noteidinnotes}\marg{notenum}\marg{id} is used to typeset the note
27230 % identification (in the note listing). It is set so that it typesets the
27231 % \meta{id} if it is not empty, otherwise it sets the \meta{notenum}.
27232 % \begin{macrocode}
27233 \newcommand{\noteidinnotes}[2]{%
27234 \@ifmtarg{#2}{%
27235 \notenuminnotes{#1}}{\idtextinnotes{#2}}}
27236 % \end{macrocode}
27237 % \end{macro}
27238 %
27239 % \begin{macro}{\pageinnotes}
27240 % \begin{macro}{\printpageinnotes}
27241 % \begin{macro}{\printpageinnoteshyperref}
27242 % \changes{v3.6h}{2011/01/19}{Changed to match new implementation}
27243 % \cs{pageinnotes}\marg{key} calls
27244 % \cs{printpageinnotes}\marg{key} to typeset the originating
27245 % page number (in the note), but only if the \cs{notepageref} declaration
27246 % has been used. Remember we provide an automatically generated label
27247 % key, thus we use \cs{pageref} to get the page number. We provide a
27248 % \Lpack{hyperref} version which is automatically used whenever
27249 % \Lpack{hyperref} is loaded.
27250 % \begin{macrocode}
27251 \newcommand{\pageinnotes}[1]{%
27252 \ifm@mpnpageopt \printpageinnotes{#1}\fi}
27253 \newcommand*{\printpageinnotes}[1]{%
27254 (\pagerefname\ \pageref{#1})\space}
27255 \newcommand\printpageinnoteshyperref[1]{%
27256 (\hyperref[#1]{\pagerefname\ \pageref*{#1}})\space}
27257 % \end{macrocode}
27258 % \end{macro}
27259 % \end{macro}
27260 % \end{macro}
27261 %
27262 % \begin{macro}{\noteinnotes}
27263 % \cs{noteinnotes}\marg{text} is used to typeset the note's text
27264 % (in the note list). This macro is not used any more, but doesn't do
27265 % any harm to leave it here.
27266 % \begin{macrocode}
27267 \newcommand{\noteinnotes}[1]{#1} % not used anymore!
27268
27269 % \end{macrocode}
27270 % \end{macro}
27271 %
27272 % \begin{macro}{\prenoteinnotes}
27273 % \begin{macro}{\postnoteinnotes}
27274 % These are called immediately before and after the note information is
27275 % typeset.
27276 % \begin{macrocode}
27277 \newcommand{\prenoteinnotes}{\par\noindent}
27278 \newcommand{\postnoteinnotes}{\par}
27279
27280 % \end{macrocode}
27281 % \end{macro}
27282 % \end{macro}
27283 %
27284 % \begin{macro}{\prenotetext}
27285 % \begin{macro}{\postnotetext}
27286 % Thise two macros are executed just before and just after the note
27287 % text. Does nothing by default.
27288 % \begin{macrocode}
27289 \newcommand\prenotetext{}
27290 \newcommand\postnotetext{}
27291
27292 % \end{macrocode}
27293 %
27294 % \end{macro}
27295 % \end{macro}
27296 %
27297 % \begin{macro}{\notesname}
27298 % \begin{macro}{\notedivision}
27299 % Heading for note list.
27300 % \begin{macrocode}
27301 \providecommand*{\notesname}{Notes}
27302 \newcommand*{\notedivision}{\chapter{\notesname}}
27303
27304 % \end{macrocode}
27305 % \end{macro}
27306 % \end{macro}
27307 %
27308 % \changes{v3.6h}{2010/12/14}{typo}
27309 % \changes{v3.6h}{2011/01/19}{There is no reason to use two macros to
27310 % implement a starred and non starred version in this case.}
27311 % \begin{macro}{\printpagenotes}
27312 % \begin{macro}{\printpagenotes*}
27313 % User commands to print the note file.
27314 % \begin{macrocode}
27315 \newcommand*{\printpagenotes}{\@ifstar{\mem@printpagenotes{00}}{\mem@printpagenotes{01}}}
27316 % \end{macrocode}
27317 % \end{macro}
27318 % \end{macro}
27319 %
27320 % \begin{macro}{\mempnofilewarn}
27321 % Warning when the notes file does not exist.
27322 % \begin{macrocode}
27323 \newcommand*{\mempnofilewarn}{%
27324 \ClassWarning{memoir}{There is no .ent file}}
27325
27326 % \end{macrocode}
27327 % \end{macro}
27328 %
27329 % \begin{macro}{\startnoteentrystart}
27330 % \begin{macro}{\endnoteentryend}
27331 % \begin{macro}{\pagenoteanchor}
27332 % \begin{macro}{\pagenotebyanchor}
27333 % Utility macros to handle page note formating and hyperlinks.
27334 % \changes{v3.6k}{2013/05/16}{altered to use four arguments instead of three}
27335 % \changes{v3.6k}{2013/05/16}{Added page note anchor}
27336 % \changes{v3.6k}{2013/05/17}{Forgot about labels in the note text.}
27337 % \changes{v3.7g}{2018/01/03}{Added \cs{phantomsection}, otherwise
27338 % \cs{label} does not work correctly. Reported in \texttt{https://tex.stackexchange.com/q/408448/3929}}
27339 % \changes{v3.8}{2023/07/26}{added \cs{@currentcounter} and
27340 % defined that \cs{@currentlabel} points to}
27341 % \changes{v3.8.4}{2025/09/16}{Replaced \cs{phantomsection} with \cs{MakeLinkTarget}}
27342 % \begin{macrocode}
27343 \newcommand\startnoteentrystart[4]{% number; manual id; auto label; href anchor
27344 \prenoteinnotes%
27345 \noteidinnotes{#1}{#2}%
27346 % \phantomsection%
27347 \MakeLinkTarget[pagenote]{}%
27348 \@ifmtarg{#2}{\def\@currentlabel{#1}}{\def\@currentlabel{#2}}%
27349 \def\@currentcounter{pagenote}%
27350 \pagenoteanchor{#4}%
27351 \pageinnotes{#3}%
27352 \prenotetext%
27353 }
27354 \def\endnoteentryend{\postnotetext\postnoteinnotes}
27355 \let\pagenoteanchor\@gobble
27356 % \end{macrocode}
27357 % The page note hyper anchor should of course only be added when there
27358 % is an anchor.
27359 % \changes{v3.6k}{2013/05/17}{Forgot to test the argument}
27360 % \begin{macrocode}
27361 \newcommand\pagenotehyperanchor[1]{%
27362 \expandafter\@ifmtarg\expandafter{#1}{}{%
27363 \Hy@raisedlink{\hyper@@anchor{#1}{\relax}}}}%
27364
27365 % \end{macrocode}
27366 % \end{macro}
27367 % \end{macro}
27368 % \end{macro}
27369 % \end{macro}
27370 %
27371 % \begin{macro}{\mem@printpagenotes}
27372 % \begin{macro}{\startnoteentry}
27373 % \begin{macro}{\ednoteentry}
27374 % The internal macro for printing the list of page notes. The two
27375 % macros \cs{startnoteentry} and \cs{endnoteentry} are also defined here.
27376 % \changes{v3.6k}{2011/03/09}{Start and end entry better be long}
27377 % \changes{v3.6k}{2011/04/06}{We no longer use \cs{meaning} when
27378 % writing the data to disk, so no need to remove \texttt{>} any
27379 % more. Also removed the safe GT stuff}
27380 % \begin{macrocode}
27381 % \changes{v3.6k}{2013/05/16}{\cs{startnoteentry} should expect four args}
27382 \newcommand\mem@printpagenotes[1]{%
27383 \ifmempagenotes
27384 \notedivision
27385 \IfFileExists{\jobname.ent}{%
27386 \begingroup
27387 \long\def\startnoteentry####1####2####3####4{%
27388 \begingroup
27389 \startnoteentrystart{####1}{####2}{####3}{####4}%
27390 }
27391 \long\def\endnoteentry{\endnoteentryend\endgroup}
27392 \immediate\closeout\@notefile
27393 \input{\jobname.ent}%
27394 \if#1\immediate\openout\@notefile=\jobname.ent\fi%
27395 \endgroup
27396 }{%
27397 \mempnofilewarn
27398 }%
27399 \fi%
27400 }
27401
27402 % \end{macrocode}
27403 % \end{macro}
27404 % \end{macro}
27405 % \end{macro}
27406 %
27407 % \begin{macro}{\@sprintpagenotes}
27408 % Macro implementing \cs{printpagenotes*}. Removed
27409 % \changes{v3.6h}{2011/01/20}{Removed}
27410 % \begin{macrocode}
27411 % \newcommand*{\@sprintpagenotes}{%
27412 % \ifmempagenotes
27413 % \notedivision
27414 % \IfFileExists{\jobname.ent}{%
27415 % \immediate\closeout\@notefile
27416 % \input{\jobname.ent}%
27417 % \immediate\openout\@notefile=\jobname.ent%
27418 % }{%
27419 % \mempnofilewarn
27420 % }%
27421 % \fi}
27422
27423 % \end{macrocode}
27424 % \end{macro}
27425 %
27426 % \begin{macro}{\@printpagenotes}
27427 % Macro implementing \cs{printpagenotes}. Removed
27428 % \changes{v3.6h}{2011/01/20}{Removed}
27429 % \begin{macrocode}
27430 % \newcommand*{\@printpagenotes}{%
27431 % \ifmempagenotes
27432 % \notedivision
27433 % \IfFileExists{\jobname.ent}{%
27434 % \immediate\closeout\@notefile
27435 % \input{\jobname.ent}%
27436 % }{%
27437 % \mempnofilewarn
27438 % }
27439 % \fi}
27440
27441 % \end{macrocode}
27442 % \end{macro}
27443 %
27444 % \begin{macro}{\pagenotesubhead}
27445 % \begin{macro}{\pagenotesubheadstarred}
27446 % \changes{v3.6h}{2011/01/25}{Added \cs{pagenotesubheadstarred}}
27447 % The section heading before each set of notes. \\
27448 % \cs{pagenotesubhead}\marg{chaptername}\marg{number}\marg{title}
27449 % The \cs{pagenotesubheadstarred} macro is used for unnumbered
27450 % devisions. By default it is the same as \cs{pagenotesubhead}, but
27451 % the user can change this. For example it may look odd with an title
27452 % like this: >>Chapter Title<< when there is no number.
27453 % \begin{macrocode}
27454 \newcommand*{\pagenotesubhead}[3]{%
27455 \section*{#1 #2 #3}}
27456 \newcommand\pagenotesubheadstarred{\pagenotesubhead}
27457 % \end{macrocode}
27458 % \end{macro}
27459 % \end{macro}
27460 %
27461 % \section{Change marks} \label{sec:vct}
27462 %
27463 % When preparing a manuscript it normally goes through
27464 % several iterations. The commands provided may be used to identify
27465 % changes made to a document during its life cycle.
27466 %
27467 % The code for this part of the class is based on the version
27468 % controls in the \Lpack{iso} class~\cite{ISOCLASS}.
27469 %
27470 % \subsection{Print control}
27471 %
27472 % Members of the development group often need to see the changes
27473 % between document versions, while the general public does not.
27474 % \begin{macro}{\ifchangemarks}
27475 % This controls the appearence of the version controls defined
27476 % below.
27477 % \begin{macrocode}
27478 \newif\ifchangemarks\changemarksfalse
27479 % \end{macrocode}
27480 % The marks only work properly when the \Lopt{draft} option
27481 % is in effect. Also, the command \cs{changemarkstrue} must be
27482 % put in the document preamble.
27483 % \end{macro}
27484 %
27485 % \begin{macro}{\changemarks}
27486 % \begin{macro}{\nochangemarks}
27487 % More user friendly version of \cs{changemarks(true/false)}.
27488 % \changes{v1.61803}{2008/01/30}{Added \cs{changemarks} and \cs{nochangemarks}}
27489 % \begin{macrocode}
27490 \newcommand*{\changemarks}{\changemarkstrue}
27491 \newcommand*{\nochangemarks}{\changemarksfalse}
27492
27493 % \end{macrocode}
27494 % \end{macro}
27495 % \end{macro}
27496 %
27497 % \begin{macro}{\v@rid}
27498 % This acts as an alias for \cs{marginpar} when both \cs{ifchangemarks} is
27499 % true and the \Lopt{draft} option is in effect, otherwise it throws
27500 % away its two arguments.
27501 % \changes{v1.2}{2002/07/27}{Added \cs{@bsphack} and \cs{@esphack} to \cs{v@rid}}
27502 % \begin{macrocode}
27503 \newcommand{\v@rid}[2]{%
27504 \@bsphack
27505 \ifchangemarks
27506 \ifdraftdoc
27507 \marginpar[#1]{#2}%
27508 \fi\fi
27509 \@esphack}
27510
27511 % \end{macrocode}
27512 % \end{macro}
27513 %
27514 % \subsection{Change marking}
27515 %
27516 % The following commands flag changes in the typeset document. Each of
27517 % the commands takes one parameter which is intended to be a
27518 % `change number' or comment for tracking purposes. A symbol and
27519 % the \meta{change-id} is put into the margin near where the command
27520 % is given. The marking commands should be attached to some word or
27521 % punctuation mark in the text otherwise extraneous spaces may creep
27522 % into the final document.
27523 % \changes{v1.2}{2002/07/27}{Added \cs{@bsphack} and \cs{@esphack} to changemarks}
27524 % \begin{macro}{\added}
27525 % \cs{added}\marg{change-id}
27526 % Flags, with the symbol $\oplus$, that something has been added
27527 % to the manuscript.
27528 % \begin{macrocode}
27529 \newcommand{\added}[1]{%
27530 \@bsphack
27531 \ifchangemarks
27532 \v@rid{\small$\oplus$ #1}{\small$\oplus$ #1}%
27533 \fi
27534 \@esphack}
27535 % \end{macrocode}
27536 % \end{macro}
27537 %
27538 % \begin{macro}{\deleted}
27539 % \cs{deleted}\marg{change-id}
27540 % Flags, with the symbol $\neq$, that something has been deleted
27541 % from the manuscript.
27542 % \begin{macrocode}
27543 \newcommand{\deleted}[1]{%
27544 \@bsphack
27545 \ifchangemarks
27546 \v@rid{\small$\neq$ #1}{\small$\neq$ #1}%
27547 \fi
27548 \@esphack}
27549 % \end{macrocode}
27550 % \end{macro}
27551 %
27552 % \begin{macro}{\changed}
27553 % \cs{changed}\marg{change-id}
27554 % Flags, with the symbol $\Leftrightarrow$, that something
27555 % has been changed in the text.
27556 % \begin{macrocode}
27557 \newcommand{\changed}[1]{%
27558 \@bsphack
27559 \ifchangemarks
27560 \v@rid{\small$\Leftrightarrow$ #1}{\small$\Leftrightarrow$ #1}%
27561 \fi
27562 \@esphack}
27563
27564 % \end{macrocode}
27565 % \end{macro}
27566 %
27567 % \section{Trimming marks}
27568 %
27569 % The \Lopt{showtrims} options prints trimming marks at the corners
27570 % of the logical page. The code for this comes from ideas gleaned
27571 % from Martin Schr\"{o}der's \Lpack{everyshi} package~\cite{EVERYSHI}
27572 % and Melchior Franz's \Lpack{crop} package~\cite{CROP}.
27573 % The implementation and any errors are mine.
27574 %
27575 % The implementation up to October 2002 was limited to putting a cross
27576 % at the page corners. The manual directed users to the \Lpack{crop}
27577 % packge if they wanted anything more. In October 2002 the implementation
27578 % was substantially extended. The background to this is below.
27579 %
27580 % Before the release of version 1.7 of \Lpack{crop} in May 2002 its
27581 % author asked me to make some changes to \Lpack{memoir} that would be
27582 % helpful to him, and I did so. Later he told me that the changes were
27583 % unnecessary and I reverted to the original \Lpack{memoir} code.
27584 %
27585 % On 2002/10/06 Peter Heslin started a thread on \url{comp.text.tex}
27586 % titled `Incompatibility of memoir.cls and crop.sty' in which he said
27587 % that \Lpack{memoir} and \Lpack{crop} did not seem to work
27588 % together. The following are some snippets from that thread,
27589 % identified by the various proponents.
27590 % \begin{description}
27591 % \item[crop] Ah, yes. It cannot work with all those \cs{settrims} etc.
27592 % crop.sty does only respect \verb?\stock{width,height}?,
27593 % but none of the other memoir specific trim marks stuff \ldots
27594 %
27595 % \item[crop] \ldots I'm not a memoir expert. crop.sty respects all the
27596 % usual LaTeX paper dimensions and simply puts the marks around the
27597 % page. It works with all standard classes and the KOMA classes. memoir
27598 % seems to do things completely differently \ldots
27599 %
27600 % Sorry, but I'm afraid I have to pass the problem to the memoir
27601 % author. \ldots
27602 %
27603 % \item[memoir] I will try and take a look at the problem but I'm
27604 % not a crop expert --- I've never used it. However it seems odd to
27605 % me that crop doesn't work with memoir. Memoir provides a different
27606 % interface for specifying the page layout but then translates everything
27607 % to the standard length variables. \ldots
27608 %
27609 % \item[crop] You've just taken code from it \verb?...:->?
27610 %
27611 % crop doesn't have its own idea at all. It just uses that of DEK
27612 % and LaTeX, which says, that the reference point of the output box
27613 % in the output routine is assumed 1 inch to the left [later corrected
27614 % to right] and 1 inch down
27615 % from the upper left (virtual) paper corner.
27616 %
27617 % \item[crop] With other words: crop changes \cs{hoffset} and \cs{voffset},
27618 % in order to center the logical (virtual) page on the physical sheet
27619 % of paper, in the middle of the crop marks. The length macros
27620 % \cs{evensidemargin} and \cs{oddsidemargin} are unchanged and refer still
27621 % to the logical page (modulo 1 inch).
27622 %
27623 % The memoir class, in contrast (mis)uses the LaTeX margins
27624 % \cs{even(odd)sidemargin} for that purpose.
27625 %
27626 % Thus, the meaning of \cs{even(odd)sidemargin} is different
27627 % in both packages.
27628 % \end{description}
27629 %
27630 % Given all the above I concluded that \Lpack{crop} would remain
27631 % as it was, and that in order to satisfy Peter Heslin I would have
27632 % to extend the trimming marks. The following was originally limited to
27633 % extensions
27634 % asked for by Peter Heslin.
27635 %
27636 % \begin{macro}{\showtrimsoff}
27637 % \begin{macro}{\showtrimson}
27638 % Switch trimming marksoff and on. Requested by James Hunt on CTT
27639 % \textit{Are crop marks needed on every page?}, February 2006.
27640 % \changes{v1.61803}{2008/01/30}{Added \cs{showtrimsoff} and \cs{showtrimson}
27641 % (mempatch v4.5)}
27642 % \begin{macrocode}
27643 \newcommand*{\showtrimsoff}{\showtrimsfalse}
27644 \newcommand*{\showtrimson}{\showtrimstrue}
27645
27646 % \end{macrocode}
27647 % \end{macro}
27648 % \end{macro}
27649 %
27650 % \begin{macro}{\trimmark}
27651 % This is a cross in a zero sized picture for marking the corner of
27652 % a logical page. Up to version 1.0 the macro used \cs{setlength}
27653 % for adjusting the \cs{unitlength} but Henrik Holm (Message to
27654 % \ctt{} on 2002/01/04) discovered that if the \Lpack{calc} package
27655 % is used then LaTeX complains about a missing number.
27656 % \changes{v1.0a}{2002/01/04}{Removed \cs{setlength} from \cs{trimmark}. Stops
27657 % problem with the calc package.}
27658 % \begin{macrocode}
27659 \newcommand*{\trimmark}{%
27660 \begin{picture}(0,0)
27661 \unitlength 1cm
27662 \thinlines
27663 \put(-2,0){\line(1,0){4}}
27664 \put(0,-2){\line(0,1){4}}
27665 \end{picture}}
27666
27667 % \end{macrocode}
27668 % \end{macro}
27669 %
27670 % \begin{macro}{\Ltrimpictl}
27671 % \begin{macro}{\Ltrimpictr}
27672 % \begin{macro}{\Ltrimpicbl}
27673 % \begin{macro}{\Ltrimpicbr}
27674 % `L' shaped trim marks for four corners.
27675 % \changes{v1.3}{2002/10/10}{Added \cs{Ltrimpictl}, \cs{Ltrimpictr}, \cs{Ltrimpicbl}
27676 % and \cs{Ltrimpicbr}}
27677 % \begin{macrocode}
27678 \newcommand*{\Ltrimpictl}{%
27679 \begin{picture}(0,0)
27680 \unitlength 1mm
27681 \thinlines
27682 \put(-2,0){\line(-1,0){18}}
27683 \put(0,2){\line(0,1){18}}
27684 \end{picture}}
27685 \newcommand*{\Ltrimpictr}{%
27686 \begin{picture}(0,0)
27687 \unitlength 1mm
27688 \thinlines
27689 \put(2,0){\line(1,0){18}}
27690 \put(0,2){\line(0,1){18}}
27691 \end{picture}}
27692 \newcommand*{\Ltrimpicbl}{%
27693 \begin{picture}(0,0)
27694 \unitlength 1mm
27695 \thinlines
27696 \put(-2,0){\line(-1,0){18}}
27697 \put(0,-2){\line(0,-1){18}}
27698 \end{picture}}
27699 \newcommand*{\Ltrimpicbr}{%
27700 \begin{picture}(0,0)
27701 \unitlength 1mm
27702 \thinlines
27703 \put(2,0){\line(1,0){18}}
27704 \put(0,-2){\line(0,-1){18}}
27705 \end{picture}}
27706
27707 % \end{macrocode}
27708 % \end{macro}
27709 % \end{macro}
27710 % \end{macro}
27711 % \end{macro}
27712 %
27713 % \begin{macro}{\Ftrimpicbl}
27714 % Frame the page.
27715 % \changes{v1.3}{2002/10/10}{Added \cs{Ftrimpictl}}
27716 % \begin{macrocode}
27717 \newcommand*{\Ftrimpicbl}{%
27718 \begin{picture}(0,0)
27719 \unitlength 1pt
27720 \thinlines
27721 \put(0,0){\framebox(\strip@pt\paperwidth,\strip@pt\paperheight){}}
27722 \end{picture}}
27723
27724 % \end{macrocode}
27725 % \end{macro}
27726 %
27727 % \begin{macro}{\tmarktl}
27728 % \begin{macro}{\tmarktr}
27729 % \begin{macro}{\tmarkbl}
27730 % \begin{macro}{\tmarkbr}
27731 % The trimming marks used for corner display.
27732 % \changes{v1.3}{2002/10/10}{Added \cs{tmarktl}, \cs{tmarktr}, \cs{tmarkbl}
27733 % and \cs{tmarkbr}}
27734 % \begin{macrocode}
27735 \newcommand*{\tmarktl}{\trimmark}
27736 \newcommand*{\tmarktr}{\trimmark}
27737 \newcommand*{\tmarkbl}{\trimmark}
27738 \newcommand*{\tmarkbr}{\trimmark}
27739
27740 % \end{macrocode}
27741 % \end{macro}
27742 % \end{macro}
27743 % \end{macro}
27744 % \end{macro}
27745 %
27746 % \begin{macro}{\tmarktm}
27747 % \begin{macro}{\tmarkml}
27748 % \begin{macro}{\tmarkmr}
27749 % \begin{macro}{\tmarkbm}
27750 % The trimming marks used for mid-side display.
27751 % \changes{v1.3}{2002/10/10}{Added \cs{tmarktm}, \cs{tmarkml}, \cs{tmarkmr}
27752 % and \cs{tmarkbm}}
27753 % \changes{v1.6180339c}{2009/11/13}{Fill in these four macros. Easier
27754 % for users to define them to do nothing, than coming up with the code}
27755 % \begin{macrocode}
27756 \newcommand*{\tmarktm}{%
27757 \begin{picture}(0,0)%
27758 \unitlength 1mm
27759 \thinlines
27760 \put(0,2){\line(0,1){10}}
27761 \end{picture}}
27762 \newcommand*{\tmarkml}{%
27763 \begin{picture}(0,0)%
27764 \unitlength 1mm
27765 \thinlines
27766 \put(-2,0){\line(-1,0){10}}
27767 \end{picture}}
27768 \newcommand*{\tmarkmr}{%
27769 \begin{picture}(0,0)%
27770 \unitlength 1mm
27771 \thinlines
27772 \put(2,0){\line(1,0){10}}
27773 \end{picture}}
27774 \newcommand*{\tmarkbm}{%
27775 \begin{picture}(0,0)%
27776 \unitlength 1mm
27777 \thinlines
27778 \put(0,-12){\line(0,1){10}}
27779 \end{picture}}
27780
27781 % \end{macrocode}
27782 % \end{macro}
27783 % \end{macro}
27784 % \end{macro}
27785 % \end{macro}
27786 %
27787 % \begin{macro}{\trimXmarks}
27788 % \begin{macro}{\trimLmarks}
27789 % \begin{macro}{\trimFrame}
27790 % \begin{macro}{\trimNone}
27791 % These are declarations for the different kinds of trimming marks.
27792 % \changes{v1.3}{2002/10/10}{Added \cs{trimXmarks}, \cs{trimLmarks},
27793 % \cs{trimFrame} and \cs{trimNone}}
27794 % \begin{macrocode}
27795 \newcommand*{\trimXmarks}{%
27796 \let\tmarktl\trimmark
27797 \let\tmarktr\trimmark
27798 \let\tmarkbl\trimmark
27799 \let\tmarkbr\trimmark}
27800 \newcommand*{\trimLmarks}{%
27801 \let\tmarktl\Ltrimpictl
27802 \let\tmarktr\Ltrimpictr
27803 \let\tmarkbl\Ltrimpicbl
27804 \let\tmarkbr\Ltrimpicbr}
27805 \newcommand*{\trimFrame}{%
27806 \let\tmarktl\null
27807 \let\tmarktr\null
27808 \let\tmarkbl\Ftrimpicbl
27809 \let\tmarkbr\null}
27810 \newcommand*{\trimNone}{%
27811 \let\tmarktl\relax
27812 \let\tmarktr\relax
27813 \let\tmarkbl\relax
27814 \let\tmarkbr\relax
27815 \let\tmarktm\relax
27816 \let\tmarkml\relax
27817 \let\tmarkmr\relax
27818 \let\tmarkbm\relax}
27819
27820 % \end{macrocode}
27821 % \end{macro}
27822 % \end{macro}
27823 % \end{macro}
27824 % \end{macro}
27825 %
27826 % \begin{macro}{\trimmarks}
27827 % \begin{macro}{\trimmarkscolor}
27828 % This positions four marks (\cs{trimmark}) at the corners of a
27829 % logical page. It is basically a \cs{vbox} with zero height and width.
27830 %
27831 % Bastiaan Niels Veelo reported (2003/07/11) odd things (e.g., some
27832 % macros ignored) when changing trim marks. Turns out to be related
27833 % to the use of \cs{protect}. The macro \cs{trimmarkscolor} can be
27834 % used to change the color of the trimmarks. Despite its name, it is
27835 % not a color but just an empty macro.
27836 % \changes{v1.1}{2002/03/10}{Changed \cs{trimmarks} to work properly with the oneside option}
27837 % \changes{v1.3}{2002/10/10}{Changed \cs{trimmarks} to use \cs{tmarktl}, etc.,
27838 % instead of four \cs{trimmark}s}
27839 % \changes{v1.4}{2003/11/22}{Fiddled \cs{protect} in \cs{trimmaks}
27840 % (from patch v1.7)}
27841 % \changes{v3.6h}{2010/12/05}{Added \cs{trimmarkscolor}}
27842 % \changes{v3.7m}{2020/08/05}{From the 2020/10/01 format, we don't
27843 % need the \cs{vskip}\texttt{-1in} and \cs{hskip}\texttt{-1in} as the
27844 % trimmarks are added in a different manner}
27845 % \begin{macrocode}
27846 \newcommand*\trimmarkscolor{}
27847 % \end{macrocode}
27848 % \changes{v3.7m}{2020/08/05}{Factored out two skips}
27849 % Factoring out two skips to make it easy to remove them in the
27850 % 2020/10/01 onwards.
27851 % \begin{macrocode}
27852 \newcommand\mem@trimmarks@initial@vskip{\vskip-1in}
27853 \newcommand\mem@trimmarks@initial@hskip{\hskip-1in}
27854 \newcommand*{\trimmarks}{%
27855 \vbox to \z@{%
27856 \mem@trimmarks@initial@vskip%
27857 \vskip\trimtop % top of logical page
27858 \hb@xt@\z@{%
27859 \mem@trimmarks@initial@hskip%
27860 \ifodd\c@page
27861 \hskip\stockwidth
27862 \hskip-\trimedge
27863 \hskip-\paperwidth
27864 \else
27865 \if@twoside
27866 \hskip\trimedge % left of logical page
27867 \else
27868 \hskip\stockwidth
27869 \hskip-\trimedge
27870 \hskip-\paperwidth
27871 \fi
27872 \fi
27873 \vbox to \paperheight{%
27874 \let\protect\relax % <- v1.4 addition
27875 \hb@xt@\paperwidth{\trimmarkscolor\tmarktl\hfil\tmarktm\hfil\tmarktr}%
27876 \vfil
27877 \hb@xt@\paperwidth{\trimmarkscolor\tmarkml\hfil\tmarkmr}%
27878 \vfil
27879 \hb@xt@\paperwidth{\trimmarkscolor\tmarkbl\hfil\tmarkbm\hfil\tmarkbr}}%
27880 \hss}%
27881 \vss}}
27882
27883 % \end{macrocode}
27884 % \end{macro}
27885 % \end{macro}
27886 %
27887 %
27888 % \subsection{Quark marks}
27889 %
27890 % William Adams (2006/08/28) supplied the following code to use trim marks
27891 % along the style of Quark Xpress.
27892 %
27893 % \begin{macro}{\registrationColour}
27894 % \begin{macro}{\quarkmarks}
27895 % Trim marks on the style of Quark Express.
27896 % \changes{v1.61803}{2008/01/30}{Added \cs{quarkmarks} (mempatch v4.6)}
27897 % \changes{v3.6h}{2010/12/05}{Added \cs{normalfont} such that font
27898 % changes going over a page break does not effect the quarks
27899 % text. Reported by Rasmus Villemoes.}
27900 % \changes{v3.6j}{2011/02/28}{Typo hsip -> hskip, reported by Alex Ball}
27901 % \begin{macrocode}
27902 \newcommand*{\registrationColour}[1]{#1}
27903 \newcommand*{\quarkmarks}{%
27904 \renewcommand*{\tmarktl}{\registrationColour{%
27905 \begin{picture}(0,0)
27906 \setlength{\unitlength}{1bp}\thicklines
27907 \put(-36,0){\line(1,0){24}}
27908 \put(0,12){\line(0,1){24}}
27909 \put(3,27){\normalfont\ttfamily\fontsize{8bp}{10bp}\selectfont\jobname\ \
27910 \today\ \ \printtime\ \ Page \thepage}
27911 \end{picture}}}
27912 \renewcommand*{\tmarktm}{\registrationColour{%
27913 \begin{picture}(0,0)
27914 \setlength{\unitlength}{1bp}\thicklines
27915 \put(-24,24){\line(1,0){48}}
27916 \put(0,12){\line(0,1){24}}
27917 \put(0,24){\oval(12,12)}
27918 \end{picture}}}
27919 \renewcommand*{\tmarktr}{\registrationColour{%
27920 \begin{picture}(0,0)
27921 \setlength{\unitlength}{1bp}\thicklines
27922 \put(12,0){\line(1,0){24}}
27923 \put(0,12){\line(0,1){24}}
27924 \end{picture}}}
27925 \renewcommand*{\tmarkmr}{\registrationColour{%
27926 \begin{picture}(0,0)
27927 \setlength{\unitlength}{1bp}\thicklines
27928 \put(12,0){\line(1,0){24}}
27929 \put(24,-24){\line(0,1){48}}
27930 \put(24,0){\oval(12,12)}
27931 \end{picture}}}
27932 \renewcommand*{\tmarkbr}{\registrationColour{%
27933 \begin{picture}(0,0)
27934 \setlength{\unitlength}{1bp}\thicklines
27935 \put(12,0){\line(1,0){24}}
27936 \put(0,-36){\line(0,1){24}}
27937 \end{picture}}}
27938 \renewcommand*{\tmarkbm}{\registrationColour{%
27939 \begin{picture}(0,0)
27940 \setlength{\unitlength}{1bp}\thicklines
27941 \put(-24,-24){\line(1,0){48}}
27942 \put(0,-36){\line(0,1){24}}
27943 \put(0,-24){\oval(12,12)}
27944 \end{picture}}}
27945 \renewcommand*{\tmarkbl}{\registrationColour{%
27946 \begin{picture}(0,0)
27947 \setlength{\unitlength}{1bp}\thicklines
27948 \put(-36,0){\line(1,0){24}}
27949 \put(0,-36){\line(0,1){24}}
27950 \end{picture}}}
27951 \renewcommand*{\tmarkml}{\registrationColour{%
27952 \begin{picture}(0,0)
27953 \setlength{\unitlength}{1bp}\thicklines
27954 \put(-36,0){\line(1,0){24}}
27955 \put(-24,-24){\line(0,1){48}}
27956 \put(-24,0){\oval(12,12)}
27957 \end{picture}}}
27958 % \end{macrocode}
27959 %
27960 % \changes{v3.7m}{2020/08/05}{Removed redefinition of \cs{trimmarks}
27961 % inside \cs{quarkmarks}, it only adds an extra group compared to the
27962 % normal \cs{trimmarks}}
27963 % Removed redefintion of \cmd{\trimmarks}, seemingly no need for it.
27964 % \begin{macrocode}
27965 %% \renewcommand*{\trimmarks}{%
27966 %% %% \special{papersize=\the\stockwidth,\the\stockheight}
27967 %% {%
27968 %% \vbox to \z@{\vskip-1in \vskip\trimtop % top of logical page
27969 %% \hb@xt@\z@{\hskip-1in
27970 %% \ifodd\c@page
27971 %% \hskip\stockwidth \hskip-\trimedge \hskip-\paperwidth
27972 %% \else
27973 %% \if@twoside
27974 %% \hskip\trimedge % left of logical page
27975 %% \else
27976 %% \hskip\stockwidth \hskip-\trimedge \hskip-\paperwidth
27977 %% \fi
27978 %% \fi
27979 %% \vbox to \paperheight{%
27980 %% \let\protect\relax % <- v1.4 addition
27981 % \end{macrocode}
27982 % We remember to add \cs{trimmarkscolor}
27983 % \changes{v3.6h}{2010/12.05}{added \cs{trimmarkscolor}}
27984 % \begin{macrocode}
27985 %% \hb@xt@\paperwidth{\trimmarkscolor\tmarktl\hfil\tmarktm\hfil\tmarktr}%
27986 %% \vfil
27987 %% \hb@xt@\paperwidth{\trimmarkscolor\tmarkml\hfil\tmarkmr}%
27988 %% \vfil
27989 %% \hb@xt@\paperwidth{\trimmarkscolor\tmarkbl\hfil\tmarkbm\hfil\tmarkbr}}%
27990 %% \hss}%
27991 %% \vss}}%
27992 %% }
27993 }
27994
27995 % \end{macrocode}
27996 % \end{macro}
27997 % \end{macro}
27998 %
27999 %
28000 % As of the format update 2020/10/01 a hooking mechanism was added
28001 % to the kernel. One of these provides a hook into the background of
28002 % the shipped out pages, ideal for adding trimmarks. This hooking
28003 % system saves us from messing with \cmd{\shipout} direction (in
28004 % potentially incompatible ways).
28005 %
28006 % \changes{v3.7m}{2020/08/05}{Applying a format check and adding
28007 % trimmarks via hook if available}
28008 %
28009 % Note that the hook will be named \texttt{memoir/trimmarks} of easy
28010 % reference if one ever need to do some order readjustments. See
28011 % \cite{LTHOOKS,LTSHIPOUT} for more details on the hooking system. The
28012 % extra \cmd{\ifshowtrims} inside the hook is to accommodate for the
28013 % \cmd{\showtrimson}/\cmd{\showtrimsoff} commands which can be
28014 % adjusted after the hook was added.
28015 % \changes{v3.8.4}{2025/09/24}{Removed format check}
28016 % \begin{macrocode}
28017 \renewcommand\mem@trimmarks@initial@vskip{}
28018 \renewcommand\mem@trimmarks@initial@hskip{}
28019 \ifshowtrims
28020 \AddToHook{shipout/background}[./trimmarks]{%
28021 \ifshowtrims\put(0,0){\trimmarks}\fi
28022 }
28023 \fi
28024
28025 % \end{macrocode}
28026 % ^^A % Here follows then the old code where Any marks are put onto the pages by adding to the \cs{shipout}
28027 % ^^A % routine.
28028 % ^^A %
28029 % ^^A % \begin{macro}{\mem@oldshipout}
28030 % ^^A % Keep a copy of the current version of \cs{shipout} in \cs{mem@oldshipout}.
28031 % ^^A % \begin{macrocode}
28032 % ^^A \let\mem@oldshipout\shipout
28033 % ^^A % \end{macrocode}
28034 % ^^A % \end{macro}
28035 % ^^A %
28036 % ^^A % \begin{macro}{\mem@shipi}
28037 % ^^A % \begin{macro}{\mem@shipii}
28038 % ^^A % Effectively these will add the \cs{trimmarks} to the box holding
28039 % ^^A % the contents of the page. Note that any \cs{makeindex} must come
28040 % ^^A % \emph{before} \Lpack{pagesel} (and \Lpack{selectp}) package.
28041 % ^^A % \changes{v1.618}{2005/09/03}{Changed \cs{mem@shipii} for the pagesel package,
28042 % ^^A % courtesy James Szinger (mempatch v311)}
28043 % ^^A % \changes{v1.61803}{2008/01/30}{Added \cs{ifshowtrims} to \cs{mem@shipii}
28044 % ^^A % (mempatch v4.5)}
28045 % ^^A % \changes{v1.6180339f}{2009/06/24}{Added Dan Luecking's fix to
28046 % ^^A % \cs{mem@shippii} to cater for another merry hyperref change!}
28047 % ^^A % \changes{v1.6180339c}{2009/11/13}{Replaced Dans fix with a fix from
28048 % ^^A % Heiko Oberdiek}
28049 % ^^A % \begin{macrocode}
28050 % ^^A \newcommand*{\mem@shipi}{%
28051 % ^^A \ifvoid\@cclv\expandafter\aftergroup\fi\mem@shipii}
28052 % ^^A \newcommand*\mem@shipii{%
28053 % ^^A \ifvoid\@cclv
28054 % ^^A \mem@oldshipout\box\@cclv
28055 % ^^A \else
28056 % ^^A \ifshowtrims
28057 % ^^A % \end{macrocode}
28058 % ^^A % Heiko Oberdiek responded to a problem reported by Rolf
28059 % ^^A % Niepraschk. The earlier implementation might cause the output box to
28060 % ^^A % be shifted. Heikos explanation (in response to the line
28061 % ^^A % \verb?\mem@oldshipout\vbox{\trimmarks\ifvbox\@cclv\unvbox\else\box\fi\@cclv}?) :
28062 % ^^A % \begin{verbatim}
28063 % ^^A % In vertical mode (\mem@oldshipout\vbox{...}) TeX puts
28064 % ^^A % interline skip between two boxes (\trimmarks and \@cclv),
28065 % ^^A % here \linekskip (1pt) is put inbetween causing the
28066 % ^^A % shift downwards.
28067 % ^^A % \end{verbatim}
28068 % ^^A % Heiko also provided the fix used below. Actually Heikos fix also
28069 % ^^A % fixes a problem that might cause glue settings to disappear.
28070 % ^^A % \begin{macrocode}
28071 % ^^A \mem@oldshipout\vbox{%
28072 % ^^A \trimmarks
28073 % ^^A \nointerlineskip
28074 % ^^A \box\@cclv
28075 % ^^A }%
28076 % ^^A \else
28077 % ^^A \mem@oldshipout\box\@cclv
28078 % ^^A \fi
28079 % ^^A \fi}
28080 % ^^A % \end{macrocode}
28081 % ^^A % \end{macro}
28082 % ^^A % \end{macro}
28083 % ^^A %
28084 % ^^A % \begin{macro}{\shipout}
28085 % ^^A % Our new version of \cs{shipout}, which is only needed for the
28086 % ^^A % \Lopt{showtrims} option. This adds \cs{mem@shipi} to the page box
28087 % ^^A % which then calls the original version of \cs{shipout}.
28088 % ^^A % \begin{macrocode}
28089 % ^^A \ifshowtrims
28090 % ^^A \renewcommand*{\shipout}{\afterassignment\mem@shipi\setbox\@cclv=}
28091 % ^^A \fi
28092 % ^^A % \end{macrocode}
28093 % ^^A % \end{macro}
28094 % ^^A % \begin{macrocode}
28095 % ^^A } % end format check, else part
28096 % ^^A
28097 % ^^A % \end{macrocode}
28098 % ^^A %
28099 %
28100 % \section{Verbatims, boxes, and files}
28101 %
28102 %
28103 % Until January 2024 the class contained an embedded and modified
28104 % version of the \Lpack{verbatim} package where PW had added some
28105 % extra features to the verbatim system. As time have progressed the
28106 % LaTeX team has taken all the required tool packages under their wing
28107 % and continuously update them. Thus is it unfeasible to embed a
28108 % package like \Lpack{verbatim} anymore. The embeded copy have
28109 % therefore been replaced by simply loading the \Lpack{verbatim}
28110 % package.
28111 %
28112 % Eventhough we could patch in the changed PW made to \Lpack{verbatim}
28113 % we've decided against it. The two features he added was marking tabs
28114 % using a number of spaces (turned off by default) and enabling line
28115 % breaks at white space (turned off by default). It simply gets to
28116 % messy trying to patch in both features, given that the number of
28117 % users using it is probably very low.
28118 %
28119 % Note that our modified copy of \Lpack{verbatim} had all references
28120 % to \cs{leftskip} and \cs{rightskip} replaced by \cs{memRTLleftskip}
28121 % and \cs{memRTLrightskip}. For now we have no intention of patching
28122 % these into the \Lpack{verbatim} code, but it should be straight
28123 % forward if needed.
28124 %
28125 % \subsection{Additions to the verbatim package}
28126 %
28127 % \changes{v3.8.2}{2024/01/24}{Replaced embedded altered copy of
28128 % \Lpack{verbatim} with loading the package}
28129 % Load the package instead of embedding it.
28130 % \begin{macrocode}
28131 \RequirePackage{verbatim}
28132 % \end{macrocode}
28133 %
28134 % A future update (\verb|github #1245|) to \Lpack{verbatim} will enable
28135 % \cs{verbatiminput*} to mark tabs as if it was spaces. If that
28136 % version has not been released yet, we add the patch
28137 % \begin{macrocode}
28138 \@ifpackagelater{verbatim}{2024/01/21}{}{
28139 \def\verbatiminput{\begingroup
28140 \@ifstar{\verbatim@input{\@setupverbvisiblespace\@vobeyspaces}}%
28141 {\verbatim@input{\frenchspacing\@vobeyspaces}}}
28142 }
28143
28144 % \end{macrocode}
28145 % it of course requires an updated kernel.
28146 %
28147 % \begin{macro}{\setverbatimfont}
28148 % \begin{macro}{\m@mverbfont}
28149 % We do provide an interface to set the font used in
28150 % verbatims. Internally in \Lpack{verbatim} this is done via \cs{verbatim@font}.
28151 % \begin{macrocode}
28152 \newcommand{\setverbatimfont}[1]{\def\m@mverbfont{#1}}
28153 \setverbatimfont{\normalfont\ttfamily}
28154 \patchcmd\verbatim@font{\normalfont\ttfamily}%
28155 {\m@mverbfont}%
28156 {}%
28157 {\typeout{Paching \string\verbatim@font\space failed}}
28158
28159 % \end{macrocode}
28160 % \end{macro}
28161 % \end{macro}
28162 %
28163 % % \subsubsection{The \texttt{comment} environment}
28164 %
28165 % The \Lpack{verbatim} package provides the \Lenv{comment} environment
28166 % that ignores its contents. This is a very useful feature, and we
28167 % would like users to be able todefine their own \Lenv{comment} like
28168 % envs. The following code is PWs original code, only difference is
28169 % that we do not define \Lenv{comment} using the code. We leave the
28170 % \Lpack{verbatim} alone.
28171 % % \begin{macro}{\setupcomment}
28172 % \cs{setupcomment} does all the \cs{let}s in the original \cs{comment} code. For reference see the \cite{VERBATIM} sources.
28173 % \begin{macrocode}
28174 \newcommand{\setupcomment}{%
28175 \let\do\@makeother\dospecials\catcode`\^^M\active
28176 \let\verbatim@startline\relax
28177 \let\verbatim@addtoline\@gobble
28178 \let\verbatim@processline\relax
28179 \let\verbatim@finish\relax}
28180 % \end{macrocode}
28181 % \end{macro}
28182 %
28183 % The macros below do no checking to see if something has (not) been defined
28184 % previously. It's `user beware' time.
28185 %
28186 % \begin{macro}{\newcomment}
28187 % \cs{newcomment}\marg{name} creates a new comment environment called
28188 % \meta{name}. This is a generalisation of the original comment code.
28189 % \begin{macrocode}
28190 \newcommand{\newcomment}[1]{%
28191 \expandafter\def\csname #1\endcsname{\@bsphack\setupcomment\verbatim@}%
28192 \expandafter\let\csname end#1\endcsname=\@esphack}
28193 % \end{macrocode}
28194 % \end{macro}
28195 %
28196 % \begin{macro}{\commentsoff}
28197 % \cs{commentsoff}\marg{name} switches off the \meta{name} comment
28198 % environment by defining the relevent macros to do nothing.
28199 % \begin{macrocode}
28200 \newcommand{\commentsoff}[1]{%
28201 \expandafter\def\csname #1\endcsname{}%
28202 \expandafter\def\csname end#1\endcsname{}}
28203 % \end{macrocode}
28204 % \end{macro}
28205 %
28206 % \begin{macro}{\commentson}
28207 % \cs{commentson}\marg{name} switches on the \meta{name} comment
28208 % environment. It has to do the same things as \cs{newcomment} does,
28209 % so let \cs{newcomment} do the work.
28210 % \begin{macrocode}
28211 \newcommand{\commentson}[1]{\newcomment{#1}}
28212
28213 % \end{macrocode}
28214 % \end{macro}
28215 %
28216 %
28217 %
28218 % \subsubsection{Disabled interface macros}
28219 %
28220 % These are macros that via the un-embedding are no longer
28221 % used. Relevant macros are defined to to issue a warning, others just
28222 % does not do anything.
28223 %
28224 % \changes{v3.8.2}{2024/01/24}{Added defaults for disabled macros}
28225 % Macros for enabling marking tabs in verbatim, have been
28226 % discontinued.
28227 % \begin{macrocode}
28228 \newcommand*\tabsoff{} % defined to do nothing
28229 \newcommand*\tabson{
28230 \@memwarn{As of January 2024, \string\tabson\space has been discontinued.}
28231 }
28232
28233 % \end{macrocode}
28234 %
28235 % Code for automatic line breaking in verbatim has been discontinued.
28236 % \begin{macrocode}
28237 \newlength\verbatimindent
28238 \newcommand*\verbatimbreakchar{} % silently does nothing as it
28239 % needs \wrappingon to be enabled
28240 \newcommand*\setverbatimbreak{} % never used
28241 \newcommand*\wrappingon{
28242 \@memwarn{As of January 2024, \string\wrappingon\space has been discontinued.}
28243 }
28244 \newcommand*\wrappingoff{} % defined to do nothing
28245 \def\wrapright{} % internal macro no longer used
28246 % \end{macrocode}
28247 %
28248 %
28249 % \subsubsection{About the \texttt{verbatim} adjustments that have been removed}
28250 %
28251 % The adjustments PW made that we removed (in January 2024) can
28252 % actually be patched back in using the following code and
28253 % patches. Left here for reference. Will probably be removed at some
28254 % point.
28255 %
28256 % First the code needed by the patches
28257 % \begin{verbatim}
28258 % % extra hook to be added at the end of verbatims
28259 % \newtoks\afterevery@verbatim
28260 % \afterevery@verbatim={}
28261 % % code for marking tabs using a number of spaces
28262 % \newcount\tab@position
28263 % \def\mem@xobeytab{%
28264 % \typeout{\the\tab@position}
28265 % \loop
28266 % \toks@\expandafter{\the\toks@\@xobeysp}%
28267 % \advance\tab@position-1
28268 % \ifnum\tab@position>-1 \repeat% was 0, but that never gave 4 spaces
28269 % }
28270 % \def\verbatim@tabexpand#1{%
28271 % \ifx#1\@nil
28272 % \the\toks@
28273 % \expandafter\par
28274 % \else
28275 % \ifx#1\@xobeytab
28276 % \@xobeytab
28277 % \else
28278 % \toks@\expandafter{\the\toks@#1}%
28279 % \advance\tab@position\m@ne
28280 % \fi
28281 % \ifnum\tab@position=0 \tab@position\tab@size \fi
28282 % \expandafter\verbatim@tabexpand
28283 % \fi
28284 % }
28285 % \newif\ift@bs
28286 % \def\@maybeobeytabs{}%
28287 % % The code to enable marking tabs
28288 % \newcommand{\tabson}[1][4]{%
28289 % % firstly, has to be at least 1, so if less than one, we disable visible tabs
28290 % \ifnum\@ne > #1\relax
28291 % \typeout{#1 gives tabs off}
28292 % \tabsoff
28293 % \else
28294 % \t@bstrue
28295 % \let\@xobeytab\mem@xobeytab
28296 % \def\tab@size{#1\relax}%
28297 % \def\@maybeobeytabs{\@vobeytabs}%
28298 % \fi
28299 % }
28300 % \newcommand{\tabsoff}{%
28301 % \t@bsfalse
28302 % \def\tab@size{\z@}%
28303 % \def\@maybeobeytabs{}%
28304 % }
28305 % % default is off
28306 % \tabsoff
28307 % % \verbatim@processline is redefined to this in certain places if tabs are on
28308 % \def\tabverbatim@processline{\tab@position\tab@size%
28309 % \toks@{}%
28310 % \expandafter\verbatim@tabexpand\the\verbatim@line\@nil}
28311 % % Code for the wrapping system, \cs{raggedwrap} was moved
28312 % % elsewhere in the code so is still there.
28313 % \newcommand*{\wrappingon}{%
28314 % \def\@xobeysp{~\discretionary{\verbatimbreakchar}%
28315 % {\kern\verbatimindent}{}}%
28316 % \def\wrapright{\raggedwrap}}
28317 % \newcommand*{\wrappingoff}{%
28318 % \def\@xobeysp{\leavevmode\penalty\@M\ }%
28319 % \def\wrapright{}}
28320 % \wrappingoff
28321 % \end{verbatim}
28322 %
28323 % Next the actual patching
28324 % \begin{verbatim}
28325 % % % patch \@verbatim, two changes
28326 % % firstly change leftskip into the memoir aliases
28327 % \patchcmd\@verbatim{%
28328 % \leftskip\@totalleftmargin\rightskip\z@%
28329 % }{%
28330 % \memRTLleftskip\@totalleftmargin\memRTLrightskip\z@%
28331 % }{}{\typeout{first patch for \string\@verbatim\space failed}}
28332 % % secondly add the wrapping code at the very end, we could probably
28333 % % use the macro hook here
28334 % \patchcmd\@verbatim{%
28335 % \everypar \expandafter{\the\everypar \unpenalty}%
28336 % }{%
28337 % \everypar \expandafter{\the\everypar \unpenalty}%
28338 % \wrapright\the\afterevery@verbatim%
28339 % }{}{\typeout{second patch for \string\@verbatim\space failed}}
28340 %
28341 % % add tabs support for \verbatim
28342 % \patchcmd\verbatim{\begingroup\@verbatim}{%
28343 % \begingroup%
28344 % \ift@bs%
28345 % \def\verbatim@processline{\tabverbatim@processline}%
28346 % \fi%
28347 % \@verbatim%
28348 % }{}{\typeout{Patch 1 for \string\verbatim\space failed}}
28349 % % add tab support
28350 % \patchcmd\verbatim{\@vobeyspaces}{%
28351 % \@vobeyspaces\@maybeobeytabs%
28352 % }{}{\typeout{Patch 2 for \string\verbatim\space failed}}
28353 %
28354 % \expandafter\patchcmd\expandafter{\csname verbatim*\endcsname}%
28355 % {\begingroup\@verbatim}{%
28356 % \begingroup%
28357 % \ift@bs%
28358 % \def\verbatim@processline{\tabverbatim@processline}%
28359 % \def\@setupverbvisibletab{}% remove redef of \@xobeytab
28360 % \fi%
28361 % \@verbatim%
28362 % }{}{\typeout{Patch 1 for \string\verbatim*\space failed}}
28363 % \expandafter\patchcmd\expandafter{\csname verbatim*\endcsname}%
28364 % {\@vobeyspaces}{%
28365 % \@vobeyspaces\@maybeobeytabs%
28366 % }{}{\typeout{Patch 2 for \string\verbatim*\space failed}}
28367 %
28368 % patches for \verbatiminput, there are 3
28369 % \patchcmd\verbatiminput{\begingroup\@ifstar}{%
28370 % \begingroup%
28371 % \ift@bs%
28372 % \def\verbatim@processline{\tabverbatim@processline}%
28373 % \fi%
28374 % \@ifstar%
28375 % }{}{\typeout{Patch 1 for \string\verbatiminput\space failed}}
28376 %
28377 % \patchcmd\verbatiminput{\@ifstar{\verbatim@input\relax}}{%
28378 % \@ifstar{\verbatim@input{\@maybeobeytabs}}%
28379 % }{}{\typeout{Patch 2 for \string\verbatiminput\space failed}}
28380 %
28381 % \patchcmd\verbatiminput{\frenchspacing\@vobeyspaces}{%
28382 % \frenchspacing\@vobeyspaces\@maybeobeytabs%
28383 % }{}{\typeout{Patch 3 for \string\verbatiminput\space failed}}
28384 %
28385 % \end{verbatim}
28386 %
28387 %
28388 %
28389 %
28390 % ^^A % All the code in this section was added for version 1.2 of the class.
28391 % ^^A % \changes{v1.2}{2002/07/27}{Section `Verbatims, boxes and files' added}
28392 % ^^A %
28393 % ^^A % \subsection{Modified version of the verbatim package}
28394 % ^^A %
28395 % ^^A % \noindent{\color{red}\rule\textwidth{5mm}}
28396 % ^^A %
28397 % ^^A % Much of this is from the \Lpack{verbatim} package code~\cite{VERBATIM}.
28398 % ^^A % Unless indicated otherwise, the code and commentary is from that
28399 % ^^A % package.
28400 % ^^A %
28401 % ^^A %
28402 % ^^A % \subsubsection{Preliminaries}
28403 % ^^A %
28404 % ^^A % \begin{macro}{\every@verbatim}
28405 % ^^A % \begin{macro}{\afterevery@verbatim}
28406 % ^^A % The hook (i.e., token register) \cs{every@verbatim}
28407 % ^^A % is initialized to \meta{empty}.
28408 % ^^A %
28409 % ^^A % PW added the \cs{afterevery@verbatim} hook.
28410 % ^^A % \begin{macrocode}
28411 % ^^A \newtoks\every@verbatim
28412 % ^^A \every@verbatim={}
28413 % ^^A \newtoks\afterevery@verbatim
28414 % ^^A \afterevery@verbatim={}
28415 % ^^A
28416 % ^^A % \end{macrocode}
28417 % ^^A % \end{macro}
28418 % ^^A % \end{macro}
28419 % ^^A %
28420 % ^^A %
28421 % ^^A % \begin{macro}{\@makeother}
28422 % ^^A % \cs{@makeother} takes as argument a character and changes
28423 % ^^A % its category code to $12$ (other).
28424 % ^^A % \begin{macrocode}
28425 % ^^A \def\@makeother#1{\catcode`#112\relax}
28426 % ^^A % \end{macrocode}
28427 % ^^A % \end{macro}
28428 % ^^A %
28429 % ^^A %
28430 % ^^A % \begin{macro}{\@vobeyspaces}
28431 % ^^A % The macro \cs{@vobeyspaces} causes spaces in the input
28432 % ^^A % to be printed as spaces in the output.
28433 % ^^A %
28434 % ^^A % In the Nov-2023 kernel update, some changes were made to how
28435 % ^^A % \verb|\verb| handles tabs. We need to adjust accordingly. Note
28436 % ^^A % that it will be better to just load the \Lpack{verbatim} package
28437 % ^^A % and make adjustments to it. The fix comes from \url{https://github.com/latex3/latex2e/issues/1160#issuecomment-1793564381}.
28438 % ^^A % \changes{v3.8.2}{2023/11/07}{Added fix for kernel update}
28439 % ^^A % \begin{macrocode}
28440 % ^^A \begingroup
28441 % ^^A \catcode`\ =\active%
28442 % ^^A \IfFormatAtLeastTF{2023-11-01}%
28443 % ^^A % active spaces at line beginning are absorbed as macro arguments
28444 % ^^A {\def\x{\def\@vobeyspaces{\catcode`\ \active\let \@xobeysp\@vobeytabs}}}%
28445 % ^^A {\def\x{\def\@vobeyspaces{\catcode`\ \active\let \@xobeysp}}}%
28446 % ^^A % was: \def\x{\def\@vobeyspaces{\catcode`\ \active\let \@xobeysp}}
28447 % ^^A \expandafter\endgroup\x
28448 % ^^A % \end{macrocode}
28449 % ^^A % \end{macro}
28450 % ^^A %
28451 % ^^A %
28452 % ^^A % \begin{macro}{\@xobeysp}
28453 % ^^A % The macro \cs{@xobeysp} produces exactly one space in
28454 % ^^A % the output, protected against breaking just before it.
28455 % ^^A % (\cs{@M} is an abbreviation for the number $10000$.)
28456 % ^^A % \begin{macrocode}
28457 % ^^A \def\@xobeysp{\leavevmode\penalty\@M\ }
28458 % ^^A % \end{macrocode}
28459 % ^^A % \end{macro}
28460 % ^^A %
28461 % ^^A %
28462 % ^^A % \begin{macro}{\verbatim@line}
28463 % ^^A % We use a newly defined token register called \cs{verbatim@line}
28464 % ^^A % that will be used as the character buffer.
28465 % ^^A % \begin{macrocode}
28466 % ^^A \newtoks\verbatim@line
28467 % ^^A % \end{macrocode}
28468 % ^^A % \end{macro}
28469 % ^^A %
28470 % ^^A % PW. I have extended the original \Lpack{verbatim} package code to handle
28471 % ^^A % TABs within verbatims. Normally TeX replaces a TAB by either a single space or
28472 % ^^A % ignores it altogether. For this purpose I have bits of code from the \Lpack{moreverb}
28473 % ^^A % package~\cite{MOREVERB} for handling TABs.
28474 % ^^A %
28475 % ^^A % \textit{Code and commentary from moreverb.}
28476 % ^^A %
28477 % ^^A % We define a few auxiliary macros and counters for expanding tabs.
28478 % ^^A % \begin{macrocode}
28479 % ^^A \newcount\tab@position
28480 % ^^A % \end{macrocode}
28481 % ^^A %
28482 % ^^A % \begin{macro}{\@xobeytab}
28483 % ^^A % \cs{@xobeytab} puts enough spaces in to get to the next nominal
28484 % ^^A % tab stop
28485 % ^^A % \begin{macrocode}
28486 % ^^A \def\@xobeytab{%
28487 % ^^A \loop
28488 % ^^A \toks@\expandafter{\the\toks@\@xobeysp}%
28489 % ^^A \advance\tab@position-1
28490 % ^^A \ifnum\tab@position>0 \repeat
28491 % ^^A }
28492 % ^^A % \end{macrocode}
28493 % ^^A % \end{macro}
28494 % ^^A %
28495 % ^^A % \begin{macro}{\@vobeytabs}
28496 % ^^A % \cs{@vobeytabs} initialises use of \cs{@xobeytab}. Needs to be
28497 % ^^A % executed within a group, as mustn't be allowed to leak out into the
28498 % ^^A % wide world.
28499 % ^^A %
28500 % ^^A % \begin{macrocode}
28501 % ^^A \begingroup
28502 % ^^A \catcode`\^^I=\active
28503 % ^^A \gdef\@vobeytabs{\catcode`\^^I\active\let^^I\@xobeytab}%
28504 % ^^A \endgroup
28505 % ^^A % \end{macrocode}
28506 % ^^A % \end{macro}
28507 % ^^A %
28508 % ^^A % \begin{macro}{\verbatim@tabexpand}
28509 % ^^A % \cs{verbatim@tabexpand}\marg{body of line}\cs{@nil} processes every
28510 % ^^A % character of a line by tail recursion, counting the characters and
28511 % ^^A % juggling things when a tab is encountered.
28512 % ^^A % \begin{macrocode}
28513 % ^^A \def\verbatim@tabexpand#1{%
28514 % ^^A \ifx#1\@nil
28515 % ^^A \the\toks@
28516 % ^^A \expandafter\par
28517 % ^^A \else
28518 % ^^A \ifx#1\@xobeytab
28519 % ^^A \@xobeytab
28520 % ^^A \else
28521 % ^^A % \end{macrocode}
28522 % ^^A %
28523 % ^^A % We can safely put \cs{@xobeysp} into the token register, since it
28524 % ^^A % does precisely what we need
28525 % ^^A % \begin{macrocode}
28526 % ^^A \toks@\expandafter{\the\toks@#1}%
28527 % ^^A \advance\tab@position\m@ne
28528 % ^^A \fi
28529 % ^^A \ifnum\tab@position=0 \tab@position\tab@size \fi
28530 % ^^A \expandafter\verbatim@tabexpand
28531 % ^^A \fi
28532 % ^^A }
28533 % ^^A
28534 % ^^A % \end{macrocode}
28535 % ^^A % \end{macro}
28536 % ^^A %
28537 % ^^A % \textit{End of code and commentary from moreverb.}
28538 % ^^A %
28539 % ^^A % PW. Some macros for turning tabbing on and off.
28540 % ^^A %
28541 % ^^A % \begin{macro}{\tabson}
28542 % ^^A % \begin{macro}{\tabsoff}
28543 % ^^A % \begin{macro}{\@maybeobeytabs}
28544 % ^^A % \cs{tabson} turns tabbing on, and \cs{tabsoff} turns it off. Default
28545 % ^^A % is no tabbing.
28546 % ^^A % \begin{macrocode}
28547 % ^^A \newif\ift@bs
28548 % ^^A \newcommand{\tabson}[1][4]{%
28549 % ^^A \ifnum\@ne > #1\relax
28550 % ^^A \tabsoff
28551 % ^^A \else
28552 % ^^A \t@bstrue
28553 % ^^A \def\tab@size{#1\relax}%
28554 % ^^A \def\@maybeobeytabs{\@vobeytabs}%
28555 % ^^A \fi
28556 % ^^A }
28557 % ^^A \newcommand{\tabsoff}{%
28558 % ^^A \t@bsfalse
28559 % ^^A \def\tab@size{\z@}%
28560 % ^^A \def\@maybeobeytabs{}%
28561 % ^^A }
28562 % ^^A \tabsoff
28563 % ^^A
28564 % ^^A % \end{macrocode}
28565 % ^^A % \end{macro}
28566 % ^^A % \end{macro}
28567 % ^^A % \end{macro}
28568 % ^^A %
28569 % ^^A % \begin{macro}{\tabverbatim@processline}
28570 % ^^A % Process a line with TABs (extracted from \Lpack{moreverb}).
28571 % ^^A % \begin{macrocode}
28572 % ^^A \def\tabverbatim@processline{\tab@position\tab@size
28573 % ^^A \toks@{}%
28574 % ^^A \expandafter\verbatim@tabexpand\the\verbatim@line\@nil}
28575 % ^^A % \end{macrocode}
28576 % ^^A % \end{macro}
28577 % ^^A %
28578 % ^^A % \begin{macro}{\notabverbatim@processline}
28579 % ^^A % Processes a line ignoring TABs (this is the original \Lpack{verbatim}
28580 % ^^A % package definition of \cs{verbatim@processline}).
28581 % ^^A % \begin{macrocode}
28582 % ^^A \def\notabverbatim@processline{\the\verbatim@line\par}
28583 % ^^A
28584 % ^^A % \end{macrocode}
28585 % ^^A % \end{macro}
28586 % ^^A %
28587 % ^^A % \textit{We are now back to the \Lpack{verbatim} code.}
28588 % ^^A %
28589 % ^^A % The following four macros are defined globally in a way suitable for
28590 % ^^A % the \texttt{verbatim} and \texttt{verbatim*} environments.
28591 % ^^A % \begin{macro}{\verbatim@startline}
28592 % ^^A % \begin{macro}{\verbatim@addtoline}
28593 % ^^A % \begin{macro}{\verbatim@processline}
28594 % ^^A % \cs{verbatim@startline} initializes processing of a line
28595 % ^^A % by emptying the character buffer (\cs{verbatim@line}).
28596 % ^^A % \begin{macrocode}
28597 % ^^A \def\verbatim@startline{\verbatim@line{}}
28598 % ^^A % \end{macrocode}
28599 % ^^A % \cs{verbatim@addtoline} adds the tokens in its argument
28600 % ^^A % to our buffer register \cs{verbatim@line} without expanding
28601 % ^^A % them.
28602 % ^^A % \begin{macrocode}
28603 % ^^A \def\verbatim@addtoline#1{%
28604 % ^^A \verbatim@line\expandafter{\the\verbatim@line#1}}
28605 % ^^A % \end{macrocode}
28606 % ^^A % Processing a line inside a \texttt{verbatim} or \texttt{verbatim*}
28607 % ^^A % environment means printing it.
28608 % ^^A % Ending the line means that we have to begin a new paragraph.
28609 % ^^A % We use \cs{par} for this purpose. Note that \cs{par}
28610 % ^^A % is redefined in \cs{@verbatim} to force \TeX{} into horizontal
28611 % ^^A % mode and to insert an empty box so that empty lines in the input
28612 % ^^A % do appear in the output.
28613 % ^^A % (PW changed next line from \\
28614 % ^^A % \verb?\def\verbatim@processline{\the\verbatim@line\par}?
28615 % ^^A % \begin{macrocode}
28616 % ^^A \def\verbatim@processline{\notabverbatim@processline}
28617 % ^^A % \end{macrocode}
28618 % ^^A % \end{macro}
28619 % ^^A % \end{macro}
28620 % ^^A % \end{macro}
28621 % ^^A %
28622 % ^^A % \begin{macro}{\verbatim@finish}
28623 % ^^A % As a default, \cs{verbatim@finish} processes the remaining
28624 % ^^A % characters.
28625 % ^^A % When this macro is called we are facing the following problem:
28626 % ^^A % when the \verb?\end{verbatim}?
28627 % ^^A % command is encountered \cs{verbatim@processline} is called
28628 % ^^A % to process the characters preceding the command on the same
28629 % ^^A % line. If there are none, an empty line would be output if we
28630 % ^^A % did not check for this case.
28631 % ^^A %
28632 % ^^A % If the line is empty \verb?\the\verbatim@line? expands to
28633 % ^^A % nothing. To test this we use a trick similar to that on p.\ 376
28634 % ^^A % of the \TeX{}book, but with \verb?$?\ldots\verb?|$? instead of
28635 % ^^A % the \verb?!? tokens. These \verb?$? tokens can never have the same
28636 % ^^A % category code as a \verb?$? token that might possibly appear in the
28637 % ^^A % token register \cs{verbatim@line}, as such a token will always have
28638 % ^^A % been read with category code $12$ (other).
28639 % ^^A % Note that \cs{ifcat} expands the following tokens so that
28640 % ^^A % \verb?\the\verbatim@line? is replaced by the accumulated
28641 % ^^A % characters
28642 % ^^A % \begin{macrocode}
28643 % ^^A \def\verbatim@finish{\ifcat$\the\verbatim@line$\else
28644 % ^^A \verbatim@processline\fi}
28645 % ^^A % \end{macrocode}
28646 % ^^A % \end{macro}
28647 % ^^A %
28648 % ^^A %
28649 % ^^A % \subsubsection{The \texttt{verbatim} and \texttt{verbatim*} environments}
28650 % ^^A %
28651 % ^^A % \begin{macro}{\verbatim@font}
28652 % ^^A % We start by defining the macro \cs{verbatim@font} that is
28653 % ^^A % to select the font and to set font-dependent parameters.
28654 % ^^A % Then we go through \cs{verbatim@nolig@list} to avoid
28655 % ^^A % certain ligatures.
28656 % ^^A % \cs{verbatim@nolig@list} is a macro defined in the \LaTeXe{} kernel
28657 % ^^A % to expand to
28658 % ^^A % \begin{verbatim}
28659 % ^^A % \do\`\do\<\do\>\do\,\do\'\do\-
28660 % ^^A % \end{verbatim}
28661 % ^^A % All the characters in this list can be part of a ligature in some
28662 % ^^A % font or other.
28663 % ^^A %
28664 % ^^A % PW. This is the original version which I'm going to replace.
28665 % ^^A % \begin{verbatim}
28666 % ^^A % \def\verbatim@font{\normalfont\ttfamily
28667 % ^^A % \hyphenchar\font\m@ne
28668 % ^^A % \let\do\do@noligs
28669 % ^^A % \verbatim@nolig@list}
28670 % ^^A % \end{verbatim}
28671 % ^^A % Actually the kernel defines the macro \verb+\@noligs+ which just
28672 % ^^A % runs the last two lines of the \verb+\verbatim@font+ above. As other
28673 % ^^A % package may add stuff to \verb+\@noligs+, we will use that instead.
28674 % ^^A % \end{macro}
28675 % ^^A %
28676 % ^^A % \begin{macro}{\setverbatimfont}
28677 % ^^A % \begin{macro}{\m@mverbfont}
28678 % ^^A % \begin{macro}{\verbatim@font}
28679 % ^^A % User level handle for changing the font used for verbatim text.
28680 % ^^A % \changes{v1.61803398}{2009/09/10}{Changed the last two lines of
28681 % ^^A % \cs{verbatim@font} into using \cs{@noligs} instead. This fixes
28682 % ^^A % problem with upquote.}
28683 % ^^A % \begin{macrocode}
28684 % ^^A \newcommand{\setverbatimfont}[1]{\def\m@mverbfont{#1}}
28685 % ^^A \setverbatimfont{\normalfont\ttfamily}
28686 % ^^A
28687 % ^^A \def\verbatim@font{\m@mverbfont
28688 % ^^A \hyphenchar\font\m@ne
28689 % ^^A \@noligs}
28690 % ^^A
28691 % ^^A % \end{macrocode}
28692 % ^^A % \end{macro}
28693 % ^^A % \end{macro}
28694 % ^^A % \end{macro}
28695 % ^^A %
28696 % ^^A %
28697 % ^^A % \begin{macro}{\@verbatim}
28698 % ^^A % The macro \cs{@verbatim} sets up things properly.
28699 % ^^A % First of all, the tokens of the \cs{every@verbatim} hook
28700 % ^^A % are inserted.
28701 % ^^A % Then a \texttt{trivlist} environment is started and its first
28702 % ^^A % \cs{item} command inserted.
28703 % ^^A % Each line of the \texttt{verbatim} or \texttt{verbatim*}
28704 % ^^A % environment will be treated as a separate paragraph.
28705 % ^^A % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{@verbatim}}
28706 % ^^A % \begin{macrocode}
28707 % ^^A \def\@verbatim{\the\every@verbatim
28708 % ^^A \trivlist \item \relax
28709 % ^^A % \end{macrocode}
28710 % ^^A % The following extra vertical space is for compatibility with the
28711 % ^^A % \LaTeX kernel: otherwise, using the \Lpack{verbatim} package changes
28712 % ^^A % the vertical spacing of a \texttt{verbatim} environment nested within a
28713 % ^^A % \texttt{quote} environment.
28714 % ^^A % \begin{macrocode}
28715 % ^^A \if@minipage\else\vskip\parskip\fi
28716 % ^^A % \end{macrocode}
28717 % ^^A % The paragraph parameters are set appropriately:
28718 % ^^A % the penalty at the beginning of the environment,
28719 % ^^A % left and right margins, paragraph indentation, the glue to
28720 % ^^A % fill the last line, and the vertical space between paragraphs.
28721 % ^^A % The latter space has to be zero since we do not want to add
28722 % ^^A % extra space between lines.
28723 % ^^A % \begin{macrocode}
28724 % ^^A \@beginparpenalty \predisplaypenalty
28725 % ^^A %%% \leftskip\@totalleftmargin\rightskip\z@
28726 % ^^A \memRTLleftskip\@totalleftmargin\memRTLrightskip\z@
28727 % ^^A \parindent\z@\parfillskip\@flushglue\parskip\z@
28728 % ^^A % \end{macrocode}
28729 % ^^A % There's one point to make here:
28730 % ^^A % the \texttt{list} environment uses \TeX's \cs{parshape}
28731 % ^^A % primitive to get a special indentation for the first line
28732 % ^^A % of the list.
28733 % ^^A % If the list begins with a \texttt{verbatim} environment
28734 % ^^A % this \cs{parshape} is still in effect.
28735 % ^^A % Therefore we have to reset this internal parameter explicitly.
28736 % ^^A % We could do this by assigning $0$ to \cs{parshape}.
28737 % ^^A % However, there is a simpler way to achieve this:
28738 % ^^A % we simply tell \TeX{} to start a new paragraph.
28739 % ^^A % As is explained on p.~103 of the \TeX{}book, this resets
28740 % ^^A % \cs{parshape} to zero.
28741 % ^^A % \begin{macrocode}
28742 % ^^A \@@par
28743 % ^^A % \end{macrocode}
28744 % ^^A % We now ensure that \cs{par} has the correct definition,
28745 % ^^A % namely to force \TeX{} into horizontal mode
28746 % ^^A % and to include an empty box.
28747 % ^^A % This is to ensure that empty lines do appear in the output.
28748 % ^^A % Afterwards, we insert the \cs{interlinepenalty} since \TeX{}
28749 % ^^A % does not add a penalty between paragraphs (here: lines)
28750 % ^^A % by its own initiative. Otherwise a \texttt{verbatim} environment
28751 % ^^A % could be broken across pages even if a \cs{samepage}
28752 % ^^A % declaration were present.
28753 % ^^A %
28754 % ^^A % However, in a top-aligned minipage, this will result in an extra
28755 % ^^A % empty line added at the top. Therefore, a slightly more
28756 % ^^A % complicated construct is necessary.
28757 % ^^A % One of the important things here is the inclusion of
28758 % ^^A % \cs{leavevmode} as the first macro in the first line, for example,
28759 % ^^A % a blank verbatim line is the first thing in a list item.
28760 % ^^A % \begin{macrocode}
28761 % ^^A \def\par{%
28762 % ^^A \if@tempswa
28763 % ^^A \leavevmode\null\@@par\penalty\interlinepenalty
28764 % ^^A \else
28765 % ^^A \@tempswatrue
28766 % ^^A \ifhmode\@@par\penalty\interlinepenalty\fi
28767 % ^^A \fi}%
28768 % ^^A % \end{macrocode}
28769 % ^^A % But to avoid an error message when the environment
28770 % ^^A % doesn't contain any text, we redefine \cs{@noitemerr}
28771 % ^^A % which will in this case be called by \cs{endtrivlist}.
28772 % ^^A % \begin{macrocode}
28773 % ^^A \def\@noitemerr{\@warning{No verbatim text}}%
28774 % ^^A % \end{macrocode}
28775 % ^^A % Now we call \cs{obeylines} to make the end of line character
28776 % ^^A % active,
28777 % ^^A % \begin{macrocode}
28778 % ^^A \obeylines
28779 % ^^A % \end{macrocode}
28780 % ^^A % change the category code of all special characters,
28781 % ^^A % to $12$ (other).
28782 % ^^A % \begin{macrocode}
28783 % ^^A \let\do\@makeother \dospecials
28784 % ^^A % \end{macrocode}
28785 % ^^A % and switch to the font to be used.
28786 % ^^A % \begin{macrocode}
28787 % ^^A \verbatim@font
28788 % ^^A % \end{macrocode}
28789 % ^^A % To avoid a breakpoint after the labels box, we remove the penalty
28790 % ^^A % put there by the list macros: another use of \cs{unpenalty}!
28791 % ^^A % \begin{macrocode}
28792 % ^^A \everypar \expandafter{\the\everypar \unpenalty}%
28793 % ^^A % \end{macrocode}
28794 % ^^A % PW added next code at end of \cs{@verbatim}.
28795 % ^^A % \begin{macrocode}
28796 % ^^A \wrapright\the\afterevery@verbatim}
28797 % ^^A % \end{macrocode}
28798 % ^^A % \end{macro}
28799 % ^^A %
28800 % ^^A %
28801 % ^^A % \begin{macro}{\verbatim}
28802 % ^^A % \begin{macro}{\verbatim*}
28803 % ^^A % Now we define the toplevel macros.
28804 % ^^A % \cs{verbatim} is slightly changed:
28805 % ^^A % after setting up things properly it calls
28806 % ^^A % \cs{verbatim@start}.
28807 % ^^A % This is done inside a group, so that \cs{verbatim} can be used
28808 % ^^A % directly, without \cs{begin}.
28809 % ^^A %
28810 % ^^A % PW. The following is the original code, but I want a version of
28811 % ^^A % \texttt{verbatim} that recognises TABs.
28812 % ^^A % \begin{verbatim}
28813 % ^^A % \begin{macrocode}
28814 % ^^A % \def\verbatim{%
28815 % ^^A % \begingroup\@verbatim \frenchspacing\@vobeyspaces
28816 % ^^A % \verbatim@start}
28817 % ^^A % \end{macrocode}
28818 % ^^A % \cs{verbatim*} is defined accordingly.
28819 % ^^A % \begin{macrocode}
28820 % ^^A % \@namedef{verbatim*}{\begingroup\@verbatim\verbatim@start}
28821 % ^^A % \def\endverbatim{\endtrivlist\endgroup}
28822 % ^^A % \expandafter\let\csname endverbatim*\endcsname=\endverbatim
28823 % ^^A % \end{macrocode}
28824 % ^^A % \end{verbatim}
28825 % ^^A %
28826 % ^^A % PW. My code for these is a modified version of the original \Lpack{verbatim}
28827 % ^^A % code.
28828 % ^^A % \begin{macrocode}
28829 % ^^A \def\verbatim{\begingroup
28830 % ^^A \ift@bs
28831 % ^^A \def\verbatim@processline{\tabverbatim@processline}%
28832 % ^^A \fi
28833 % ^^A \@verbatim \frenchspacing\@vobeyspaces\@maybeobeytabs\verbatim@start}
28834 % ^^A \@namedef{verbatim*}{\begingroup
28835 % ^^A \ift@bs
28836 % ^^A \def\verbatim@processline{\tabverbatim@processline}%
28837 % ^^A \fi
28838 % ^^A \@verbatim\@maybeobeytabs\verbatim@start}
28839 % ^^A % \end{macrocode}
28840 % ^^A % \end{macro}
28841 % ^^A % \end{macro}
28842 % ^^A %
28843 % ^^A %
28844 % ^^A % \begin{macro}{\endverbatim}
28845 % ^^A % \begin{macro}{\endverbatim*}
28846 % ^^A % To end the \texttt{verbatim} and \texttt{verbatim*}
28847 % ^^A % environments it is only necessary to finish the
28848 % ^^A % \texttt{trivlist} environment started in \cs{@verbatim} and
28849 % ^^A % close the corresponding group, and handle\footnote{Noted by
28850 % ^^A % Zarko Cucej.} following (non-) paragraph,
28851 % ^^A % by using \cs{@doendpe}.
28852 % ^^A % \changes{v1.4}{2003/11/22}{Added \cs{@doendpe} to \cs{endverbatim}
28853 % ^^A % (from patch v1.8)}
28854 % ^^A % \changes{v2.0a}{2004/03/01}{Refixed \cs{endverbatim}}
28855 % ^^A % \begin{macrocode}
28856 % ^^A \def\endverbatim{\endtrivlist\endgroup\@doendpe}
28857 % ^^A \@namelet{endverbatim*}\endverbatim
28858 % ^^A
28859 % ^^A % \end{macrocode}
28860 % ^^A % \end{macro}
28861 % ^^A % \end{macro}
28862 % ^^A %
28863 % ^^A % For abnormal \cs{parskip}s the NTG class included the following, but I'm
28864 % ^^A % not sure if it is relevant here, but if it is just how it should be included.
28865 % ^^A % \begin{verbatim}
28866 % ^^A % From NTG, where it is a \cs{def}
28867 % ^^A % \providecommand*{\verbatim}{%
28868 % ^^A % \topsep=-0.5\parskip
28869 % ^^A % \@verbatim
28870 % ^^A % \frenchspacing\@vobeyspaces \@xverbatim}
28871 % ^^A % \end{verbatim}
28872 % ^^A %
28873 % ^^A %
28874 % ^^A % \subsubsection{The \texttt{comment} environment}
28875 % ^^A %
28876 % ^^A % The \cs{comment} macro is similar to \cs{verbatim*}.
28877 % ^^A % However, we do not need to switch fonts or set special
28878 % ^^A % formatting parameters such as \cs{parindent} or \cs{parskip}.
28879 % ^^A % We need only set the category code of all special characters
28880 % ^^A % to $12$ (other) and that of \verb?^^M? (the end of line character)
28881 % ^^A % to $13$ (active).
28882 % ^^A % The latter is needed for macro parameter delimiter matching in
28883 % ^^A % the internal macros defined below.
28884 % ^^A % In contrast to the default definitions used by the
28885 % ^^A % \cs{verbatim} and \cs{verbatim*} macros,
28886 % ^^A % we define \cs{verbatim@addtoline} to throw away its argument
28887 % ^^A % and \cs{verbatim@processline}, \cs{verbatim@startline},
28888 % ^^A % and \cs{verbatim@finish} to act as no-ops.
28889 % ^^A % Then we call \cs{verbatim@}.
28890 % ^^A % But the first thing we do is to call \cs{@bsphack} so that
28891 % ^^A % this environment has no influence whatsoever upon the spacing.
28892 % ^^A %
28893 % ^^A % PW: This is the original code for the \texttt{comment} environment,
28894 % ^^A % which I'm going to change.
28895 % ^^A % \begin{verbatim}
28896 % ^^A % \def\comment{\@bsphack
28897 % ^^A % \let\do\@makeother\dospecials\catcode`\^^M\active
28898 % ^^A % \let\verbatim@startline\relax
28899 % ^^A % \let\verbatim@addtoline\@gobble
28900 % ^^A % \let\verbatim@processline\relax
28901 % ^^A % \let\verbatim@finish\relax
28902 % ^^A % \verbatim@}
28903 % ^^A % \end{verbatim}
28904 % ^^A % \cs{endcomment} is very simple: it only calls
28905 % ^^A % \cs{@esphack} to take care of the spacing.
28906 % ^^A % The \cs{end} macro closes the group and therefore takes care
28907 % ^^A % of restoring everything we changed.
28908 % ^^A % \begin{verbatim}
28909 % ^^A % \let\endcomment=\@esphack
28910 % ^^A % \end{verbatim}
28911 % ^^A %
28912 % ^^A % PW: The remainder of this section is my code.
28913 % ^^A %
28914 % ^^A % \begin{macro}{\setupcomment}
28915 % ^^A % \cs{setupcomment} does all the \cs{let}s in the original \cs{comment} code.
28916 % ^^A % \begin{macrocode}
28917 % ^^A \newcommand{\setupcomment}{%
28918 % ^^A \let\do\@makeother\dospecials\catcode`\^^M\active
28919 % ^^A \let\verbatim@startline\relax
28920 % ^^A \let\verbatim@addtoline\@gobble
28921 % ^^A \let\verbatim@processline\relax
28922 % ^^A \let\verbatim@finish\relax}
28923 % ^^A % \end{macrocode}
28924 % ^^A % \end{macro}
28925 % ^^A %
28926 % ^^A % The macros below do no checking to see if something has (not) been defined
28927 % ^^A % previously. It's `user beware' time.
28928 % ^^A %
28929 % ^^A % \begin{macro}{\newcomment}
28930 % ^^A % \cs{newcomment}\marg{name} creates a new comment environment called
28931 % ^^A % \meta{name}. This is a generalisation of the original comment code.
28932 % ^^A % \begin{macrocode}
28933 % ^^A \newcommand{\newcomment}[1]{%
28934 % ^^A \expandafter\def\csname #1\endcsname{\@bsphack\setupcomment\verbatim@}%
28935 % ^^A \expandafter\let\csname end#1\endcsname=\@esphack}
28936 % ^^A % \end{macrocode}
28937 % ^^A % \end{macro}
28938 % ^^A %
28939 % ^^A % \begin{macro}{\commentsoff}
28940 % ^^A % \cs{commentsoff}\marg{name} switches off the \meta{name} comment
28941 % ^^A % environment by defining the relevent macros to do nothing.
28942 % ^^A % \begin{macrocode}
28943 % ^^A \newcommand{\commentsoff}[1]{%
28944 % ^^A \expandafter\def\csname #1\endcsname{}%
28945 % ^^A \expandafter\def\csname end#1\endcsname{}}
28946 % ^^A % \end{macrocode}
28947 % ^^A % \end{macro}
28948 % ^^A %
28949 % ^^A % \begin{macro}{\commentson}
28950 % ^^A % \cs{commentson}\marg{name} switches on the \meta{name} comment
28951 % ^^A % environment. It has to do the same things as \cs{newcomment} does,
28952 % ^^A % so let \cs{newcomment} do the work.
28953 % ^^A % \begin{macrocode}
28954 % ^^A \newcommand{\commentson}[1]{\newcomment{#1}}
28955 % ^^A
28956 % ^^A % \end{macrocode}
28957 % ^^A % \end{macro}
28958 % ^^A %
28959 % ^^A % We had better supply the \texttt{comment} environment, as promised.
28960 % ^^A % \begin{macrocode}
28961 % ^^A \newcomment{comment}
28962 % ^^A
28963 % ^^A % \end{macrocode}
28964 % ^^A %
28965 % ^^A % PW: That is the end of my changes and extensions to the original
28966 % ^^A % \texttt{comment} environment code.
28967 % ^^A %
28968 % ^^A %
28969 % ^^A % \subsubsection{The main loop}
28970 % ^^A %
28971 % ^^A % Here comes the tricky part:
28972 % ^^A % During the definition of the macros we need to use the special
28973 % ^^A % characters \verb?\?, \verb?{?, and \verb?}? not only with their
28974 % ^^A % normal category codes,
28975 % ^^A % but also with category code $12$ (other).
28976 % ^^A % We achieve this by the following trick:
28977 % ^^A % first we tell \TeX{} that \verb?\?, \verb?{?, and \verb?}?
28978 % ^^A % are the lowercase versions of \verb?!?, \verb?[?, and \verb?]?.
28979 % ^^A % Then we replace every occurrence of \verb?\?, \verb?{?, and \verb?}?
28980 % ^^A % that should be read with category code $12$ by \verb?!?, \verb?[?,
28981 % ^^A % and \verb?]?, respectively,
28982 % ^^A % and give the whole list of tokens to \cs{lowercase},
28983 % ^^A % knowing that category codes are not altered by this primitive!
28984 % ^^A %
28985 % ^^A % But first we have ensure that
28986 % ^^A % \verb?!?, \verb?[?, and \verb?]? themselves have
28987 % ^^A % the correct category code!
28988 % ^^A % To allow special settings of these codes we hide their setting in
28989 % ^^A % the macro \cs{vrb@catcodes}. If it is already defined our new
28990 % ^^A % definition is skipped.
28991 % ^^A % \begin{macrocode}
28992 % ^^A \@ifundefined{vrb@catcodes}%
28993 % ^^A {\def\vrb@catcodes{%
28994 % ^^A \catcode`\!12\catcode`\[12\catcode`\]12}}{}
28995 % ^^A % \end{macrocode}
28996 % ^^A % This trick allows us to use this code for applications where other
28997 % ^^A % category codes are in effect.
28998 % ^^A %
28999 % ^^A % We start a group to keep the category code changes local.
29000 % ^^A % \begin{macrocode}
29001 % ^^A \begingroup
29002 % ^^A \vrb@catcodes
29003 % ^^A \lccode`\!=`\\ \lccode`\[=`\{ \lccode`\]=`\}
29004 % ^^A % \end{macrocode}
29005 % ^^A % We also need the end-of-line character \verb?^^M?,
29006 % ^^A % as an active character.
29007 % ^^A % If we were to simply write \verb?\catcode`\^^M=\active?
29008 % ^^A % then we would get an unwanted active end of line character
29009 % ^^A % at the end of every line of the following macro definitions.
29010 % ^^A % Therefore we use the same trick as above:
29011 % ^^A % we write a tilde \verb?~? instead of \verb?^^M? and
29012 % ^^A % pretend that the
29013 % ^^A % latter is the lowercase variant of the former.
29014 % ^^A % Thus we have to ensure now that the tilde character has
29015 % ^^A % category code $13$ (active).
29016 % ^^A % \begin{macrocode}
29017 % ^^A \catcode`\~=\active \lccode`\~=`\^^M
29018 % ^^A % \end{macrocode}
29019 % ^^A % The use of the \cs{lowercase} primitive leads to one problem:
29020 % ^^A % the uppercase character `\texttt{C}' needs to be used in the
29021 % ^^A % code below and its case must be preserved.
29022 % ^^A % So we add the command:
29023 % ^^A % \begin{macrocode}
29024 % ^^A \lccode`\C=`\C
29025 % ^^A % \end{macrocode}
29026 % ^^A % Now we start the token list passed to \cs{lowercase}.
29027 % ^^A % We use the following little trick (proposed by Bernd Raichle):
29028 % ^^A % The very first token in the token list we give to \cs{lowercase} is
29029 % ^^A % the \cs{endgroup} primitive. This means that it is processed by
29030 % ^^A % \TeX{} immediately after \cs{lowercase} has finished its operation,
29031 % ^^A % thus ending the group started by \cs{begingroup} above. This avoids
29032 % ^^A % the global definition of all macros.
29033 % ^^A % \begin{macrocode}
29034 % ^^A \lowercase{\endgroup
29035 % ^^A % \end{macrocode}
29036 % ^^A % \begin{macro}{\verbatim@start}
29037 % ^^A % The purpose of \cs{verbatim@start} is to check whether there
29038 % ^^A % are any characters on the same line as the \verb?\begin{verbatim}?
29039 % ^^A % and to pretend that they were on a line by themselves.
29040 % ^^A % On the other hand, if there are no characters remaining
29041 % ^^A % on the current line we shall just find an end of line character.
29042 % ^^A % \cs{verbatim@start} performs its task by first grabbing the
29043 % ^^A % following character (its argument).
29044 % ^^A % This argument is then compared to an active \verb?^^M?,
29045 % ^^A % the end of line character.
29046 % ^^A % \begin{macrocode}
29047 % ^^A \def\verbatim@start#1{%
29048 % ^^A \verbatim@startline
29049 % ^^A \if\noexpand#1\noexpand~%
29050 % ^^A % \end{macrocode}
29051 % ^^A % If this is true we transfer control to \cs{verbatim@}
29052 % ^^A % to process the next line. We use
29053 % ^^A % \cs{next} as the macro which will continue the work.
29054 % ^^A % \begin{macrocode}
29055 % ^^A \let\next\verbatim@
29056 % ^^A % \end{macrocode}
29057 % ^^A % Otherwise, we define \cs{next} to expand to a call
29058 % ^^A % to \cs{verbatim@} followed by the character just
29059 % ^^A % read so that it is reinserted into the text.
29060 % ^^A % This means that those characters remaining on this line
29061 % ^^A % are handled as if they formed a line by themselves.
29062 % ^^A % \begin{macrocode}
29063 % ^^A \else \def\next{\verbatim@#1}\fi
29064 % ^^A % \end{macrocode}
29065 % ^^A % Finally we call \cs{next}.
29066 % ^^A % \begin{macrocode}
29067 % ^^A \next}%
29068 % ^^A % \end{macrocode}
29069 % ^^A % \end{macro}
29070 % ^^A %
29071 % ^^A % \begin{macro}{\verbatim@}
29072 % ^^A % The three macros \cs{verbatim@}, \cs{verbatim@@},
29073 % ^^A % and \cs{verbatim@@@} form the ``main loop'' of the
29074 % ^^A % \texttt{verbatim} environment.
29075 % ^^A % The purpose of \cs{verbatim@} is to read exactly one line
29076 % ^^A % of input.
29077 % ^^A % \cs{verbatim@@} and \cs{verbatim@@@} work together to
29078 % ^^A % find out whether the four characters
29079 % ^^A % \cs{end} (all with category code $12$ (other)) occur in that
29080 % ^^A % line.
29081 % ^^A % If so, \cs{verbatim@@@} will call
29082 % ^^A % \cs{verbatim@test} to check whether this \cs{end} is
29083 % ^^A % part of \verb?\end{verbatim}? and will terminate the environment
29084 % ^^A % if this is the case.
29085 % ^^A % Otherwise we continue as if nothing had happened.
29086 % ^^A % So let's have a look at the definition of \cs{verbatim@}:
29087 % ^^A % \begin{macrocode}
29088 % ^^A \def\verbatim@#1~{\verbatim@@#1!end\@nil}%
29089 % ^^A % \end{macrocode}
29090 % ^^A % Note that the \verb?!? character will have been replaced by a
29091 % ^^A % \verb?\? with category code $12$ (other) by the \cs{lowercase}
29092 % ^^A % primitive governing this code before the definition of this
29093 % ^^A % macro actually takes place.
29094 % ^^A % That means that
29095 % ^^A % it takes the line, puts \cs{end} (four character tokens)
29096 % ^^A % and \cs{@nil} (one control sequence token) as a
29097 % ^^A % delimiter behind it, and
29098 % ^^A % then calls \cs{verbatim@@}.
29099 % ^^A % \end{macro}
29100 % ^^A %
29101 % ^^A % \begin{macro}{\verbatim@@}
29102 % ^^A % \cs{verbatim@@} takes everything up to the next occurrence of
29103 % ^^A % the four characters \cs{end} as its argument.
29104 % ^^A % \begin{macrocode}
29105 % ^^A \def\verbatim@@#1!end{%
29106 % ^^A % \end{macrocode}
29107 % ^^A % That means: if they do not occur in the original line, then
29108 % ^^A % argument \verb?#1? is the
29109 % ^^A % whole input line, and \cs{@nil} is the next token
29110 % ^^A % to be processed.
29111 % ^^A % However, if the four characters \cs{end} are part of the
29112 % ^^A % original line, then
29113 % ^^A % \verb?#1? consists of the characters in front of \cs{end},
29114 % ^^A % and the next token is the following character (always remember
29115 % ^^A % that the line was lengthened by five tokens).
29116 % ^^A % Whatever \verb?#1? may be, it is verbatim text,
29117 % ^^A % so \verb?#1? is added to the line currently built.
29118 % ^^A % \begin{macrocode}
29119 % ^^A \verbatim@addtoline{#1}%
29120 % ^^A % \end{macrocode}
29121 % ^^A % The next token in the input stream
29122 % ^^A % is of special interest to us.
29123 % ^^A % Therefore \cs{futurelet} defines \cs{next} to be equal
29124 % ^^A % to it before calling \cs{verbatim@@@}.
29125 % ^^A % \begin{macrocode}
29126 % ^^A \futurelet\next\verbatim@@@}%
29127 % ^^A % \end{macrocode}
29128 % ^^A % \end{macro}
29129 % ^^A %
29130 % ^^A % \begin{macro}{\verbatim@@@}
29131 % ^^A % \cs{verbatim@@@} will now read the rest of the tokens on
29132 % ^^A % the current line,
29133 % ^^A % up to the final \cs{@nil} token.
29134 % ^^A % \begin{macrocode}
29135 % ^^A \def\verbatim@@@#1\@nil{%
29136 % ^^A % \end{macrocode}
29137 % ^^A % If the first of the above two cases occurred, i.e.\ no
29138 % ^^A % \cs{end} characters were on that line, \verb?#1? is empty
29139 % ^^A % and \cs{next} is equal to \cs{@nil}.
29140 % ^^A % This is easily checked.
29141 % ^^A % \begin{macrocode}
29142 % ^^A \ifx\next\@nil
29143 % ^^A % \end{macrocode}
29144 % ^^A % If so, this was a simple line.
29145 % ^^A % We finish it by processing the line we accumulated so far.
29146 % ^^A % Then we prepare to read the next line.
29147 % ^^A % \begin{macrocode}
29148 % ^^A \verbatim@processline
29149 % ^^A \verbatim@startline
29150 % ^^A \let\next\verbatim@
29151 % ^^A % \end{macrocode}
29152 % ^^A % Otherwise we have to check what follows these \cs{end}
29153 % ^^A % tokens.
29154 % ^^A % \begin{macrocode}
29155 % ^^A \else
29156 % ^^A % \end{macrocode}
29157 % ^^A % Before we continue, it's a good idea to stop for a moment
29158 % ^^A % and remember where we are:
29159 % ^^A % We have just read the four character tokens \cs{end}
29160 % ^^A % and must now check whether the name of the environment (surrounded
29161 % ^^A % by braces) follows.
29162 % ^^A % To this end we define a macro called \cs{@tempa}
29163 % ^^A % that reads exactly one character and decides what to do next.
29164 % ^^A % This macro should do the following: skip spaces until
29165 % ^^A % it encounters either a left brace or the end of the line.
29166 % ^^A % But it is important to remember which characters are skipped.
29167 % ^^A % The \cs{end}\meta{optional spaces}\verb?{? characters
29168 % ^^A % may be part of the verbatim text, i.e.\ these characters
29169 % ^^A % must be printed.
29170 % ^^A %
29171 % ^^A % Assume for example that the current line contains
29172 % ^^A % \begin{verbatim*}
29173 % ^^A % \end {AVeryLongEnvironmentName}
29174 % ^^A %\end{verbatim*}
29175 % ^^A % As we shall soon see, the scanning mechanism implemented here
29176 % ^^A % will not find out that this is text to be printed until
29177 % ^^A % it has read the right brace.
29178 % ^^A % Therefore we need a way to accumulate the characters read
29179 % ^^A % so that we can reinsert them if necessary.
29180 % ^^A % The token register \cs{@temptokena} is used for this purpose.
29181 % ^^A %
29182 % ^^A % Before we do this we have to get rid of the superfluous
29183 % ^^A % \cs{end} tokens at the end of the line.
29184 % ^^A % To this end we define a temporary macro whose argument
29185 % ^^A % is delimited by \verb?\end\@nil? (four character tokens
29186 % ^^A % and one control sequence token) to be used below
29187 % ^^A % on the rest of the line, after appending a \cs{@nil} token to it.
29188 % ^^A % (Note that this token can never appear in \verb?#1?.)
29189 % ^^A % We use the following definition of
29190 % ^^A % \cs{@tempa} to get the rest of the line (after the first
29191 % ^^A % \cs{end}).
29192 % ^^A % \begin{macrocode}
29193 % ^^A \def\@tempa##1!end\@nil{##1}%
29194 % ^^A % \end{macrocode}
29195 % ^^A % We mentioned already that we use token register
29196 % ^^A % \cs{@temptokena}
29197 % ^^A % to remember the characters we skip, in case we need them again.
29198 % ^^A % We initialize this with the \cs{end} we have thrown away
29199 % ^^A % in the call to \cs{@tempa}.
29200 % ^^A % \begin{macrocode}
29201 % ^^A \@temptokena{!end}%
29202 % ^^A % \end{macrocode}
29203 % ^^A % We shall now call \cs{verbatim@test}
29204 % ^^A % to process the characters
29205 % ^^A % remaining on the current line.
29206 % ^^A % But wait a moment: we cannot simply call this macro
29207 % ^^A % since we have already read the whole line.
29208 % ^^A % Therefore we have to first expand the macro \cs{@tempa} to insert
29209 % ^^A % them again after the \cs{verbatim@test} token.
29210 % ^^A % A \verb?^^M? character is appended to denote the end of the line.
29211 % ^^A % (Remember that this character comes disguised as a tilde.)
29212 % ^^A % \begin{macrocode}
29213 % ^^A \def\next{\expandafter\verbatim@test\@tempa#1\@nil~}%
29214 % ^^A % \end{macrocode}
29215 % ^^A % That's almost all, but we still have to
29216 % ^^A % now call \cs{next} to do the work.
29217 % ^^A % \begin{macrocode}
29218 % ^^A \fi \next}%
29219 % ^^A % \end{macrocode}
29220 % ^^A % \end{macro}
29221 % ^^A %
29222 % ^^A %
29223 % ^^A % \begin{macro}{\verbatim@test}
29224 % ^^A % We define \cs{verbatim@test} to investigate every token
29225 % ^^A % in turn.
29226 % ^^A % \begin{macrocode}
29227 % ^^A \def\verbatim@test#1{%
29228 % ^^A % \end{macrocode}
29229 % ^^A % First of all we set \cs{next} equal to \cs{verbatim@test}
29230 % ^^A % in case this macro must call itself recursively in order to
29231 % ^^A % skip spaces.
29232 % ^^A % \begin{macrocode}
29233 % ^^A \let\next\verbatim@test
29234 % ^^A % \end{macrocode}
29235 % ^^A % We have to distinguish four cases:
29236 % ^^A % \begin{enumerate}
29237 % ^^A % \item The next token is a \verb?^^M?, i.e.\ we reached
29238 % ^^A % the end of the line. That means that nothing
29239 % ^^A % special was found.
29240 % ^^A % Note that we use \cs{if} for the following
29241 % ^^A % comparisons so that the category code of the
29242 % ^^A % characters is irrelevant.
29243 % ^^A % \begin{macrocode}
29244 % ^^A \if\noexpand#1\noexpand~%
29245 % ^^A % \end{macrocode}
29246 % ^^A % We add the characters accumulated in token register
29247 % ^^A % \cs{@temptokena} to the current line. Since
29248 % ^^A % \cs{verbatim@addtoline} does not expand its argument,
29249 % ^^A % we have to do the expansion at this point. Then we
29250 % ^^A % \cs{let} \cs{next} equal to \cs{verbatim@}
29251 % ^^A % to prepare to read the next line.
29252 % ^^A % \begin{macrocode}
29253 % ^^A \expandafter\verbatim@addtoline
29254 % ^^A \expandafter{\the\@temptokena}%
29255 % ^^A \verbatim@processline
29256 % ^^A \verbatim@startline
29257 % ^^A \let\next\verbatim@
29258 % ^^A % \end{macrocode}
29259 % ^^A % \item A space character follows.
29260 % ^^A % This is allowed, so we add it to \cs{@temptokena}
29261 % ^^A % and continue.
29262 % ^^A % \begin{macrocode}
29263 % ^^A \else \if\noexpand#1
29264 % ^^A \@temptokena\expandafter{\the\@temptokena#1}%
29265 % ^^A % \end{macrocode}
29266 % ^^A % \item An open brace follows.
29267 % ^^A % This is the most interesting case.
29268 % ^^A % We must now collect characters until we read the closing
29269 % ^^A % brace and check whether they form the environment name.
29270 % ^^A % This will be done by \cs{verbatim@testend}, so here
29271 % ^^A % we let \cs{next} equal this macro.
29272 % ^^A % Again we will process the rest of the line, character
29273 % ^^A % by character.
29274 % ^^A % The characters forming the name of the environment will
29275 % ^^A % be accumulated in \cs{@tempc}.
29276 % ^^A % We initialize this macro to expand to nothing.
29277 % ^^A % \begin{macrocode}
29278 % ^^A \else \if\noexpand#1\noexpand[%
29279 % ^^A \let\@tempc\@empty
29280 % ^^A \let\next\verbatim@testend
29281 % ^^A % \end{macrocode}
29282 % ^^A % Note that the \verb?[? character will be a \verb?{? when
29283 % ^^A % this macro is defined.
29284 % ^^A % \item Any other character means that the \cs{end} was part
29285 % ^^A % of the verbatim text.
29286 % ^^A % Add the characters to the current line and prepare to call
29287 % ^^A % \cs{verbatim@} to process the rest of the line.
29288 % ^^A % \begin{macrocode}
29289 % ^^A \else
29290 % ^^A \expandafter\verbatim@addtoline
29291 % ^^A \expandafter{\the\@temptokena}%
29292 % ^^A \def\next{\verbatim@#1}%
29293 % ^^A \fi\fi\fi
29294 % ^^A % \end{macrocode}
29295 % ^^A % \end{enumerate}
29296 % ^^A % The last thing this macro does is to call \cs{next}
29297 % ^^A % to continue processing.
29298 % ^^A % \begin{macrocode}
29299 % ^^A \next}%
29300 % ^^A % \end{macrocode}
29301 % ^^A % \end{macro}
29302 % ^^A %
29303 % ^^A % \begin{macro}{\verbatim@testend}
29304 % ^^A % \cs{verbatim@testend} is called when
29305 % ^^A % \cs{end}\meta{optional spaces}\verb?{? was seen.
29306 % ^^A % Its task is to scan everything up to the next \verb?}?
29307 % ^^A % and to call \cs{verbatim@@testend}.
29308 % ^^A % If no \verb?}? is found it must reinsert the characters it read
29309 % ^^A % and return to \cs{verbatim@}.
29310 % ^^A % The following definition is similar to that of
29311 % ^^A % \cs{verbatim@test}:
29312 % ^^A % it takes the next character and decides what to do.
29313 % ^^A % \begin{macrocode}
29314 % ^^A \def\verbatim@testend#1{%
29315 % ^^A % \end{macrocode}
29316 % ^^A % Again, we have four cases:
29317 % ^^A % \begin{enumerate}
29318 % ^^A % \item \verb?^^M?: As no \verb?}? is found in the current line,
29319 % ^^A % add the characters to the buffer. To avoid a
29320 % ^^A % complicated construction for expanding
29321 % ^^A % \cs{@temptokena}
29322 % ^^A % and \cs{@tempc} we do it in two steps. Then we
29323 % ^^A % continue with \cs{verbatim@} to process the
29324 % ^^A % next line.
29325 % ^^A % \begin{macrocode}
29326 % ^^A \if\noexpand#1\noexpand~%
29327 % ^^A \expandafter\verbatim@addtoline
29328 % ^^A \expandafter{\the\@temptokena[}%
29329 % ^^A \expandafter\verbatim@addtoline
29330 % ^^A \expandafter{\@tempc}%
29331 % ^^A \verbatim@processline
29332 % ^^A \verbatim@startline
29333 % ^^A \let\next\verbatim@
29334 % ^^A % \end{macrocode}
29335 % ^^A % \item \verb?}?: Call \cs{verbatim@@testend} to check
29336 % ^^A % if this is the right environment name.
29337 % ^^A % \begin{macrocode}
29338 % ^^A \else\if\noexpand#1\noexpand]%
29339 % ^^A \let\next\verbatim@@testend
29340 % ^^A % \end{macrocode}
29341 % ^^A % \item \verb?\?: This character must not occur in the name of
29342 % ^^A % an environment. Thus we stop collecting characters.
29343 % ^^A % In principle, the same argument would apply to other
29344 % ^^A % characters as well, e.g., \verb?{?.
29345 % ^^A % However, \verb?\? is a special case, since it may be
29346 % ^^A % the first character of \cs{end}. This means that
29347 % ^^A % we have to look again for
29348 % ^^A % \cs{end}\marg{environment name}
29349 % ^^A % Note that we prefixed the \verb?!? by a \cs{noexpand}
29350 % ^^A % primitive, to protect ourselves against it being an
29351 % ^^A % active character.
29352 % ^^A % \begin{macrocode}
29353 % ^^A \else\if\noexpand#1\noexpand!%
29354 % ^^A \expandafter\verbatim@addtoline
29355 % ^^A \expandafter{\the\@temptokena[}%
29356 % ^^A \expandafter\verbatim@addtoline
29357 % ^^A \expandafter{\@tempc}%
29358 % ^^A \def\next{\verbatim@!}%
29359 % ^^A % \end{macrocode}
29360 % ^^A % \item Any other character: collect it and continue.
29361 % ^^A % We cannot use \cs{edef} to define \cs{@tempc}
29362 % ^^A % since its replacement text might contain active
29363 % ^^A % character tokens.
29364 % ^^A % \begin{macrocode}
29365 % ^^A \else \expandafter\def\expandafter\@tempc\expandafter
29366 % ^^A {\@tempc#1}\fi\fi\fi
29367 % ^^A % \end{macrocode}
29368 % ^^A % \end{enumerate}
29369 % ^^A % As before, the macro ends by calling itself, to
29370 % ^^A % process the next character if appropriate.
29371 % ^^A % \begin{macrocode}
29372 % ^^A \next}%
29373 % ^^A % \end{macrocode}
29374 % ^^A % \end{macro}
29375 % ^^A %
29376 % ^^A % \begin{macro}{\verbatim@@testend}
29377 % ^^A % Unlike the previous macros \cs{verbatim@@testend} is simple:
29378 % ^^A % it has only to check if the \cs{end}\marg{...}
29379 % ^^A % matches the corresponding \cs{begin}\marg{...}
29380 % ^^A % \begin{macrocode}
29381 % ^^A \def\verbatim@@testend{%
29382 % ^^A % \end{macrocode}
29383 % ^^A % We use \cs{next} again to define the things that are
29384 % ^^A % to be done.
29385 % ^^A % Remember that the name of the current environment is
29386 % ^^A % held in \cs{@currenvir}, the characters accumulated
29387 % ^^A % by \cs{verbatim@testend} are in \cs{@tempc}.
29388 % ^^A % So we simply compare these and prepare to execute
29389 % ^^A % \cs{end}\marg{current environment}
29390 % ^^A % macro if they match.
29391 % ^^A % Before we do this we call \cs{verbatim@finish} to process
29392 % ^^A % the last line.
29393 % ^^A % We define \cs{next} via \cs{edef} so that
29394 % ^^A % \cs{@currenvir} is replaced by its expansion.
29395 % ^^A % Therefore we need \cs{noexpand} to inhibit the expansion
29396 % ^^A % of \cs{end} at this point.
29397 % ^^A % \begin{macrocode}
29398 % ^^A \ifx\@tempc\@currenvir
29399 % ^^A \verbatim@finish
29400 % ^^A \edef\next{\noexpand\end{\@currenvir}%
29401 % ^^A % \end{macrocode}
29402 % ^^A % Without this trick the \cs{end} command would not be able
29403 % ^^A % to correctly check whether its argument matches the name of
29404 % ^^A % the current environment and you'd get an
29405 % ^^A % interesting \LaTeX{} error message such as:
29406 % ^^A % \begin{verbatim}
29407 % ^^A %! \begin{verbatim*} ended by \end{verbatim*}.
29408 % ^^A %\end{verbatim}
29409 % ^^A % But what do we do with the rest of the characters, those
29410 % ^^A % that remain on that line?
29411 % ^^A % We call \cs{verbatim@rescan} to take care of that.
29412 % ^^A % Its first argument is the name of the environment just
29413 % ^^A % ended, in case we need it again.
29414 % ^^A % \cs{verbatim@rescan} takes the list of characters to be
29415 % ^^A % reprocessed as its second argument.
29416 % ^^A % (This token list was inserted after the current macro
29417 % ^^A % by \cs{verbatim@@@}.)
29418 % ^^A % Since we are still in an \cs{edef} we protect it
29419 % ^^A % by means of\cs{noexpand}.
29420 % ^^A % \begin{macrocode}
29421 % ^^A \noexpand\verbatim@rescan{\@currenvir}}%
29422 % ^^A % \end{macrocode}
29423 % ^^A % If the names do not match, we reinsert everything read up
29424 % ^^A % to now and prepare to call \cs{verbatim@} to process
29425 % ^^A % the rest of the line.
29426 % ^^A % \begin{macrocode}
29427 % ^^A \else
29428 % ^^A \expandafter\verbatim@addtoline
29429 % ^^A \expandafter{\the\@temptokena[}%
29430 % ^^A \expandafter\verbatim@addtoline
29431 % ^^A \expandafter{\@tempc]}%
29432 % ^^A \let\next\verbatim@
29433 % ^^A \fi
29434 % ^^A % \end{macrocode}
29435 % ^^A % Finally we call \cs{next}.
29436 % ^^A % \begin{macrocode}
29437 % ^^A \next}%
29438 % ^^A % \end{macrocode}
29439 % ^^A % \end{macro}
29440 % ^^A %
29441 % ^^A % \begin{macro}{\verbatim@rescan}
29442 % ^^A % In principle \cs{verbatim@rescan} could be used to
29443 % ^^A % analyse the characters remaining after the \verb?\end{...}?
29444 % ^^A % command and pretend that these were read
29445 % ^^A % ``properly'', assuming ``standard'' category codes are in
29446 % ^^A % force.\footnote{Remember that they were all read with
29447 % ^^A % category codes $11$ (letter) and $12$ (other) so
29448 % ^^A % that control sequences are not recognized as such.}
29449 % ^^A % But this is not always possible (when there are unmatched
29450 % ^^A % curly braces in the rest of the line).
29451 % ^^A % Besides, we think that this is not worth the effort:
29452 % ^^A % After a \texttt{verbatim} or \texttt{verbatim*} environment
29453 % ^^A % a new line in the output is begun anyway,
29454 % ^^A % and an \verb?\end{comment}? can easily be put on a line by itself.
29455 % ^^A % So there is no reason why there should be any text here.
29456 % ^^A % For the benefit of the user who did put something there
29457 % ^^A % (a comment, perhaps)
29458 % ^^A % we simply issue a warning and drop them.
29459 % ^^A % The method of testing is explained in Appendix~D, p.\ 376 of
29460 % ^^A % the \TeX{}book. We use \verb?^^M? instead of the \verb?!?
29461 % ^^A % character used there
29462 % ^^A % since this is a character that cannot appear in \verb?#1?.
29463 % ^^A % The two \cs{noexpand} primitives are necessary to avoid
29464 % ^^A % expansion of active characters and macros.
29465 % ^^A %
29466 % ^^A % One extra subtlety should be noted here: remember that
29467 % ^^A % the token list we are currently building will first be
29468 % ^^A % processed by the \cs{lowercase} primitive before \TeX{}
29469 % ^^A % carries out the definitions.
29470 % ^^A % This means that the `\texttt{C}' character in the
29471 % ^^A % argument to the \cs{@warning} macro must be protected against
29472 % ^^A % being changed to `\texttt{c}'. That's the reason why we added the
29473 % ^^A % \verb?\lccode`\C=`\C? assignment above.
29474 % ^^A % We can now finish the argument to \cs{lowercase} as well as the
29475 % ^^A % group in which the category codes were changed.
29476 % ^^A % \begin{macrocode}
29477 % ^^A \def\verbatim@rescan#1#2~{\if\noexpand~\noexpand#2~\else
29478 % ^^A \@warning{Characters dropped after `\string\end{#1}'}\fi}}
29479 % ^^A % \end{macrocode}
29480 % ^^A % \end{macro}
29481 % ^^A %
29482 % ^^A % \subsubsection{The \cs{verbatiminput} command}
29483 % ^^A %
29484 % ^^A % \begin{macro}{\verbatim@in@stream}
29485 % ^^A % We begin by allocating an input stream (out of the 16 available
29486 % ^^A % input streams).
29487 % ^^A % \begin{macrocode}
29488 % ^^A \newread\verbatim@in@stream
29489 % ^^A % \end{macrocode}
29490 % ^^A % \end{macro}
29491 % ^^A %
29492 % ^^A % \begin{macro}{\verbatim@readfile}
29493 % ^^A % The macro \cs{verbatim@readfile} encloses the main loop by calls to
29494 % ^^A % the macros \cs{verbatim@startline} and \cs{verbatim@finish},
29495 % ^^A % respectively. This makes sure
29496 % ^^A % that the user can initialize and finish the command when the file
29497 % ^^A % is empty or doesn't exist. The \texttt{verbatim} environment has a
29498 % ^^A % similar behaviour when called with an empty text.
29499 % ^^A % \begin{macrocode}
29500 % ^^A \def\verbatim@readfile#1{%
29501 % ^^A \verbatim@startline
29502 % ^^A % \end{macrocode}
29503 % ^^A % When the file is not found we issue a warning.
29504 % ^^A % \begin{macrocode}
29505 % ^^A \openin\verbatim@in@stream #1\relax
29506 % ^^A \ifeof\verbatim@in@stream
29507 % ^^A \typeout{No file #1.}%
29508 % ^^A \else
29509 % ^^A % \end{macrocode}
29510 % ^^A % At this point we pass the name of the file to \cs{@addtofilelist}
29511 % ^^A % so that its appears appears in the output of a \cs{listfiles}
29512 % ^^A % command.
29513 % ^^A % In addition, we use \cs{ProvidesFile} to make a log entry in the
29514 % ^^A % transcript file and to distinguish files read in via
29515 % ^^A % \cs{verbatiminput} from others.
29516 % ^^A % \begin{macrocode}
29517 % ^^A \@addtofilelist{#1}%
29518 % ^^A \ProvidesFile{#1}[(verbatim)]%
29519 % ^^A % \end{macrocode}
29520 % ^^A % While reading from the file it is useful to switch off the
29521 % ^^A % recognition of the end-of-line character. This saves us stripping
29522 % ^^A % off spaces from the contents of the line.
29523 % ^^A % \begin{macrocode}
29524 % ^^A \expandafter\endlinechar\expandafter\m@ne
29525 % ^^A \expandafter\verbatim@read@file
29526 % ^^A \expandafter\endlinechar\the\endlinechar\relax
29527 % ^^A \closein\verbatim@in@stream
29528 % ^^A \fi
29529 % ^^A \verbatim@finish
29530 % ^^A }
29531 % ^^A % \end{macrocode}
29532 % ^^A % \end{macro}
29533 % ^^A %
29534 % ^^A % \begin{macro}{\verbatim@read@file}
29535 % ^^A % All the work is done in \cs{verbatim@read@file}. It reads the input
29536 % ^^A % file line by line and recursively calls itself until the end of
29537 % ^^A % the file.
29538 % ^^A % \begin{macrocode}
29539 % ^^A \def\verbatim@read@file{%
29540 % ^^A \read\verbatim@in@stream to\next
29541 % ^^A \ifeof\verbatim@in@stream
29542 % ^^A \else
29543 % ^^A % \end{macrocode}
29544 % ^^A % For each line we call \cs{verbatim@addtoline} with the contents of
29545 % ^^A % the line. \hskip0pt plus 3cm\penalty0\hskip0pt plus -3cm
29546 % ^^A % \cs{verbatim@processline} is called next.
29547 % ^^A % \begin{macrocode}
29548 % ^^A \expandafter\verbatim@addtoline\expandafter{\next}%
29549 % ^^A \verbatim@processline
29550 % ^^A % \end{macrocode}
29551 % ^^A % After processing the line we call \cs{verbatim@startline} to
29552 % ^^A % initialize all before we read the next line.
29553 % ^^A % \begin{macrocode}
29554 % ^^A \verbatim@startline
29555 % ^^A % \end{macrocode}
29556 % ^^A % Without \cs{expandafter} each call of \cs{verbatim@read@file} uses
29557 % ^^A % space in \TeX's input stack.\footnote{A standard \TeX\ would
29558 % ^^A % report an overflow error if you try to read a file with more than
29559 % ^^A % ca.\ 200~lines. The same error occurs if the first line of code
29560 % ^^A % in \S 390 of \textsl{``TeX: The Program''\/} is missing.}
29561 % ^^A % \begin{macrocode}
29562 % ^^A \expandafter\verbatim@read@file
29563 % ^^A \fi
29564 % ^^A }
29565 % ^^A % \end{macrocode}
29566 % ^^A % \end{macro}
29567 % ^^A %
29568 % ^^A %
29569 % ^^A % \begin{macro}{\verbatiminput}
29570 % ^^A % \cs{verbatiminput} first starts a group to keep font and category
29571 % ^^A % changes local.
29572 % ^^A % Then it calls the macro \cs{verbatim@input} with additional
29573 % ^^A % arguments, depending on whether an asterisk follows.
29574 % ^^A %
29575 % ^^A % PW. I added the TAB checking code.
29576 % ^^A % \begin{macrocode}
29577 % ^^A \def\verbatiminput{\begingroup
29578 % ^^A \ift@bs
29579 % ^^A \def\verbatim@processline{\tabverbatim@processline}%
29580 % ^^A \fi
29581 % ^^A \@ifstar{\verbatim@input{\@maybeobeytabs}}%
29582 % ^^A {\verbatim@input{\frenchspacing\@vobeyspaces\@maybeobeytabs}}}
29583 % ^^A % \end{macrocode}
29584 % ^^A % \end{macro}
29585 % ^^A %
29586 % ^^A % \begin{macro}{\verbatim@input}
29587 % ^^A % \cs{verbatim@input} first checks whether the file exists, using
29588 % ^^A % the standard macro cs{IfFileExists} which leaves the name of the
29589 % ^^A % file found in \cs{@filef@und}.
29590 % ^^A % Then everything is set up as in the \cs{verbatim} macro.
29591 % ^^A % \begin{macrocode}
29592 % ^^A \def\verbatim@input#1#2{%
29593 % ^^A \IfFileExists {#2}{\@verbatim #1\relax
29594 % ^^A % \end{macrocode}
29595 % ^^A % Then it reads in the file, finishes off the \texttt{trivlist}
29596 % ^^A % environment started by \cs{@verbatim} and closes the group.
29597 % ^^A % This restores everything to its normal settings.
29598 % ^^A % \begin{macrocode}
29599 % ^^A \verbatim@readfile{\@filef@und}\endtrivlist\endgroup\@doendpe}%
29600 % ^^A % \end{macrocode}
29601 % ^^A % If the file is not found a more or less helpful message is
29602 % ^^A % printed. The final \cs{endgroup} is needed to close the group
29603 % ^^A % started in \cs{verbatiminput} above.
29604 % ^^A % \begin{macrocode}
29605 % ^^A {\typeout {No file #2.}\endgroup}}
29606 % ^^A % \end{macrocode}
29607 % ^^A % \end{macro}
29608 % ^^A %
29609 % ^^A % \textit{That completes my borrowings from \Lpack{verbatim}.}
29610 % ^^A %
29611 % ^^A
29612 % ^^A % ^^A end embedded verbatim
29613 % ^^A
29614 % ^^A % The next bunch of code implements wrapping verbatim lines so they, hopefully,
29615 % ^^A % stay within the typeblock.
29616 % ^^A %
29617 % ^^A % \begin{macro}{\verbatimindent}
29618 % ^^A % \begin{macro}{\verbatimbreakchar}
29619 % ^^A % \begin{macro}{\setverbatimbreak}
29620 % ^^A % The length \cs{verbatimindent} is the distance continuation lines are indented
29621 % ^^A % from the left margin. \cs{verbatimbreakchar} is the character to indicate
29622 % ^^A % a wrapped line.
29623 % ^^A % \begin{macrocode}
29624 % ^^A \newlength{\verbatimindent}
29625 % ^^A \setlength{\verbatimindent}{3em}
29626 % ^^A \newcommand*{\verbatimbreakchar}{\char`\%}
29627 % ^^A \newcommand*{\setverbatimbreak}{%
29628 % ^^A \vspace*{-\baselineskip}%
29629 % ^^A \def\@xobeysp{~\discretionary{\verbatimbreakchar}%
29630 % ^^A {\kern\verbatimindent}{}}%
29631 % ^^A }
29632 % ^^A
29633 % ^^A % \end{macrocode}
29634 % ^^A % \end{macro}
29635 % ^^A % \end{macro}
29636 % ^^A % \end{macro}
29637 % ^^A %
29638 % ^^A % ^^A \begin{macro}{\wrappingon}
29639 % ^^A % \begin{macro}{\wrapright}
29640 % ^^A % \begin{macro}{\wrappingoff}
29641 % ^^A % \cs{wrappingon} and \cs{wrappingoff} enable/prohibit wrapping. The
29642 % ^^A % default is \cs{wrappingoff}.
29643 % ^^A %
29644 % ^^A % The macro
29645 % ^^A % \cs{wrapright} is used to set paragraph skips; without raggedright the
29646 % ^^A % lines
29647 % ^^A % may break at the first space \emph{outside} the text area. However,
29648 % ^^A % Paul found that wrapped verbatims
29649 % ^^A % in a list (e.g., \texttt{itemize}) were not indented although regular
29650 % ^^A % verbatims were indented. \cs{raggedwrap} is a variation on \cs{raggedright}
29651 % ^^A % (\cs{leftskip} is set to \cs{@totalleftmargin} instead of 0pt), and seems
29652 % ^^A % to have fixed the problem with the original code which used
29653 % ^^A % \cs{raggedright}.
29654 % ^^A % \changes{v1.61803}{2008/01/30}{Added \cs{raggedwrap} (mempatch v4.4)}
29655 % ^^A % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{raggedwrap}}
29656 % ^^A % \begin{macrocode}
29657 % ^^A % \newcommand*{\raggedwrap}{%
29658 % ^^A % \@rightskip\@flushglue
29659 % ^^A % %%% \rightskip\@rightskip
29660 % ^^A % \memRTLrightskip\@rightskip
29661 % ^^A % %%% \leftskip\@totalleftmargin
29662 % ^^A % \memRTLleftskip\@totalleftmargin
29663 % ^^A % \parindent\ragrparindent}
29664 % ^^A \newcommand*{\wrappingon}{%
29665 % ^^A \def\@xobeysp{~\discretionary{\verbatimbreakchar}%
29666 % ^^A {\kern\verbatimindent}{}}%
29667 % ^^A \def\wrapright{\raggedwrap}}
29668 % ^^A \newcommand*{\wrappingoff}{%
29669 % ^^A \def\@xobeysp{\leavevmode\penalty\@M\ }%
29670 % ^^A \def\wrapright{}}
29671 % ^^A \wrappingoff
29672 % ^^A
29673 % ^^A % \end{macrocode}
29674 % ^^A % \end{macro}
29675 % ^^A % \end{macro}
29676 % ^^A % \end{macro}
29677 % ^^A % ^^A \end{macro}
29678 % ^^A %
29679 % ^^A % \noindent{\color{red}\rule\textwidth{5mm}}
29680 %
29681 % \subsection{Writing and boxing verbatim}
29682 %
29683 % This bunch of code is from the \Lpack{moreverb} package.
29684 %
29685 % \begin{environment}{verbatimoutput}
29686 % \verb?\begin{verbatimoutput}?\marg{filename} writes all text in its body to a
29687 % file, the name of which it is given as an argument. (The code was
29688 % written by Rainer Sch\"opf but the environment was called
29689 % \verb?verbatimwrite?). In the code below, uncommenting \\
29690 % \verb?\catcode`\^^I=12? \\
29691 % will result in TABs being written as \verb?^^I?.
29692 % \changes{v1.3}{2002/09/27}{Changed name verbatimwrite to
29693 % verbatimoutput (but neither were mentioned in the manual)}
29694 % \begin{macrocode}
29695 \newwrite \verbatim@out
29696 \def\verbatimoutput#1{%
29697 \@bsphack
29698 \immediate\openout \verbatim@out #1
29699 \let\do\@makeother\dospecials
29700 \catcode`\^^M\active %% \catcode`\^^I=12
29701 \def\verbatim@processline{%
29702 \immediate\write\verbatim@out
29703 {\the\verbatim@line}}%
29704 \verbatim@start}
29705 % \end{macrocode}
29706 % \begin{macrocode}
29707 \def\endverbatimoutput{%
29708 \immediate\closeout\verbatim@out
29709 \@esphack}
29710 % \end{macrocode}
29711 % \end{environment}
29712 %
29713 %
29714 %
29715 % \begin{environment}{fboxverbatim}
29716 % \texttt{fboxverbatim} puts the contents of a verbatim environment
29717 % in a framing box. (PW: This was originally called \texttt{boxedverbatim}).
29718 %
29719 % (Written by Victor Eijkhout.)
29720 %
29721 % Bug fix (supplied by David Carlisle) 1995/12/28, marked
29722 % \verb+%%%DPC%%%+
29723 %
29724 % First, redefine `processline' to produce only a line as wide
29725 % as the natural width of the line
29726 %
29727 % \begin{macrocode}
29728 \def\fboxverbatim{\begingroup%
29729 \tabsoff %% PW otherwise box fills the width
29730 \def\verbatim@processline{%
29731 {\setbox0=\hbox{\the\verbatim@line}%
29732 \hsize=\wd0 \the\verbatim@line\par}}%
29733 % \end{macrocode}
29734 %
29735 % Now save the verbatim code in a box
29736 %
29737 % \begin{macrocode}
29738 \@minipagetrue%%%DPC%%%
29739 \@tempswatrue%%%DPC%%%
29740 \setbox0=\vbox\bgroup \verbatim
29741 }
29742 % \end{macrocode}
29743 %
29744 % At the end of the environment, we (umm) simply have to stick the
29745 % results into a frame.
29746 %
29747 % \begin{macrocode}
29748 \def\endfboxverbatim{%
29749 \endverbatim
29750 \unskip\setbox0=\lastbox %%%DPC%%%
29751 % \end{macrocode}
29752 %
29753 % Now everything's in the box, so we can close it\dots
29754 %
29755 % \begin{macrocode}
29756 \egroup
29757 % \end{macrocode}
29758 %
29759 % To change the code for centering, the next line needs a spot of
29760 % hacking.
29761 %
29762 % \begin{macrocode}
29763 \fbox{\box0}% <<<=== change here for centering,...
29764 \endgroup}
29765 % \end{macrocode}
29766
29767 % \end{environment}
29768 %
29769 %
29770 %
29771 % \subsection{The shortvrb package}
29772 %
29773 %
29774 % \changes{v3.8.2}{2024/01/10}{Replaced embedded copy if
29775 % \Lpack{shortvrb} with loading the package. The embedded code is just
29776 % outcommented for now.}
29777 %
29778 % In earlier versions of the class we had an embedded copy of the code
29779 % from the \Lpack{shortvrb} package, as the functionality is very
29780 % useful.
29781 %
29782 % As of 2024 we load the package instead. This also gives us access to
29783 % the starred version of \verb!\MakeShortVerb!. For details see
29784 % \cite{SHORTVRB}.
29785 %
29786 % It adds the following macros
29787 % \begin{verbatim}
29788 % \MakeShortVerb
29789 % \MakeShortVerb*
29790 % \DeleteShortVerb
29791 % \end{verbatim}
29792 % \begin{macrocode}
29793 % load shortvrb instead of embedding it
29794 \RequirePackage{shortvrb}
29795
29796 % \end{macrocode}
29797 %
29798 % ^^A % The following is the \Lpack{shortvrb} package code (from \texttt{doc.dtx}
29799 % ^^A % by Frank Mittelbach). It has been so useful to me that I wanted
29800 % ^^A % to include it in the class.
29801 % ^^A %
29802 % ^^A % CODE AND COMMENTARY IS BY FRANK MITTELBACH
29803 % ^^A % start shortvrb code
29804 % ^^A %
29805 % ^^A % \begin{macro}{\MakeShortVerb}
29806 % ^^A % \begin{macrocode}
29807 % ^^A \def\MakeShortVerb#1{%
29808 % ^^A \expandafter\ifx\csname cc\string#1\endcsname\relax
29809 % ^^A % \end{macrocode}
29810 % ^^A % \begin{macrocode}
29811 % ^^A \@shortvrbinfo{Made }{#1}%
29812 % ^^A \add@special{#1}%
29813 % ^^A % \end{macrocode}
29814 % ^^A % Then the character's current catcode is stored in \verb?\cc\?\meta{c}.
29815 % ^^A % \begin{macrocode}
29816 % ^^A \expandafter
29817 % ^^A \xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
29818 % ^^A % \end{macrocode}
29819 % ^^A % The character is spliced into the definition using the same trick as
29820 % ^^A % used in \cs{verb} (for instance), having activated \verb?~? in a group.
29821 % ^^A % \begin{macrocode}
29822 % ^^A \begingroup
29823 % ^^A \catcode`\~\active \lccode`\~`#1%
29824 % ^^A \lowercase{%
29825 % ^^A % \end{macrocode}
29826 % ^^A % The character's old meaning is recorded in \verb?\ac\?\meta{c} prior to
29827 % ^^A % assigning it a new one.
29828 % ^^A % \begin{macrocode}
29829 % ^^A \global\expandafter\let
29830 % ^^A \csname ac\string#1\endcsname~%
29831 % ^^A \gdef~{\verb~}}%
29832 % ^^A \endgroup
29833 % ^^A % \end{macrocode}
29834 % ^^A % Finally the character is made active.
29835 % ^^A % \begin{macrocode}
29836 % ^^A \global\catcode`#1\active
29837 % ^^A % \end{macrocode}
29838 % ^^A % If we suspect that \meta{c} is already a short reference, we tell
29839 % ^^A % the user. Now he or she is responsible if anything goes wrong\,\dots
29840 % ^^A % \begin{macrocode}
29841 % ^^A \else
29842 % ^^A % \end{macrocode}
29843 % ^^A % \begin{macrocode}
29844 % ^^A \@shortvrbinfo\@empty{#1 already}%
29845 % ^^A \fi}
29846 % ^^A % \end{macrocode}
29847 % ^^A % \end{macro}
29848 % ^^A % \begin{macro}{\DeleteShortVerb}
29849 % ^^A % Here's the means of undoing a \cs{MakeShortVerb}, for instance in a
29850 % ^^A % region where you need to use the character outside a verbatim
29851 % ^^A % environment. It arranges for \cs{dospecials} and \cs{@sanitize} to be
29852 % ^^A % altered appropriately, restores the saved catcode and, if necessary,
29853 % ^^A % the character's meaning (as stored by
29854 % ^^A % \cs{MakeShortVerb}). If the catcode wasn't stored in
29855 % ^^A % \verb?\cc\?\meta{c} (by \cs{MakeShortVerb}) the command is silently
29856 % ^^A % ignored.
29857 % ^^A % \begin{macrocode}
29858 % ^^A \def\DeleteShortVerb#1{%
29859 % ^^A \expandafter\ifx\csname cc\string#1\endcsname\relax
29860 % ^^A \else
29861 % ^^A % \end{macrocode}
29862 % ^^A % \begin{macrocode}
29863 % ^^A \@shortvrbinfo{Deleted }{#1 as}%
29864 % ^^A \rem@special{#1}%
29865 % ^^A \global\catcode`#1\csname cc\string#1\endcsname
29866 % ^^A % \end{macrocode}
29867 % ^^A % We must not forget to reset \verb?\cc\?\meta{c}, otherwise the check in
29868 % ^^A % \cs{MakeShortVerb} for a repeated definition will not work.
29869 % ^^A % \begin{macrocode}
29870 % ^^A \global \expandafter\let \csname cc\string#1\endcsname \relax
29871 % ^^A \ifnum\catcode`#1=\active
29872 % ^^A \begingroup
29873 % ^^A \catcode`\~\active \lccode`\~`#1%
29874 % ^^A \lowercase{%
29875 % ^^A \global\expandafter\let\expandafter~%
29876 % ^^A \csname ac\string#1\endcsname}%
29877 % ^^A \endgroup \fi \fi}
29878 % ^^A % \end{macrocode}
29879 % ^^A % \end{macro}
29880 % ^^A %
29881 % ^^A % \begin{macro}{\@shortvrbinfo}
29882 % ^^A % Helper function for info messages.
29883 % ^^A % \begin{macrocode}
29884 % ^^A \def\@shortvrbinfo#1#2{%
29885 % ^^A \ClassInfo{memoir}{%
29886 % ^^A #1\expandafter\@gobble\string#2 a short reference
29887 % ^^A for \string\verb}}
29888 % ^^A % \end{macrocode}
29889 % ^^A % \end{macro}
29890 % ^^A %
29891 % ^^A % \begin{macro}{\add@special}
29892 % ^^A % This helper macro adds its argument to the
29893 % ^^A % \cs{dospecials} macro which is conventionally used by verbatim macros
29894 % ^^A % to alter the catcodes of the currently active characters. We need
29895 % ^^A % to add \verb?\do\?\meta{c} to the expansion of \cs{dospecials} after
29896 % ^^A % removing the character if it was already there to avoid multiple
29897 % ^^A % copies building up should \cs{MakeShortVerb} not be balanced by
29898 % ^^A % \cs{DeleteShortVerb} (in case anything that uses \cs{dospecials} cares
29899 % ^^A % about repetitions).
29900 % ^^A % \begin{macrocode}
29901 % ^^A \def\add@special#1{%
29902 % ^^A \rem@special{#1}%
29903 % ^^A \expandafter\gdef\expandafter\dospecials\expandafter
29904 % ^^A {\dospecials \do #1}%
29905 % ^^A % \end{macrocode}
29906 % ^^A % Similarly we have to add \verb?\@makeother\?\meta{c} to \cs{@sanitize}
29907 % ^^A % (which is used in things like \cs{index} to re-catcode all special
29908 % ^^A % characters except braces).
29909 % ^^A % \begin{macrocode}
29910 % ^^A \expandafter\gdef\expandafter\@sanitize\expandafter
29911 % ^^A {\@sanitize \@makeother #1}}
29912 % ^^A % \end{macrocode}
29913 % ^^A % \end{macro}
29914 % ^^A % \begin{macro}{\rem@special}
29915 % ^^A % The inverse of cs{add@special} is slightly trickier. \cs{do} is
29916 % ^^A % re-defined to expand to nothing if its argument is the character of
29917 % ^^A % interest, otherwise to expand simply to the argument. We can then
29918 % ^^A % re-define \cs{dospecials} to be the expansion of itself. The space
29919 % ^^A % after \verb?=`##1? prevents an expansion to \cs{relax}!
29920 % ^^A % \begin{macrocode}
29921 % ^^A \def\rem@special#1{%
29922 % ^^A \def\do##1{%
29923 % ^^A \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
29924 % ^^A \xdef\dospecials{\dospecials}%
29925 % ^^A % \end{macrocode}
29926 % ^^A % Fixing \cs{@sanitize} is the same except that we need to re-define
29927 % ^^A % \cs{@makeother} which obviously needs to be done in a group.
29928 % ^^A % \begin{macrocode}
29929 % ^^A \begingroup
29930 % ^^A \def\@makeother##1{%
29931 % ^^A \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
29932 % ^^A \xdef\@sanitize{\@sanitize}%
29933 % ^^A \endgroup}
29934 % ^^A % \end{macrocode}
29935 % ^^A % \end{macro}
29936 % ^^A %
29937 % ^^A % end shortvrb code
29938 % ^^A % END OF MITTELBACH CODE AND COMMENTARY.
29939 %
29940 % \subsection{General verbatim boxing and line numbering}
29941 %
29942 % A while ago I wrote a package that I never released. Here it is
29943 % now, updated and improved. The package was based on code originally
29944 % posted to \ctt{} by Donald Arseneau on 13 July 2000.
29945 %
29946 % This is DA's posted code.
29947 % \begin{verbatim}
29948 % \RequirePackage{verbatim}
29949 % \def\boxverbflag{14 }
29950 %
29951 % \def\boxedverbatim{%
29952 % \fboxsep=1em
29953 % \def\verbatim@processline{\leavevmode
29954 % \vrule\vbox{\advance\hsize-.8p@ \@@line
29955 % {\strut\kern\fboxsep\the\verbatim@line\hss}%
29956 % \kern\fbozsep}\vrule\par}%
29957 % \@verbatim % but make some replacement settings
29958 % % \ifdim\@totalleftmargin>\fboxsep \fboxsep\@totalleftmargin \fi
29959 % \leftskip\x@skip \rightskip\z@skip
29960 % \interlinepenalty\boxverbflag
29961 % \parfillskip\z@ plus\p@ minus\p@
29962 % \lineskip-\fboxsep \baselineskip\z@skip
29963 % \frenchspacing\@vobeyspaces
29964 % \boxverb@toprule
29965 % \verbatim@start}
29966 %
29967 % \def\endboxedverbatim{\hrule\endtrivlist}
29968 %
29969 % \@namefdef{boxedverbatim*}{\let\frenchspacing\@gobble \boxedverbatim}
29970 % \@namefdef{endboxedverbatim*}{\hrule\endtrivlist}
29971 %
29972 % \output=\expandafter{\expandafter\boxverb@split \the\output}
29973 %
29974 % \def\boxverb@toprule{\hrule \nobreak \vskip-.1\p@
29975 % \@@line{\vrule height2\fboxsep \hss \vrule}}
29976 %
29977 % \def\boxverb@split{\ifnum\outputpenalty=\boxverbflag
29978 % \ifdim\dp\@cclv=\z@
29979 % \setbox\@cclv\vbox{\unvbox\@cclv\hrule\kern-.4pt}%
29980 % \null \kern-.7\topskip \boxverb@toprule
29981 % \fi\fi}
29982 % \end{verbatim}
29983 % That's the end of DA's posted code
29984 %
29985 % I have extended this to provide:
29986 % \begin{itemize}
29987 % \item A (multipage) boxed verbatim
29988 % \item A (multipage) boxed verbatim input
29989 % \item Normally each `page' is boxed, but start/end rules can be switched off
29990 % at page boundaries
29991 % \item A heading can be put at the start of `continuation' pages
29992 % \item Lines of verbatim text can be numbered
29993 % \item Can be `downgraded' to normal verbatim environment
29994 % \end{itemize}
29995 %
29996 % OK, on to the main code.
29997 %
29998 % \begin{macro}{\boxverbflag}
29999 % \begin{macro}{\bvboxsep}
30000 % \begin{macrocode}
30001 \def\boxverbflag{14 }
30002 \newlength{\bvboxsep} % user can change this
30003 \setlength{\bvboxsep}{1em}
30004
30005 % \end{macrocode}
30006 % \end{macro}
30007 % \end{macro}
30008 %
30009 % \begin{macrocode}
30010 \newif\ifbvperpage % start/end lines on every page of multipage verbatim
30011 \bvperpagetrue
30012
30013 % \end{macrocode}
30014 %
30015 % \begin{macro}{\bvtopofpage}
30016 % \begin{macro}{\b@vtop}
30017 % Can use \cs{bvtopofpage} to put a heading above continued verbatims.
30018 % For example \\
30019 % \verb?\bvtopofpage{\begin{center}\normalfont (Continued)\end{center}}? \\
30020 % It only works for \cs{bvperpagetrue}.
30021 % \begin{macrocode}
30022 \newcommand{\bvtopofpage}[1]{%
30023 \long\def\b@vtop{#1}}
30024 \def\b@vtop{} % used in \boxverb@split for heading
30025
30026 % \end{macrocode}
30027 % \end{macro}
30028 % \end{macro}
30029 %
30030 % \begin{macro}{\c@memfbvline}
30031 % \begin{macro}{\c@bvlinectr}
30032 % Counter for adjusting the starting line number for boxed verbatims
30033 % and for the line number itself..
30034 % \begin{macrocode}
30035 \newcounter{memfbvline}
30036 \c@memfbvline=\z@
30037 \newcounter{bvlinectr}
30038 % \end{macrocode}
30039 % \end{macro}
30040 % \end{macro}
30041 %
30042 % \begin{macro}{\setbvlinenums}
30043 % \cs{setbvlinenums}\marg{firstline}\marg{startnumsat} sets the first line
30044 % number to \meta{firstline} and the first line number to be printed is
30045 % \meta{startnumsat}.
30046 % \changes{v1.61803}{2008/01/30}{Added \cs{setbvlinenums} (mempatch v4.9)}
30047 % \begin{macrocode}
30048 \newcommand*{\setbvlinenums}[2]{%
30049 \c@bvlinectr #1\relax \advance\c@bvlinectr \m@ne
30050 \ifnum\z@<\linemodnum% we are printing line numbers
30051 \@tempcnta #2\relax
30052 \divide\@tempcnta\linemodnum
30053 \multiply\@tempcnta\linemodnum
30054 \c@memfbvline #2\relax
30055 \advance\c@memfbvline-\@tempcnta
30056 \fi}
30057
30058 % \end{macrocode}
30059 % \end{macro}
30060 %
30061 % \begin{macro}{\theb@vlinenumber}
30062 % \begin{macro}{\resetbvlinenumber}
30063 % \cs{resetbvlinenumber} reinitializes the line numbering.
30064 % \changes{v1.61803}{2008/01/30}{Changed \cs{theb@vlinenumber} (mempatch v4.9)}
30065 % \begin{macrocode}
30066 \def\theb@vlinenumber{\getthelinenumber{bvlinectr}{memfbvline}}
30067 \newcommand*{\resetbvlinenumber}{\setcounter{bvlinectr}{0}}
30068
30069 % \end{macrocode}
30070 % \end{macro}
30071 % \end{macro}
30072 %
30073 % \begin{macro}{\b@vdocount}
30074 % \begin{macro}{\bvnumlength}
30075 % Increment line number if counting. A line number is printed in
30076 % a space width \cs{bvnumlength}, which is given a temporary value here.
30077 % \begin{macrocode}
30078 \def\b@vdocount{\ifbvcountlines\stepcounter{bvlinectr}\fi}
30079 \newlength{\bvnumlength}
30080 %% \settowidth{\bvnumlength}{\vlvnumfont 9999}
30081 \settowidth{\bvnumlength}{\normalfont 999}
30082
30083 % \end{macrocode}
30084 % \end{macro}
30085 % \end{macro}
30086 %
30087 % \begin{macro}{\ifbvcountinside}
30088 % \begin{macro}{\bvnumbersinside}
30089 % \begin{macro}{\bvnumbersoutside}
30090 % Flag and commands for positioning the numbers. Default is to print
30091 % them inside the box.
30092 % \begin{macrocode}
30093 \newif\ifbvcountinside % TRUE if line numbers inside box
30094 \bvcountinsidetrue
30095 \newcommand*{\bvnumbersinside}{\bvcountinsidetrue}
30096 \newcommand*{\bvnumbersoutside}{\bvcountinsidefalse}
30097
30098 % \end{macrocode}
30099 % \end{macro}
30100 % \end{macro}
30101 % \end{macro}
30102 %
30103 % \begin{macro}{\b@vdoinside}
30104 % \begin{macro}{\b@vdooutside}
30105 % Print numbers inside (outside) the box.
30106 % \begin{macrocode}
30107 \def\b@vdoinside{%
30108 \ifbvcountlines\ifbvcountinside%
30109 \makebox[\bvnumlength][r]{%
30110 \vlvnumfont \theb@vlinenumber\space}%
30111 \fi\fi}
30112
30113 \def\b@vdooutside{%
30114 \ifbvcountlines\ifbvcountinside\else%
30115 \llap{\makebox[\bvnumlength][r]{%
30116 \vlvnumfont \theb@vlinenumber\space}}%
30117 \fi\fi}
30118
30119 % \end{macrocode}
30120 % \end{macro}
30121 % \end{macro}
30122 %
30123 % \begin{macro}{\@@m@mline}
30124 % \cs{@@line} is defined as \verb?\def\@@line{\hb@xt@\hsize}? and I need
30125 % an equivalent for \cs{linewidth} instead of \cs{hsize} for use in
30126 % \cs{setupboxverb@line}.
30127 % \changes{v1.61803}{2008/01/30}{Added \cs{@@m@mline} (mempatch v4.9)}
30128 % \begin{macrocode}
30129 \newcommand*{\@@m@mline}{\hb@xt@\linewidth}
30130
30131 % \end{macrocode}
30132 % \end{macro}
30133 %
30134 % \begin{macro}{\setupboxverb@line}
30135 % Use a macro for the first main part of DA's code for \cs{boxedverbatim},
30136 % adding lots of hooks.
30137 %
30138 % Per Starb\"{a}ck had problems with the combination of \texttt{adjustwidth}
30139 % with \texttt{boxedverbatim} (see CTT \textit{Re: [memoir] adjustwidth +
30140 % boxedverbatim}, 2007/02/10) and Lars Madsen came up with a suggestion to
30141 % use \cs{linewidth} instead of \cs{hsize}.
30142 % \changes{v1.61803}{2008/01/30}{Changed \cs{hsize} to \cs{linewidth} in
30143 % \cs{setupboxverb@line} (mempatch v4.9)}
30144 % \begin{macrocode}
30145 \newcommand{\setupboxverb@line}{%
30146 \par
30147 \ifbvperpage
30148 \output=\expandafter{\expandafter\boxverb@split \the\output}
30149 \fi
30150 % \end{macrocode}
30151 % \begin{macro}{\verbatim@processline}
30152 % \changes{v3.8.2}{2024/01/25}{Removed tab support}
30153 % \begin{macrocode}
30154 \def\verbatim@processline{\leavevmode
30155 \b@vdocount%
30156 \bvleftsidehook\vbox{\advance% \hsize-.8\p@ \@@line % changed to \linewidth
30157 \linewidth-.8\p@ \@@line
30158 {\b@vdooutside\strut\kern\bvboxsep%
30159 \b@vdoinside%
30160 %\ift@bs
30161 % \tabverbatim@processline
30162 %\else
30163 \the\verbatim@line
30164 %\fi
30165 \hss}%
30166 \kern\bvboxsep}\bvrightsidehook\par}}
30167
30168 % \end{macrocode}
30169 % \end{macro}
30170 % \end{macro}
30171 %
30172 %
30173 % \begin{macro}{\setupbox@verb}
30174 % Use a macro for the second main part of DA's code, and integrate it
30175 % with the other verbatim codes.
30176 %
30177 % \changes{v3.8.2}{2024/01/25}{Removed \cs{@maybeobeytags}}
30178 % \begin{macrocode}
30179 \newcommand{\setupbox@verb}{%
30180 \leftskip\z@skip \rightskip\z@skip
30181 \interlinepenalty\boxverbflag
30182 \parfillskip\z@ plus\p@ minus\p@
30183 \lineskip-\bvboxsep \baselineskip\z@skip
30184 \frenchspacing\@vobeyspaces%\@maybeobeytabs
30185 \boxverb@toprule}
30186
30187 % \end{macrocode}
30188 % \end{macro}
30189 %
30190 %
30191 % \begin{macro}{\boxedverbatim}
30192 % \begin{macro}{\endboxedverbatim}
30193 % \begin{macro}{\boxedverbatim*}
30194 % \begin{macro}{\endboxedverbatim*}
30195 % Given the two macros above, we can write a briefer version of DA's
30196 % \cs{boxedverbatim(*)}.
30197 % As noted by Zarko Cucej, have to handle
30198 % a following (no-) paragraph.
30199 % \changes{v1.4}{2003/11/22}{Added \cs{@doendpe} to \cs{endboxedverbatim}
30200 % (from patch v1.8)}
30201 % \begin{macrocode}
30202 \def\boxedverbatim{\begingroup
30203 \let\@@line\@@m@mline% new from mempatch v4.9
30204 \setupboxverb@line
30205 \@verbatim
30206 \setupbox@verb
30207 \verbatim@start}
30208 \def\endboxedverbatim{\bvendrulehook\endtrivlist\endgroup\@doendpe}
30209 \@namedef{boxedverbatim*}{\let\frenchspacing\@gobble \boxedverbatim}
30210 \@namelet{endboxedverbatim*}\endboxverbatim
30211
30212 % \end{macrocode}
30213 % \end{macro}
30214 % \end{macro}
30215 % \end{macro}
30216 % \end{macro}
30217 %
30218 % \begin{macrocode}
30219 \def\boxverb@toprule{\bvtoprulehook
30220 \@@line{\bvleftsidehook \bvtopmidhook \bvrightsidehook}}
30221
30222 % \end{macrocode}
30223 %
30224 % \begin{macro}{\bvendofpage}
30225 % \cs{bvendofpage}\marg{spec} sets the boxed verbatim `end of page' to \meta{spec}.
30226 % \changes{v1.618}{2005/09/02}{Added \cs{bvendofpage} (mempatch v2.3d)}
30227 % \changes{v1.61803}{2008/01/30}{Changed \cs{bvendofpage} to include width}
30228 % \begin{macrocode}
30229 \newcommand*{\bvendofpage}[1]{%
30230 \def\boxverb@botpage{#1}}
30231 %%%%\bvendofpage{\hrule\kern-.4pt}
30232 \bvendofpage{\hrule width\linewidth\kern-.4pt}
30233
30234 % \end{macrocode}
30235 % \end{macro}
30236 %
30237 % \begin{macro}{\boxverb@split}
30238 % \begin{macrocode}
30239 \def\boxverb@split{\ifnum\outputpenalty=\boxverbflag
30240 \ifdim\dp\@cclv=\z@
30241 %%%% \setbox\@cclv\vbox{\unvbox\@cclv\hrule\kern-.4pt}%
30242 \setbox\@cclv\vbox{\unvbox\@cclv\boxverb@botpage}%
30243 \null \kern-.7\topskip \b@vtop \boxverb@toprule
30244 \fi
30245 \fi}
30246
30247 % \end{macrocode}
30248 % \end{macro}
30249 %
30250 % \begin{macro}{\bvtoprulehook}
30251 % \begin{macro}{\bvendrulehook}
30252 % \begin{macro}{\bvleftsidehook}
30253 % \begin{macro}{\bvrightsidehook}
30254 % \begin{macro}{\bvtopmidhook}
30255 % The new hooks, for the top, bottom, left and right of the box.
30256 % \changes{v1.61803}{2008/01/30}{Added \cs{linewidth} to \cs{bvtoprulehook} and
30257 % \cs{bvendrulehook} (mempatch v4.9)}
30258 % \begin{macrocode}
30259 \def\bvtoprulehook{\hrule width\linewidth \nobreak\vskip-.1\p@}
30260 \def\bvendrulehook{\hrule width\linewidth}
30261 \def\bvleftsidehook{\vrule}
30262 \def\bvrightsidehook{\vrule}
30263 \def\bvtopmidhook{\rule{0\p@}{2\bvboxsep} \hss}
30264
30265 % \end{macrocode}
30266 % \end{macro}
30267 % \end{macro}
30268 % \end{macro}
30269 % \end{macro}
30270 % \end{macro}
30271 %
30272 % \begin{macro}{\boxedverbatiminput}
30273 % \begin{macro}{\boxedverbatim@input}
30274 % \cs{boxedverbatiminput}\marg{filename} read in filename contents as verbatim
30275 % \begin{macrocode}
30276 \newcommand{\boxedverbatiminput}{\begingroup
30277 \@ifstar{\let\frenchspacing\@gobble
30278 \boxedverbatim@input\relax}%
30279 {\boxedverbatim@input{\frenchspacing\@vobeyspaces}}}
30280
30281 % \end{macrocode}
30282 %
30283 % \begin{macrocode}
30284 \def\boxedverbatim@input#1#2{%
30285 \setupboxverb@line
30286 \IfFileExists{#2}{\@verbatim #1\relax
30287 \setupbox@verb
30288 \verbatim@readfile{\@filef@und}%
30289 \bvendrulehook\endtrivlist\endgroup\@doendpe}%
30290 {\typeout {No file #2.}\endgroup}}
30291
30292 % \end{macrocode}
30293 % \end{macro}
30294 % \end{macro}
30295 %
30296 % Some prepackaged boxing styles.
30297 %
30298 % \begin{macro}{\bvbox}
30299 % Original (default) boxing.
30300 % \begin{macrocode}
30301 \newcommand{\bvbox}{%
30302 \bvperpagetrue%
30303 \renewcommand{\bvtoprulehook}{\hrule \nobreak \vskip-.1\p@}%
30304 \renewcommand{\bvleftsidehook}{\vrule}%
30305 \renewcommand{\bvrightsidehook}{\vrule}%
30306 \renewcommand{\bvendrulehook}{\hrule}}
30307
30308 % \end{macrocode}
30309 % \end{macro}
30310 %
30311 % \begin{macro}{\nobvbox}
30312 % No boxing
30313 % \begin{macrocode}
30314 \newcommand{\nobvbox}{%
30315 \bvperpagefalse%
30316 \renewcommand{\bvtoprulehook}{}%
30317 \renewcommand{\bvleftsidehook}{}%
30318 \renewcommand{\bvrightsidehook}{}%
30319 \renewcommand{\bvendrulehook}{}}
30320
30321 % \end{macrocode}
30322 % \end{macro}
30323 %
30324 % \begin{macro}{\bvtopandtail}
30325 % Head and foot horizontal lines only
30326 % \begin{macrocode}
30327 \newcommand{\bvtopandtail}{%
30328 \bvperpagefalse%
30329 \renewcommand{\bvtoprulehook}{\hrule \nobreak \vskip-.1\p@}%
30330 \renewcommand{\bvleftsidehook}{}%
30331 \renewcommand{\bvrightsidehook}{}%
30332 \renewcommand{\bvendrulehook}{\hrule}}
30333
30334 % \end{macrocode}
30335 % \end{macro}
30336 %
30337 % \begin{macro}{\bvsides}
30338 % Side vertical lines only
30339 % \begin{macrocode}
30340 \newcommand{\bvsides}{%
30341 \bvperpagefalse%
30342 \renewcommand{\bvtoprulehook}{\vskip 3ex}%
30343 \renewcommand{\bvleftsidehook}{\vrule}%
30344 \renewcommand{\bvrightsidehook}{\vrule}%
30345 \renewcommand{\bvendrulehook}{}}
30346
30347 % \end{macrocode}
30348 % \end{macro}
30349 %
30350 %
30351 %
30352 % \subsection{The framed package}
30353 %
30354 % The following code is the \Lpack{framed} package~\cite{FRAMED}
30355 % by Donald Arseneau.
30356 % \changes{v1.4}{2003/11/22}{Updated framed code to v0.8a of the package}
30357 % \changes{v1.61803}{2008/01/30}{Updated framed code to v0.95 of the package}
30358 %
30359 % \begin{macro}{\framed}
30360 % \begin{macro}{\endframed}
30361 % \begin{macro}{\shaded}
30362 % \begin{macro}{\endshaded}
30363 % \begin{macrocode}
30364 \let\framed\relax \let\endframed\relax
30365 \let\shaded\relax \let\endshaded\relax
30366
30367 % \end{macrocode}
30368 % \end{macro}
30369 % \end{macro}
30370 % \end{macro}
30371 % \end{macro}
30372 %
30373 % Way back when DA sent me a pre-release copy of v0.6 of his \Lpack{framed}
30374 % package~\cite{FRAMED}.
30375 % We also discussed good ways of embedding it into the class. One result
30376 % being that I defined some some items \cs{AtBeginDocument}, but this is
30377 % no longer required as DA has changed \Lpack{framed} to cooperate
30378 % with memoir. We continue to have sporadic email conversations about the
30379 % interaction of \Lpack{memoir} and \Lpack{framed}.
30380 %
30381 % Here is a modified version of \file{framed.sty}. In particular
30382 % I moved some of DA's description of the code into the general commentary
30383 % instead of comments within the code.
30384 %
30385 % \begin{verbatim}
30386 % framed.sty v 0.95 2007/10/04
30387 % Copyright (C) 1992-2007 by Donald Arseneau ([email protected])
30388 % These macros may be freely transmitted, reproduced, or modified
30389 % provided that this notice is left intact.
30390 %
30391 %====================== Begin Instructions =======================
30392 %
30393 % framed.sty
30394 % ~~~~~~~~~~
30395 % Create framed, shaded, or differently highlighted regions that can
30396 % break across pages. The environments defined are
30397 % framed -- ordinary frame box (\fbox) with edge at margin
30398 % shaded -- shaded background (\colorbox) bleeding into margin
30399 % snugshade -- similar
30400 % leftbar -- thick vertical line in left margin
30401 % to be used like
30402 % \begin{framed}
30403 % copious text
30404 % \end{framed}
30405 %
30406 % But the more general purpose of this package is to facilitate the
30407 % creation of environments that enable page breaking
30408 % within arbitrary decorations using a simple new-environment definition
30409 % incorporating \FrameCommand and
30410 % \begin{MakeFramed}{settings} ... \end{MakeFramed}
30411 %
30412 % The "framed" environment uses "\fbox" as its "\FrameCommand" with
30413 % the additional settings \fboxrule=\FrameRule and \fboxsep=\FrameSep.
30414 % You can change these lengths (using \setlength) and you can change
30415 % the definition of \FrameCommand to use much fancier boxes.
30416 %
30417 % In fact, the "shaded" environment just redefines \FrameCommand to be
30418 % \colorbox{shadecolor} (and you have to define the color "shadecolor":
30419 % \definecolor{shadecolor}...).
30420 %
30421 % A page break is allowed, and even encouraged, before the framed
30422 % environment. If you want to attach some text (a box title) to the
30423 % frame, then the text should be inserted by \FrameCommand.
30424 %
30425 % The contents of the framed regions are restricted:
30426 % Floats, footnotes, marginpars and head-line entries will be lost.
30427 % (Some of these may be handled in a later version.)
30428 % This package will not work with the page breaking of multicol.sty,
30429 % or other systems that perform column-balancing.
30430 %
30431 % The MakeFramed environment does the work. Its "settings" argument
30432 % should contain any adjustments to the text width (applied to \hsize,
30433 % and using the "\width" of the frame itself) as well as a "restore"
30434 % command -- \@parboxrestore or \FrameRestore or something similar;
30435 % as an example, the snugshade environment shows how to suppress excess
30436 % spacing within the box, copying the code from minipage.
30437 %
30438 % Expert commands:
30439 % \MakeFramed, \endMakeFramed: the "MakeFramed" environment
30440 % \FrameCommand: command to draw the frame around its argument
30441 % \FrameRestore: restore some text settings, but fewer than \@parboxrestore
30442 % \FrameRule: length register; \fboxrule for default "framed".
30443 % \FrameSep: length register; \fboxsep for default "framed".
30444 % \FrameHeightAdjust: macro; height of frame above baseline at top of page
30445 %
30446 % This is still a `pre-production' version because I can think of many
30447 % features/improvements that should be made. Nevertheless, starting
30448 % with version 0.5 it should be bug-free.
30449 %
30450 % ToDo:
30451 % Test more varieties of list
30452 % Improve and correct documentation
30453 % Propagation of \marks
30454 % Handle footnotes (how??) floats (?) and marginpars.
30455 % Stretchability modification.
30456 %======================== End Instructions ========================
30457 %
30458 % \ProvidesPackage{framed}[2007/10/04 v 0.95:
30459 % framed or shaded text with page breaks]
30460 %
30461 % \newenvironment{framed}% using default \FrameCommand
30462 % {\MakeFramed {\advance\hsize-\width \FrameRestore}}%
30463 % {\endMakeFramed}
30464 %
30465 % \newenvironment{shaded}{%
30466 % \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
30467 % \MakeFramed {\FrameRestore}}%
30468 % {\endMakeFramed}
30469 %
30470 % \newenvironment{leftbar}{%
30471 % \def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
30472 % \MakeFramed {\advance\hsize-\width \FrameRestore}}%
30473 % {\endMakeFramed}
30474 %
30475 % \newenvironment{snugshade}{%
30476 % \def\FrameCommand{\colorbox{shadecolor}}%
30477 % \MakeFramed {\FrameRestore\@setminipage}}%
30478 % {\par\unskip\endMakeFramed}
30479 %
30480 % \end{verbatim}
30481 %
30482 % Now for the package code.
30483 %
30484 % \begin{macrocode}
30485 \chardef\FrameRestore=\catcode`\| % for debug
30486 \catcode`\|=\catcode`\% % (debug: insert space after backslash)
30487
30488 % \end{macrocode}
30489 %
30490 % \begin{macro}{\MakeFramed}
30491 % \begin{macrocode}
30492 \def\MakeFramed#1{\par
30493 % \end{macrocode}
30494 % measure added width and height; call result \cs{width} and \cs{height}
30495 % \begin{macrocode}
30496 \fb@sizeofframe\FrameCommand
30497 \let\width\fb@frw \let\height\fb@frh
30498 % \end{macrocode}
30499 % insert pre-penalties and skips
30500 % \begin{macrocode}
30501 \begingroup
30502 \skip@\lastskip
30503 \if@nobreak\else
30504 \penalty9999 % updates \page parameters
30505 \ifdim\pagefilstretch=\z@ \ifdim\pagefillstretch=\z@
30506 % \end{macrocode}
30507 % not infinitely stretchable, so encourage a page break here
30508 % \begin{macrocode}
30509 \edef\@tempa{\the\skip@}%
30510 \ifx\@tempa\zero@glue \penalty-30
30511 \else \vskip-\skip@ \penalty-30 \vskip\skip@
30512 \fi\fi\fi
30513 \penalty\z@
30514 % \end{macrocode}
30515 % Give a stretchy breakpoint that will always be taken in preference
30516 % to the \cs{penalty} 9999 used to update page parameters. The cube root
30517 % of 10000/100 indicates a multiplier of 0.21545, but the maximum
30518 % calculated badness is really 8192, not 10000, so the multiplier
30519 % is 0.2301.
30520 % \begin{macrocode}
30521 \advance\skip@ \z@ plus-.5\baselineskip
30522 \advance\skip@ \z@ plus-.231\height
30523 \advance\skip@ \z@ plus-.231\skip@
30524 \advance\skip@ \z@ plus-.231\topsep
30525 \vskip-\skip@ \penalty 1800 \vskip\skip@
30526 \fi
30527 \addvspace{\topsep}%
30528 \endgroup
30529 % \end{macrocode}
30530 % clear out pending page break
30531 % \begin{macrocode}
30532 \penalty\@M \vskip 2\baselineskip \vskip\height
30533 \penalty9999 \vskip -2\baselineskip \vskip-\height
30534 \penalty9999 % updates \pagetotal
30535 |\message{After clearout, \pagetotal=\the\pagetotal,
30536 | \pagegoal=\the\pagegoal. }%
30537 \fb@adjheight
30538 \setbox\@tempboxa\vbox\bgroup
30539 #1% Modifications to \hsize (can use \width and \height)
30540 \textwidth\hsize \columnwidth\hsize}
30541
30542 % \end{macrocode}
30543 % \end{macro}
30544 %
30545 % \begin{macro}{\endMakeFramed}
30546 % \begin{macrocode}
30547 \def\endMakeFramed{\par
30548 \kern\z@
30549 \hrule\@width\hsize\@height\z@
30550 \penalty-100 % put depth into height
30551 \egroup
30552 % {\showoutput\showbox\@tempboxa}%
30553 \begingroup
30554 \fb@put@frame\FrameCommand\FirstFrameCommand
30555 \endgroup}
30556
30557 % \end{macrocode}
30558 % \end{macro}
30559 %
30560 % \begin{macro}{\fb@put@frame}
30561 % \cs{fb@put@frame}\marg{nosplit}\marg{split}
30562 % takes the contents of \cs{@tempboxa} and puts all,
30563 % or a piece,
30564 % of it on the page with a frame (\cs{FrameCommand}, \cs{FirstFrameCommand},
30565 % \cs{MidFrameCommand}, or \cs{LastFrameCommand}). It recurses until all of
30566 % \cs{@tempboxa} has been used up. (\cs{@tempboxa} must have zero depth.) \\
30567 % \meta{nosplit} = attempted framing command, if no split \\
30568 % \meta{split} = framing command if split.
30569 %
30570 % First iteration: Try to fit with \cs{FrameCommand}. If it does not fit,
30571 % split for \cs{FirstFrameCommand}.
30572 %
30573 % Later iteration: Try to fit with \cs{LastFrameCommand}. If it does not
30574 % fit, split for \cs{MidFrameCommand}.
30575 % \begin{macrocode}
30576 \def\fb@put@frame#1#2{\relax
30577 \ifdim\pagegoal=\maxdimen \pagegoal\vsize \fi
30578 \ifinner
30579 \fb@putboxa#1%
30580 \fb@afterframe
30581 \else
30582 \dimen@\pagegoal \advance\dimen@-\pagetotal % natural space left on page
30583 \ifdim\dimen@<2\baselineskip % Too little room on page
30584 | \message{Page has only \the\dimen@\space room left; eject. }%
30585 \eject \fb@adjheight \fb@put@frame#1#2%
30586 \else % there's appreciable room left on the page
30587 \fb@sizeofframe#1%
30588 | \message{\string\pagetotal=\the\pagetotal,
30589 | \string\pagegoal=\the\pagegoal,
30590 | \string\pagestretch=\the\pagestretch,
30591 | \string\pageshrink=\the\pageshrink,
30592 | \string\fb@frh=\fb@frh. \space}
30593 | \message{Box of size \the\ht\@tempboxa\space + \fb@frh}%
30594 \begingroup % temporarily set \dimen@ to be...
30595 \advance\[email protected]\pageshrink % maximum space available on page
30596 \advance\dimen@-\fb@frh\relax % space available for frame's contents
30597 \expandafter\endgroup
30598 % \end{macrocode}
30599 % expand \cs{ifdim}, then restore \cs{dimen@} to real room left on page
30600 % \begin{macrocode}
30601 \ifdim\dimen@>\ht\@tempboxa % whole box does fit
30602 | \message{fits in \the\dimen@. }%
30603 % \end{macrocode}
30604 % Use vsplit anyway to capture the marks \\
30605 % !!!???!!! MERGE THIS WITH THE else CLAUSE!!!
30606 % \begin{macrocode}
30607 \fb@putboxa#1%
30608 \fb@afterframe
30609 \else % box must be split
30610 | \message{must be split to fit in \the\dimen@. }%
30611 % \end{macrocode}
30612 % update frame measurement to use \cs{FirstFrameCommand}
30613 % or \cs{MidFrameCommand}
30614 % \begin{macrocode}
30615 \fb@sizeofframe#2%
30616 \setbox\@tempboxa\vbox{% simulate frame and flexiblity of the page:
30617 \vskip \fb@frh \@plus\pagestretch \@minus.8\pageshrink
30618 \kern137sp\kern-137sp\penalty-30
30619 \unvbox\@tempboxa}%
30620 \edef\fb@resto@set{\boxmaxdepth\the\boxmaxdepth
30621 \splittopskip\the\splittopskip}%
30622 \boxmaxdepth\z@ \splittopskip\z@
30623 | \message{Padded box of size \the\ht\@tempboxa\space split
30624 | to \the\dimen@}%
30625 % \end{macrocode}
30626 % Split box here
30627 % \begin{macrocode}
30628 \setbox\tw@\vsplit\@tempboxa to\dimen@
30629 | \toks99\expandafter{\splitfirstmark}%
30630 | \toks98\expandafter{\splitbotmark}%
30631 | \message{Marks are: \the\toks99, \the\toks98. }%
30632 \setbox\tw@\vbox{\unvbox\tw@}% natural-sized
30633 | \message{Natural height of split box is \the\ht\tw@, leaving
30634 | \the\ht\@tempboxa\space remainder. }%
30635 % \end{macrocode}
30636 % If the split-to size $>$ (\cs{vsize}-\cs{topskip}), then set box to full size
30637 % \begin{macrocode}
30638 \begingroup
30639 \advance\dimen@\topskip
30640 \expandafter\endgroup
30641 \ifdim\dimen@>\pagegoal
30642 | \message{Frame is big -- Use up the full column. }%
30643 \dimen@ii\pagegoal
30644 \advance\dimen@ii -\topskip
30645 \advance\dimen@ii \FrameHeightAdjust\relax
30646 \else % suspect this is wrong:
30647 % \end{macrocode}
30648 % If the split-to size $>$ feasible room-on-page, rebox it smaller.
30649 % \begin{macrocode}
30650 \advance\[email protected]\pageshrink
30651 \ifdim\ht\tw@>\dimen@
30652 | \message{Box too tall; rebox it to \the\dimen@. }%
30653 \dimen@ii\dimen@
30654 \else % use natural size
30655 \dimen@ii\ht\tw@
30656 \fi
30657 \fi
30658 % \end{macrocode}
30659 % Re-box contents to desired size \cs{dimen@ii}
30660 % \begin{macrocode}
30661 \advance\dimen@ii -\fb@frh
30662 \setbox\tw@\vbox to\dimen@ii \bgroup
30663 % \end{macrocode}
30664 % remove simulated frame and page flexibility:
30665 % \begin{macrocode}
30666 \vskip -\fb@frh \@plus-\pagestretch \@minus-.8\pageshrink
30667 \unvbox\tw@ \unpenalty\unpenalty
30668 \ifdim\lastkern=-137sp % whole box went to next page
30669 | \message{box split at beginning! }%
30670 % need work here???
30671 \egroup \fb@resto@set \eject % (\vskip for frame size was discarded)
30672 \fb@adjheight
30673 \fb@put@frame#1#2% INSERTED ???
30674 \else % Got material split off at the head
30675 \egroup \fb@resto@set
30676 \ifvoid\@tempboxa % it all fit after all
30677 | \message{box split at end! }%
30678 \setbox\@tempboxa\box\tw@
30679 \fb@putboxa#1%
30680 \fb@afterframe
30681 \else % it really did split
30682 | \message{box split as expected. Its reboxed height
30683 | is \the\ht\tw@. }%
30684 \ifdim\wd\tw@>\z@
30685 \wd\tw@\wd\@tempboxa
30686 % \end{macrocode}
30687 % PW: the next line was: \\
30688 % \verb!\centerline{#2{\box\tw@}}% ??? \centerline bad idea?! \\
30689 % but I have changed it as follows so that \cs{centerline} can be changed
30690 % from elsewhere if useful.
30691 % \begin{macrocode}
30692 \memfblineboxtwo{#2{\box\tw@}}% ??? \centerline bad idea? \\
30693 \else
30694 | \message{Zero width means likely blank.
30695 | Don't frame it (guess)}%
30696 \box\tw@
30697 \fi
30698 \hrule \@height\z@ \@width\hsize
30699 \eject
30700 \fb@adjheight
30701 \fb@put@frame\LastFrameCommand\MidFrameCommand
30702 \fi\fi\fi\fi\fi}
30703
30704 % \end{macrocode}
30705 % \end{macro}
30706 %
30707 % \begin{macro}{\memfblineboxtwo}
30708 % \begin{macro}{\memfblineboxa}
30709 % PW: this is an addition of mine. There is a question mark against the
30710 % use of \cs{centerline} within the \Lenv{framed} code. I have
30711 % created these two macros which are used in the code instead of
30712 % \cs{centerline}, so that those parts of the code can be easily altered.
30713 % are used instead
30714 % \begin{macrocode}
30715 \newcommand{\memfblineboxtwo}[1]{\centerline{#1}}
30716 \newcommand{\memfblineboxa}[1]{\centerline{#1}}
30717
30718 % \end{macrocode}
30719 % \end{macro}
30720 % \end{macro}
30721 %
30722 % \begin{macro}{\fb@putboxa}
30723 % \begin{macrocode}
30724 \def\fb@putboxa#1{%
30725 \ifvoid\@tempboxa
30726 %%%% PackageWarning{framed}{Boxa is void -- discard it. }%
30727 \@memwarn{Boxa is void -- discard it. }%
30728 \else
30729 | \message{Frame and place boxa. }%
30730 | %{\showoutput\showbox\@tempboxa}%
30731 %%%%%%% \centerline{#1{\box\@tempboxa}}%
30732 \memfblineboxa{#1{\box\@tempboxa}}%
30733 \fi}
30734
30735 % \end{macrocode}
30736 % \end{macro}
30737 %
30738 % \begin{macro}{\fb@afterframe}
30739 % \begin{macrocode}
30740 \def\fb@afterframe{%
30741 \nointerlineskip \null %{\showoutput \showlists}
30742 \penalty-30 \vskip\topsep \relax}
30743
30744 % \end{macrocode}
30745 % \end{macro}
30746 %
30747 % \begin{macro}{\fb@frw}
30748 % \begin{macro}{\fb@frh}
30749 % \begin{macro}{\fb@sizeofframe}
30750 % \cs{fb@sizeofframe}\marg{framecommand} measures width and height added by
30751 % frame (\meta{framecommand}) and call the results \cs{fb@frw} and \cs{fb@frh}.
30752 % \begin{macrocode}
30753 \newdimen\fb@frw
30754 \newdimen\fb@frh
30755 \def\fb@sizeofframe#1{\begingroup
30756 \setbox\z@\vbox{\vskip-5in \hbox{\hskip-5in
30757 #1{\hbox{\vrule \@height 4.7in \@depth.3in \@width 5in}}}%
30758 \vskip\z@skip}%
30759 | \message{Measuring frame addition for \string#1 in \@currenvir\space
30760 | gives ht \the\ht\z@\space and wd \the\wd\z@. }%
30761 %{\showoutput\showbox\z@}%
30762 \global\fb@frw\wd\z@ \global\fb@frh\ht\z@
30763 \endgroup}
30764
30765 % \end{macrocode}
30766 % \end{macro}
30767 % \end{macro}
30768 % \end{macro}
30769 %
30770 % \begin{macro}{\fb@adjheight}
30771 % \begin{macrocode}
30772 \def\fb@adjheight{%
30773 \vbox to\FrameHeightAdjust{}% get proper baseline skip from above.
30774 \penalty\@M \nointerlineskip
30775 \vskip-\FrameHeightAdjust
30776 \penalty\@M} % useful for tops of pages
30777
30778 % \end{macrocode}
30779 % \end{macro}
30780 %
30781 % \begin{macro}{\zero@glue}
30782 % \begin{macrocode}
30783 \edef\zero@glue{\the\z@skip}
30784
30785 \catcode`\|=\FrameRestore
30786
30787 % \end{macrocode}
30788 % \end{macro}
30789 %
30790 % \begin{macro}{\FrameCommand}
30791 % \begin{macro}{\FrameRule}
30792 % \begin{macro}{\FrameSep}
30793 % \begin{macro}{\FirstFrameCommand}
30794 % \begin{macro}{\MidFrameCommand}
30795 % \begin{macro}{\LastFrameCommand}
30796 % Provide configuration commands:
30797 % \begin{macrocode}
30798 \providecommand\FrameCommand{%
30799 \setlength\fboxrule{\FrameRule}\setlength\fboxsep{\FrameSep}%
30800 \fbox}
30801 \@ifundefined{FrameRule}{\newdimen\FrameRule \FrameRule=\fboxrule}{}
30802 \@ifundefined{FrameSep} {\newdimen\FrameSep \FrameSep =3\fboxsep}{}
30803 \providecommand\FirstFrameCommand{\FrameCommand}
30804 \providecommand\MidFrameCommand{\FrameCommand}
30805 \providecommand\LastFrameCommand{\FrameCommand}
30806 % \end{macrocode}
30807 % \end{macro}
30808 % \end{macro}
30809 % \end{macro}
30810 % \end{macro}
30811 % \end{macro}
30812 % \end{macro}
30813 %
30814 % \begin{macro}{\FrameHeightAdjust}
30815 % Height of frame above first baseline when frame starts a page:
30816 % \begin{macrocode}
30817 \providecommand\FrameHeightAdjust{6pt}
30818
30819 % \end{macrocode}
30820 % \end{macro}
30821 %
30822 % \begin{macro}{\FrameRestore}
30823 % \cs{FrameRestore} has parts of \cs{@parboxrestore}, performing a similar but
30824 % less complete restoration of a default layout. See how it is used in the
30825 % "settings" argument of \cs{MakeFrame}. Though not a parameter, \cs{hsize}
30826 % should be set to the desired total line width available inside the
30827 % frame before invoking \cs{FrameRestore}.
30828 % \begin{macrocode}
30829 \def\FrameRestore{%
30830 \let\if@nobreak\iffalse
30831 \let\if@noskipsec\iffalse
30832 \let\-\@dischyph
30833 \let\'\@acci\let\`\@accii\let\=\@acciii
30834 % \message{FrameRestore:
30835 % \@totalleftmargin=\the \@totalleftmargin,
30836 % \rightmargin=\the\rightmargin,
30837 % \@listdepth=\the\@listdepth. }%
30838 % \end{macrocode}
30839 % Test if we are in a list (or list-like paragraph)
30840 % \begin{macrocode}
30841 \ifnum \ifdim\@totalleftmargin>\z@ 1\fi
30842 \ifdim\rightmargin>\z@ 1\fi
30843 \ifnum\@listdepth>0 1\fi 0>\z@
30844 % \message{In a list: \linewidth=\the\linewidth,
30845 % \@totalleftmargin=\the\@totalleftmargin,
30846 % \parshape=\the\parshape, \columnwidth=\the\columnwidth,
30847 % \hsize=\the\hsize,
30848 % \labelwidth=\the\labelwidth. }%
30849 % \end{macrocode}
30850 % Now try to propagate changes of width from \cs{hsize} to list parameters.
30851 % This is deficient, but a more advanced way to indicate modification to text
30852 % dimensions is not (yet) provided; in particular, no separate left/right
30853 % adjustment. (PW. I have provided a macro for the next few lines as I think
30854 % that I may have a reason to allow them to be easily changed).
30855 % \begin{macrocode}
30856 %%% \@setminipage % snug fit around the item
30857 %%% \advance\linewidth-\columnwidth \advance\linewidth\hsize
30858 %%% \parshape\@ne \@totalleftmargin \linewidth
30859 \memfblistfixparams
30860 \else % Not in list
30861 \linewidth=\hsize
30862 %\message{No list, set \string\linewidth=\the\hsize. }%
30863 \fi
30864 \sloppy}
30865
30866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30867
30868 % \end{macrocode}
30869 % \end{macro}
30870 %
30871 % \begin{macro}{\memfblistfixparams}
30872 % An extract of some code from \cs{FrameRestore}.
30873 % Try to propagate changes of width from \cs{hsize} to list parameters.
30874 % This is deficient, but a more advanced way to indicate modification to text
30875 % dimensions is not (yet) provided; in particular, no separate left/right
30876 % adjustment.
30877 % \begin{macrocode}
30878 \newcommand*{\memfblistfixparams}{%
30879 \@setminipage % snug fit around the item
30880 \advance\linewidth-\columnwidth \advance\linewidth\hsize
30881 \parshape\@ne \@totalleftmargin \linewidth}
30882
30883 % \end{macrocode}
30884 % \end{macro}
30885 %
30886 % I have moved the following from the start of the \Lpack{framed}
30887 % package to here.
30888 %
30889 % \begin{environment}{framed}
30890 % \begin{environment}{shaded}
30891 % \begin{environment}{leftbar}
30892 % \begin{environment}{snugshade}
30893 % \begin{macrocode}
30894 \newenvironment{framed}% using default \FrameCommand
30895 {\MakeFramed {\advance\hsize-\width \FrameRestore}}%
30896 {\endMakeFramed}
30897
30898 \newenvironment{shaded}{%
30899 \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
30900 \MakeFramed {\FrameRestore}}%
30901 {\endMakeFramed}
30902
30903 \newenvironment{leftbar}{%
30904 \def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
30905 \MakeFramed {\advance\hsize-\width \FrameRestore}}%
30906 {\endMakeFramed}
30907
30908 \newenvironment{snugshade}{%
30909 \def\FrameCommand{\colorbox{shadecolor}}%
30910 \MakeFramed {\FrameRestore\@setminipage}}%
30911 {\par\unskip\endMakeFramed}
30912
30913 % \end{macrocode}
30914 % \end{environment}
30915 % \end{environment}
30916 % \end{environment}
30917 % \end{environment}
30918 %
30919 % As the package used \cs{newenvironment} it will
30920 % burp if it is used with the class. There are two options: either
30921 % prevent \Lpack{framed} from being loaded, or kill the environments
30922 % if it is loaded. I'm going for the latter as Donald will be updating
30923 % his package at some point and author's may want to use it before it's
30924 % updated here.
30925 %
30926 % \begin{macrocode}
30927 \AtBeginPackage{framed}{%
30928 \let\framed\relax \let\endframed\relax
30929 \let\shaded\relax \let\endshaded\relax
30930 \let\leftbar\relax \let\endleftbar\relax
30931 \let\snugshade\relax \let\endsnugshade\relax}
30932
30933 % \end{macrocode}
30934 %
30935 %
30936 % \begin{environment}{qframe}
30937 % This is from an email to me from DA shortly after he released \Lpack{framed}
30938 % v 0.95.
30939 % \begin{quote}
30940 % A frame more like a simple parbox.
30941 % Notably useful for use
30942 % inside a single list item --- the frame matches the text of the other
30943 % items.
30944 % \end{quote}
30945 % He actually called it \Lenv{pframe} and said that something similar
30946 % could be in a later version of \Lpack{framed}.
30947 %
30948 % I have found it useful for framing \Lenv{quote} or \Lenv{adjustwidth}
30949 % environments, or similar. Hence the name, from
30950 % `\textit{q}uote \textit{frame}'.
30951 % \changes{v1.61803}{2008/01/30}{Added the qframe environment}
30952 % \begin{macrocode}
30953 \newenvironment{qframe}{%
30954 \def\FrameCommand##1{\fboxrule=\FrameRule\fboxsep=\FrameSep
30955 \hskip\@totalleftmargin\fbox{##1}% There is no \@totalrightmargin, so...
30956 \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
30957 \MakeFramed{\advance\hsize-\width
30958 \advance\hsize \FrameSep
30959 \@totalleftmargin\z@ \linewidth=\hsize}}%
30960 {\endMakeFramed}
30961
30962 % \end{macrocode}
30963 % \end{environment}
30964 %
30965 % \begin{environment}{qshade}
30966 % And here is my corresponding version for \Lenv{shaded}.
30967 % \changes{v1.61803}{2008/01/30}{Added the qshade environment}
30968 % \begin{macrocode}
30969 \newenvironment{qshade}{%
30970 \def\FrameCommand##1{\fboxsep=\FrameSep
30971 \hskip\@totalleftmargin
30972 \hskip -1\FrameSep
30973 \colorbox{shadecolor}{##1}%
30974 \hskip-\linewidth \hskip-\@totalleftmargin
30975 \hskip -1\FrameSep
30976 \hskip\columnwidth}%
30977 \MakeFramed{\advance\hsize-\width
30978 \advance\hsize 3\FrameSep
30979 \@totalleftmargin\z@ \linewidth=\hsize}}%
30980 {\endMakeFramed}
30981
30982 % \end{macrocode}
30983 % \end{environment}
30984 %
30985 %
30986 % \subsection{The newfile package}
30987 %
30988 % The following code is from the \Lpack{newfile} package.
30989 % To try and avoid name clashes with other packages, each internal macro
30990 % in this package includes the character string `\verb?stre@m?'.
30991 %
30992 % \begin{macro}{\newoutputstream}
30993 % \cs{newoutputstream}\marg{stream} creates a new output stream called \meta{stream}.
30994 % Different files may be associated with the \meta{stream}. Note that
30995 % TeX permits no more than 16 output streams.
30996 % \begin{macrocode}
30997 \newcommand*{\newoutputstream}[1]{%
30998 \@ifundefined{#1outstre@m}%
30999 {\expandafter\newwrite\csname #1outstre@m\endcsname
31000 \csname newif\expandafter\endcsname
31001 \csname ifstre@m#1open\endcsname
31002 \global\csname stre@m#1openfalse\endcsname
31003 \expandafter\ifx\csname atstreamopen#1\endcsname\relax
31004 \global\@namedef{atstreamopen#1}{}%
31005 \fi
31006 \expandafter\ifx\csname atstreamclose#1\endcsname\relax
31007 \global\@namedef{atstreamclose#1}{}%
31008 \fi
31009 }%
31010 {\@memwarn{Output stream #1\space is already defined}}}
31011
31012 % \end{macrocode}
31013 % \end{macro}
31014 %
31015 % \begin{macro}{\newinputstream}
31016 % \cs{newinputstream}\marg{stream} creates a new input stream called \meta{stream}.
31017 % Different files may be associated with the \meta{stream}. Note that
31018 % TeX permits no more than 16 input streams.
31019 % \begin{macrocode}
31020 \newcommand*{\newinputstream}[1]{%
31021 \@ifundefined{#1instre@m}%
31022 {\expandafter\newread\csname #1instre@m\endcsname
31023 \csname newif\expandafter\endcsname
31024 \csname ifstre@m#1open\endcsname
31025 \global\csname stre@m#1openfalse\endcsname
31026 \expandafter\ifx\csname atstreamopen#1\endcsname\relax
31027 \global\@namedef{atstreamopen#1}{}%
31028 \fi
31029 \expandafter\ifx\csname atstreamclose#1\endcsname\relax
31030 \global\@namedef{atstreamclose#1}{}%
31031 \fi
31032 }%
31033 {\@memwarn{Input stream #1\space is already defined}}}
31034
31035 % \end{macrocode}
31036 % \end{macro}
31037 %
31038 % Some checking macros will be useful as some of the checks occur in
31039 % multiple places.
31040 %
31041 % \begin{macro}{\IfStreamOpen}
31042 % \cs{IfStreamOpen}\marg{stream}\marg{TRUE code}\marg{FALSE code}
31043 % checks if stream \meta{stream} is currently open.
31044 % \begin{macrocode}
31045 \newcommand{\IfStreamOpen}[3]{%
31046 \csname ifstre@m#1open\endcsname#2\else#3\fi}
31047 % \end{macrocode}
31048 % \end{macro}
31049 %
31050 % \begin{macro}{\instre@mandopen}
31051 % \cs{instre@mandopen}\marg{stream}\marg{TRUE code} checks if \meta{stream}
31052 % is an input stream and is open. If so, it executes \meta{TRUE code}.
31053 % \begin{macrocode}
31054 \newcommand{\instre@mandopen}[2]{%
31055 \@ifundefined{#1instre@m}{%
31056 \@memwarn{#1\space is not an input stream}}%
31057 {\IfStreamOpen{#1}{#2}{%
31058 \@memwarn{Input stream #1\space is not open}}}}
31059
31060 % \end{macrocode}
31061 % \end{macro}
31062 %
31063 % \begin{macro}{\instre@mandclosed}
31064 % \cs{instre@mandclosed}\marg{stream}\marg{TRUE code} checks if \meta{stream}
31065 % is an input stream and is closed (not open).
31066 % If so, it executes \meta{TRUE code}.
31067 % \begin{macrocode}
31068 \newcommand{\instre@mandclosed}[2]{%
31069 \@ifundefined{#1instre@m}{%
31070 \@memwarn{#1\space is not an input stream}}%
31071 {\IfStreamOpen{#1}{%
31072 \@memwarn{Input stream #1\space is open}}{#2}}}
31073
31074 % \end{macrocode}
31075 % \end{macro}
31076 %
31077 % \begin{macro}{\outstre@mandopen}
31078 % \cs{outstre@mandopen}\marg{stream}\marg{TRUE code} checks if \meta{stream}
31079 % is an output stream and is open. If so, it executes \meta{TRUE code}.
31080 % \begin{macrocode}
31081 \newcommand{\outstre@mandopen}[2]{%
31082 \@ifundefined{#1outstre@m}{%
31083 \@memwarn{#1\space is not an output stream}}%
31084 {\IfStreamOpen{#1}{#2}{%
31085 \@memwarn{Output stream #1\space is not open}}}}
31086
31087 % \end{macrocode}
31088 % \end{macro}
31089 %
31090 % \begin{macro}{\outstre@mandclosed}
31091 % \cs{outstre@mandclosed}\marg{stream}\marg{TRUE code} checks if \meta{stream}
31092 % is an output stream and is closed (not open).
31093 % If so, it executes \meta{TRUE code}.
31094 % \begin{macrocode}
31095 \newcommand{\outstre@mandclosed}[2]{%
31096 \@ifundefined{#1outstre@m}{%
31097 \@memwarn{#1\space is not an output stream}}%
31098 {\IfStreamOpen{#1}{%
31099 \@memwarn{Output stream #1\space is open}}{#2}}}
31100
31101 % \end{macrocode}
31102 % \end{macro}
31103 %
31104 % \begin{macro}{\openoutputfile}
31105 % \cs{openoutputfile}\marg{filename}\marg{stream} opens the file called
31106 % \meta{filename} and attaches it to the stream \meta{stream} for
31107 % writing. However, if the \cs{nofiles} command has been given the
31108 % file is \emph{not} attached to the stream. No more than one file can be
31109 % attached to a stream at any given time.
31110 % \begin{macrocode}
31111 \newcommand*{\openoutputfile}[2]{%
31112 \outstre@mandclosed{#2}{%
31113 \global\@namedef{#1@filename}{#1}%
31114 \if@filesw
31115 \immediate\openout\@nameuse{#2outstre@m}=\@nameuse{#1@filename}%
31116 \fi
31117 \global\csname stre@m#2opentrue\endcsname%
31118 \@nameuse{atstreamopen#2}}}
31119
31120 % \end{macrocode}
31121 % \end{macro}
31122 %
31123 % \begin{macro}{\closeoutputstream}
31124 % \cs{closeoutputstream}\marg{stream} closes the stream \meta{stream}.
31125 % \begin{macrocode}
31126 \newcommand*{\closeoutputstream}[1]{%
31127 \outstre@mandopen{#1}{%
31128 \@nameuse{atstreamclose#1}%
31129 \immediate\closeout\@nameuse{#1outstre@m}%
31130 \global\csname stre@m#1openfalse\endcsname}}
31131
31132 % \end{macrocode}
31133 % \end{macro}
31134 %
31135 % \begin{macro}{\openinputfile}
31136 % \cs{openinputfile}\marg{filename}\marg{stream} opens the file called
31137 % \meta{filename} and attaches it to the stream \meta{stream} for
31138 % reading. The file is added to the list of files.
31139 % No more than one file can be attached to a stream at
31140 % any given time.
31141 % \begin{macrocode}
31142 \newcommand{\openinputfile}[2]{%
31143 \IfFileExists{#1}{% file exists
31144 \instre@mandclosed{#2}{%
31145 \@addtofilelist{#1}%
31146 \global\@namedef{#1@filename}{#1}%
31147 \immediate\openin\@nameuse{#2instre@m}=\@nameuse{#1@filename}%
31148 \global\csname stre@m#2opentrue\endcsname%
31149 \@nameuse{atstreamopen#2}}}%
31150 {% file not found
31151 \typeout{No file #1.}
31152 }}
31153
31154 % \end{macrocode}
31155 % \end{macro}
31156 %
31157 % \begin{macro}{\closeinputstream}
31158 % \cs{closeinputstream}\marg{stream} closes the stream \meta{stream}.
31159 % \begin{macrocode}
31160 \newcommand{\closeinputstream}[1]{%
31161 \instre@mandopen{#1}{%
31162 \@nameuse{atstreamclose#1}%
31163 \immediate\closein\@nameuse{#1instre@m}%
31164 \global\csname stre@m#1openfalse\endcsname}}
31165
31166 % \end{macrocode}
31167 % \end{macro}
31168 %
31169 % \begin{environment}{writeverbatim}
31170 % \verb?\begin{writeverbatim}?\marg{stream} writes the contents of
31171 % the environment as verbatim text to the given \meta{stream}.
31172 % \begin{macrocode}
31173 \def\writeverbatim#1{%
31174 \@bsphack
31175 \let\do\@makeother\dospecials
31176 \catcode`\^^M\active
31177 \def\verbatim@processline{%
31178 \immediate\write\@nameuse{#1outstre@m}{\the\verbatim@line}}%
31179 \verbatim@start}
31180 \def\endwriteverbatim{\@esphack}
31181
31182 % \end{macrocode}
31183 % \end{environment}
31184 %
31185 % \begin{macro}{\addtostream}
31186 % \cs{addtostream}\marg{stream}\marg{text} writes \meta{text} to the
31187 % given \meta{stream}.
31188 % \begin{macrocode}
31189 \newcommand{\addtostream}[2]{%
31190 \@bsphack
31191 \outstre@mandopen{#1}{%
31192 {\let\protect\string
31193 \immediate\write\@nameuse{#1outstre@m}{#2}%
31194 }}%
31195 \@esphack}
31196
31197 % \end{macrocode}
31198 % \end{macro}
31199 %
31200 % \begin{macro}{\ifstre@mnoteof}
31201 % \begin{macro}{\checkstre@mnoteof}
31202 % \cs{checkstre@mnoteof}\marg{stream} sets \cs{ifstre@mnoteof} to TRUE if
31203 % \meta{stream} is not at the end of the file (i.e., it is the opposite
31204 % of \cs{ifeof}).
31205 % \begin{macrocode}
31206 \newif\ifstre@mnoteof
31207 \newcommand{\checkstre@meof}[1]{%
31208 \stre@mnoteoftrue\ifeof\@nameuse{#1instre@m}\stre@mnoteoffalse\fi}
31209
31210 % \end{macrocode}
31211 % \end{macro}
31212 % \end{macro}
31213 %
31214 % \begin{macro}{\readstream}
31215 % \cs{readstream}\marg{stream} reads the contents of
31216 % the given \meta{stream} as \cs{input} text.
31217 % \begin{macrocode}
31218 \def\readstream#1{
31219 \instre@mandopen{#1}{%
31220 \loop \checkstre@meof{#1} \ifstre@mnoteof
31221 \read\@nameuse{#1instre@m} to\temptokstre@m
31222 \temptokstre@m
31223 \repeat
31224 }}
31225
31226 % \end{macrocode}
31227 % \end{macro}
31228 %
31229 % \begin{macro}{\readaline}
31230 % \cs{readaline}\marg{stream} reads what TeX considers to be one line
31231 % from the given \meta{stream} as \cs{input} text.
31232 % \begin{macrocode}
31233 \def\readaline#1{
31234 \instre@mandopen{#1}{%
31235 \ifeof\@nameuse{#1instre@m}
31236 \@memwarn{No more to read from stream #1}
31237 \else
31238 \read\@nameuse{#1instre@m} to\temptokstre@m
31239 \temptokstre@m
31240 \fi}}
31241
31242 % \end{macrocode}
31243 % \end{macro}
31244 %
31245 %
31246 % \begin{macro}{\readverbatim}
31247 % \cs{readverbatim}\marg{stream} reads the contents of
31248 % the given \meta{stream} as verbatim text.
31249 %
31250 % The read verbatim code is a slight variation on code from the
31251 % \Lpack{verbatim} package. Most of the setup is done by the macros
31252 % \cs{stre@mverb@input}\marg{setup}\marg{stream} and
31253 % \cs{verbatim@readstre@m}\marg{stream}. Finally, \cs{verbatim@read@file}
31254 % is a \Lpack{verbatim} package macro.
31255 % \changes{v3.8.2}{2024/01/26}{Removed tabs support and added the tab
31256 % marking support to the starred version like we did for \cs{verbatiminput}}
31257 % \begin{macrocode}
31258 \def\readverbatim{\begingroup
31259 %\ift@bs
31260 % \def\verbatim@processline{\tabverbatim@processline}%
31261 %\fi
31262 \@ifstar{\stre@mverb@input{\@setupverbvisiblespace\@vobeyspaces}}%{\@maybeobeytabs}}%
31263 {\stre@mverb@input{\frenchspacing\@vobeyspaces}}}%\@maybeobeytabs}}}
31264
31265 % \end{macrocode}
31266 % \end{macro}
31267 %
31268 % \begin{macro}{\stre@mverb@input}
31269 % \begin{macro}{\@verbinstre@m}
31270 % \cs{stre@mverb@input}\marg{setup}\marg{stream} is a stream
31271 % version of \cs{verbatim@input}. It defines \cs{@verbinstre@m}
31272 % to be \meta{stream}.
31273 %
31274 % \begin{macrocode}
31275 \newcommand{\stre@mverb@input}[2]{%
31276 \IfStreamOpen{#2}%
31277 {\@verbatim #1\relax
31278 \def\@verbinstre@m{\@nameuse{#2instre@m}}
31279 \verb@readstre@m\endtrivlist\endgroup\@doendpe}%
31280 {\@memwarn{Stream #2\space is not open}\endgroup}}
31281
31282 % \end{macrocode}
31283 % \end{macro}
31284 % \end{macro}
31285 %
31286 % \begin{macro}{\verb@readstre@m}
31287 % \cs{verb@readstre@m} is the stream analogue to \cs{verbatim@readfile}.
31288 % \begin{macrocode}
31289 \newcommand{\verb@readstre@m}{%
31290 \verbatim@startline
31291 \expandafter\endlinechar\expandafter\m@ne
31292 \expandafter\verbatim@read@stre@m
31293 \expandafter\endlinechar\the\endlinechar\relax
31294 \verbatim@finish}
31295
31296 % \end{macrocode}
31297 % \end{macro}
31298 %
31299 % \begin{macro}{\verbatim@read@stre@m}
31300 % \cs{verbatim@read@stre@m} is the analogue to \cs{verbatim@readfile}.
31301 % It gets its input from the stream \cs{@verbinstre@m}, which is defined
31302 % in the \cs{stre@mverb@input} macro.
31303 % \begin{macrocode}
31304 \newcommand{\verbatim@read@stre@m}{%
31305 \read\@verbinstre@m to\next
31306 \ifeof\@verbinstre@m
31307 \else
31308 \expandafter\verbatim@addtoline\expandafter{\next}%
31309 \verbatim@processline
31310 \verbatim@startline
31311 \expandafter\verbatim@read@stre@m
31312 \fi}
31313
31314 % \end{macrocode}
31315 % \end{macro}
31316 %
31317 %
31318 % \begin{macro}{\readboxedverbatim}
31319 % \cs{readboxedverbatim}\marg{stream} is the equivalent of
31320 % \cs{readverbtim} except that it generates a boxed verbatim.
31321 % \begin{macrocode}
31322 \newcommand{\readboxedverbatim}{\begingroup
31323 \@ifstar{\stre@mbvin\relax}%
31324 {\stre@mbvin{\frenchspacing\@vobeyspaces}}}
31325
31326 % \end{macrocode}
31327 % \end{macro}
31328 %
31329 % \begin{macro}{\stre@mbvin}
31330 % \cs{stre@mbvin}\marg{setup}\marg{stream} is the workhorse for
31331 % \cs{readboxedverbatim}, and in its turn it uses \cs{verb@readstre@m}.
31332 % \begin{macrocode}
31333 \newcommand{\stre@mbvin}[2]{%
31334 \IfStreamOpen{#2}%
31335 {\setupboxverb@line
31336 \@verbatim #1\relax
31337 \def\@verbinstre@m{\@nameuse{#2instre@m}}%
31338 \setupbox@verb
31339 \verb@readstre@m\bvendrulehook\endtrivlist\endgroup\@doendpe}%
31340 {\@memwarn{Stream #2\space is not open}\endgroup}}
31341
31342 % \end{macrocode}
31343 % \end{macro}
31344 %
31345 %
31346 %
31347 % \section{Utilities}
31348 %
31349 %
31350 % \subsection{Extra `provide' commands}
31351 %
31352 % \begin{macro}{\provideenvironment}
31353 % Works like \cs{providecommand} but for environments.
31354 % \changes{v1.2}{2002/08/04}{Added \cs{provideenvironment} and supports}
31355 % \begin{macrocode}
31356 \newcommand{\provideenvironment}{\@star@or@long\m@mprovenv}
31357 % \end{macrocode}
31358 % \end{macro}
31359 %
31360 % \begin{macro}{\m@mprovenv}
31361 % This checks if the environment has been defined. If not it calls
31362 % the kernel code for \cs{newenvironment} otherwise it calls code to
31363 % discard arguments.
31364 % \begin{macrocode}
31365 \newcommand{\m@mprovenv}[1]{\@ifundefined{#1}%
31366 {\new@environment{#1}}% % create new environment
31367 {\@memwarn{Environment `#1' already defined}%
31368 \m@mgobbleoptsandtwo}}
31369 % \end{macrocode}
31370 % \end{macro}
31371 %
31372 %
31373 % \begin{macro}{\m@mgobbleoptsandtwo}
31374 % \begin{macro}{\m@mgobbleoptandtwo}
31375 % \cs{m@mgobbleoptsandtwo} gobbles the \verb?[opt][opt]{begin}{end}? arguments to
31376 % \cs{provideenvironment}. It is actually more general than that as it will
31377 % gobble any sequence of any number of optional arguments followed by
31378 % two required arguments. If there are no optional arguments it disposes
31379 % of the two required ones, otherwise it calls a recursive procedure to
31380 % discard any number of optionals, then two required ones.
31381 %
31382 % \cs{m@mgobbleoptandtwo} recursively discards optional arguments, then finally
31383 % two required arguments.
31384 % \begin{macrocode}
31385 \newcommand{\m@mgobbleoptsandtwo}{%
31386 \@ifnextchar [{\m@mgobbleoptandtwo}{\@gobbletwo}}
31387 \def\m@mgobbleoptandtwo[#1]{%
31388 \@ifnextchar [{\m@mgobbleoptandtwo}{\@gobbletwo}}
31389
31390 % \end{macrocode}
31391 % \end{macro}
31392 % \end{macro}
31393 %
31394 % \begin{macro}{\providecounter}
31395 % Works like the other \cs{provide...} commands, but for counters.
31396 % Code is based on \cs{newcounter} in \file{ltcounts.dtx}.
31397 % \changes{v1.2}{2002/07/17}{Added \cs{providecounter}}
31398 % \begin{macrocode}
31399 \newcommand*{\providecounter}[1]{%
31400 \@ifundefined{c@#1}%
31401 {\newcounter{#1}}%
31402 {\@memwarn{Counter `#1' already defined}%
31403 \@ifnextchar[{\m@mgobbleopt}{}}}
31404
31405 % \end{macrocode}
31406 % \end{macro}
31407 %
31408 % \begin{macro}{\m@mgobbleopt}
31409 % Gobble an optional argument.
31410 % \changes{v1.2}{2002/07/07}{Added \cs{m@mgobbleopt}}
31411 % \begin{macrocode}
31412 \def\m@mgobbleopt[#1]{}
31413
31414 % \end{macrocode}
31415 % \end{macro}
31416 %
31417 % \begin{macro}{\providelength}
31418 % Works like the other \cs{provide...} commands, but for lengths.
31419 % Code is based on \cs{provide@command} in \file{ltdefns.dtx}.
31420 % \changes{v1.2}{2002/07/17}{Added \cs{providelength}}
31421 % \begin{macrocode}
31422 \newcommand*{\providelength}[1]{%
31423 \begingroup
31424 \escapechar\m@ne\xdef\@gtempa{{\string#1}}%
31425 \endgroup
31426 \expandafter\@ifundefined\@gtempa
31427 {\newlength{#1}}%
31428 {\@memwarn{Length #1 already defined}}}
31429
31430 % \end{macrocode}
31431 % \end{macro}
31432 %
31433 % \begin{macro}{\newloglike}
31434 % \begin{macro}{\m@mnewlog}
31435 % \begin{macro}{\m@mnewlogs}
31436 % For defining a new log-like math function.
31437 % \verb?\newloglike{\fun}{string}? or \verb?\newloglike*{\fun}{string}?.
31438 % The starred version is for functions with limits (like an integral sign).
31439 % \changes{v1.6}{2004/01/28}{Added \cs{newloglike}}
31440 % \MarkedForDeprecation{\cs{newloglike}}
31441 % \begin{macrocode}
31442 \newcommand*{\newloglike}{%
31443 \MarkDeprecated{\newloglike}{in 2026. We recommand using\MessageBreak%
31444 \string\DeclareMathOperator\space from amsopn (amsmath) instead.}%
31445 \@ifstar{\m@mnewlogs}{\m@mnewlog}}
31446 \newcommand*{\m@mnewlogs}[2]{%
31447 \newcommand*{#1}{\mathop{\operator@font #2}}}
31448 \newcommand*{\m@mnewlog}[2]{%
31449 \newcommand*{#1}{\mathop{\operator@font #2}\nolimits}}
31450
31451 % \end{macrocode}
31452 % \end{macro}
31453 % \end{macro}
31454 % \end{macro}
31455 %
31456 % \begin{macro}{\provideloglike}
31457 % \begin{macro}{\m@mprovlogs}
31458 % \begin{macro}{\m@mprovlog}
31459 % The provide version of \cs{newloglike}.
31460 % \changes{v1.6}{2004/01/28}{Added \cs{provideloglike}}
31461 % \MarkedForDeprecation{\cs{provideloglike}}
31462 % \begin{macrocode}
31463 \newcommand*{\provideloglike}{%
31464 \MarkDeprecated*{\provideloglike}{in 2026}
31465 \@ifstar{\m@mprovlogs}{\m@mprovlog}}
31466 \newcommand*{\m@mprovlogs}[2]{%
31467 \providecommand*{#1}{\mathop{\operator@font #2}}}
31468 \newcommand*{\m@mprovlog}[2]{%
31469 \providecommand*{#1}{\mathop{\operator@font #2}\nolimits}}
31470
31471 % \end{macrocode}
31472 % \end{macro}
31473 % \end{macro}
31474 % \end{macro}
31475 %
31476 %
31477 % \subsection{Changing counters}
31478 %
31479 % \changes{v3.8.3}{2024/02/02}{Removed code for \cs{counterwithin},
31480 % \cs{counterwithout} and \cs{@removefromreset}, they have been
31481 % `provided' since 2018}
31482 %
31483 % The class used to have code similar to the package \Lpack{chngcntr}
31484 % and \Lpack{remreset}. Since 2018 these have been in the
31485 % \LaTeX-kernel and was just provided by the class. By 2024 the code
31486 % was removed.
31487 %
31488 %
31489 % \begin{macro}{\letcountercounter}
31490 % \begin{macro}{\c@m@morig@ctr}
31491 % \begin{macro}{\unletcounter}
31492 % At times it is handy to `let' one counter act as if it was a
31493 % different counter. Say you have two constructions, each with their
31494 % own counter A and B, now you want them to cooperate, counting in
31495 % unison. This can be done using the \verb?\letcountercounter?.
31496 %
31497 % \medskip
31498 %
31499 % \cs{letcountercounter}\marg{counterA}\marg{counterB} \cs{let}s
31500 % (make the same) \meta{counterA} to \meta{counterB}. The
31501 % original of \meta{counterA} is kept in \cs{c@m@morig@ctr}\meta{counterA}.
31502 %
31503 % \cs{unletcounter}\marg{counterA} restores \meta{counterA} to its un\cs{let}
31504 % condition.
31505 %
31506 % The code is based on Donald Arseneau's `Re: \cs{let}, \cs{csname} and
31507 % \cs{endcsname}', CTT, 2004/12/08. The long version, where \cs{xp}
31508 % is actually \cs{expandafter} is along the lines of:
31509 % \begin{verbatim}
31510 % \xp\xp\xp\let\xp\csname\xp c@#1\xp\endcsname\csname c@#2\endcsname
31511 % \end{verbatim}
31512 % which employs 6 \cs{expandafter}s. DA's version uses only 2. The technique
31513 % can be applied to other kinds of \cs{let}s.
31514 %
31515 % \begin{macrocode}
31516 \newcommand*{\letcountercounter}[2]{%
31517 \expandafter\let\csname c@m@morig@ctr#1\expandafter\endcsname%
31518 \csname c@#1\endcsname
31519 \expandafter\let\csname c@#1\expandafter\endcsname%
31520 \csname c@#2\endcsname}
31521 \newcommand*{\unletcounter}[1]{%
31522 \expandafter\let\csname c@#1\expandafter\endcsname%
31523 \csname c@m@morig@ctr#1\endcsname}
31524
31525 % \end{macrocode}
31526 % \end{macro}
31527 % \end{macro}
31528 % \end{macro}
31529 %
31530 %
31531 % \subsection{Odd/even page checking}
31532 %
31533 % It is difficult to check robustly if the current page is odd or even.
31534 % This code, which is based on the \Lpack{chngpage} package~\cite{CHNGPAGE},
31535 % provides a method that has proved (so far) to be robust.
31536 % It works by writing out a label and on the next LaTeX run checks
31537 % the page reference for the label.
31538 %
31539 % \begin{macro}{\ifoddpage}
31540 % \begin{macro}{\oddpagetrue}
31541 % \begin{macro}{\oddpagefalse}
31542 % \begin{macro}{\ifstrictpagecheck}
31543 % \begin{macro}{\strictpagechecktrue}
31544 % \begin{macro}{\strictpagecheckfalse}
31545 % \begin{macro}{\strictpagecheck}
31546 % \begin{macro}{\easypagecheck}
31547 % The boolean \cs{ifoddpage} is TRUE if the checked page is odd. The
31548 % boolean \cs{ifstrictpagecheck} is for turning on (TRUE) and off (FALSE)
31549 % the strictest method of page checking.
31550 % \changes{v1.61803}{2008/01/30}{Added \cs{strictpagecheck} and \cs{easypagecheck}}
31551 % \begin{macrocode}
31552 \newif\ifoddpage
31553 \newif\ifstrictpagecheck
31554 \strictpagecheckfalse
31555 \newcommand*{\strictpagecheck}{\strictpagechecktrue}
31556 \newcommand*{\easypagecheck}{\strictpagecheckfalse}
31557
31558 % \end{macrocode}
31559 % \end{macro}
31560 % \end{macro}
31561 % \end{macro}
31562 % \end{macro}
31563 % \end{macro}
31564 % \end{macro}
31565 % \end{macro}
31566 % \end{macro}
31567 %
31568 % \begin{macro}{\c@cp@cntr}
31569 % \begin{macro}{\cplabel}
31570 % The counter \verb?cp@cntr? is used to make unique labels, which start
31571 % with \cs{cplabel}.
31572 % \begin{macrocode}
31573 \newcounter{cp@cntr}
31574 \newcommand{\cplabel}{^_}
31575 % \end{macrocode}
31576 % \end{macro}
31577 % \end{macro}
31578 %
31579 %
31580 % \begin{macro}{\checkoddpage}
31581 % This is the user level command to check for odd/even page. It does
31582 % a robust check for \cs{strictpagecheck} otherwise the simple minded
31583 % check. It sets \cs{ifoddpage} to TRUE if the page is odd, otherwise
31584 % it sets it to FALSE.
31585 %
31586 % This is now fixed so that it should work for non-arabic page numbering.
31587 % It uses a new label/pageref variant based on the page counter value, not
31588 % its printed representation. This also gets rid of worrying about hyperref!!
31589 % The problem was discovered by Bastiaan Niels Veelo
31590 %
31591 % \changes{v1.4}{2003/11/22}{Complete rewrite of odd page checking
31592 % (from patch v1.6)}
31593 % \begin{macrocode}
31594 \DeclareRobustCommand{\checkoddpage}{%
31595 \oddpagefalse%
31596 \ifstrictpagecheck%
31597 \stepcounter{cp@cntr}\pmemlabel{\cplabel\thecp@cntr}%
31598 \@memcnta=\pmemlabelref{\cplabel\thecp@cntr}\relax
31599 \ifodd\@memcnta\oddpagetrue\fi
31600 \else
31601 \ifodd\c@page\oddpagetrue\fi
31602 \fi}
31603
31604 % \end{macrocode}
31605 % \end{macro}
31606 %
31607 %
31608 % \begin{macro}{\thepmemc@@page}
31609 % The value of the page counter.
31610 % \begin{macrocode}
31611 \gdef\thepmemc@@page{\the\c@page}
31612
31613 % \end{macrocode}
31614 % \end{macro}
31615 %
31616 % \begin{macro}{\pmemprotected@write}
31617 % \cs{pmemprotected@write} is a modified version of the kernel's
31618 % \cs{protected@write}.
31619 %
31620 % This version of the macro was provided by Romano Giannetti on 15
31621 % July 2003.
31622 % \begin{macrocode}
31623 \long\def\pmemprotected@write#1#2#3{%
31624 \begingroup
31625 \let\thepmemc@@page\relax
31626 #2%
31627 \let\protect\@unexpandable@protect
31628 \edef\reserved@a{\write#1{#3}}%
31629 \reserved@a
31630 \endgroup
31631 \if@nobreak\ifvmode\nobreak\fi\fi}
31632
31633 % \end{macrocode}
31634 % \end{macro}
31635 %
31636 % \begin{macro}{\pmemlabel}
31637 % A version of \cs{label} that uses \cs{pmemprotected@write}.
31638 % \begin{macrocode}
31639 \newcommand{\pmemlabel}[1]{\@bsphack
31640 \pmemprotected@write\@auxout{}%
31641 {\string\newpmemlabel{#1}{\thepmemc@@page}}%
31642 \@esphack}
31643 % \end{macrocode}
31644 % \end{macro}
31645 %
31646 % \begin{macro}{\newpmemlabel}
31647 % \begin{macro}{\pmemlabelref}
31648 % We have to be able to cope with a particular label
31649 % not (yet) being in the the \file{.aux} file when we come to check
31650 % the page number.
31651 % \begin{macrocode}
31652 \newcommand{\newpmemlabel}[2]{{\global\@namedef{m@#1}{#2}}}
31653 \newcommand{\pmemlabelref}[1]{%
31654 \expandafter\ifx\csname m@#1\endcsname\relax
31655 0%
31656 \else
31657 \csname m@#1\endcsname
31658 \fi}
31659
31660 % \end{macrocode}
31661 % \end{macro}
31662 % \end{macro}
31663 %
31664 % \subsection{Checking for empty arguments}
31665 %
31666 % Like page checking, testing for an empty macro argument is more
31667 % difficult than it might appear at first sight.
31668 %
31669 % The following code is from the \Lpack{ifmtarg} package~\cite{IFMTARG}.
31670 %
31671 % \begin{macro}{\@ifmtarg}
31672 % \begin{macro}{\@ifnotmtarg}
31673 % \cs{@ifmtarg}\marg{arg}\marg{code when empty}\marg{code when arg not empty} \\
31674 % \cs{@ifnotmtarg}\marg{arg}\marg{code when arg not empty} \\
31675 % \begin{macrocode}
31676 \begingroup
31677 \catcode`\Q=3
31678 \long\gdef\@ifmtarg#1{\@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
31679 \long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4}
31680 \long\gdef\@ifnotmtarg#1{\@xifmtarg#1QQ\@firstofone\@gobble\@nil}
31681 \endgroup
31682
31683 % \end{macrocode}
31684 % \end{macro}
31685 % \end{macro}
31686 %
31687 % Some example uses:
31688 % \begin{verbatim}
31689 % \newcommand{\isempty}[1]{%
31690 % \@ifmtarg{#1}{\typeout{YES}}{\typeout{NO}}}
31691 % \newcommand{\isnotempty}[1]{%
31692 % \@ifnotmtarg{#1}{\typeout{YES}}}
31693 %
31694 % \isempty{} -> YES \isnotempty{} ->
31695 % \isempty{ } -> YES \isnotempty{ } ->
31696 % \isempty{A} -> NO \isnotempty{A} -> YES
31697 % \isempty{ A } -> NO \isnotempty{ A } -> YES
31698 % \end{verbatim}
31699 %
31700 %
31701 % \subsection{Changing the page layout in the document}
31702 %
31703 % You should not do this, but\ldots
31704 %
31705 % The following code is essentially from the \Lpack{chngpage}
31706 % package~\cite{CHNGPAGE}.
31707 %
31708 % \begin{macro}{\ch@ngetext}
31709 % This macro sets the page output parameters.
31710 % \begin{macrocode}
31711 \DeclareRobustCommand{\ch@ngetext}{%
31712 \setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}%
31713 \setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}%
31714 \if@twocolumn%
31715 \advance\columnwidth-\columnsep \divide\columnwidth\tw@%
31716 \@firstcolumntrue%
31717 \fi%
31718 \setlength{\hsize}{\columnwidth}%
31719 \setlength{\linewidth}{\hsize}}
31720
31721 % \end{macrocode}
31722 % \end{macro}
31723 %
31724 % \begin{macro}{\changetext}
31725 % \cs{changetext}\marg{H}\marg{W}\marg{E}\marg{O}\marg{G}
31726 % adds the given lengths to 5 main bits of the page layout. An empty
31727 % argument means `no change'.
31728 % \begin{macrocode}
31729 \DeclareRobustCommand{\changetext}[5]{%
31730 \@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}%
31731 \@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}%
31732 \@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}%
31733 \@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}%
31734 \@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}%
31735 \ch@ngetext}
31736
31737 % \end{macrocode}
31738 % \end{macro}
31739 %
31740 % Any given change lasts until another \cs{changetext} command is given.
31741 % A \cs{changetext} command should only be issued between two paragraphs.
31742 %
31743 % \cs{changetext} should not be used by anyone unless they really
31744 % know what they are doing. If you really know what you are doing
31745 % then you should know enough not to use it.
31746 %
31747 % \begin{macro}{\changepage}
31748 % Change the page layout, but DON'T.
31749 % \changes{v1.61803}{2008/01/30}{Added \cs{changepage} to match chngpage.sty}
31750 % \begin{macrocode}
31751 \DeclareRobustCommand{\changepage}[9]{%
31752 \@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}%
31753 \@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}%
31754 \@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}%
31755 \@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}%
31756 \@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}%
31757 \ch@ngetext
31758 \@ifmtarg{#6}{}{\addtolength{\topmargin}{#6}}%
31759 \@ifmtarg{#7}{}{\addtolength{\headheight}{#7}}%
31760 \@ifmtarg{#8}{}{\addtolength{\headsep}{#8}}%
31761 \@ifmtarg{#9}{}{\addtolength{\footskip}{#9}}}
31762
31763 % \end{macrocode}
31764 % \end{macro}
31765 %
31766 % \subsection{Temporarily changing the text width}
31767 %
31768 %
31769 % \begin{environment}{adjustwidth}
31770 % \begin{environment}{adjustwidth*}
31771 % \verb?\begin{adjustwidth}?\marg{left}\marg{right}
31772 % adds the given lengths to the left and right hand margins. A positive
31773 % value will shorten the text and a negative value will widen it. The
31774 % starred version of the environment will cause the
31775 % margin changes to switch between odd and even pages.
31776 %
31777 % This code is based on the \Lpack{chngpage} package.
31778 % \changes{v0.2}{2001/06/03}{Replaced optional arg of adjustwidth by adjustwidth*}
31779 % \begin{macrocode}
31780 \newenvironment{adjustwidth}[2]{%
31781 \begin{list}{}{%
31782 \topsep\z@%
31783 \listparindent\parindent%
31784 \parsep\parskip%
31785 \@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
31786 {\setlength{\leftmargin}{#1}}%
31787 \@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
31788 {\setlength{\rightmargin}{#2}}%
31789 }
31790 \item[]}{\end{list}}
31791
31792 % \end{macrocode}
31793 %
31794 % \begin{macrocode}
31795 \newenvironment{adjustwidth*}[2]{%
31796 \begin{list}{}{%
31797 \topsep\z@%
31798 \listparindent\parindent%
31799 \parsep\parskip%
31800 \checkoddpage
31801 \ifoddpage % odd numbered page
31802 \@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
31803 {\setlength{\leftmargin}{#1}}%
31804 \@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
31805 {\setlength{\rightmargin}{#2}}%
31806 \else % even numbered page
31807 \@ifmtarg{#2}{\setlength{\leftmargin}{\z@}}%
31808 {\setlength{\leftmargin}{#2}}%
31809 \@ifmtarg{#1}{\setlength{\rightmargin}{\z@}}%
31810 {\setlength{\rightmargin}{#1}}%
31811 \fi
31812 }
31813 \item[]}{\end{list}}
31814
31815 % \end{macrocode}
31816 % \end{environment}
31817 % \end{environment}
31818 %
31819 % The environments only work for complete paragraphs.
31820 %
31821 % \subsection{Centering text}
31822 %
31823 % \begin{macro}{\calccentering}
31824 % This macro calculates the amount to be added to the spine margin
31825 % (and subtracted from the foredge margin)
31826 % in order to center the textblock. Call as \\
31827 % \verb?\calccentering{\length}? and it sets \cs{length}
31828 % to the required value. Then use as \\
31829 % \verb?\begin{adjustwidth*}{\length}{-\length}...?
31830 % \begin{macrocode}
31831 \newcommand{\calccentering}[1]{
31832 #1 = \paperwidth
31833 \advance #1 by -\textwidth
31834 \divide #1 by \tw@
31835 \advance #1 by -\spinemargin}
31836
31837 % \end{macrocode}
31838 % \end{macro}
31839 %
31840 % \begin{environment}{vplace}
31841 % \verb?\begin{vplace}?\oarg{decimal number} centers its body vertically. The
31842 % optional argument \meta{decimal number} increases ($>1.0$) or decreases
31843 % ($<1.0$) the space above the body with respect to the space below.
31844 % This is more robust than the method proposed in the manual.
31845 % \changes{v1.61803}{2008/01/30}{Added vplace environment (mempatch v4.4)}
31846 % \changes{v3.6g}{2010/08/27}{Both should be \cs{vspace*}}
31847 % \begin{macrocode}
31848 \newenvironment{vplace}[1][1]{%
31849 \par\vspace*{\stretch{#1}}%
31850 }{%
31851 \vspace*{\stretch{1}}%
31852 \par}
31853
31854 % \end{macrocode}
31855 % \end{environment}
31856 %
31857 %
31858 % \subsection{Moving from the current page}
31859 %
31860 % Much of this code is taken from the \Lpack{nextpage} package~\cite{NEXTPAGE}.
31861 %
31862 % Clear to next page is \cs{clearpage}.
31863 %
31864 % \begin{macro}{\cleartoevenpage}
31865 % \cs{cleartoevenpage}\oarg{text} clears to the next even
31866 % numbered page,
31867 % putting the optional \meta{text} on the skipped page, if any.
31868 % \begin{macrocode}
31869 \newcommand{\cleartoevenpage}[1][\@empty]{%
31870 \clearpage%
31871 \ifodd\c@page\hbox{}#1\clearpage\fi}
31872
31873 % \end{macrocode}
31874 % \end{macro}
31875 %
31876 % Move to the next page without flushing floats is \cs{newpage}.
31877 %
31878 % \begin{macro}{\movetoevenpage}
31879 % \cs{movetoevenpage}\oarg{text} moves to the next even
31880 % numbered page without flushing floats,
31881 % putting the optional \meta{text} on the skipped page, if any.
31882 % \begin{macrocode}
31883 \newcommand{\movetoevenpage}[1][\@empty]{%
31884 \newpage%
31885 \ifodd\c@page\hbox{}#1\newpage\fi}
31886
31887 % \end{macrocode}
31888 % \end{macro}
31889 %
31890 % Clear to next odd numbered page is \cs{cleardoublepage}.
31891 %
31892 % \begin{macro}{\cleartooddpage}
31893 % \cs{cleartooddpage}\oarg{text} clears to the next odd
31894 % numbered page,
31895 % putting the optional \meta{text} on the skipped page, if any.
31896 % \begin{macrocode}
31897 \newcommand{\cleartooddpage}[1][\@empty]{%
31898 \clearpage%
31899 \ifodd\c@page\else\hbox{}#1\clearpage\fi}
31900
31901 % \end{macrocode}
31902 % \end{macro}
31903 %
31904 % \begin{macro}{\movetooddpage}
31905 % \cs{movetooddpage}\oarg{text} moves to the next odd
31906 % numbered page without flushing floats,
31907 % putting the optional \meta{text} on the skipped page, if any.
31908 % \begin{macrocode}
31909 \newcommand{\movetooddpage}[1][\@empty]{%
31910 \newpage%
31911 \ifodd\c@page\else\hbox{}#1\newpage\fi}
31912
31913 % \end{macrocode}
31914 % \end{macro}
31915 %
31916 % Example uses: \\
31917 % \begin{verbatim}
31918 % \cleartooddpage % same as \cleardouble page
31919 % \cleartooddpage[\thispagestyle{empty}] % No headings on the skipped page
31920 % \cleartoevenpage % go to next even numbered page
31921 % Next example puts text on a skipped page
31922 % \cleartoevenpage[\vspace*{\hfill}THIS PAGE LEFT BLANK\vspace*{\hfill}]
31923 % \end{verbatim}
31924 %
31925 %
31926 %
31927 % \subsection{Needing space at the bottom of a page}
31928 %
31929 % \begin{macro}{\needspace}
31930 % \cs{needspace}\marg{length} checks if the is \meta{length} amount
31931 % of vertical space left on the page. If there is not it will start
31932 % a new page. The code is a variant of code thought of for the
31933 % \Lpack{needspace} package~\cite{NEEDSPACE}.
31934 % \changes{v1.4}{2003/11/16}{Added patch v1.4 versions of needspace macros}
31935 % \changes{v3.6g}{2010/09/09}{Added a \cs{vskip0pt} at the end to make
31936 % it work better with \cs{section} and friends}
31937 % \begin{macrocode}
31938 \newcommand{\needspace}[1]{\begingroup\setlength{\dimen@}{#1}%
31939 \vskip\z@\@plus\dimen@\penalty -100\vskip\z@\@plus-\dimen@
31940 \vskip\dimen@\penalty 9999\vskip-\dimen@\vskip\z@skip\endgroup}
31941
31942 % \end{macrocode}
31943 % \end{macro}
31944 %
31945 % \begin{macro}{\Needspace}
31946 % \begin{macro}{\Needspace*}
31947 % \cs{Needspace} and \cs{Needspace*} are more robust versions of \cs{needspace},
31948 % which depends on penalties. If either \cs{needspace} or \cs{Needspace}
31949 % produce a short page it will be ragged bottom, even if \cs{flushbottom}
31950 % is in effect. The \cs{Needspace*} version honours the \cs{...bottom}
31951 % declaration.
31952 % \begin{macrocode}
31953 \newcommand{\Needspace}{\@ifstar{\M@sneedsp@}{\M@needsp@}}
31954 % \end{macrocode}
31955 % \end{macro}
31956 % \end{macro}
31957 %
31958 % \begin{macro}{\M@sneedsp@}
31959 % \begin{macro}{\M@needsp@}
31960 % These implement \cs{Needspace*} and \cs{needspace} respectively.
31961 % \begin{macrocode}
31962 \newcommand{\M@sneedsp@}[1]{\par \penalty-100\begingroup
31963 \setlength{\dimen@}{#1}%
31964 \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
31965 \ifdim \dimen@>\dimen@ii
31966 \break
31967 \fi\endgroup}
31968 \newcommand{\M@needsp@}[1]{\par \penalty-100\begingroup
31969 \setlength{\dimen@}{#1}%
31970 \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
31971 \ifdim \dimen@>\dimen@ii
31972 \ifdim \dimen@ii>\z@
31973 \vfil
31974 \fi
31975 \break
31976 \fi\endgroup}
31977
31978 % \end{macrocode}
31979 % \end{macro}
31980 % \end{macro}
31981 %
31982 %
31983 % \subsection{Overlong lines}
31984 %
31985 % LaTeX provides \cs{fussy} and \cs{sloppy} to control the amount of slack
31986 % in a line while trying to make justified lines. Their definitions are:
31987 % \begin{verbatim}
31988 % \def\fussy{%
31989 % \emergencystretch\z@
31990 % \tolerance 200%
31991 % \hfuzz .1\p@
31992 % \vfuzz\hfuzz}
31993 % \def\sloppy{%
31994 % \tolerance 9999%
31995 % \emergencystretch 3em%
31996 % \hfuzz .5\p@
31997 % \vfuzz\hfuzz}
31998 % \end{verbatim}
31999 %
32000 % \begin{macro}{\midsloppy}
32001 % Somewhere between \cs{fussy} and \cs{sloppy}.
32002 % \changes{v1.61803}{2008/01/30}{Added \cs{midsloppy} and midsloppypar
32003 % (mempatch v4.5)}
32004 % \begin{macrocode}
32005 \newcommand*{\midsloppy}{%
32006 \tolerance 5000%
32007 \hbadness 4000%
32008 \emergencystretch 1.5em%
32009 \hfuzz .1\p@
32010 \vfuzz\hfuzz}
32011 % \end{macrocode}
32012 % \end{macro}
32013 %
32014 % \begin{environment}{midsloppypar}
32015 % A paragraph form of \cs{midsloppy}; equivalent to \verb?\par \midsloppy ... \par}?
32016 % \begin{macrocode}
32017 \newenvironment{midsloppypar}{\par\midsloppy}{\par}
32018
32019 % \end{macrocode}
32020 % \end{environment}
32021 %
32022 % \subsection{Text spacing commands}
32023 %
32024 % While we're at it, new text spacing commands to supplement
32025 % the kernel's \\
32026 % \verb?\, (\thinspace) = 3/18 em?
32027 % \changes{v1.4}{2003/11/16}{Extra text spacing macros from patch v1.4}
32028 % \changes{v3.7l}{2020/06/02}{Added kernel wrapper}
32029 % As of the kernel/format update for october 2020, these will be moved
32030 % to the kernel, so we remove them of you are using that kernel.
32031 % \begin{macrocode}
32032 \@ifl@t@r\fmtversion{2020-10-01}{
32033 % nothing to do with newer kernel
32034 }{%
32035 % \end{macrocode}
32036 % \begin{macro}{\medspace}
32037 % \begin{macro}{\:}
32038 % Medium space \verb?\: (\medspace) = 4/18 em?
32039 % \changes{v3.7q}{2022/02/17}{use \cs{providecommand} on \cs{medspace}}
32040 % \begin{macrocode}
32041 \providecommand{\medspace}{\kern .22222em }
32042 \DeclareRobustCommand{\:}{%
32043 \relax\ifmmode\mskip\medmuskip\else\medspace\fi}
32044 % \end{macrocode}
32045 % \end{macro}
32046 % \end{macro}
32047 %
32048 % \begin{macro}{\!}
32049 % Negative thin space (- 3/18 em).
32050 % Patrik Nyman (private email 2003/10/06) pointed out I had missed
32051 % the final \verb?\fi? !!!!.
32052 % \begin{macrocode}
32053 \DeclareRobustCommand{\!}{%
32054 \relax\ifmmode\mskip-\thinmuskip\else\negthinspace\fi}
32055
32056 } % end kernel version wrapper
32057 % \end{macrocode}
32058 % \end{macro}
32059 %
32060 % \subsection{Fractions and subscripts}
32061 %
32062 %
32063 % Styles for fractions like 3/4 (but better).
32064 %
32065 % \begin{macro}{\slashfracstyle}
32066 % \cs{slashfracstyle} based on the kernel \cs{textsuperscript} macro
32067 % \changes{v1.4}{2003/11/16}{Added \cs{slashfrac} and supports (from patch v1.4)}
32068 % \begin{macrocode}
32069 \DeclareRobustCommand*{\slashfracstyle}[1]{%
32070 {\m@th\ensuremath{\mbox{\fontsize\sf@size\z@\selectfont #1}}}}
32071 % \end{macrocode}
32072 % \end{macro}
32073 %
32074 % \begin{macro}{\slashfrac}
32075 % \cs{slashfrac} based on TeXbook exercise 11.6
32076 % \begin{macrocode}
32077 \DeclareRobustCommand*{\slashfrac}[2]{\leavevmode
32078 \raise.5ex\hbox{\slashfracstyle{#1}}\kern-.13em/%
32079 \kern-.15em\lower.25ex\hbox{\slashfracstyle{#2}}}
32080
32081 % \end{macrocode}
32082 % \end{macro}
32083 %
32084 %
32085 % \subsection{Numbers to names}
32086 %
32087 % \begin{macrocode}
32088 %%%%%%%%%%%%%%%%%%%% number formatting
32089
32090 % \end{macrocode}
32091 %
32092 % The macros here convert an integer number in the range 0--2147483647
32093 % (TeX's maximum) into
32094 % the natural language name of the number.
32095 % \changes{v1.4}{2003/11/16}{Much extended numbers to names (patch v1.2)}
32096 %
32097 % \begin{macro}{\iflowernumtoname}
32098 % A flag for lowercasing the initial letters.
32099 % \begin{macrocode}
32100 \newif\iflowernumtoname
32101 \lowernumtonamefalse
32102 % \end{macrocode}
32103 % \end{macro}
32104 %
32105 % \begin{macro}{\ifpriornum}
32106 % \begin{macro}{\ifminusnumber}
32107 % \begin{macro}{\ifnotnumtonameallcaps}
32108 % \begin{macro}{\ifmakeordinal}
32109 % Some new booleans
32110 % \begin{macrocode}
32111 \newif\ifpriornum
32112 \newif\ifminusnumber
32113 \newif\ifnotnumtonameallcaps
32114 \newif\ifmakeordinal
32115
32116 % \end{macrocode}
32117 % \end{macro}
32118 % \end{macro}
32119 % \end{macro}
32120 % \end{macro}
32121 %
32122 % \begin{macro}{\namenumberand}
32123 % \begin{macro}{\namenumbercomma}
32124 % \begin{macro}{\lcminusname}
32125 % \begin{macro}{\ucminusname}
32126 % \begin{macro}{\minusname}
32127 % Some macros representing characters/words for number formatting.
32128 % \begin{macrocode}
32129 \newcommand*{\namenumberand}{ and }
32130 \newcommand*{\namenumbercomma}{, }
32131 \newcommand*{\lcminusname}{minus }
32132 \newcommand*{\ucminusname}{Minus }
32133 \let\minusname\lcminusname
32134 % \end{macrocode}
32135 % \end{macro}
32136 % \end{macro}
32137 % \end{macro}
32138 % \end{macro}
32139 % \end{macro}
32140 %
32141 % \begin{macro}{\fnumbersep}
32142 % \begin{macro}{\tensunitsep}
32143 % \begin{macro}{\nthstring}
32144 % \begin{macro}{\iststring}
32145 % \begin{macro}{\iindstring}
32146 % \begin{macro}{\iiirdstring}
32147 % \begin{macro}{\tiethstring}
32148 % \begin{macro}{\teenstring}
32149 % More characters/words for formatting
32150 % \begin{macrocode}
32151 \newcommand*{\fnumbersep}{,}
32152 \newcommand*\tensunitsep{-}
32153 \newcommand*{\nthstring}{th} % nth
32154 \newcommand*{\iststring}{st} % 1st
32155 \newcommand*{\iindstring}{nd} % 2nd
32156 \newcommand*{\iiirdstring}{rd} % 3rd
32157 \newcommand*{\tiethstring}{tieth} % tieth
32158 \newcommand*{\teenstring}{teen} % teen
32159 % \end{macrocode}
32160 % \end{macro}
32161 % \end{macro}
32162 % \end{macro}
32163 % \end{macro}
32164 % \end{macro}
32165 % \end{macro}
32166 % \end{macro}
32167 % \end{macro}
32168 %
32169 % \begin{macro}{\ordscript}
32170 % How to format the ordinal string
32171 % \begin{macrocode}
32172 \newcommand{\ordscript}[1]{#1}
32173
32174 % \end{macrocode}
32175 % \end{macro}
32176 %
32177 % \begin{macro}{\m@mten}
32178 % An internal shorthand for 10
32179 % \begin{macrocode}
32180 \chardef\m@mten=10 % shorthand for 10
32181
32182 % \end{macrocode}
32183 % \end{macro}
32184 %
32185 % \begin{macro}{\c@ism@mctr}
32186 % \begin{macro}{\c@xsm@mctr}
32187 % \begin{macro}{\c@csm@mctr}
32188 % \begin{macro}{\c@ksm@mctr}
32189 % \begin{macro}{\c@xksm@mctr}
32190 % Counters for digits (units to ten thousands) in a number
32191 % \begin{macrocode}
32192 \newcounter{ism@mctr} % units
32193 \newcounter{xsm@mctr} % tens
32194 \newcounter{csm@mctr} % hundreds
32195 \newcounter{ksm@mctr} % thousands
32196 \newcounter{xksm@mctr} % ten thousands
32197 % \end{macrocode}
32198 % \end{macro}
32199 % \end{macro}
32200 % \end{macro}
32201 % \end{macro}
32202 % \end{macro}
32203 %
32204 % \begin{macro}{\c@cksm@mctr}
32205 % \begin{macro}{\c@msm@mctr}
32206 % \begin{macro}{\c@xmsm@mctr}
32207 % \begin{macro}{\c@cmsm@mctr}
32208 % \begin{macro}{\c@bsm@mctr}
32209 % Counters for digits (hundred thousands to billions) in a number
32210 % \begin{macrocode}
32211 \newcounter{cksm@mctr} % hundred thousands
32212 \newcounter{msm@mctr} % millions
32213 \newcounter{xmsm@mctr} % ten millions
32214 \newcounter{cmsm@mctr} % hundred millions
32215 \newcounter{bsm@mctr} % billions
32216 % \end{macrocode}
32217 % \end{macro}
32218 % \end{macro}
32219 % \end{macro}
32220 % \end{macro}
32221 % \end{macro}
32222 %
32223 % \begin{macro}{\c@workm@mctr}
32224 % A `work' counter.
32225 % \begin{macrocode}
32226 \newcounter{workm@mctr}
32227
32228 % \end{macrocode}
32229 % \end{macro}
32230 %
32231 % \begin{macro}{\numdigits}
32232 % \cs{numdigits}\marg{number} splits the \meta{number} into individual digits.
32233 % It sets \cs{minusnumbertrue} if the number is negative, otherwise it is false.
32234 % \begin{macrocode}
32235 \newcommand*{\numdigits}[1]{%
32236 \setcounter{ism@mctr}{0}%
32237 \setcounter{xsm@mctr}{0}%
32238 \setcounter{csm@mctr}{0}%
32239 \setcounter{ksm@mctr}{0}%
32240 \setcounter{xksm@mctr}{0}%
32241 \setcounter{cksm@mctr}{0}%
32242 \setcounter{msm@mctr}{0}%
32243 \setcounter{xmsm@mctr}{0}%
32244 \setcounter{cmsm@mctr}{0}%
32245 \setcounter{bsm@mctr}{0}%
32246 \setcounter{workm@mctr}{#1}%
32247 \minusnumberfalse
32248 \ifnum \c@workm@mctr < \z@ % negative
32249 \minusnumbertrue
32250 \c@workm@mctr = -\c@workm@mctr
32251 \fi
32252 \ifnum \c@workm@mctr > \m@ne % units
32253 \c@ism@mctr = \c@workm@mctr
32254 \divide \c@workm@mctr by \m@mten
32255 \multiply \c@workm@mctr by \m@mten
32256 \advance \c@ism@mctr by -\c@workm@mctr
32257 \divide \c@workm@mctr by \m@mten
32258 \fi
32259 \ifnum \c@workm@mctr > \z@ % tens
32260 \c@xsm@mctr = \c@workm@mctr
32261 \divide \c@workm@mctr by \m@mten
32262 \multiply \c@workm@mctr by \m@mten
32263 \advance \c@xsm@mctr by -\c@workm@mctr
32264 \divide \c@workm@mctr by \m@mten
32265 \fi
32266 \ifnum \c@workm@mctr > \z@ % hundreds
32267 \c@csm@mctr = \c@workm@mctr
32268 \divide \c@workm@mctr by \m@mten
32269 \multiply \c@workm@mctr by \m@mten
32270 \advance \c@csm@mctr by -\c@workm@mctr
32271 \divide \c@workm@mctr by \m@mten
32272 \fi
32273 \ifnum \c@workm@mctr > \z@ % thousands
32274 \c@ksm@mctr = \c@workm@mctr
32275 \divide \c@workm@mctr by \m@mten
32276 \multiply \c@workm@mctr by \m@mten
32277 \advance \c@ksm@mctr by -\c@workm@mctr
32278 \divide \c@workm@mctr by \m@mten
32279 \fi
32280 \ifnum \c@workm@mctr > \z@ % ten thousands
32281 \c@xksm@mctr = \c@workm@mctr
32282 \divide \c@workm@mctr by \m@mten
32283 \multiply \c@workm@mctr by \m@mten
32284 \advance \c@xksm@mctr by -\c@workm@mctr
32285 \divide \c@workm@mctr by \m@mten
32286 \fi
32287 \ifnum \c@workm@mctr > \z@ % hundred thousands
32288 \c@cksm@mctr = \c@workm@mctr
32289 \divide \c@workm@mctr by \m@mten
32290 \multiply \c@workm@mctr by \m@mten
32291 \advance \c@cksm@mctr by -\c@workm@mctr
32292 \divide \c@workm@mctr by \m@mten
32293 \fi
32294 \ifnum \c@workm@mctr > \z@ % millions
32295 \c@msm@mctr = \c@workm@mctr
32296 \divide \c@workm@mctr by \m@mten
32297 \multiply \c@workm@mctr by \m@mten
32298 \advance \c@msm@mctr by -\c@workm@mctr
32299 \divide \c@workm@mctr by \m@mten
32300 \fi
32301 \ifnum \c@workm@mctr > \z@ % ten millions
32302 \c@xmsm@mctr = \c@workm@mctr
32303 \divide \c@workm@mctr by \m@mten
32304 \multiply \c@workm@mctr by \m@mten
32305 \advance \c@xmsm@mctr by -\c@workm@mctr
32306 \divide \c@workm@mctr by \m@mten
32307 \fi
32308 \ifnum \c@workm@mctr > \z@ % hundred millions
32309 \c@cmsm@mctr = \c@workm@mctr
32310 \divide \c@workm@mctr by \m@mten
32311 \multiply \c@workm@mctr by \m@mten
32312 \advance \c@cmsm@mctr by -\c@workm@mctr
32313 \divide \c@workm@mctr by \m@mten
32314 \fi
32315 \ifnum \c@workm@mctr > \z@% billions
32316 \c@bsm@mctr = \c@workm@mctr
32317 \divide \c@workm@mctr by \m@mten
32318 \multiply \c@workm@mctr by \m@mten
32319 \advance \c@bsm@mctr by -\c@workm@mctr
32320 \fi}
32321
32322 % \end{macrocode}
32323 % \end{macro}
32324 %
32325 % \begin{macro}{\form@tnumber}
32326 % \cs{form@tnumber}\marg{number} formats \meta{number} as digits.
32327 % \begin{macrocode}
32328 \newcommand*{\form@tnumber}[1]{%
32329 \numdigits{#1}%
32330 \ifminusnumber-\fi
32331 \priornumfalse
32332 \ifnum \c@bsm@mctr > \z@ % billions
32333 \priornumtrue
32334 \thebsm@mctr\fnumbersep
32335 \fi
32336 \ifpriornum % hundred millions
32337 \thecmsm@mctr
32338 \else
32339 \ifnum \c@cmsm@mctr > \z@
32340 \priornumtrue
32341 \thecmsm@mctr
32342 \fi
32343 \fi
32344 \ifpriornum % ten millions
32345 \thexmsm@mctr
32346 \else
32347 \ifnum \c@xmsm@mctr > \z@
32348 \priornumtrue
32349 \thexmsm@mctr
32350 \fi
32351 \fi
32352 \ifpriornum % millions
32353 \themsm@mctr\fnumbersep
32354 \else
32355 \ifnum \c@msm@mctr > \z@
32356 \priornumtrue
32357 \themsm@mctr\fnumbersep
32358 \fi
32359 \fi
32360 \ifpriornum % hundred thousands
32361 \thecksm@mctr
32362 \else
32363 \ifnum \c@cksm@mctr > \z@
32364 \priornumtrue
32365 \thecksm@mctr
32366 \fi
32367 \fi
32368 \ifpriornum % ten thousands
32369 \thexksm@mctr
32370 \else
32371 \ifnum \c@xksm@mctr > \z@
32372 \priornumtrue
32373 \thexksm@mctr
32374 \fi
32375 \fi
32376 \ifpriornum % thousands
32377 \theksm@mctr\fnumbersep
32378 \else
32379 \ifnum \c@ksm@mctr > \z@
32380 \priornumtrue
32381 \theksm@mctr\fnumbersep
32382 \fi
32383 \fi
32384 \ifpriornum % hundreds
32385 \thecsm@mctr
32386 \else
32387 \ifnum \c@csm@mctr > \z@
32388 \priornumtrue
32389 \thecsm@mctr
32390 \fi
32391 \fi
32392 \ifpriornum % tens
32393 \thexsm@mctr
32394 \else
32395 \ifnum \c@xsm@mctr > \z@
32396 \priornumtrue
32397 \thexsm@mctr
32398 \fi
32399 \fi
32400 \theism@mctr} % units
32401
32402 % \end{macrocode}
32403 % \end{macro}
32404 %
32405 % \begin{macro}{\cardinal}
32406 % \cs{cardinal}\marg{number} prints \meta{number} unformatted.
32407 % \begin{macrocode}
32408 \newcommand*{\cardinal}[1]{%
32409 \begingroup
32410 \let\fnumbersep\relax
32411 \form@tnumber{#1}%
32412 \endgroup}
32413 % \end{macrocode}
32414 % \end{macro}
32415 %
32416 % \begin{macro}{\fcardinal}
32417 % \cs{fcardinal}\marg{number} prints \meta{number} formatted.
32418 % \begin{macrocode}
32419 \newcommand*{\fcardinal}[1]{%
32420 \begingroup
32421 \form@tnumber{#1}%
32422 \endgroup}
32423
32424 % \end{macrocode}
32425 % \end{macro}
32426 %
32427 % \begin{macro}{\ordinal}
32428 % \cs{ordinal}\marg{number} prints \meta{number} as an unformatted ordinal.
32429 % \begin{macrocode}
32430 \newcommand*{\ordinal}[1]{%
32431 \begingroup
32432 \let\fnumbersep\relax
32433 \form@tnumber{#1}%
32434 \let\ordstring\nthstring
32435 \ifnum \c@xsm@mctr=\@ne\else
32436 \ifcase \c@ism@mctr
32437 \or \let\ordstring\iststring% 1st
32438 \or \let\ordstring\iindstring% 2nd
32439 \or \let\ordstring\iiirdstring% 3rd
32440 \fi
32441 \fi
32442 \ordscript{\ordstring}%
32443 \endgroup
32444 }
32445 % \end{macrocode}
32446 % \end{macro}
32447 %
32448 % \begin{macro}{\fordinal}
32449 % \cs{fordinal}\marg{number} prints \meta{number} as a formatted ordinal.
32450 % \begin{macrocode}
32451 \newcommand*{\fordinal}[1]{%
32452 \begingroup
32453 \form@tnumber{#1}%
32454 \let\ordstring\nthstring
32455 \ifnum \c@xsm@mctr=\@ne\else
32456 \ifcase \c@ism@mctr
32457 \or \let\ordstring\iststring% 1st
32458 \or \let\ordstring\iindstring% 2nd
32459 \or \let\ordstring\iiirdstring% 3rd
32460 \fi
32461 \fi
32462 \ordscript{\ordstring}%
32463 \endgroup
32464 }
32465
32466 % \end{macrocode}
32467 % \end{macro}
32468 %
32469 % The next, tedious, code is for translating numbers into names.
32470 %
32471 % \begin{macro}{\nNameo}
32472 % \begin{macro}{\nNamec}
32473 % \begin{macro}{\nNamem}
32474 % \begin{macro}{\nNamemm}
32475 % \begin{macro}{\nNamemmm}
32476 % Names of major numbers: $0$, $10^{2}$, $10^{3}$, $10^{6}$, and $10^{9}$.
32477 % \begin{macrocode}
32478 \newcommand*\nNameo{\iflowernumtoname z\else Z\fi ero}
32479 \newcommand*\nNamec{\iflowernumtoname h\else H\fi undred}
32480 \newcommand*\nNamem{\iflowernumtoname t\else T\fi housand}
32481 \newcommand*\nNamemm{\iflowernumtoname m\else M\fi illion}
32482 \newcommand*\nNamemmm{\iflowernumtoname b\else B\fi illion}
32483
32484 % \end{macrocode}
32485 % \end{macro}
32486 % \end{macro}
32487 % \end{macro}
32488 % \end{macro}
32489 % \end{macro}
32490 %
32491 % \begin{macro}{\nNamei}
32492 % \begin{macro}{\nNameii}
32493 % \begin{macro}{\nNameiii}
32494 % \begin{macro}{\nNameiv}
32495 % \begin{macro}{\nNamev}
32496 % These are the names for numbers 1 to 5.
32497 % \begin{macrocode}
32498 \newcommand*\nNamei{\iflowernumtoname o\else O\fi ne}
32499 \newcommand*\nNameii{\iflowernumtoname t\else T\fi wo}
32500 \newcommand*\nNameiii{\iflowernumtoname t\else T\fi hree}
32501 \newcommand*\nNameiv{\iflowernumtoname f\else F\fi our}
32502 \newcommand*\nNamev{\iflowernumtoname f\else F\fi ive}
32503 % \end{macrocode}
32504 % \end{macro}
32505 % \end{macro}
32506 % \end{macro}
32507 % \end{macro}
32508 % \end{macro}
32509 %
32510 % \begin{macro}{\nNamevi}
32511 % \begin{macro}{\nNamevii}
32512 % \begin{macro}{\nNameviii}
32513 % \begin{macro}{\nNameix}
32514 % \begin{macro}{\nNamex}
32515 % These are the names for numbers 6 to 10.
32516 % \begin{macrocode}
32517 \newcommand*\nNamevi{\iflowernumtoname s\else S\fi ix}
32518 \newcommand*\nNamevii{\iflowernumtoname s\else S\fi even}
32519 \newcommand*\nNameviii{\iflowernumtoname e\else E\fi ight}
32520 \newcommand*\nNameix{\iflowernumtoname n\else N\fi ine}
32521 \newcommand*\nNamex{\iflowernumtoname t\else T\fi en}
32522 % \end{macrocode}
32523 % \end{macro}
32524 % \end{macro}
32525 % \end{macro}
32526 % \end{macro}
32527 % \end{macro}
32528 %
32529 % \begin{macro}{\nNamexi}
32530 % \begin{macro}{\nNamexii}
32531 % \begin{macro}{\nNamexiii}
32532 % \begin{macro}{\nNamexiv}
32533 % \begin{macro}{\nNamexv}
32534 % These are the names for numbers 11 to 15.
32535 % \begin{macrocode}
32536 \newcommand*\nNamexi{\iflowernumtoname e\else E\fi leven}
32537 \newcommand*\nNamexii{\iflowernumtoname t\else T\fi welve}
32538 \newcommand*\nNamexiii{\iflowernumtoname t\else T\fi hir\teenstring}
32539 \newcommand*\nNamexiv{\iflowernumtoname f\else F\fi our\teenstring}
32540 \newcommand*\nNamexv{\iflowernumtoname f\else F\fi if\teenstring}
32541 % \end{macrocode}
32542 % \end{macro}
32543 % \end{macro}
32544 % \end{macro}
32545 % \end{macro}
32546 % \end{macro}
32547 %
32548 % \begin{macro}{\nNamexvi}
32549 % \begin{macro}{\nNamexvii}
32550 % \begin{macro}{\nNamexviii}
32551 % \begin{macro}{\nNamexix}
32552 % \begin{macro}{\nNamexx}
32553 % These are the names for numbers 16 to 20.
32554 % \begin{macrocode}
32555 \newcommand*\nNamexvi{\iflowernumtoname s\else S\fi ix\teenstring}
32556 \newcommand*\nNamexvii{\iflowernumtoname s\else S\fi even\teenstring}
32557 \newcommand*\nNamexviii{\iflowernumtoname e\else E\fi igh\teenstring}
32558 \newcommand*\nNamexix{\iflowernumtoname n\else N\fi ine\teenstring}
32559 \newcommand*\nNamexx{\iflowernumtoname t\else T\fi wenty}
32560 % \end{macrocode}
32561 % \end{macro}
32562 % \end{macro}
32563 % \end{macro}
32564 % \end{macro}
32565 % \end{macro}
32566 %
32567 % \begin{macro}{\nNamexxx}
32568 % \begin{macro}{\nNamexl}
32569 % \begin{macro}{\nNamel}
32570 % \begin{macro}{\nNamelx}
32571 % \begin{macro}{\nNamelxx}
32572 % These are the names for numbers 30 to 70.
32573 % \begin{macrocode}
32574 \newcommand*\nNamexxx{\iflowernumtoname t\else T\fi hirty}
32575 \newcommand*\nNamexl{\iflowernumtoname f\else F\fi orty}
32576 \newcommand*\nNamel{\iflowernumtoname f\else F\fi ifty}
32577 \newcommand*\nNamelx{\iflowernumtoname s\else S\fi ixty}
32578 \newcommand*\nNamelxx{\iflowernumtoname s\else S\fi eventy}
32579 % \end{macrocode}
32580 % \end{macro}
32581 % \end{macro}
32582 % \end{macro}
32583 % \end{macro}
32584 % \end{macro}
32585 %
32586 % \begin{macro}{\nNamelxxx}
32587 % \begin{macro}{\nNamexc}
32588 % These are the names for numbers 80 to 90.
32589 % \begin{macrocode}
32590 \newcommand*\nNamelxxx{\iflowernumtoname e\else E\fi ighty}
32591 \newcommand*\nNamexc{\iflowernumtoname n\else N\fi inety}
32592
32593 % \end{macrocode}
32594 % \end{macro}
32595 % \end{macro}
32596 %
32597 %
32598 %
32599 % \begin{macro}{\unitnumbername}
32600 % Get the name of a unit (0 -- 9).
32601 % \begin{macrocode}
32602 \newcommand*{\unitnumbername}[1]{%
32603 \ifcase #1 \nNameo\or
32604 \nNamei\or
32605 \nNameii\or
32606 \nNameiii\or
32607 \nNameiv\or
32608 \nNamev\or
32609 \nNamevi\or
32610 \nNamevii\or
32611 \nNameviii\or
32612 \nNameix\fi}
32613
32614 % \end{macrocode}
32615 % \end{macro}
32616 %
32617 % \begin{macro}{\teennumbername}
32618 % Get the name of a 'teen number (10 -- 19)
32619 % \begin{macrocode}
32620 \newcommand*{\teennumbername}[1]{%
32621 \ifcase #1 \nNamex\or
32622 \nNamexi\or
32623 \nNamexii\or
32624 \nNamexiii\or
32625 \nNamexiv\or
32626 \nNamexv\or
32627 \nNamexvi\or
32628 \nNamexvii\or
32629 \nNamexviii\or
32630 \nNamexix\fi}
32631
32632 % \end{macrocode}
32633 % \end{macro}
32634 %
32635 % \begin{macro}{\tensnumbername}
32636 % Get the name of a tens number (20 -- 90)
32637 % \begin{macrocode}
32638 \newcommand*{\tensnumbername}[2]{%
32639 \ifnum #1=\@ne
32640 \teennumbername{#2}\ifnotnumtonameallcaps\lowernumtonametrue\fi
32641 \else
32642 \ifcase #1
32643 \or
32644 \or \nNamexx
32645 \or \nNamexxx
32646 \or \nNamexl
32647 \or \nNamel
32648 \or \nNamelx
32649 \or \nNamelxx
32650 \or \nNamelxxx
32651 \or \nNamexc
32652 \fi
32653 \ifnotnumtonameallcaps\lowernumtonametrue\fi
32654 \ifnum #2 > \z@ \tensunitsep\unitnumbername{#2}\fi
32655 \fi}
32656
32657 % \end{macrocode}
32658 % \end{macro}
32659 %
32660 % Names of small ordinals. The use of \cs{nthstring} instead of `th' saves
32661 % some tokens.
32662 % \begin{macrocode}
32663 \newcommand*\nthNameo{\nNameo\nthstring}
32664 \newcommand*\nthNamei{\iflowernumtoname f\else F\fi irst}
32665 \newcommand*\nthNameii{\iflowernumtoname s\else S\fi econd}
32666 \newcommand*\nthNameiii{\iflowernumtoname t\else T\fi hird}
32667 \newcommand*\nthNameiv{\nNameiv\nthstring}
32668 \newcommand*\nthNamev{\iflowernumtoname f\else F\fi if\nthstring}
32669 \newcommand*\nthNamevi{\nNamevi\nthstring}
32670 \newcommand*\nthNamevii{\nNamevii\nthstring}
32671 \newcommand*\nthNameviii{\iflowernumtoname e\else E\fi igh\nthstring}
32672 \newcommand*\nthNameix{\iflowernumtoname n\else N\fi in\nthstring}
32673 \newcommand*\nthNamexii{\iflowernumtoname t\else T\fi welf\nthstring}
32674
32675 % \end{macrocode}
32676 %
32677 % \begin{macro}{\unitordinalname}
32678 % Get the ordinal name of a unit (0 -- 9)
32679 % \begin{macrocode}
32680 \newcommand*{\unitordinalname}[1]{%
32681 \ifcase #1 \nthNameo\or
32682 \nthNamei\or
32683 \nthNameii\or
32684 \nthNameiii\or
32685 \nthNameiv\or
32686 \nthNamev\or
32687 \nthNamevi\or
32688 \nthNamevii\or
32689 \nthNameviii\or
32690 \nthNameix\fi}
32691
32692 % \end{macrocode}
32693 % \end{macro}
32694 %
32695 % \begin{macro}{\teenordinalname}
32696 % Get the ordinal name of a 'teen number (10 -- 19). Using \cs{nthstring}
32697 % instead of `th' to save some tokens.
32698 % \begin{macrocode}
32699 \newcommand*{\teenordinalname}[1]{%
32700 \ifcase #1 \nNamex\nthstring\or
32701 \nNamexi\nthstring\or
32702 \nthNamexii\or
32703 \nNamexiii\nthstring\or
32704 \nNamexiv\nthstring\or
32705 \nNamexv\nthstring\or
32706 \nNamexvi\nthstring\or
32707 \nNamexvii\nthstring\or
32708 \nNamexviii\nthstring\or
32709 \nNamexix\nthstring\fi}
32710
32711 % \end{macrocode}
32712 % \end{macro}
32713 %
32714 % \begin{macro}{\tensordinalname}
32715 % Get the ordinal name of a tens number (20 -- 90)
32716 % (Mathew Dafilis) sent Email on 2003/11/14
32717 % saying that \cs{ordinaltoname} didn't work for 20, 30, etc. He was
32718 % correct. It is now fixed.
32719 % \begin{macrocode}
32720 \newcommand*{\tensordinalname}[2]{%
32721 \ifnum #1=\@ne
32722 \teenordinalname{#2}\ifnotnumtonameallcaps\lowernumtonametrue\fi
32723 \else
32724 \ifnum #2> \z@
32725 \ifcase #1
32726 \or
32727 \or \nNamexx
32728 \or \nNamexxx
32729 \or \nNamexl
32730 \or \nNamel
32731 \or \nNamelx
32732 \or \nNamelxx
32733 \or \nNamelxxx
32734 \or \nNamexc
32735 \fi
32736 \ifnotnumtonameallcaps\lowernumtonametrue\fi
32737 \tensunitsep\unitordinalname{#2}
32738 \else
32739 \ifcase #1
32740 \or
32741 \or \nthNamexx
32742 \or \nthNamexxx
32743 \or \nthNamexl
32744 \or \nthNamel
32745 \or \nthNamelx
32746 \or \nthNamelxx
32747 \or \nthNamelxxx
32748 \or \nthNamexc
32749 \fi
32750 \ifnotnumtonameallcaps\lowernumtonametrue\fi
32751 \fi
32752 \fi}
32753
32754 % \end{macrocode}
32755 % \end{macro}
32756 %
32757 % The names of tens ordinals. The use of \cs{tiethstring} instead
32758 % of `tieth' saves somes tokens.
32759 % \begin{macrocode}
32760 \newcommand*\nthNamexx{\iflowernumtoname t\else T\fi wen\tiethstring}
32761 \newcommand*\nthNamexxx{\iflowernumtoname t\else T\fi hir\tiethstring}
32762 \newcommand*\nthNamexl{\iflowernumtoname f\else F\fi or\tiethstring}
32763 \newcommand*\nthNamel{\iflowernumtoname f\else F\fi if\tiethstring}
32764 \newcommand*\nthNamelx{\iflowernumtoname s\else S\fi ix\tiethstring}
32765 \newcommand*\nthNamelxx{\iflowernumtoname s\else S\fi even\tiethstring}
32766 \newcommand*\nthNamelxxx{\iflowernumtoname e\else E\fi igh\tiethstring}
32767 \newcommand*\nthNamexc{\iflowernumtoname n\else N\fi ine\tiethstring}
32768
32769 % \end{macrocode}
32770 %
32771 % \begin{macro}{\n@me@number}
32772 % \cs{n@me@number}\marg{number} is an internal macro to convert a
32773 % \meta{number} to names.
32774 % \begin{macrocode}
32775 \newcommand*{\n@me@number}[1]{%
32776 \begingroup
32777 \numdigits{#1}%
32778 \ifminusnumber\minusname\fi
32779 \priornumfalse
32780 %% billions
32781 \ifnum \c@bsm@mctr > \z@
32782 \unitnumbername{\thebsm@mctr}\space
32783 \ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamemmm
32784 \priornumtrue
32785 \fi
32786 %% hundred millions
32787 \ifnum \c@cmsm@mctr > \z@
32788 \ifpriornum\namenumbercomma\fi
32789 \unitnumbername{\thecmsm@mctr}\space
32790 \ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
32791 \priornumtrue
32792 \fi
32793 %% tens/units millions
32794 \ifnum \c@xmsm@mctr > \z@
32795 \ifpriornum
32796 \ifnum\c@cmsm@mctr>\z@\namenumberand\else\namenumbercomma\fi
32797 \fi
32798 \tensnumbername{\thexmsm@mctr}{\themsm@mctr}%
32799 \priornumtrue
32800 \else
32801 \ifnum \c@msm@mctr > \z@
32802 \ifpriornum
32803 \ifnum\c@cmsm@mctr>\z@\namenumberand\else\namenumbercomma\fi
32804 \fi
32805 \unitnumbername{\themsm@mctr}%
32806 \ifnotnumtonameallcaps\lowernumtonametrue\fi
32807 \priornumtrue
32808 \fi
32809 \fi
32810 \ifnum \c@cmsm@mctr > \z@
32811 \ifpriornum\space\fi
32812 \nNamemm
32813 \else
32814 \ifnum \c@xmsm@mctr > \z@
32815 \ifpriornum\space\fi
32816 \nNamemm
32817 \else
32818 \ifnum \c@msm@mctr > \z@
32819 \ifpriornum\space\fi
32820 \nNamemm
32821 \fi
32822 \fi
32823 \fi
32824 %% hundred thousands
32825 \ifnum \c@cksm@mctr > \z@
32826 \ifpriornum\namenumbercomma\fi
32827 \unitnumbername{\thecksm@mctr}\space
32828 \ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
32829 \priornumtrue
32830 \fi
32831 %% tens/units thousands
32832 \ifnum \c@xksm@mctr > \z@
32833 \ifpriornum
32834 \ifnum\c@cksm@mctr>\z@\namenumberand\else\namenumbercomma\fi
32835 \fi
32836 \tensnumbername{\thexksm@mctr}{\theksm@mctr}%
32837 \priornumtrue
32838 \else
32839 \ifnum \c@ksm@mctr > \z@
32840 \ifpriornum
32841 \ifnum\c@cksm@mctr>\z@\namenumberand\else\namenumbercomma\fi
32842 \fi
32843 \unitnumbername{\theksm@mctr}%
32844 \ifnotnumtonameallcaps\lowernumtonametrue\fi
32845 \priornumtrue
32846 \fi
32847 \fi
32848 \ifnum \c@cksm@mctr > \z@
32849 \ifpriornum\space\fi
32850 \nNamem
32851 \else
32852 \ifnum \c@xksm@mctr > \z@
32853 \ifpriornum\space\fi
32854 \nNamem
32855 \else
32856 \ifnum \c@ksm@mctr > \z@
32857 \ifpriornum\space\fi
32858 \nNamem
32859 \fi
32860 \fi
32861 \fi
32862 %% hundreds
32863 \ifnum \c@csm@mctr > \z@
32864 \ifpriornum\namenumbercomma\fi
32865 \unitnumbername{\thecsm@mctr}\space
32866 \ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
32867 \priornumtrue
32868 \fi
32869 %% tens/units
32870 \ifmakeordinal
32871 \ifnum \c@xsm@mctr > \z@
32872 \ifpriornum\namenumberand\fi
32873 \tensordinalname{\thexsm@mctr}{\theism@mctr}%
32874 \else
32875 \ifnum \c@ism@mctr > \z@
32876 \ifpriornum\namenumberand\fi
32877 \unitordinalname{\theism@mctr}%
32878 \else
32879 \ifpriornum\nthstring\else\unitordinalname{\theism@mctr}\fi
32880 \fi
32881 \fi
32882 \else % not ordinal
32883 \ifnum \c@xsm@mctr > \z@
32884 \ifpriornum\namenumberand\fi
32885 \tensnumbername{\thexsm@mctr}{\theism@mctr}%
32886 \else
32887 \ifnum \c@ism@mctr > \z@
32888 \ifpriornum\namenumberand\fi
32889 \unitnumbername{\theism@mctr}%
32890 \else
32891 \ifpriornum\else\unitnumbername{\theism@mctr}\fi
32892 \fi
32893 \fi
32894 \fi % end ifmakeordinal
32895 \endgroup}
32896
32897 % \end{macrocode}
32898 % \end{macro}
32899 %
32900 % \changes{v1.61803}{2008/01/30}{Made all \cs{(num/ordinal)toname} robust}
32901 % \begin{macro}{\numtoname}
32902 % Lowercase all names
32903 % \begin{macrocode}
32904 \DeclareRobustCommand{\numtoname}[1]{%
32905 \makeordinalfalse
32906 \notnumtonameallcapstrue%
32907 \lowernumtonametrue%
32908 \n@me@number{#1}}
32909
32910 % \end{macrocode}
32911 % \end{macro}
32912 %
32913 % \begin{macro}{\numtoName}
32914 % Uppercase first letter of first name (all else lowercase).
32915 % \begin{macrocode}
32916 \DeclareRobustCommand{\numtoName}[1]{%
32917 \makeordinalfalse
32918 \notnumtonameallcapstrue%
32919 \lowernumtonamefalse%
32920 \n@me@number{#1}}
32921
32922 % \end{macrocode}
32923 % \end{macro}
32924 %
32925 % \begin{macro}{\NumToName}
32926 % Uppercase first letter of all names (all else lowercase).
32927 % \begin{macrocode}
32928 \DeclareRobustCommand{\NumToName}[1]{%
32929 \makeordinalfalse
32930 \notnumtonameallcapsfalse%
32931 \lowernumtonamefalse%
32932 \n@me@number{#1}}
32933
32934 % \end{macrocode}
32935 % \end{macro}
32936 %
32937 % \begin{macro}{\ordinaltoname}
32938 % Lowercase all ordinal names
32939 % \begin{macrocode}
32940 \DeclareRobustCommand{\ordinaltoname}[1]{%
32941 \makeordinaltrue
32942 \notnumtonameallcapstrue%
32943 \lowernumtonametrue%
32944 \n@me@number{#1}}
32945
32946 % \end{macrocode}
32947 % \end{macro}
32948 %
32949 % \begin{macro}{\ordinaltoName}
32950 % Uppercase first letter of first ordinal name (all else lowercase).
32951 % \begin{macrocode}
32952 \DeclareRobustCommand{\ordinaltoName}[1]{%
32953 \makeordinaltrue
32954 \notnumtonameallcapstrue%
32955 \lowernumtonamefalse%
32956 \n@me@number{#1}}
32957
32958 % \end{macrocode}
32959 % \end{macro}
32960 %
32961 % \begin{macro}{\OrdinalToName}
32962 % Uppercase first letter of all ordinal names (all else lowercase).
32963 % \begin{macrocode}
32964 \DeclareRobustCommand{\OrdinalToName}[1]{%
32965 \makeordinaltrue
32966 \notnumtonameallcapsfalse%
32967 \lowernumtonamefalse%
32968 \n@me@number{#1}}
32969
32970 % \end{macrocode}
32971 % \end{macro}
32972 %
32973 %
32974 % \subsection{A fix for two column headings}
32975 %
32976 %
32977 % This is from a posting by Donald Arseneau to \ctt{} on 23 April 2001 to fix
32978 % a problem --- `When I use \verb?\onecolumn\chapter...? its headline
32979 % is printed lower on the page than for two-column chapters'
32980 %
32981 % DA and I had previously discussed this in relation to the Index
32982 % and I had put a hack into the \Lpack{tocbibind} package to fix the Index.
32983 %
32984 % Donald posted the following.
32985 %
32986 % \cs{vspace*} gives bad spacing after a pagebreak and \cs{@makechapterhead}
32987 % starts with \cs{vspace*}.
32988 % The biggest problem is the definition of \cs{@topnewpage}, which is used
32989 % for the two-column spanning text. Here is a redefinition:
32990 % \changes{v0.2}{2001/06/03}{Added DA's redefinition of \cs{@topnewpage}}
32991 % \begin{macro}{\@topnewpage}
32992 % \begin{macrocode}
32993 \long\def \@topnewpage [#1]{%
32994 \@nodocument
32995 \@next\@currbox\@freelist{}{}%
32996 \global \setbox\@currbox
32997 \vbox {%
32998 \break
32999 \prevdepth\z@
33000 \begingroup
33001 \normalcolor
33002 \hsize\textwidth
33003 \@parboxrestore
33004 \col@number \@ne
33005 #1%
33006 \vskip -\dbltextfloatsep
33007 \endgroup
33008 \null % ordinary \baselineskip
33009 \vskip -\topskip
33010 }%
33011 \begingroup %% \showbox\@currbox
33012 \splitmaxdepth\maxdepth \splittopskip\topskip
33013 \setbox\@tempboxa \vsplit\@currbox to \z@
33014 \endgroup %% \showbox\@currbox
33015 \ifdim \ht\@currbox>\textheight
33016 \ht\@currbox \textheight
33017 \fi
33018 \global \count\@currbox \tw@
33019 \@tempdima -\ht\@currbox
33020 \advance \@tempdima -\dbltextfloatsep
33021 \global \advance \@colht \@tempdima
33022 \ifx \@dbltoplist \@empty
33023 \else
33024 \@latexerr{Float(s) lost}\@ehb
33025 \let \@dbltoplist \@empty
33026 \fi
33027 \@cons \@dbltoplist \@currbox
33028 \global \@dbltopnum \m@ne
33029 \ifdim \@colht<2.5\baselineskip
33030 \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
33031 too tall on page \thepage}%
33032 \@emptycol
33033 \if@firstcolumn
33034 \else
33035 \@emptycol
33036 \fi
33037 \else
33038 \global \vsize \@colht
33039 \global \@colroom \@colht
33040 \@floatplacement
33041 \fi}
33042
33043 % \end{macrocode}
33044 % \end{macro}
33045 %
33046 % The original version of \cs{@topnewpage} is in \file{ltouput.dtx}, line 159.
33047 %
33048 % \subsection{Time of day}
33049 %
33050 % William Adams (2006/08/28) supplied a basis for
33051 % \cs{printime}, which he needed for \cs{quarkmarks} but I have used one
33052 % from \textit{TeX for the Impatient}
33053 % as it saves some counters.
33054 % \changes{v1.61803}{2008/01/30}{Added \cs{printime} and friends (mempatch v4.6)}
33055 % \begin{macro}{\m@mcalchm}
33056 % Calculate the hours and minutes from \cs{time}.
33057 % \begin{macrocode}
33058 \newcommand*{\m@mcalchm}{%
33059 \count0 = \time \divide \count0 by 60\relax
33060 \count2 = \count0\relax% the hour
33061 \count4 = \time \multiply\count0 by 60\relax
33062 \advance\count4 by -\count0\relax% the minute
33063 \ifnum\count4<10 \toks1 = {0}% make a leading zero
33064 \else \toks1 = {}%
33065 \fi}
33066 % \end{macrocode}
33067 % \end{macro}
33068 %
33069 % \begin{macro}{\hmpunct}
33070 % \begin{macro}{\amname}
33071 % \begin{macro}{\pmname}
33072 % User format controls for \cs{printtime}
33073 % \begin{macrocode}
33074 %%% punctuation, am and pm for \printtime
33075 \newcommand*{\hmpunct}{:}% hours minutes separator
33076 \newcommand*{\amname}{am}% ante meridiem
33077 \newcommand*{\pmname}{pm}% post meridiem
33078
33079 % \end{macrocode}
33080 % \end{macro}
33081 % \end{macro}
33082 % \end{macro}
33083 %
33084 % \begin{macro}{\printtime}
33085 % \begin{macro}{\printtime*}
33086 % Print the time of day as 24 hour clock or 12 hour clock
33087 % \cs{printtime} prints the time par 24 hour clock and \cs{printtime*}
33088 % per 12 hour clock.
33089 % \begin{macrocode}
33090 \newcommand*{\printtime}{%
33091 \@ifstar{\m@msprtime}{\m@mprtime}}
33092 % \end{macrocode}
33093 % \end{macro}
33094 % \end{macro}
33095 %
33096 % \begin{macro}{\m@mprtime}
33097 % \begin{macro}{\m@msprtime}
33098 % These implement time printing: \cs{m@mprtime} as 24 hour clock and
33099 % \cs{m@msprtime} as 12 hour clock
33100 % \begin{macrocode}
33101 \newcommand*{\m@mprtime}{\begingroup
33102 \m@mcalchm
33103 \number\count2\hmpunct\the\toks1 \number\count4
33104 \endgroup}
33105 \newcommand*{\m@msprtime}{\begingroup
33106 \m@mcalchm
33107 \def\@mpm{\pmname}%
33108 \ifnum\count2<1\relax% early in the morning
33109 \count2=12\relax
33110 \ifnum\count4>0\relax% not midnight
33111 \def\@mpm{\amname}%
33112 \fi
33113 \else
33114 \ifnum\time<721\relax% noon or earlier
33115 \def\@mpm{\amname}%
33116 \else
33117 \ifnum\time>779\relax% 1300 hrs or later
33118 \advance\count2 by -12\relax
33119 \fi
33120 \fi
33121 \fi
33122 \number\count2\hmpunct\the\toks1 \number\count4\ \@mpm
33123 \endgroup}
33124
33125 % \end{macrocode}
33126 % \end{macro}
33127 % \end{macro}
33128 %
33129 % \subsection{Sequential sheet (page) numbers}
33130 %
33131 % \begin{macro}{\c@sheetsequence}
33132 % Peter Heslin asked for the ability to add a sequential page number
33133 % (1 for the first page, N for the last page, no matter what value
33134 % the page counter has) to the trimming marks.
33135 %
33136 % \cs{c@sheetsequence} is a new counter for pages starting at the
33137 % beginning and independent
33138 % of the standard page counter. This should not be reset by anything.
33139 % The counter increment has to be added to the output routine.
33140 %
33141 % This may also be useful for page N of M numbering.
33142 % \changes{v1.3}{2002/10/10}{Added sheetsequence counter.}
33143 % \begin{macrocode}
33144 \newcounter{sheetsequence}
33145 \setcounter{sheetsequence}{1}
33146 \renewcommand{\thesheetsequence}{\@arabic\c@sheetsequence}
33147 \g@addto@macro{\@outputpage}{\stepcounter{sheetsequence}}
33148
33149 % \end{macrocode}
33150 % \end{macro}
33151 %
33152 % \begin{macro}{\c@lastsheet}
33153 % \begin{macro}{\c@lastpage}
33154 % While we're at it, might as well provide for lastpage and lastsheet counters
33155 % \changes{v1.3}{2002/11/14}{Added lastsheet and lastpage functions.}
33156 % \begin{macrocode}
33157 \newcounter{lastsheet}
33158 \setcounter{lastsheet}{0}
33159 \newcounter{lastpage}
33160 \setcounter{lastpage}{0}
33161 % \end{macrocode}
33162 % \end{macro}
33163 % \end{macro}
33164 %
33165 % \begin{macro}{\dol@stsheet}
33166 % \begin{macro}{\dol@stpage}
33167 % These two macros write the values of lastsheet and lastpage to the
33168 % \file{aux} file. They have to be called at the end of the document
33169 % after a \cs{clearpage} to flush out any floats.
33170 % \changes{v1.4}{2003/02/27}{In \cs{dol@stpage} use the page counter value,
33171 % not \cs{thepage} otherwise problems with
33172 % non-arabic page numbers (patch 1.1)}
33173 % \changes{v1.61}{2004/03/21}{In \cs{dol@stpage} use the sheet counter value,
33174 % not \cs{thesheetsequence} otherwise problems
33175 % if (e.g., hangul.sty) \cs{@arabic} is redefined}
33176 % \changes{v1.618}{2005/09/02}{Made \cs{dol@stsheet} and \cs{dol@stpage}
33177 % obey \cs{nofiles}}
33178 % \changes{v1.61803}{2008/01/30}{Made \cs{dol@stsheet} and \cs{dolastpage}
33179 % use \cs{memsetcounter} instead of \cs{setcounter}}
33180
33181 % \begin{macrocode}
33182 \newcommand{\dol@stsheet}{%
33183 \if@filesw
33184 \addtocounter{sheetsequence}{-1}%
33185 \immediate\write\@auxout%
33186 {\string\memsetcounter{lastsheet}{\the\c@sheetsequence}}%
33187 \stepcounter{sheetsequence}%
33188 \fi}
33189 \newcommand{\dol@stpage}{%
33190 \if@filesw
33191 \addtocounter{page}{-1}%
33192 \immediate\write\@auxout%
33193 {\string\memsetcounter{lastpage}{\the\c@page}}%
33194 \stepcounter{page}%
33195 \fi}
33196 % \end{macrocode}
33197 % I originally used this: \\
33198 % \verb?\AtEndDocument{\clearpage\dol@stsheet\dol@stpage}?
33199 % but following the CTT thread \textit{AtEndDocument produces unwanted page
33200 % break}, 2004/03/11, and in particular Dan Luecking's response I now
33201 % try as hard as possible to do it right at the end, but even this is not
33202 % 100\% reliable. The only way to ensure reliability is to modify the kernel
33203 % \verb?\enddocument? which doesn't seem to be a particularly wise thing
33204 % to do.
33205 % \changes{v1.61}{2004/03/14}{Changed location of calls to \cs{dol@stsheet}
33206 % and \cs{dol@stpage}}
33207 % \begin{macrocode}
33208 \AtBeginDocument{\AtEndDocument{\clearpage\dol@stsheet\dol@stpage}}
33209
33210 % \end{macrocode}
33211 % \end{macro}
33212 % \end{macro}
33213 %
33214 % \subsection{Leaves per gathering}
33215 %
33216 % Traditionally books are assembled in terms of gatherings, or signatures,
33217 % with perhaps 8 or 16 pages (or leaves) per grouping (a leaf has two pages,
33218 % recto and one verso). At the request of Alan Ristow code for this has
33219 % been included in the class.
33220 %
33221 % \begin{macro}{\ifcntrmod}
33222 % \begin{macro}{\ifnotcntrmod}
33223 % \begin{macro}{\iscntrmod}
33224 % \cs{iscntrmod}\marg{counter}\marg{number} returns \cs{cntrmod(true|false)}
33225 % and \cs{notcntrmod(false|true)} if \meta{counter} is a multiple of
33226 % \meta{number}.
33227 % \changes{v1.61803}{2008/01/30}{Added \cs{iscntrmod}}
33228 % \begin{macrocode}
33229 \newif\ifcntrmod
33230 \newif\ifnotcntrmod
33231 \newcommand*{\iscntrmod}[2]{
33232 \@tempcnta=\@nameuse{c@#1}%
33233 \@tempcntb=\@tempcnta
33234 \divide\@tempcnta #2\relax
33235 \multiply\@tempcnta #2\relax
33236 \advance\@tempcntb-\@tempcnta
33237 \ifnum\@tempcntb=0\relax
33238 \cntrmodtrue
33239 \notcntrmodfalse
33240 \else
33241 \cntrmodfalse
33242 \notcntrmodtrue
33243 \fi}
33244
33245 % \end{macrocode}
33246 % \end{macro}
33247 % \end{macro}
33248 % \end{macro}
33249 %
33250 % \begin{macro}{\@memensuresigpages}
33251 % Ouput enough (empty) pages to make up a complete final signature.
33252 % \changes{v1.61803}{2008/01/30}{Added \cs{@memensuresigpages}}
33253 % \begin{macrocode}
33254 \newcommand*{\@memensuresigpages}{%
33255 \ifnum\@mempagespersig<\@ne
33256 \else
33257 \iscntrmod{sheetsequence}{\@mempagespersig}
33258 \ifcntrmod
33259 \else
33260 \clearpage
33261 \pagestyle{empty}
33262 \mbox{}
33263 \loop
33264 \iscntrmod{sheetsequence}{\@mempagespersig}
33265 \ifnotcntrmod
33266 \clearpage
33267 \pagestyle{empty}
33268 \mbox{}
33269 \repeat
33270 \fi
33271 \fi}
33272
33273 % \end{macrocode}
33274 % \end{macro}
33275 %
33276 % \begin{macro}{\leavespergathering}
33277 % \cs{leavespergathering}\marg{num} is the user command for specifying that
33278 % there must be \meta{num} leaves per gathering (2\meta{num} pages per
33279 % gathering). For \meta{num} more than one the total number of pages output
33280 % is exactly divisible by 2\meta{num}. \meta{num} less than two (the default)
33281 % has no effect.
33282 % \changes{v1.61803}{2008/01/30}{Added \cs{leavespergathering}}
33283 % \begin{macrocode}
33284 \newcommand*{\leavespergathering}[1]{\@memcnta=#1\relax
33285 \ifnum\@memcnta<\tw@
33286 \def\@mempagespersig{-1}%
33287 \else
33288 \multiply\@memcnta \tw@
33289 \edef\@mempagespersig{\@memcnta}%
33290 \fi}
33291 \leavespergathering{0}
33292
33293 % \end{macrocode}
33294 % \end{macro}
33295 %
33296 % Finally, make sure that the requested number of pages is output.
33297 % \begin{macrocode}
33298 \AtEndDocument{\@memensuresigpages}
33299
33300 % \end{macrocode}
33301 %
33302 % \subsection{Text case}
33303 % \changes{v3.6k}{2012/09/13}{Included a copy of the \texttt{textcase}
33304 % package.}
33305 %
33306 % \changes{3.7i}{2019/10/22}{Made textcase into a required package instead}
33307 %
33308 % Since, say, \cs{MakeUppercase} does too much, i.e.\ also upper case
33309 % math and arguments to, say, \cs{ref}, we provide a version that does
33310 % not. David Carlisle wrote the simple package ---
33311 % \Lpack{textcase}~\cite{TEXTCASE} which we simply present as a carbon
33312 % copy including Davids explanations. We do \emph{not} mark this
33313 % package as have been emulated. Loading \texttt{textcase} just
33314 % overwrites the macros if they exist.
33315 %
33316 % As of October 2019, we will instead load the \texttt{textcase}
33317 % package if found. If not we resort to the old version we had
33318 % embedded.
33319 %
33320 % As of Summer 2022 the functionality of \Lpack{textcase} was build
33321 % into the kernel \cs{MakeUppercase} and \cs{MakeLowercase}, plus
33322 % their functionalily regarding UTF8 was greatly extended. We will
33323 % instead let \cs{MakeTextUppercase} and \cs{MakeTextLowercase} be
33324 % aliases for the original.
33325 %
33326 % \changes{v3.8.4}{2025/08/08}{Got rid of the textcase package.}
33327 % \begin{macrocode}
33328 \AtBeginDocument{
33329 \providecommand\MakeTextUppercase{\MakeUppercase}
33330 \providecommand\MakeTextLowercase{\MakeLowercase}
33331 }
33332 \newcommand\MemRestoreOrigMakecase{
33333 \@memarn{\string\MemRestoreOrigMakecase\ no longer does anything and can be removed}
33334 }
33335 % \end{macrocode}
33336 %
33337 %
33338 % \section{Initialization} \label{sec:init}
33339 %
33340 % \subsection{Words and phrases}
33341 %
33342 % This document class is for documents prepared in the English language.
33343 % To prepare a version for another language, various English words
33344 % and phrases must
33345 % be replaced. The English elements that require replacement are
33346 % defined below in command names.
33347 %
33348 % \begin{macro}{\abstractname}
33349 % \begin{macro}{\contentsname}
33350 % \begin{macro}{\listfigurename}
33351 % \begin{macro}{\listtablename}
33352 % \begin{macro}{\bookname}
33353 % \begin{macro}{\partname}
33354 % \begin{macro}{\chaptername}
33355 % \begin{macro}{\appendixname}
33356 % \begin{macro}{\appendixtocname}
33357 % \begin{macro}{\appendixpagename}
33358 % \begin{macro}{\bibname}
33359 % \begin{macro}{\indexname}
33360 % \begin{macro}{\glossaryname}
33361 %
33362 % This list is for titles of document sections.
33363 %
33364 % \begin{macrocode}
33365 \newcommand*{\abstractname}{Abstract}
33366 \newcommand*{\contentsname}{Contents}
33367 \newcommand*{\listfigurename}{List of Figures}
33368 \newcommand*{\listtablename}{List of Tables}
33369 \newcommand*{\bookname}{Book}
33370 \newcommand*{\partname}{Part}
33371 \newcommand*{\chaptername}{Chapter}
33372 \newcommand*{\appendixname}{Appendix}
33373 \newcommand*{\appendixtocname}{Appendices}
33374 \newcommand*{\appendixpagename}{Appendices}
33375 \newcommand*{\bibname}{Bibliography}
33376 \newcommand*{\indexname}{Index}
33377 \newcommand*{\glossaryname}{Glossary}
33378 % \end{macrocode}
33379 % \end{macro}
33380 % \end{macro}
33381 % \end{macro}
33382 % \end{macro}
33383 % \end{macro}
33384 % \end{macro}
33385 % \end{macro}
33386 % \end{macro}
33387 % \end{macro}
33388 % \end{macro}
33389 % \end{macro}
33390 % \end{macro}
33391 % \end{macro}
33392 %
33393 % \begin{macro}{\figurename}
33394 % \begin{macro}{\tablename}
33395 % \begin{macro}{\figurerefname}
33396 % \begin{macro}{\tablerefname}
33397 % \begin{macro}{\pagename}
33398 % \begin{macro}{\pagrefename}
33399 %
33400 % These are the names and phrases used for general elements.
33401 %
33402 % \changes{v3.8.4}{2025/07/30}{\cs{...refname} ought to refer to \cs{...nane}}
33403 % \begin{macrocode}
33404 \newcommand*{\figurename}{Figure}
33405 \newcommand*{\tablename}{Table}
33406 \newcommand*{\figurerefname}{\figurename}
33407 \newcommand*{\tablerefname}{\tablename}
33408 \newcommand*{\pagename}{page}
33409 \newcommand*{\pagerefname}{\pagename}
33410 % \end{macrocode}
33411 % \end{macro}
33412 % \end{macro}
33413 % \end{macro}
33414 % \end{macro}
33415 % \end{macro}
33416 % \end{macro}
33417 %
33418 % \begin{macro}{\bookrefname}
33419 % \begin{macro}{\partrefname}
33420 % \begin{macro}{\chapterrefname}
33421 % \begin{macro}{\sectionrefname}
33422 % \begin{macro}{\appendixrefname}
33423 % More names for referencing.
33424 % \changes{v1.2}{2002/07/27}{Added \cs{partrefname}, \cs{chapterrefname}
33425 % and \cs{sectionrefname}}
33426 % \changes{v1.61803}{2008/01/30}{Added \cs{bookrefname} (mempatch v4.9+)}
33427 % \changes{v1.61803}{2008/05/17}{Added \cs{appendixrefname}}
33428 % \changes{v3.8.4}{2025/07/22}{These should not use hardcoded words, use \cs{...name} macros, plus removed tilde from them}
33429 % \begin{macrocode}
33430 \newcommand*{\bookrefname}{\bookname}
33431 \newcommand*{\partrefname}{\partname}
33432 \newcommand*{\chapterrefname}{\chaptername}
33433 \newcommand*{\sectionrefname}{\S}
33434 \newcommand*{\appendixrefname}{\appendixname}
33435
33436 % \end{macrocode}
33437 % \end{macro}
33438 % \end{macro}
33439 % \end{macro}
33440 % \end{macro}
33441 % \end{macro}
33442 %
33443 %
33444 % \subsection{Date}
33445 %
33446 % \begin{macro}{\today}
33447 % This macro uses the \TeX\ primitives \cs{month}, \cs{day} and \cs{year}
33448 % to provide the date of the \LaTeX-run.
33449 % \begin{macrocode}
33450 \newcommand{\today}{\ifcase\month\or
33451 January\or February\or March\or April\or May\or June\or
33452 July\or August\or September\or October\or November\or December\fi
33453 \space\number\day, \number\year}
33454 % \end{macrocode}
33455 % \end{macro}
33456 %
33457 % \subsection{Two column mode}
33458 %
33459 % \begin{macro}{\columnsep}
33460 % This gives the distance between two columns in two column mode.
33461 % \begin{macrocode}
33462 \setlength\columnsep{10\p@}
33463 % \end{macrocode}
33464 % \end{macro}
33465 %
33466 % \begin{macro}{\columnseprule}
33467 % This gives the width of the rule between two columns in two
33468 % column mode. We have no visible rule.
33469 % \begin{macrocode}
33470 \setlength\columnseprule{0\p@}
33471 % \end{macrocode}
33472 % \end{macro}
33473 %
33474 % \subsection{Some counters}
33475 % We set the sectional counters to zero, the \verb?tocdepth? to
33476 % one (sections and above listed), the \verb?secnumdepth? to
33477 % two (sections and above numbered), and \cs{maxsecnumdepth} to
33478 % the same.
33479 % \changes{v1.1a}{2002/04/28}{Added initialisation of \cs{maxsecnumdepth}}
33480 % \begin{macrocode}
33481 \setcounter{part}{0}
33482 \setcounter{chapter}{0}
33483 \setcounter{tocdepth}{1}
33484 \setcounter{secnumdepth}{2}
33485 \maxsecnumdepth{section}
33486
33487 % \end{macrocode}
33488 %
33489 % Set the \cs{linenumberfrequency} to zero to prohibit line numbering
33490 % and also set the font for line numbers. Can now set the final space
33491 % for boxed verbatim line numbers.
33492 % \begin{macrocode}
33493 \linenumberfrequency{0}
33494 \linenumberfont{\small\rmfamily}
33495 \settowidth{\bvnumlength}{\vlvnumfont 9999}
33496
33497 % \end{macrocode}
33498 %
33499 %
33500 % \subsection{Single or double sided printing}
33501 %
33502 %
33503 % Unless the \Lopt{twoside} wasn't specified, We do not try to make
33504 % each page of equal height.
33505 % \begin{macrocode}
33506 \if@twoside
33507 \else
33508 \raggedbottom
33509 \fi
33510 % \end{macrocode}
33511 % When the \Lopt{twocolumn} option was specified we call
33512 % \cs{twocolumn} to activate this mode. We try to make each column as
33513 % long as the others, but call \cs{sloppy} to make our life easier.
33514 % \begin{macrocode}
33515 \if@twocolumn
33516 \twocolumn
33517 \sloppy
33518 \flushbottom
33519 % \end{macrocode}
33520 % Normally we call \cs{onecolumn} to initiate typesetting in one
33521 % column.
33522 % \begin{macrocode}
33523 \else
33524 \onecolumn
33525 \fi
33526
33527 % \end{macrocode}
33528 %
33529 % \subsection{Floats}
33530 %
33531 % Here are the implementations of the figure and table environments
33532 % and their accompanying List of\ldots
33533 %
33534 % \begin{environment}{figure}
33535 % \begin{environment}{figure*}
33536 % This is the definition of the actual environment. The form with the
33537 % \verb?*? is used for double column figures. We use \cs{newfloat} to set it.
33538 % In this class figures are numbered per chapter, but we need to change
33539 % the default definition of \cs{thefigure} if a figure
33540 % is in a pre-numbered chapter.
33541 % \changes{v1.3a}{2002/11/22}{Added \cs{kill@lastcounter} after new
33542 % figure float}
33543 % \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
33544 % figure float}
33545 % \begin{macrocode}
33546 \newfloat[chapter]{figure}{lof}{\figurename}
33547 \renewcommand{\thefigure}{\thechapter.\@arabic\c@figure}
33548
33549 % \end{macrocode}
33550 % \end{environment}
33551 % \end{environment}
33552 %
33553 % \begin{macro}{\listoffigures}
33554 % \begin{macro}{\listoffigures*}
33555 % These macros request that LaTeX produces a list of figures.
33556 % The LoF heading is added to the ToC unless the starred
33557 % version is used.
33558 % \changes{v1.3}{2002/11/14}{Added \cs{kill@lastcounter} after new
33559 % list of figures}
33560 % \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
33561 % listoffigures}
33562 % \begin{macrocode}
33563 \newlistof{listoffigures}{lof}{\listfigurename}
33564 % \end{macrocode}
33565 % \end{macro}
33566 % \end{macro}
33567 %
33568 % \begin{macro}{\l@figure}
33569 % \cs{l@figure}\marg{title}\marg{page} typesets the LoF entry for
33570 % a \cs{figure} caption heading.
33571 % \changes{v1.3a}{2002/11/22}{Deleted \cs{kill@lastcounter} after new
33572 % figure listentry}
33573 % \begin{macrocode}
33574 \newlistentry[chapter]{figure}{lof}{0}
33575 \cftsetindents{figure}{0em}{2.3em}
33576
33577 % \end{macrocode}
33578 % \end{macro}
33579 %
33580 %
33581 % \begin{environment}{table}
33582 % \begin{environment}{table*}
33583 % The definition for tables is almost identical.
33584 % \changes{v1.3a}{2002/11/22}{Added \cs{kill@lastcounter} after new
33585 % table float}
33586 % \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
33587 % table float}
33588 % \begin{macrocode}
33589 \newfloat[chapter]{table}{lot}{\tablename}
33590 \renewcommand{\thetable}{\thechapter.\@arabic\c@table}
33591
33592 % \end{macrocode}
33593 % \end{environment}
33594 % \end{environment}
33595 %
33596 % \begin{macro}{\listoftables}
33597 % \begin{macro}{\listoftables*}
33598 % These macros request that LaTeX produces a list of tables.
33599 % The LoT heading is added to the ToC unless the starred
33600 % version is used.
33601 % \changes{v1.3}{2002/11/14}{Added \cs{kill@lastcounter} after new
33602 % list of tables}
33603 % \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
33604 % list of tables}
33605 % \begin{macrocode}
33606 \newlistof{listoftables}{lot}{\listtablename}
33607 % \end{macrocode}
33608 % \end{macro}
33609 % \end{macro}
33610 %
33611 % \begin{macro}{\l@table}
33612 % \cs{l@table}\marg{title}\marg{page} typesets the LoT entry for
33613 % a \cs{table} caption heading.
33614 % \changes{v1.3a}{2002/11/22}{Deleted \cs{kill@lastcounter} after new
33615 % table listentry}
33616 % \begin{macrocode}
33617 \newlistentry[chapter]{table}{lot}{0}
33618 \cftsetindents{table}{0em}{2.3em}
33619
33620 % \end{macrocode}
33621 % \end{macro}
33622 %
33623 % The \Lpack{subfigure} package defines \verb?lofdepth? and \verb?lotdepth?
33624 % counters. If is not used, then we have to define them. The \Lpack{subfig}
33625 % package replaced \Lpack{subfigure} in 2005, and this only defined
33626 % the counters if they were not previously defined. It now seems sensible
33627 % to ignore any use of the \Lpack{subfigure} package. This makes life a lot
33628 % simpler.
33629 % \changes{v1.61803}{2008/01/30}{Ignore subfig(ure) package re \cs{lofdepth}
33630 % and \cs{lotdepth}}
33631 % \begin{macrocode}
33632 %%%\AtBeginDocument{%
33633 %%% \@ifundefined{c@lofdepth}%
33634 %%% {\newcounter{lofdepth}\setcounter{lofdepth}{1}}{}
33635 %%% \@ifundefined{c@lotdepth}%
33636 %%% {\newcounter{lotdepth}\setcounter{lotdepth}{1}}{}}
33637
33638 % \end{macrocode}
33639 %
33640 % \subsection{The \Lopt{article} option}
33641 %
33642 % The \Lopt{article} option requires changes to the default chapterstyle,
33643 % and the numbering of floats, etc.
33644 %
33645 % Emanuele Vicentini (2003/07/21) suggested making \cs{maketitle} more
33646 % closely match the real article's appearance. Alan Budden commented
33647 % on 2003/12/18 that the equation counter should be continuous.
33648 % \changes{v1.0a}{2001/12/07}{Added footnote and chaptername changes to the article option}
33649 % \changes{v1.4}{2003/11/22}{Added some resets of maketitle macros to
33650 % the article option (from patch v1.7)}
33651 % \changes{v1.4}{2003/12/18}{Added equation counter to article resets}
33652 %
33653 % Victor Ivrii (October 2014) noted that adding \pstyle{headings} and
33654 % english \Lpack{babel} produce unexpected headers containing the
33655 % frase ``Chapter''.
33656 % \begin{macrocode}
33657 \ifartopt
33658 \chapterstyle{article}
33659 \counterwithout{figure}{chapter}
33660 \counterwithout{table}{chapter}
33661 \counterwithout{footnote}{chapter}
33662 \counterwithout{equation}{chapter}
33663 % \end{macrocode}
33664 % Setting \cs{chaptername} empty was added in v1.0a, with no
33665 % indication why. Because of \Lpack{babel} (and others) this is
33666 % clearly not a good idea. We will adjust \pstyle{headings} in a
33667 % different manner, but leave all the other page styles alone as using
33668 % the \Lopt{article} as the basis of design work might not be
33669 % recommended.
33670 % \changes{v3.7d}{2014/11/05}{Redone \cs{chaptername} adjustment plus
33671 % \pstyle{headings} under \Lopt{article} option}
33672 % \begin{macrocode}
33673 %\renewcommand{\chaptername}{}
33674 \if@twoside
33675 \addtopsmarks{headings}{}{%
33676 \createmark{chapter}{left}{shownumber}{}{. \ }
33677 }
33678 \else
33679 \addtopsmarks{headings}{}{%
33680 \createmark{chapter}{right}{shownumber}{}{. \ }
33681 }
33682 \fi
33683 \renewcommand{\maketitlehookb}{%
33684 \vskip -1.5\topsep\vskip -1.5\partopsep}
33685 \renewcommand{\maketitlehookc}{%
33686 \vskip -1.5\topsep\vskip -1.5\partopsep}
33687 \fi
33688
33689 % \end{macrocode}
33690 %
33691 %
33692 % \subsection{The \Lopt{ms} option}
33693 %
33694 % This should be done last as it makes various changes to the defaults.
33695 %
33696 % \begin{macro}{\msdoublespacing}
33697 % \begin{macro}{\mssinglespacing}
33698 % These do nothing unless the \Lopt{ms} option is used; then they change
33699 % the \cs{baselinestretch}.
33700 % \begin{macrocode}
33701 \newcommand{\msdoublespacing}{}
33702 \newcommand{\mssinglespacing}{}
33703 % \end{macrocode}
33704 % \end{macro}
33705 % \end{macro}
33706 %
33707 % \begin{macrocode}
33708 \ifmsdoc
33709 \renewcommand{\msdoublespacing}{%
33710 \renewcommand{\baselinestretch}{1.6}\large\normalsize}
33711 \renewcommand{\mssinglespacing}{%
33712 \renewcommand{\baselinestretch}{1.0}\large\normalsize}
33713 \renewcommand{\familydefault}{cmtt}
33714 \renewcommand{\rmdefault}{cmtt}
33715 \renewcommand{\sfdefault}{cmtt}
33716 \renewcommand{\bfdefault}{m}
33717 \renewcommand{\itdefault}{n}
33718 \renewcommand{\sldefault}{n}
33719 \renewcommand{\scdefault}{n}
33720 \renewcommand{\baselinestretch}{1.6}
33721 \@twocolumnfalse
33722 \onecolumn
33723 \sloppy
33724 \@twosidefalse
33725 \raggedbottom
33726 \pagestyle{plain}
33727 \fi
33728
33729 % \end{macrocode}
33730 %
33731 % \subsection{Emulated packages}
33732 %
33733 % Many of the `emulations' are extensions and integration of package
33734 % facilities. In some cases an `emulated' package just won't work with the
33735 % class, so I've added it here to prevent it from being loaded. In any case,
33736 % most of the packages are mine.
33737 % \changes{v1.6180339}{2008/07/23}{Added dates to emulated packages}
33738 % \changes{v1.61803398d}{2010/02/13}{Emulated tocvsec2, used the date
33739 % from the other lines, tocvsec2 provides the same macros as memoir}
33740 % \begin{macrocode}
33741 \EmulatedPackage{abstract}[2008/07/23]
33742 \EmulatedPackage{appendix}[2008/07/23]
33743 % \end{macrocode}
33744 % \changes{v3.6k}{2012/07/19}{Changed the enumated date for the
33745 % \Lpack{array} package. Apparently the only thing changed between
33746 % v2.4b (2005) and c (2008) are some copyright years.}
33747 % \changes{v3.7g}{2018/03/05}{Embedded the latest version of the
33748 % \Lpack{array} package}
33749 % \changes{v3.7h}{2018/09/06}{\Lpack{array} no longer embedded,
33750 % required instead}
33751 % \changes{v3.8}{2023/07/28}{booktabs no longer emulated}
33752 % \begin{macrocode}
33753 % \EmulatedPackage{array}[2016/10/06]
33754 % \EmulatedPackage{booktabs}[2016/05/16]
33755 \EmulatedPackage{ccaption}[2008/07/23]
33756 \EmulatedPackage{changepage}[2008/07/23]
33757 \EmulatedPackage{chngcntr}[2008/07/23]
33758 \EmulatedPackage{chngpage}[2008/07/23]
33759 \EmulatedPackage{crop}
33760 % \end{macrocode}
33761 % \changes{v3.7h}{2018/09/06}{\Lpack{dcolumn} is no longer embedded,
33762 % emulation removed. We require it instead}
33763 % \begin{macrocode}
33764 % \EmulatedPackage{dcolumn}[2008/07/23]
33765 % \end{macrocode}
33766 % \changes{v3.7g}{2018/03/06}{Adjusted the date for \Lpack{delarray},
33767 % the code is the same}
33768 % \changes{v3.7h}{2018/09/06}{\Lpack{delarray} is no longer embedded,
33769 % emulation removed. We require it instead}
33770 % \begin{macrocode}
33771 % \EmulatedPackage{delarray}[2014/10/28]
33772 \EmulatedPackage{enumerate}[2008/07/23]
33773 \EmulatedPackage{epigraph}[2008/07/23]
33774 %%%%%\EmulatedPackage{framed}[2008/07/23]
33775 \EmulatedPackage{ifmtarg}[2008/07/23]
33776 % \end{macrocode}
33777 % \changes{v3.7g}{2018/03/08}{Removed if\meta{engine} emulation}
33778 % \begin{macrocode}
33779 %\ifm@mifetex\EmulatedPackage{ifetex}[2008/07/23]\fi
33780 %\ifm@mifluatex\EmulatedPackage{ifluatex}[2008/07/23]\fi
33781 %\ifm@mifpdf\EmulatedPackage{ifpdf}[2008/07/23]\fi
33782 %\ifm@mifxetex\EmulatedPackage{ifxetex}[2008/07/23]\fi
33783 \EmulatedPackage{index}[2008/07/23]
33784 \EmulatedPackage{makeidx}[2008/07/23]
33785 \EmulatedPackage{moreverb}[2008/07/23]
33786 % \end{macrocode}
33787 % \changes{v3.8.2a}{2024/01/29}{shortvrb is no longer emulated. No need to release as it is loaded before the emulation}
33788 % \changes{v3.7o}{2021/03/22}{removed mparhack emulation, as we don't
33789 % emulate all of it, especially not the fix for \cs{if@firstcolumn},
33790 % instead load it if twocolumn }
33791 % \changes{v3.8.3}{2025/03/04}{Removed mparhack loading. There are packages not compatible with it, and we should not autoload it when we don't know if the user needs it.}
33792 % \begin{macrocode}
33793 % \if@twocolumn
33794 % \RequirePackage{mparhack}
33795 % \fi
33796 %\EmulatedPackage{mparhack}[2008/07/23]
33797 \EmulatedPackage{needspace}[2008/07/23]
33798 \EmulatedPackage{newfile}[2008/07/23]
33799 \EmulatedPackage{nextpage}[2008/07/23]
33800 \EmulatedPackage{pagenote}[2008/07/23]
33801 \EmulatedPackage{parskip}[2008/07/23]
33802 \EmulatedPackage{patchcmd}[2008/07/23]
33803 \EmulatedPackage{setspace}[2008/07/23]
33804 % \end{macrocode}
33805 %
33806 % \changes{v3.8.3}{2025/03/05}{Forgot to remove shortvrb emulation in 3.8.2}
33807 % \begin{macrocode}
33808 % \EmulatedPackage{shortvrb}[2008/07/23]
33809 \EmulatedPackage{showidx}[2008/07/23]
33810 % \end{macrocode}
33811 % \changes{v3.7g}{2018/03/02}{Updated the embedded version of \Lpack{tabularx} to v2.11 2016/02/03}
33812 % \changes{v3.7h}{2018/09/08}{\Lpack{tabularx} is no longer emulated,
33813 % but a required package}
33814 % \changes{v3.8.2a}{2024/01/29}{shortvrb is no longer emulated. No need to release as it is loaded before the emulation}
33815 % \begin{macrocode}
33816 % \EmulatedPackage{tabularx}[2016/02/03]
33817 \EmulatedPackage{titleref}[2008/07/23]
33818 \EmulatedPackage{titling}[2008/07/23]
33819 \EmulatedPackage{tocbibind}[2008/07/23]
33820 \EmulatedPackage{tocloft}[2008/07/23]
33821 \EmulatedPackage{tocvsec2}[2008/07/23]
33822 % \EmulatedPackage{verbatim}[2008/07/23]
33823 \EmulatedPackage{verse}[2008/07/23]
33824
33825 % \end{macrocode}
33826 %
33827 % \subsection{Interaction with the \Lpack{caption} package}
33828 %
33829 % As of 2020, whenever the \Lpack{caption} package is loaded with the
33830 % memoir class, it will map relevant memoir captioning macros onto the
33831 % corresponding features provided by \Lpack{caption}. As this is now
33832 % done automatically, we have removed the code that reset \cs{caption}
33833 % to something more friendly to \Lpack{caption} in earler versions of
33834 % the class.
33835 %
33836 % \changes{v3.7o}{2021/03/15}{removed code to reset for the caption package}
33837 %
33838 % \subsection{Interaction with the \Lpack{float} package}
33839 %
33840 % The \Lpack{float} package also defines \cs{newfloat}, so kill memoir's
33841 % version when the \Lpack{float} package gets used.
33842 % \changes{v1.61803}{2008/01/30}{Killed \cs{newfloat} when float package is
33843 % used (mempatch v4.9)}
33844 % \begin{macrocode}
33845 \AtBeginPackage{float}{\let\newfloat\relax}
33846
33847 % \end{macrocode}
33848 %
33849 %
33850 % \subsection{Interaction with the \Lpack{hyperref} package}
33851 %
33852 % Ulrike Fischer has ask that the \Lpack{memhfixc} autoload is moved
33853 % from \Lpack{hyperref} to \Lpack{memoir}.
33854 % \changes{v3.7q}{2022/02/20}{Added autoloading}
33855 % \begin{macrocode}
33856 \AtEndPackage{hyperref}{\RequirePackage{memhfixc}}
33857 % \end{macrocode}
33858 %
33859 % \subsection{Package that should not be used with memoir}
33860 %
33861 % Some packages should not be used with the class. Primarily because
33862 % we already provide a more well integrated solution, or if the
33863 % package break class functionalily. We may add warnings for when
33864 % users load certain of these package.
33865 %
33866 % \changes{v3.8.3}{2024/02/15}{Added warning about fancyhdr}
33867 % \begin{macrocode}
33868 \AtBeginPackage{fancyhdr}{
33869 \@memwarn{The fancyhdr package is not
33870 recommended with memoir.\MessageBreak
33871 We have our own well integrated interface
33872 to handle\MessageBreak headers and footers. See the manual
33873 section 7.3\MessageBreak onwards for details.}
33874 }
33875 % \end{macrocode}
33876 % \changes{v3.8.3}{2024/03/04}{Added warning about titlesec}
33877 % \begin{macrocode}
33878 \AtBeginPackage{titlesec}{
33879 \@memwarn{The titlesec package is not
33880 recommended with memoir.\MessageBreak
33881 With it we loose some of the features provides by the\MessageBreak
33882 class. We provide our own interface to adjust how \MessageBreak
33883 sections and chapters should look like.\MessageBreak
33884 See the manual sections 6.4 through 6.6 for details.
33885 }
33886 }
33887 % \end{macrocode}
33888 % \changes{v3.8.3}{2024/03/04}{Added warning about titleps}
33889 % \begin{macrocode}
33890 \AtBeginPackage{titleps}{
33891 \@memwarn{The titleps package is not
33892 recommended with memoir.\MessageBreak
33893 It cannot really work properly without the titlesec\MessageBreak
33894 package, which is already incomparible with memoir.\MessageBreak
33895 We have our own well integrated interface to \MessageBreak
33896 handle headers and footers.\MessageBreak
33897 See the manual section 7.3 onwards for details.
33898 }
33899 }
33900 % \end{macrocode}
33901 % \changes{v3.8.3}{2024/03/04}{Added warning about sectsty, probably
33902 % now needed as sectsty is unusable in modern LaTeX}
33903 % \begin{macrocode}
33904 \AtBeginPackage{sectsty}{
33905 \@memwarn{%
33906 The sectsty package is super old (has not been updated\MessageBreak
33907 since 2002) and is unlikely to be compatible with modern\MessageBreak
33908 LaTeX. We provide our own interface to adjust how \MessageBreak
33909 sections and chapters should look like.\MessageBreak
33910 See the manual sections 6.4 through 6.6 for details.
33911 }
33912 }
33913 % \end{macrocode}
33914 %
33915 % \changes{v3.8.4}{2025/09/17}{Added warning about subfigure and subfig}
33916 % \begin{macrocode}
33917 \AtBeginPackage{subfigure}{
33918 \@memwarn{%
33919 The subfigure package is marked obsolete,\MessageBreak
33920 consider using the subcaption package instead.
33921 }
33922 }
33923 \AtBeginPackage{subfig}{
33924 \@memwarn{%
33925 The subfig package hasn't been updated since 2005.\MessageBreak
33926 Consider using the subcaption package instead.
33927 }
33928 }
33929 % \end{macrocode}
33930 %
33931 % \subsection{Default page style}
33932 % We use the page style \pstyle{headings} by
33933 % default and arabic page numbering. But if the \verb?article?
33934 % class option is in effect, we will use the \pstyle{plain} style
33935 % which is the default in the \verb?article? class.
33936 % \changes{v3.6d}{2010/05/13}{When emulating the article class the
33937 % plain page style should used instead of headings}
33938 % \changes{v3.7i}{2019/01/07}{Moved here because
33939 % \cs{newlistof}{...}{X}{...} also defines \cs{Xmark}, but using
33940 % \cs{markboth}, and thus if \Lopt{oneside} is active \cs{lofmark}
33941 % will still be using \cs{mathboth} and not \cs{markright} that the
33942 % \pstyle{headings} style dictates}
33943 % \begin{macrocode}
33944 \ifartopt
33945 \pagestyle{plain}
33946 \else
33947 \pagestyle{headings}
33948 \fi
33949 \pagenumbering{arabic}
33950
33951 % \end{macrocode}
33952
33953
33954
33955
33956
33957
33958 % ^^A\subsection{Patch file}
33959 % ^^A
33960 % ^^A At the suggestion of Danie Els, Dan Leucking
33961 % ^^A and others, input a patch file, if one exists,
33962 % ^^A as the final act. (This is preferable to my series of \file{memfixa.sty},
33963 % ^^A \file{memfixb.sty} packages, and so on, for each release of the class.)
33964 % ^^A \changes{v1.3}{2002/11/14}{Added input of mempatch.sty}
33965 % ^^A \changes{v1.6180339c}{2008/12/26}{Added the two missing arguments when inputting
33966 % ^^A mempatch.sty (courtesy of Wilhelm Muller)}
33967 % ^^A \changes{v1.61803398}{2009/07/27}{PW: changed call to mempatch, which I think
33968 % ^^A restores Lars' v1.6180339h change}
33969 % ^^A \changes{v3.7g}{2018/03/08}{mempatch have been empty for almost
33970 % ^^A 10years, we will no longer load it.}
33971 % ^^A \begin{macrocode}
33972 % ^^A\IfFileExists{mempatch.sty}{%
33973 % ^^A \RequirePackage{mempatch}}{}
33974 % ^^A
33975 % ^^A \end{macrocode}
33976 % ^^A
33977 % The end of the class definitions.
33978 % \begin{macrocode}
33979 %</class>
33980 % \end{macrocode}
33981 %
33982 % \section{Glossary Makeindex style file}
33983 %
33984 % Here is the basic style (configuration) file for Makeindex
33985 % for use with the default glossary setup.
33986 % \changes{v1.618}{2005/09/25}{Added basic.gst file}
33987 %
33988 % \begin{macrocode}
33989 %<*gst>
33990 %%%%% basic.gst basic makeindex glossary configuration file for memoir
33991 %%%%% Output style parameters
33992 preamble "\\begin{theglossary}"
33993 postamble "\n\\end{theglossary}\n"
33994 group_skip "\n\\glossaryspace\n"
33995 item_0 "\n\\glossitem"
33996 delim_0 "{\\memglonum{"
33997 encap_suffix "}}}"
33998 %%% Input style parameters
33999 keyword "\\glossaryentry"
34000
34001 %</gst>
34002 % \end{macrocode}
34003 %
34004 % The end of the configuration file code
34005 %
34006 % \bibliographystyle{alpha}
34007 % \begingroup
34008 % \raggedright
34009 % \begin{thebibliography}{GMSN94A}
34010 %
34011 %
34012 % \bibitem[ABH90]{bk:Impatient}
34013 % Paul W.~Abrahams, Karl Berry and Kathryn A.~Hargreaves.
34014 % \newblock \emph{TeX{} for the Impatient}.
34015 % \newblock
34016 % Addison-Wesley, Reading, Massachusetts, 1990.
34017 % \newblock (Available from CTAN in \texttt{info/impatient})
34018 %
34019 % \bibitem[Ars01a]{TITLEREF}
34020 % Donald Arseneau.
34021 % \newblock \emph{\Lpack{Titleref} package (version 3.1)}.
34022 % \newblock April 2001.
34023 % \newblock (Available from CTN as
34024 % \texttt{macros/latex/contrib/misc/titleref.sty})
34025 %
34026 % \bibitem[Ars01b]{CHAPTERBIB}
34027 % Donald Arseneau.
34028 % \newblock \emph{\Lpack{Chapterbib} package (version 1.9)}.
34029 % \newblock September 2001.
34030 % \newblock (Available from CTN as
34031 % \texttt{macros/latex/contrib/misc/chapterbib.sty})
34032 %
34033 % \bibitem[Ars03]{FRAMED}
34034 % Donald Arseneau.
34035 % \newblock \emph{\Lpack{Framed} package (version 0.8a)}.
34036 % \newblock July 2003.
34037 % \newblock (Available from CTAN as
34038 % \texttt{macros/latex/contrib/misc/framed.sty})
34039 %
34040 % \bibitem[Ars05]{PLACEINS}
34041 % Donald Arseneau.
34042 % \newblock \emph{\Lpack{Placeins} package (version 2.2)}.
34043 % \newblock May 2005.
34044 % \newblock (Available from CTAN as
34045 % \texttt{macros/latex/contrib/placeins/placeins.sty})
34046 %
34047 %
34048 % \bibitem[ArWi00]{IFMTARG}
34049 % Donald Arseneau and Peter Wilson.
34050 % \newblock \emph{The ifmtarg package}.
34051 % \newblock March, 2000.
34052 % \newblock (Available from CTAN in
34053 % \texttt{/macros/latex/contrib/misc})
34054 %
34055 % \bibitem[Source2e]{SOURCE2E}
34056 % Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank Mittelbach,
34057 % Chris Rowley and Rainer Schöpf (maintained by the \LaTeX\ Project).
34058 % \newblock \emph{The \LaTeX2e\ Sources}
34059 % \newblock November 2023.
34060 % \newblock (Available from CTAN as
34061 % \texttt{/macros/latex/base/source2e.pdf})
34062 %
34063 %
34064 % \bibitem[Car94]{DELARRAY}
34065 % David Carlisle.
34066 % \newblock \emph{The \Lpack{delarray} package}.
34067 % \newblock March 1994.
34068 % \newblock (Available from CTAN in
34069 % \texttt{/macros/latex/required/tools})
34070 %
34071 %
34072 % \bibitem[Car98a]{ENUMERATE}
34073 % David Carlisle.
34074 % \newblock \emph{The enumerate package}.
34075 % \newblock August, 1998.
34076 % \newblock (Available from CTAN in
34077 % \texttt{/macros/latex/required/tools})
34078 %
34079 % \bibitem[Car98b]{REMRESET}
34080 % David Carlisle.
34081 % \newblock \emph{The remreset package}.
34082 % \newblock August, 1998.
34083 % \newblock (Available from CTAN in
34084 % \texttt{/macros/latex/contrib/carlisle})
34085 %
34086 % \bibitem[Car99]{TABULARX}
34087 % David Carlisle.
34088 % \newblock \emph{The \Lpack{tabularx} package}.
34089 % \newblock February 2016.
34090 % \newblock (Available from CTAN in
34091 % \texttt{/macros/latex/required/tools})
34092 %
34093 % \bibitem[Car01]{DCOLUMN}
34094 % David Carlisle.
34095 % \newblock \emph{The \Lpack{dcolumn} package}.
34096 % \newblock May, 2001.
34097 % \newblock (Available from CTAN in
34098 % \texttt{/macros/latex/required/tools})
34099 %
34100 % \bibitem[Car19]{TEXTCASE}
34101 % David Carlisle.
34102 % \newblock \emph{The \Lpack{textcase} package}.
34103 % \newblock September, 2019.
34104 % \newblock (Available from CTAN in
34105 % \texttt{/macros/latex/contrib/textcase})
34106 %
34107 % \bibitem[Coc02]{SUBFIGURE}
34108 % Steven Douglas Cochran.
34109 % \newblock \emph{The subfigure package}.
34110 % \newblock March, 2002.
34111 % \newblock (Available from CTAN in
34112 % \texttt{/macros/latex/contrib/subfigure})
34113 %
34114 % \bibitem[Dal99]{NATBIB}
34115 % Patrick W. Daly.
34116 % \newblock \emph{Natural Sciences Citations and References}.
34117 % \newblock May, 1999.
34118 % \newblock (Available from CTAN in
34119 % \texttt{/macros/latex/contrib/natbib})
34120 %
34121 % \bibitem[Dow00]{PATCHCMD}
34122 % Michael J. Downes
34123 % \newblock \emph{The patchcmd package}.
34124 % \newblock July 2000.
34125 % \newblock (Available from CTAN in
34126 % \texttt{/macros/latex/contrib/patchcmd})
34127 %
34128 % \bibitem[LTX3]{LTX3}
34129 % The \LaTeX{} Project.
34130 % \newblock \emph{The \LaTeX3 sources}
34131 % \newblock June, 2023.
34132 % \newblock (Available from CTAN in \texttt{/macros/latex/contrib/l3kernel})
34133 %
34134 % \bibitem[Fai98]{MOREVERB}
34135 % Robin Fairbairns.
34136 % \newblock \emph{The moreverb package}.
34137 % \newblock December, 1998.
34138 % \newblock (Available from CTAN in
34139 % \texttt{/macros/latex/contrib/moreverb})
34140 %
34141 % \bibitem[Fai03]{FOOTMISC}
34142 % Robin Fairbairns.
34143 % \newblock \emph{\Lpack{footmisc} --- a portmanteau package for
34144 % customising footnotes in LaTeX}.
34145 % \newblock February 2003.
34146 % \newblock (Available from CTAN in
34147 % \texttt{macros/latex/contrib/footmisc})
34148 %
34149 %
34150 % \bibitem[Fea03]{BOOKTABS}
34151 % Simon Fear.
34152 % \newblock \emph{Publication quality tables in \LaTeX}.
34153 % \newblock March, 2003.
34154 % \newblock (Available from CTAN in
34155 % \texttt{macros/latex/contrib/booktabs})
34156 %
34157 % \bibitem[Fra00]{CROP}
34158 % Melchior Franz.
34159 % \newblock \emph{The crop package}.
34160 % \newblock February, 2000.
34161 % \newblock (Available from CTAN in
34162 % \texttt{/macros/latex/contrib/crop})
34163 %
34164 %
34165 % \bibitem[GMS94]{GOOSSENS94}
34166 % Michel Goossens, Frank Mittelbach, and Alexander Samarin.
34167 % \newblock \emph{The LaTeX Companion}.
34168 % \newblock Addison-Wesley Publishing Company, 1994.
34169 %
34170 %
34171 %
34172 % \bibitem[Knu84]{bk:knuth}
34173 % Donald E. Knuth.
34174 % \newblock \emph{The \TeX{}book}.
34175 % \newblock
34176 % Addison-Wesley, Reading, Massachusetts, 1984.
34177 %
34178 %
34179 % \bibitem[KWG]{TUFTE}
34180 % Bil Kleb, Bill Wood, and Kevin Godby.
34181 % \newblock \emph{Tufte LaTeX}.
34182 % \newblock December 2009.
34183 % \newblock (Available from CTAN in \texttt{macros/latex/contrib/tufte-latex/})
34184 %
34185 % \bibitem[Lam94]{bk:lamport}
34186 % Leslie Lamport.
34187 % \newblock \emph{\LaTeX\ --- A Document Preparation System}.
34188 % \newblock
34189 % Addison-Wesley, Reading, Massachusetts, 1994.
34190 %
34191 % \bibitem[LMB99]{CLASSES}
34192 % Leslie Lamport, Frank Mittelbach and Johannes Braams.
34193 % \newblock \emph{Standard Document Classes for LaTeX version 2e}.
34194 % \newblock September, 1999.
34195 % \newblock (Available from CTAN as
34196 % \texttt{/macros/latex/base/classes.dtx})
34197 %
34198 % \bibitem[LPT19]{IFTEX}
34199 % The \LaTeX{} Project Team.
34200 % \newblock \emph{The iftex package}.
34201 % \newblock November, 2019.
34202 % \newblock (Available from CTAN in \texttt{/macros/latex/contrib/iftex})
34203 %
34204 % \bibitem[MC98]{ARRAY}
34205 % Frank Mittelbach and David Carlisle.
34206 % \newblock \emph{A new implementation of LaTeX's tabular and array
34207 % environment}
34208 % \newblock April 2017.
34209 % \newblock (Available from CTAN in
34210 % \texttt{/macros/latex/required/tools})
34211 %
34212 % \bibitem[Mit2020a]{LTFILEHOOK}
34213 % Frank Mittelbach
34214 % \newblock \emph{The ltfilehook package}
34215 % \newblock July 2020.
34216 %
34217 % \bibitem[Mit2023a]{LTHOOKS}
34218 % Frank Mittelbach
34219 % \newblock \emph{\LaTeX's hook management}
34220 % \newblock June 2023.
34221 %
34222 % \bibitem[Mit2020c]{LTSHIPOUT}
34223 % Frank Mittelbach
34224 % \newblock \emph{The ltshipout package}
34225 % \newblock July 2020.
34226 %
34227 % \bibitem[Mit2023b]{SHORTVRB}
34228 % Frank Mittelbach
34229 % \newblock \emph{The doc and shortvrb Packages}
34230 % \newblock November 2023.
34231 %
34232 % \bibitem[Oos96]{FANCYHDR}
34233 % Piet van Oostrum.
34234 % \newblock \emph{Page layout in LaTeX}.
34235 % \newblock June, 1996.
34236 % \newblock (Available from CTAN in
34237 % \texttt{/macros/latex/contrib/fancyhdr})
34238 %
34239 %
34240 % \bibitem[Rah23]{NAMEREF}
34241 % Sebastian Rahtz, Heiko Oberdiek, The \LaTeX{} project.
34242 % \newblock \emph{Section name references in LaTeX}.
34243 % \newblock 2023.
34244 % \newblock (Available from CTAN in
34245 % \texttt{/macros/latex/contrib/hyperref})
34246 %
34247 % \bibitem[Rah02]{HYPERREF}
34248 % Sebastian Rahtz.
34249 % \newblock \emph{Hypertext marks in LaTeX}.
34250 % \newblock March 2002.
34251 % \newblock (Available from CTAN in
34252 % \texttt{/macros/latex/contrib/hyperref})
34253 %
34254 %
34255 % \bibitem[Sch98]{EVERYSHI}
34256 % Martin Schr\"{o}der.
34257 % \newblock \emph{The everyshi package}.
34258 % \newblock August, 1998.
34259 % \newblock (Available from CTAN in
34260 % \texttt{/macros/latex/contrib/ms})
34261 %
34262 % \bibitem[SRR01]{VERBATIM}
34263 % Rainer Sch\"{o}pf, Bernd Raichle and Chris Rowley.
34264 % \newblock \emph{A new implementation of LaTeX's verbatim and verbatim*
34265 % environments}.
34266 % \newblock March, 2001.
34267 % \newblock (Available from CTAN in
34268 % \texttt{/macros/latex/required/tools})
34269 %
34270 % \bibitem[Wil99]{TOCVSEC2}
34271 % Peter Wilson.
34272 % \newblock \emph{The tocvsec2 package}.
34273 % \newblock January, 1999.
34274 % \newblock (Available from CTAN in
34275 % \texttt{/macros/latex/contrib/tocvsec2})
34276 %
34277 % \bibitem[Wil00a]{EPIGRAPH}
34278 % Peter Wilson.
34279 % \newblock \emph{The epigraph package}.
34280 % \newblock February, 2000.
34281 % \newblock (Available from CTAN in
34282 % \texttt{/macros/latex/contrib/epigraph})
34283 %
34284 % \bibitem[Wil00b]{ISOCLASS}
34285 % Peter Wilson.
34286 % \newblock \emph{LaTeX files for typesetting ISO standards}.
34287 % \newblock February, 2000.
34288 % \newblock (Available from CTAN in
34289 % \texttt{/macros/latex/contrib/isostds/iso})
34290 %
34291 % \bibitem[Wil00c]{NEXTPAGE}
34292 % Peter Wilson.
34293 % \newblock \emph{The nextpage package}.
34294 % \newblock February, 2000.
34295 % \newblock (Available from CTAN in
34296 % \texttt{/macros/latex/contrib/misc})
34297 %
34298 % \bibitem[Wil00d]{NEEDSPACE}
34299 % Peter Wilson.
34300 % \newblock \emph{The needspace package}.
34301 % \newblock March, 2000.
34302 % \newblock (Available from CTAN in
34303 % \texttt{/macros/latex/contrib/misc})
34304 %
34305 % \bibitem[Wil01a]{ABSTRACT}
34306 % Peter Wilson.
34307 % \newblock \emph{The abstract package}.
34308 % \newblock February, 2001.
34309 % \newblock (Available from CTAN in
34310 % \texttt{/macros/latex/contrib/abstract})
34311 %
34312 % \bibitem[Wil01b]{CHNGPAGE}
34313 % Peter Wilson.
34314 % \newblock \emph{The chngpage package}.
34315 % \newblock February, 2001.
34316 % \newblock (Available from CTAN in
34317 % \texttt{/macros/latex/contrib/misc})
34318 %
34319 % \bibitem[Wil01c]{APPENDIX}
34320 % Peter Wilson.
34321 % \newblock \emph{The appendix package}.
34322 % \newblock March, 2001.
34323 % \newblock (Available from CTAN in
34324 % \texttt{/macros/latex/contrib/appendix})
34325 %
34326 % \bibitem[Wil01d]{CCAPTION}
34327 % Peter Wilson.
34328 % \newblock \emph{The ccaption package}.
34329 % \newblock March, 2001.
34330 % \newblock (Available from CTAN in
34331 % \texttt{/macros/latex/contrib/ccaption})
34332 %
34333 % \bibitem[Wil01e]{CHNGCNTR}
34334 % Peter Wilson.
34335 % \newblock \emph{The chngcntr package}.
34336 % \newblock March, 2001.
34337 % \newblock (Available from CTAN in
34338 % \texttt{/macros/latex/contrib/misc})
34339 %
34340 % \bibitem[Wil01f]{HANGING}
34341 % Peter Wilson.
34342 % \newblock \emph{The hanging package}.
34343 % \newblock March, 2001.
34344 % \newblock (Available from CTAN in
34345 % \texttt{/macros/latex/contrib/hanging})
34346 %
34347 % \bibitem[Wil01g]{TITLING}
34348 % Peter Wilson.
34349 % \newblock \emph{The titling package}.
34350 % \newblock March, 2001.
34351 % \newblock (Available from CTAN in
34352 % \texttt{/macros/latex/contrib/titling})
34353 %
34354 % \bibitem[Wil01h]{TOCBIBIND}
34355 % Peter Wilson.
34356 % \newblock \emph{The tocbibind package}.
34357 % \newblock April, 2001.
34358 % \newblock (Available from CTAN in
34359 % \texttt{/macros/latex/contrib/tocbibind})
34360 %
34361 % \bibitem[Wil01i]{TOCLOFT}
34362 % Peter Wilson.
34363 % \newblock \emph{The tocloft package}.
34364 % \newblock April, 2001.
34365 % \newblock (Available from CTAN in
34366 % \texttt{/macros/latex/contrib/tocloft})
34367 %
34368 % \bibitem[Wil01j]{VERSE}
34369 % Peter Wilson.
34370 % \newblock \emph{Typesetting simple verse with LaTeX}.
34371 % \newblock August, 2001.
34372 % \newblock (Available from CTAN in
34373 % \texttt{/macros/latex/contrib/verse})
34374 %
34375 %
34376 % \bibitem[Wil03]{LEDMAC}
34377 % Peter Wilson.
34378 % \newblock \emph{\Lpack{ledmac}: A presumptuous attempt to port EDMAC and
34379 % TABMAC to LaTeX}.
34380 % \newblock August 2003.
34381 % \newblock (Available from CTAN in
34382 % \texttt{macros/latex/contrib/ledmac})
34383 %
34384 % \bibitem[Wil07]{GLISTER07}
34385 % Peter Wilson.
34386 % \newblock `Glisterings' \emph{TUGboat}, 28(2):229--232,
34387 % \newblock 2007.
34388 %
34389 % \bibitem[Wil08]{GLISTER08}
34390 % Peter Wilson.
34391 % \newblock `Glisterings' \emph{TUGboat}, 29(2):324--327,
34392 % \newblock 2008.
34393 %
34394 %
34395 %
34396 %
34397 %
34398 % \end{thebibliography}
34399 % \endgroup
34400 %
34401 %
34402 %
34403 % ^^A\Finale
34404 %
34405 \endinput
34406
34407 %% \CharacterTable
34408 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
34409 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
34410 %% Digits \0\1\2\3\4\5\6\7\8\9
34411 %% Exclamation \! Double quote \" Hash (number) \#
34412 %% Dollar \$ Percent \% Ampersand \&
34413 %% Acute accent \' Left paren \( Right paren \)
34414 %% Asterisk \* Plus \+ Comma \,
34415 %% Minus \- Point \. Solidus \/
34416 %% Colon \: Semicolon \; Less than \<
34417 %% Equals \= Greater than \> Question mark \?
34418 %% Commercial at \@ Left bracket \[ Backslash \\
34419 %% Right bracket \] Circumflex \^ Underscore \_
34420 %% Grave accent \` Left brace \{ Vertical bar \|
34421 %% Right brace \} Tilde \~}
34422 %%
34423