Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % mempatch.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 -- 2013 Peter R. Wilson
8 % Copyright 2013-- Lars Madsen
9 %
10 % This work may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either
12 % version 1.3c of this license or (at your option) any
13 % later version.
14 % The latest version of the license is in
15 % http://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions of
17 % LaTeX version 2008/05/04 or later.
18 %
19 % This work has the LPPL maintenance status "maintained".
20 %
21 % This work consists of the files listed in the README file.
22 %
23 %
24 % \fi
25 % \CheckSum{559}
26 %
27 % \def\dtxfile{\texttt{mempatch.dtx}}
28 % \def\fileversion{v1.0} \def\filedate{2003/10/04}
29 % \def\fileversion{v1.1} \def\filedate{2003/10/07}
30 % \def\fileversion{v1.2} \def\filedate{2003/11/16}
31 % \def\fileversion{v2.0a} \def\filedate{2004/02/19}
32 % \def\fileversion{v2.1} \def\filedate{2004/03/01}
33 % \def\fileversion{v2.3} \def\filedate{2004/03/28}
34 % \def\fileversion{v2.4} \def\filedate{2004/04/26}
35 % \def\fileversion{v2.5} \def\filedate{2004/04/27}
36 % \def\fileversion{v2.6} \def\filedate{2004/04/30}
37 % \def\fileversion{v2.7} \def\filedate{2004/05/10}
38 % \def\fileversion{v2.8} \def\filedate{2004/05/13}
39 % \def\fileversion{v3.0} \def\filedate{2004/12/14}
40 % \def\fileversion{v3.1} \def\filedate{2004/12/19}
41 % \def\fileversion{v3.2} \def\filedate{2005/01/01}
42 % \def\fileversion{v3.3} \def\filedate{2005/01/17}
43 % \def\fileversion{v3.4} \def\filedate{2005/01/18}
44 % \def\fileversion{v3.5} \def\filedate{2005/02/01}
45 % \def\fileversion{v3.6} \def\filedate{2005/02/07}
46 % \def\fileversion{v3.7} \def\filedate{2005/02/26}
47 % \def\fileversion{v3.8} \def\filedate{2005/03/06}
48 % \def\fileversion{v3.9} \def\filedate{2005/03/23}
49 % \def\fileversion{v3.10} \def\filedate{2005/05/16}
50 % \def\fileversion{v3.11} \def\filedate{2005/05/23}
51 % \def\fileversion{v3.12} \def\filedate{2005/06/06}
52 % \def\fileversion{v4.1} \def\filedate{2005/10/06}
53 % \def\fileversion{v4.1h} \def\filedate{2005/11/15}
54 % \def\fileversion{v4.2} \def\filedate{2005/11/21}
55 % \def\fileversion{v4.3} \def\filedate{2005/12/13}
56 % \def\fileversion{v4.4} \def\filedate{2006/01/21}
57 % \def\fileversion{v4.4a} \def\filedate{2006/01/23}
58 % \def\fileversion{v4.5} \def\filedate{2006/08/08}
59 % \def\fileversion{v4.6} \def\filedate{2006/12/11}
60 % \def\fileversion{v4.7} \def\filedate{2006/12/23}
61 % \def\fileversion{v4.8} \def\filedate{2007/01/22}
62 % \def\fileversion{v4.9} \def\filedate{2007/12/14}
63 % \def\fileversion{v4.9a} \def\filedate{2007/12/24}
64 % \def\fileversion{v4.9a+} \def\filedate{2007/12/31}
65 % \def\fileversion{v5.0} \def\filedate{2008/05/26}
66 % \def\fileversion{v5.0} \def\filedate{2008/06/02}
67 % \def\fileversion{v5.1} \def\filedate{2008/07/11}
68 % \def\fileversion{v6.0} \def\filedate{2008/07/23}
69 % \def\fileversion{v6.0a} \def\filedate{2008/08/23}
70 % \def\fileversion{v6.0b} \def\filedate{2009/01/18}
71 % \def\fileversion{v6.0c} \def\filedate{2009/02/06}
72 % \def\fileversion{v6.0d} \def\filedate{2009/07/12}
73 % \def\fileversion{v6.0e} \def\filedate{2009/07/21}
74 % \def\fileversion{v6.0f} \def\filedate{2009/07/24}
75 % \def\fileversion{v6.0g} \def\filedate{2010/04/19}
76 %
77 % \title{The LaTeX \Lpack{memoir} class for configurable book
78 % typesetting: Code patches\thanks{This
79 % file (\dtxfile) has version number \fileversion, last revised
80 % \filedate.}}
81 %
82 % \author{%
83 % Peter Wilson
84 % ^^A\thanks{\texttt{herries dot press at earthlink dot net}}\\
85 % \\ Maintained by Lars Madsen\thanks{daleif at math dot au dot dk} \\
86 % The Herries Press
87 % }
88 % \date{\filedate}
89 % \maketitle
90 %
91 % ^^A \MakeShortVerb{\=}
92 %
93 % \begin{abstract}
94 % The \Lpack{memoir} class is designed for typesetting
95 % general books such as novels, biographies, histories,
96 % and so on, although as it supports all the functionality of the
97 % standard \Lpack{book} class it can also be used for technical writing.
98 % It provides more functions than the standard class as well as
99 % presenting a more friendly interface for the book designer.
100 % It can also simulate the typesetting style of the standard \Lpack{article}
101 % class.
102 %
103 % Because of its newness not all packages work well with \Lpack{memoir}.
104 % Also, as more users beat on it, subtle flaws are discovered in \Lpack{memoir}
105 % itself. Patching code is supplied to resolve known problems.
106 %
107 % Code is also provided for new functionality that will later be
108 % folded into the class code.
109 % \end{abstract}
110 %
111 % \tableofcontents
112 % \listoftables
113 %
114 % \StopEventually{}
115 %
116 %
117 %
118 % \section{Introduction}
119 %
120 % This document provides the commented source for packages that patch
121 % the LaTeX \Lpack{memoir} class~\cite{MEMOIR}.
122 % This class is designed for typesetting
123 % general books such as novels, biographies, histories,
124 % and so on. It has all the functionality of the standard \Lpack{book}
125 % class and, as well as providing some extra functions, also provides
126 % a more friendly interface for the document designer. As it can encompass
127 % everything that the \Lpack{book} class provides it may also be used
128 % for technical writing.
129 %
130 %
131 % Section~\ref{sec:docstrip} describes some
132 % administrative elements and code for general use later in the
133 % specification.
134 % The macros forming the package files are defined in section~\ref{sec:hyper}
135 % and in section~\ref{sec:class} onwards.
136 %
137 % This manual is typeset according to the conventions of the
138 % \LaTeX{} \textsc{docstrip} utility which enables the automatic
139 % extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
140 %
141 %
142 % \section{A driver for this document} \label{sec:docstrip}
143 %
144 % The next series of code contains the documentation driver file for
145 % \LaTeX, i.e., the file that will produce the documentation you are
146 % currently reading. This will be extracted from this file by the
147 % \textsc{docstrip} program.
148 %
149 % \begin{macrocode}
150 %<*driver>
151 \documentclass[twoside]{ltxdoc}
152 \usepackage{url}
153 % \end{macrocode}
154 %
155 % We do want an index, using linenumbers, but not update information.
156 % \begin{macrocode}
157 \makeatletter
158 \@mparswitchfalse
159 \makeatother
160 \EnableCrossrefs
161 \CodelineIndex
162 %% \RecordChanges
163 % \end{macrocode}
164 % Don't use the default Short Verb.
165 % \begin{macrocode}
166 \AtBeginDocument{\DeleteShortVerb{\|}}
167 % \end{macrocode}
168 % We had better have page headings to aid navigation, but I don't
169 % like Uppercased titles.
170 % \begin{macrocode}
171 \renewcommand{\MakeUppercase}[1]{#1}
172 \pagestyle{headings}
173 % \end{macrocode}
174 % Need more space for ToC subsection numbers
175 % \begin{macrocode}
176 \makeatletter
177 \renewcommand*{\l@subsection}{\@dottedtocline{2}{1.5em}{3.2em}}
178
179 % \end{macrocode}
180 % We may use many \file{docstrip} modules so we set the
181 % \texttt{StandardModuleDepth} counter to 1.
182 % \begin{macrocode}
183 \setcounter{StandardModuleDepth}{1}
184 % \end{macrocode}
185 % Some commonly used abbreviations
186 % \begin{macrocode}
187 \newcommand*{\Lopt}[1]{\textsf {#1}} % typeset an option
188 \newcommand*{\file}[1]{\texttt {#1}} % typeset a file
189 \newcommand*{\Lcount}[1]{\textsl {\small#1}} % typeset a counter
190 \newcommand*{\pstyle}[1]{\textsl {#1}} % typeset a pagestyle
191 \newcommand*{\Lenv}[1]{\texttt {#1}} % typeset an environment
192 \newcommand*{\Lpack}[1]{\textsf {#1}} % typeset a package
193 \newcommand*{\ctt}{\textsc{ctt}}
194 \newcommand{\Lclass}[1]{\textsf{#1}}
195 \newcommand{\ledmac}{ledmac}
196 \newcommand{\Ledmac}{\Lpack{\ledmac}}
197 \newcommand{\edmac}{\texttt{EDMAC}}
198 \newcommand{\tabmac}{\texttt{TABMAC}}
199 \newcommand{\PWcomment}[1]{}
200 \newenvironment{PW}{\itshape}{}
201 \renewenvironment{PW}{\sffamily}{}
202 \newcommand{\texbook}{\textit{TeXbook}}
203 \newcommand{\thetexbook}{\textit{The TeXbook}}
204 \newcommand{\egstart}{}
205 \newcommand{\egmid}{}
206 \newcommand{\egend}{}
207 \renewcommand{\egstart}{%
208 \par
209 \begingroup
210 \centering
211 \begin{minipage}{0.45\textwidth}}
212 \renewcommand{\egmid}{%
213 \end{minipage}\hfill\begin{minipage}{0.45\textwidth}}
214 \renewcommand{\egend}{%
215 \end{minipage}\par\endgroup}
216 % \end{macrocode}
217 % We want the full details printed.
218 % \begin{macrocode}
219 \begin{document}
220 \DocInput{mempatch.dtx}
221 \PrintIndex
222 %% \PrintChanges
223 \end{document}
224 %</driver>
225 % \end{macrocode}
226 %
227 %
228 % \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
229 % \DoNotIndex{\@centercr,\@cite}\
230 % \DoNotIndex{\@dotsep,\@empty,\@gobble,\@gobbletwo,\@ignoretrue}
231 % \DoNotIndex{\@input,\@ixpt,\@m}
232 % \DoNotIndex{\@minus,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
233 % \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
234 % \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
235 % \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
236 % \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
237 % \DoNotIndex{\advance,\Alph,\alph}
238 % \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
239 % \DoNotIndex{\bullet}
240 % \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
241 % \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
242 % \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
243 % \DoNotIndex{\EnableCrossrefs,\end,\endgroup}
244 % \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
245 % \DoNotIndex{\fbox}
246 % \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
247 % \DoNotIndex{\global,\halign,\hbox,\hfil,\hfill,\hrule}
248 % \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
249 % \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
250 % \DoNotIndex{\input}
251 % \DoNotIndex{\jobname,\kern,\leavevmode,\let}
252 % \DoNotIndex{\list,\llap,\long,\m@ne,\m@th}
253 % \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
254 % \DoNotIndex{\NeedsTeXFormat,\newdimen}
255 % \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
256 % \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
257 % \DoNotIndex{\par,\paragraph,\paragraphmark,\parfillskip}
258 % \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
259 % \DoNotIndex{\protect,\ProvidesClass}
260 % \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
261 % \DoNotIndex{\rightskip,\rlap,\rmfamily,\roman}
262 % \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
263 % \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
264 % \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
265 % \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
266 % \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
267 % \DoNotIndex{\wd,\xiipt,\year,\z@}
268 % \DoNotIndex{\@namedef,\@nameuse,\csname,\endcsname}
269 %
270 %
271 %
272 % \section{Patches for hyperref and friends} \label{sec:hyper}
273 %
274 % The \Lpack{hyperref} package~\cite{HYPERREF} is a marvel of macro coding but it does
275 % seem to have a habit of not working too well with classes or packages
276 % that contain anything out of the
277 % ordinary.
278 %
279 % \begin{macrocode}
280 %<*hyper>
281 % \end{macrocode}
282 %
283 %
284 % The \Lpack{memhfixc} package provides \Lpack{hyperref} related temporary
285 % fixes and extensions for current version of the \Lpack{memoir} class.
286 % \begin{itemize}
287 % \item hyperref fix for part and chapter entries in the ToC (v1.0)
288 % \item Other fixes as and when
289 % \end{itemize}
290 % The class will automatically load the package after
291 % \Lpack{hyperref}.
292 %
293 % \begin{macrocode}
294 %%
295 %% The memhfixc package provides hyperref related temporary
296 %% fixes and extensions for the memoir class.
297 %% o hyperref fix for part and chapter entries in the ToC (v1.0)
298 %% o Other fixes as and when
299 %%
300 %% Only use this package in conjunction with the hyperref package.
301 %% Memoir will automatically load the package after hyperref, no
302 %% interaction needed
303 %%
304 %% Version 1.24 2025/09/16
305 %% Version 1.23 2025/03/06
306 %% Version 1.22 2023/09/10
307 %% Version 1.21 2023/07/28
308 %% Version 1.21 2023/07/28
309 %% Version 1.20 2022/11/17
310 %% Version 1.19 2021/06/16
311 %% Version 1.18 2019/10/24
312 %% Version 1.17 2013/05/30
313 %% Version 1.16 2013/05/16
314 %% Version 1.15 2010/08/17
315 %% Version 1.14 2010/06/10
316 %% Version 1.13 2010/04/19
317 %% Version 1.12 2009/02/06
318 %% Version 1.11 2009/01/18
319 %% Version 1.10 2008/08/23
320 %% Version 1.9 2006/11/22
321 %% Version 1.8 2006/01/21
322 %% Version 1.7 2005/11/15
323 %% Version 1.6 2004/05/13
324 %% Version 1.5 2003/10/14
325 %% Version 1.4 2003/09/26
326 %% Version 1.3 2003/02/20
327 %% Version 1.2 2003/02/02
328 %% Version 1.1 2003/01/22
329 %% Version 1.0 2002/10/22
330 %%
331 % \end{macrocode}
332 %
333 %
334 % \begin{macrocode}
335 \ProvidesPackage{memhfixc}[2025/09/16 v1.24 hyperref package fixes for memoir class]
336 % \end{macrocode}
337 %
338 % \begin{macro}{\M@hfixcfinish}
339 % The \Lpack{memhfixc} package is only useful with the memoir class
340 % \begin{macrocode}
341 \let\M@hfixcfinish\relax
342 \@ifclassloaded{memoir}{}%
343 {\let\M@hfixcfinish\endinput
344 \typeout{No memoir class: memhfixc does nothing}}
345 \M@hfixcfinish
346
347 % \end{macrocode}
348 % \end{macro}
349 %
350 % \subsection{Patches for nameref}
351 %
352 %
353 % \changes{v1.21}{2023/07/25}{Patches removed}
354 %
355 % As of Summer 2023, memoir now autoloads \Lpack{nameref} and adjusts
356 % it self to it. Thus no patches needed.
357 %
358 %
359 % \bigskip\noindent
360 % We are done unless the \Lpack{hyperref} package has been loaded
361 % \begin{macrocode}
362 %% We are done unless the hyperref package has been loaded
363 \@ifpackageloaded{hyperref}{}{\let\M@hfixcfinish\endinput}
364 \M@hfixcfinish
365
366 % \end{macrocode}
367 %
368 % \subsection{Patches for hyperref}
369 %
370 % \begin{macro}{\H@old@sbook}
371 % \begin{macro}{\@sbook}
372 % \Lpack{hyperref} patches \cs{@spart}, we do the same for \cs{@sbook}.
373 % \changes{v1.24}{2025/09/17}{Updated to be similar to the code used for \cs{@spart} in hyperref v7}
374 % \begin{macrocode}
375 \let\H@old@sbook\@sbook
376 \def\@sbook#1{%
377 \Hy@MakeCurrentHrefAuto{book*}%
378 \Hy@raisedlink{%
379 \hyper@anchorstart{\@currentHref}\hyper@anchorend
380 }%
381 \H@old@sbook{#1}
382 }
383
384 % \end{macrocode}
385 % \end{macro}
386 % \end{macro}
387 %
388 % \subsubsection{Names for book for hyperref autoref}
389 %
390 % Added via a loop and some AI. Might be better to add it to \Lpack{hyperref} (have sendt request on GitHub).
391 % \changes{v1.24}{2025/09/17}{Changed to do this via a loop. Also found names for all the languages currently supported in \Lpack{hyperref}}
392 % \begin{macrocode}
393 \ExplSyntaxOn
394 \cs_new_protected:Npn \_memoir_append_bookautorefname:nn #1#2
395 {
396 \@ifundefined{HyLang@#1}{}{%
397 \ExpandArgs{c}\g@addto@macro{HyLang@#1}{\def\bookautorefname{#2}}}
398 }
399 \clist_set:Nn \l_tmpa_clist {
400 {afrikaans}{Boek},
401 {english}{Book},
402 {french}{Livre},
403 {german}{Buch},
404 {italian}{Libro},
405 {magyar}{K\"onyv},
406 {portuges}{Livro},
407 {russian}{\CYRK\cyrn\cyri\cyrg\cyrr\cyra},
408 {spanish}{Libro},
409 {catalan}{Llibre},
410 {vietnamese}{T\d{\^{a}}p s\'{a}ch},
411 {greek}{\textBeta\textiota\textbeta\textlambda\'\textiota\textomicron},
412 {dutch}{Boek},
413 {norsk}{Bok},
414 {danish}{Bog},
415 {swedish}{Bok},
416 }
417 \clist_map_inline:Nn \l_tmpa_clist
418 { \_memoir_append_bookautorefname:nn #1 }
419 \ExplSyntaxOff
420
421 % \end{macrocode}
422 %
423 %
424 % \begin{macro}{\bookautorefname}
425 % \begin{macro}{\subfigureautorefname}
426 % \changes{v1.21}{2023/07/28}{Added \cs{subfigureautorefname}}
427 % \begin{macrocode}
428 \providecommand{\bookautorefname}{Book}
429 \providecommand{\subfigureautorefname}{Subfigure}
430
431 % \end{macrocode}
432 % \end{macro}
433 % \end{macro}
434 %
435 % \changes{v1.24}{2025/09/16}{Removed some super old code what was moved to hyperref in 2006}
436 %
437 % \begin{macro}{\M@sect}
438 % \Lpack{hyperref} fix for memoir's redefinition of \cs{@sect}
439 % \changes{v1.14}{2010/06/10}{At some point hyperref changed the way
440 % it changed \cs{@sect} such that the link target goes above the
441 % section title. Here we bring memoir back up to speed}
442 % The change being made is quite simple. We use \cs{M@sect} and it
443 % takes 9 args not the standard 8. There are only 3 changes.
444 % \changes{v1.15}{2010/08/17}{Fixed typo, 8 -> \#8}
445 % \changes{v3.8.4}{2025/09/18}{No changes, just verification that this match hpdftex.def v7.01o}
446 % \begin{macrocode}
447 \@ifundefined{H@old@sectm@m}{% haven't fiddled with \M@sect
448 \let\H@old@sectm@m\M@sect
449 \def\M@sect#1#2#3#4#5#6[#7][#8]#9{%
450 \ifnum #2>\c@secnumdepth%
451 \expandafter\@firstoftwo%
452 \else%
453 \expandafter\@secondoftwo%
454 \fi%
455 {%
456 \Hy@MakeCurrentHrefAuto{section*}%
457 \setlength{\Hy@SectionHShift}{#3}%
458 \begingroup
459 \toks@{\H@old@sectm@m{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#8}]}% <--
460 \toks\tw@\expandafter{%
461 \expandafter\Hy@SectionAnchorHref\expandafter{\@currentHref}%
462 #9% <---
463 }%
464 \edef\x{\endgroup%
465 \the\toks@{\the\toks\tw@}%
466 }\x%
467 }{%
468 \H@old@sectm@m{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#8}]{#9}% <--
469 }%
470 }%
471 }%
472 {% already fiddled \M@sect
473 }
474
475 % \end{macrocode}
476 % \end{macro}
477 % ^^A moved addition to \@resets@pp to memoir proper
478 %
479 % ^^A moved addition to \@resets@ppsub and \endsubappendices to memoir proper
480 %
481 % \begin{macro}{\cftaddtitleline}
482 % \begin{macro}{\cftaddnumtitleline}
483 % \Lpack{hyperref} fix for memoir's add to contents macros
484 % (discovered by Martin Siegumfeldt, \ctt{} 2003/09/25
485 % \textit{`Combinig [sic] Tocloft and hyperref'}
486 % \begin{macrocode}
487 \renewcommand{\cftaddtitleline}[4]{%
488 \addtocontents{#1}{\protect\contentsline{#2}{#3}{#4}{\@currentHref}}}
489 \renewcommand{\cftaddnumtitleline}[5]{\addtocontents{#1}{%
490 \protect\contentsline{#2}{\protect\numberline{#3}#4}{#5}{\@currentHref}}}
491
492 % \end{macrocode}
493 % \end{macro}
494 % \end{macro}
495 %
496 % \begin{macro}{\caption}
497 % Yet another little jolly (fixed in version 1.5). \Lpack{hyperref}'s
498 % \verb?\def? of \verb?\caption? cunningly messes up \Lpack{memoir}'s,
499 % thereby screwing up the labels for subcaptions.
500 %
501 % \changes{v1.24}{2025/09/18}{Since this is just an prepend, we can do it with a patch}
502 % \begin{macrocode}
503 %\let\m@moldhypcaption\caption
504 %\renewcommand{\caption}{\donemaincaptiontrue\m@moldhypcaption}
505 \xpretocmd\caption{\donemaincaptiontrue}
506 {}{\typeout{Preto patch for \string\caption\space failed}}
507
508 % \end{macrocode}
509 % \end{macro}
510 %
511 % More tweaks are needed for continued captions and sidecaptions. The
512 % need for these discovered by \v{Z}arko F \v{C}u\v{c}ej (for
513 % \cs{contcaption}) and by J{\o}rgen Larsen (for \cs{sidecaption}),
514 % and by Eitan Gurari (for \texttt{tex4ht}).
515 % \changes{v1.7}{2005/11/15}{Added tweaks for \cs{contcaption},
516 % \cs{sidecaption} and \cs{sidecontcaption}}
517 %
518 % \begin{macro}{\c@memhycontfloat}
519 % \begin{macro}{\thememhycontfloat}
520 % \begin{macro}{\theHmemhycontfloat}
521 % We need an extra marker for continued captions.
522 % \changes{v1.7}{2005/11/15}{Added extra counter for continued captions}
523 % \changes{v1.10}{2008/08/23}{Fixed \cs{theHmemhycontfloat} undefined
524 % problem (courtsesy Eitan Gurari)}
525 % \begin{macrocode}
526 \newcounter{memhycontfloat}
527 \renewcommand*{\thememhycontfloat}{\arabic{memhycontfloat}}
528 \providecommand*{\theHmemhycontfloat}{}
529 \renewcommand*{\theHmemhycontfloat}{\arabic{memhycontfloat}}
530 \setcounter{memhycontfloat}{0}
531
532 % \end{macrocode}
533 % \end{macro}
534 % \end{macro}
535 % \end{macro}
536 %
537 % \begin{macro}{\contcaption}
538 % Tweak the \cs{contcaption} macro.
539 %
540 % \changes{v1.18}{2019/10/24}{Added a \cs{par} to get rid of a
541 % sporadic space comming from \cs{refstepcounter} under hyperref}
542 % \begin{macrocode}
543 \renewcommand{\contcaption}{%
544 \par%
545 \refstepcounter{memhycontfloat}%
546 \addtocounter{\@captype}{\m@ne}\H@refstepcounter{\@captype}%
547 \@contcaption\@captype}
548
549 % \end{macrocode}
550 % \end{macro}
551 %
552 % \begin{macro}{\sidecaption@refstepcounter}
553 % Under \Lpack{hyperref} we redefine what
554 % \cs{sidecaption@refstepcounter} does. Here we use that it is
555 % called with two args.
556 % \changes{v1.22}{2023/09/10}{Redef of new macro from memoir 3.8.2,
557 % that makes sidecaption handling easier.}
558 % \begin{macrocode}
559 \renewcommand*\sidecaption@refstepcounter[2]{%
560 \H@refstepcounter{#1}%
561 \hyper@makecurrent{#2}%
562 }
563
564 % \end{macrocode}
565 % \end{macro}
566 %
567 % \changes{v1.22}{2023/09/10}{Because of the redef in memoir 3.8.2 we
568 % no longer need this}
569 % ^^A \begin{macro}{\endsidecaption}
570 % ^^A % Tweak the \texttt{sidecaption} environment. I don't know why it
571 % ^^A works but it took a lot of time trying all sorts of combinations
572 % ^^A of commands to get it to do so (if it really does).
573 % ^^A \begin{macrocode}
574 % \def\endsidecaption{%
575 % \m@mscapend@fbox
576 % \H@refstepcounter{\@captype}%
577 % \hyper@makecurrent{\@captype}%
578 % \m@mscaplabel
579 % ^^A \end{macrocode}
580 % ^^A\changes{v1.17}{2013/05/30}{Forgot to add \cs{m@mscapcheckside}}
581 % ^^A \begin{macrocode}
582 % \m@mscapcheckside %<--- added 2013/05/30
583 % \begin{lrbox}{\m@mscap@capbox}%
584 % \begin{minipage}[c]{\sidecapwidth}%
585 % \sidecapstyle
586 % \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}%
587 % \end{minipage}%
588 % \end{lrbox}%
589 % \m@mscapopboxes}
590
591 % ^^A \end{macrocode}
592 % ^^A \end{macro}
593 %
594 % \begin{macro}{\sidecontcaption}
595 % \begin{macro}{\endsidecontcaption}
596 % Tweaks for the \texttt{sidecontcaption} environment. Again it was
597 % a miss, miss, \ldots hit method to get something that appears
598 % to work.
599 % \changes{v1.22}{2023/09/10}{Because of the redef in memoir 3.8.2 we
600 % no longer need the redef of \cs{endsidecontcaption}}
601 % \begin{macrocode}
602 \renewcommand*{\sidecontcaption}{%
603 \refstepcounter{memhycontfloat}%
604 \@sidecontcaption}
605 % \def\endsidecontcaption{%
606 % \m@mscapend@fbox
607 % \addtocounter{\@captype}{\m@ne}\H@refstepcounter{\@captype}%
608 % \hyper@makecurrent{memhycontfloat}%
609 % \m@mscaplabel
610 % ^^A \end{macrocode}
611 % ^^A \changes{v1.17}{2013/05/30}{Forgot to add \cs{m@mscapcheckside}}
612 % ^^A \begin{macrocode}
613 % \m@mscapcheckside %<--- added 2013/05/30
614 % \begin{lrbox}{\m@mscap@capbox}%
615 % \begin{minipage}[c]{\sidecapwidth}%
616 % \sidecapstyle
617 % \@contcaption\@captype{\m@mscap@forcap}%
618 % \end{minipage}%
619 % \end{lrbox}%
620 % \m@mscapopboxes}
621
622 % \end{macrocode}
623 % \end{macro}
624 % \end{macro}
625 %
626 % ^^A % \begin{macro}{\@mem@titlerefnolink}
627 % ^^A % \Lpack{hyperref} provide a \cs{ref*} command that does not give a
628 % ^^A % hyperlink under \Lpack{hyperref}, we extend \cs{titleref} to
629 % ^^A % support it.
630 % ^^A % \changes{v1.21}{2023/08/07}{removed}
631 % ^^A % \begin{macrocode}
632 % ^^A %\def\@mem@titlerefnolink#1{\begingroup \let\numberline\@gobble
633 % ^^A % \let\M@TitleReference\@mem@theTR % interrupt recursion of \ref
634 % ^^A % \ref*{#1}\endgroup}
635 % ^^A
636 % ^^A % \end{macrocode}
637 % ^^A % \end{macro}
638 %
639 % \begin{macro}{\printpageinnoteshyperref}
640 % When \Lpack{hyperref} is active, page references in the page notes
641 % list looks better with a specialised macro. The macro is provided
642 % within the class, and here we activate it.
643 % \begin{macrocode}
644 \AtBeginDocument{%
645 \let\printpageinnotes\printpageinnoteshyperref%
646 }
647 % \end{macrocode}
648 % \end{macro}
649 %
650 % \begin{macro}{\@footnotemark}
651 % \changes{v1.16}{2013/05/08}{Slight change to hyperfootnotes redefinition of \cs{@footnotemark}}
652 % When \Lpack{hyperref} is loaded with the \texttt{hyperfootnotes}
653 % options, then \cs{@footnotemark} is overwritten, and our added
654 % feature which automatically separate multiple footnotes with
655 % commas is lost. It is however very easy to resurrect.
656 % \begin{macrocode}
657 \ifHy@hyperfootnotes
658 \def\@footnotemark{%
659 \leavevmode
660 \ifhmode\edef\@x@sf{\the\spacefactor}%
661 \m@mmf@check% <--- added
662 \nobreak\fi
663 \stepcounter{Hfootnote}%
664 \global\let\Hy@saved@currentHref\@currentHref
665 \hyper@makecurrent{Hfootnote}%
666 \global\let\Hy@footnote@currentHref\@currentHref
667 \global\let\@currentHref\Hy@saved@currentHref
668 \hyper@linkstart{link}{\Hy@footnote@currentHref}%
669 \@makefnmark
670 \hyper@linkend
671 \m@mmf@prepare% <--- added
672 \ifhmode\spacefactor\@x@sf\fi
673 \relax
674 }%
675 \fi
676
677 % \end{macrocode}
678 %
679 % \end{macro}
680 %
681 % \changes{v1.16}{2013/05/14}{Added fix for \cs{@starttoc}}
682 % \changes{v1.20}{2022/11/17}{Patch removed, by 2022 hyperref no longer change \cs{@starttoc}}
683 % ^^A \begin{macro}{\@starttoc}
684 % ^^A In memoir we altered \cs{@starttoc} such that \cs{tableofcontents}
685 % ^^A could be used multiple times. \Lpack{hyperref} resets this. So here
686 % ^^A is our reset of that reset.
687 % ^^A \begin{macrocode}
688 % ^^A % patch removed as per 2022 hyperref does not touch \@starttoc
689 % ^^A % \Hy@AtBeginDocument{%
690 % ^^A % \ifx\hyper@last\@undefined
691 % ^^A % \def\@starttoc#1{%
692 % ^^A % \begingroup\makeatletter
693 % ^^A % \IfFileExists{\jobname.#1}{%
694 % ^^A % \Hy@WarningNoLine{%
695 % ^^A % old #1 file detected, not used; run LaTeX again%
696 % ^^A % }%
697 % ^^A % }{}%
698 % ^^A % \if@filesw
699 % ^^A % \end{macrocode}
700 % ^^A We rewrite this part to match our definition. The rest is a copy
701 % ^^A from \texttt{hyperref.sty}.
702 % ^^A % \begin{macrocode}
703 % ^^A % \AtEndDocument{%
704 % ^^A % \expandafter\ifx\csname tf@#1\endcsname\relax
705 % ^^A % \expandafter\newwrite\csname tf@#1\endcsname
706 % ^^A % \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
707 % ^^A % \fi
708 % ^^A % }
709 % ^^A % \fi
710 % ^^A % \@nobreakfalse
711 % ^^A % \endgroup
712 % ^^A % }%
713 % ^^A % \fi
714 % ^^A % }
715 % ^^A % \end{macrocode}
716 % ^^A \end{macro}
717 %
718 % \changes{v3.6k}{2013/05/16}{Added hyperref support for page notes}
719 % In order to enable hyperlinks for page notes, we need a few extra
720 % things. First of all we only enable hyperlinked page noted if hyper
721 % footnotes are enabled, seems a good choice.
722 % \begin{macrocode}
723 \ifHy@hyperfootnotes
724 % \end{macrocode}
725 % Record the current hyperref anchor in the page note data.
726 % \begin{macrocode}
727 \let\m@m@pnwrite@fourtharg\m@m@pnwrite@fourtharg@hyperref
728 % \end{macrocode}
729 % Make the note typesetter use the anchor data.
730 % \begin{macrocode}
731 \let\pagenoteanchor\pagenotehyperanchor
732 % \end{macrocode}
733 % Fill in two hook responsable for turning the note marker in the text
734 % into a hyperlink. The code is more or less copied from
735 % \Lpack{hyperref}'s footnote handling. TODO: Redefine this at some point.
736 % \changes{1.23}{2025/02/25}{Renaming the Hpagenote counter, to avoid hyperef warning.}
737 % \begin{macrocode}
738 \newcounter{mem@Hpagenote}
739 \@namedef{mem@pnmm@start@hook}{%
740 \stepcounter{mem@Hpagenote}%
741 \global\let\Hy@saved@currentHref\@currentHref
742 \hyper@makecurrent{mem@Hpagenote}%
743 \global\let\Hy@pagenote@currentHref\@currentHref
744 \global\let\@currentHref\Hy@saved@currentHref
745 \hyper@linkstart{link}{\Hy@pagenote@currentHref}%
746 }
747 \@namedef{mem@pnmm@end@hook}{\hyper@linkend}
748 \fi
749
750 % \end{macrocode}
751 %
752 %
753 % \subsection{Patch after \Lpack{hypcap}}
754 %
755 % The \Lpack{hypcap} package can help with some hyperref anchor placement in
756 % figure refences. But it also requires every figure or table to have
757 % a caption, thus it does not understand our \cmd{\contcaption} command.
758 %
759 % \changes{v3.7i}{2019/10/26}{added patch for \cmd{\contcaption} when
760 % \Lpack{hypcap} is loaded}
761 % \begin{macrocode}
762 \AtEndPackage{hypcap}{%
763 \long\def\@@contcaption##1##2{%
764 \par
765 \begingroup
766 \@parboxrestore
767 \if@minipage
768 \@setminipage
769 \fi
770 \global\@capstartfalse% added
771 \normalsize
772 \@makecaption{\csname fnum@##1\endcsname}{\ignorespaces ##2}\par
773 \endgroup}
774 }
775 % \end{macrocode}
776 %
777 % The end of the \Lpack{hyperref} related patches.
778 %
779 % \begin{macrocode}
780 %</hyper>
781 % \end{macrocode}
782 %
783 %
784 % \section{Patches for the class code} \label{sec:class}
785 %
786 % At this date, 2008/07/23, with the simultaneous release of memoir v1.6180339
787 % and the patch file, by definition there are no patches.
788 %
789 % As of 2018, we no longer generate \Lpack{mempatch}.
790 %
791 % \subsection{Identification} \label{sec:id}
792 %
793 % \changes{v2.0}{2004/01/31}{No code in mempatch.sty}
794 % \changes{v2.1}{2004/02/12}{Code now required in mempatch.sty}
795 % \changes{v2.1a}{2004/02/19}{Extra pagestyle code for handling \cs{linespread}}
796 % \changes{v2.4}{2004/04/26}{Removed extraneous spaces}
797 % \changes{v2.4+}{2004/04/26}{Stopped noting general changes}
798 %
799 % \begin{macrocode}
800 %<*patch>
801 % \end{macrocode}
802 %
803 % ^^A \typeout{mempatch.sty 2002/12/12 v1.1 Patches for memoir class v1.3a}
804 % ^^A \typeout{mempatch.sty 2003/01/06 v1.2 Patches for memoir class v1.3a}
805 % ^^A \typeout{mempatch.sty 2003/01/22 v1.3 Patches for memoir class v1.3a}
806 % ^^A \typeout{mempatch.sty 2003/02/13 v1.4 Patches for memoir class v1.3a}
807 % ^^A \typeout{mempatch.sty 2003/04/26 v1.5 Patches for memoir class v1.3a}
808 % ^^A \typeout{mempatch.sty 2003/06/28 v1.6 Patches for memoir class v1.3a}
809 % ^^A \typeout{mempatch.sty 2003/07/23 v1.7 Patches for memoir class v1.3a}
810 % ^^A \typeout{mempatch.sty 2003/09/16 v1.8 Patches for memoir class v1.3a}
811 % ^^A \typeout{mempatch.sty 2003/10/06 v1.8a Patches for memoir class v1.3a}
812 % ^^A \typeout{mempatch.sty 2003/11/16 v1.9 Patches for memoir class v1.3a}
813 % ^^A \typeout{mempatch.sty 2004/01/31 v2.0 Patches for memoir class v1.6}
814 % ^^A \typeout{mempatch.sty 2004/02/12 v2.1 Patches for memoir class v1.6}
815 % ^^A \typeout{mempatch.sty 2004/02/19 v2.1a Patches for memoir class v1.6}
816 % ^^A \typeout{mempatch.sty 2004/03/01 v2.2 Patches for memoir class v1.6}
817 % ^^A \typeout{mempatch.sty 2004/03/28 v2.3 Patches for memoir class v1.61}
818 % ^^A \typeout{mempatch.sty 2004/04/26 v2.3 Patches for memoir class v1.61}
819 % ^^A \typeout{mempatch.sty 2004/04/27 v2.3a Patches for memoir class v1.61}
820 % ^^A \typeout{mempatch.sty 2004/04/30 v2.3b Patches for memoir class v1.61}
821 % ^^A \typeout{mempatch.sty 2004/05/10 v2.3c Patches for memoir class v1.61}
822 % ^^A \typeout{mempatch.sty 2004/05/14 v2.3d Patches for memoir class v1.61}
823 % ^^A \typeout{mempatch.sty 2004/12/14 v3.0 Patches for memoir class v1.61}
824 % ^^A \typeout{mempatch.sty 2004/12/19 v3.1 Patches for memoir class v1.61}
825 % ^^A \typeout{mempatch.sty 2005/01/01 v3.2 Patches for memoir class v1.61}
826 % ^^A \typeout{mempatch.sty 2005/01/17 v3.3 Patches for memoir class v1.61}
827 % ^^A \typeout{mempatch.sty 2005/01/18 v3.4 Patches for memoir class v1.61}
828 % ^^A \typeout{mempatch.sty 2005/02/01 v3.5 Patches for memoir class v1.61}
829 % ^^A \typeout{mempatch.sty 2005/02/07 v3.6 Patches for memoir class v1.61}
830 % ^^A \typeout{mempatch.sty 2005/02/26 v3.7 Patches for memoir class v1.61}
831 % ^^A \typeout{mempatch.sty 2005/03/06 v3.8 Patches for memoir class v1.61}
832 % ^^A \typeout{mempatch.sty 2005/03/23 v3.9 Patches for memoir class v1.61}
833 % ^^A \typeout{mempatch.sty 2005/05/16 v3.10 Patches for memoir class v1.61}
834 % ^^A \typeout{mempatch.sty 2005/05/23 v3.11 Patches for memoir class v1.61}
835 % ^^A \typeout{mempatch.sty 2005/06/06 v3.12 Patches for memoir class v1.61}
836 % ^^A \typeout{mempatch.sty 2005/09/25 v4.0 Patches for memoir class v1.618}
837 % ^^A \ProvidesFile{mempatch.sty}[2005/10/06 v4.1 Patches for memoir class v1.618]
838 % ^^A \ProvidesFile{mempatch.sty}[2005/11/21 v4.2 Patches for memoir class v1.618]
839 % ^^A \ProvidesFile{mempatch.sty}[2005/12/13 v4.3 Patches for memoir class v1.618]
840 % ^^A \ProvidesFile{mempatch.sty}[2006/01/21 v4.4 Patches for memoir class v1.618]
841 % ^^A \ProvidesFile{mempatch.sty}[2006/01/23 v4.4a Patches for memoir class v1.618]
842 % ^^A \ProvidesFile{mempatch.sty}[2006/07/10 v4.5 Patches for memoir class v1.618]
843 % ^^A \ProvidesFile{mempatch.sty}[2006/08/08 v4.5 Patches for memoir class v1.618]
844 % ^^A \ProvidesFile{mempatch.sty}[2006/12/11 v4.6 Patches for memoir class v1.618]
845 % ^^A \ProvidesFile{mempatch.sty}[2006/12/23 v4.7 Patches for memoir class v1.618]
846 % ^^A \ProvidesFile{mempatch.sty}[2007/01/22 v4.8 Patches for memoir class v1.618]
847 % ^^A \ProvidesFile{mempatch.sty}[2007/12/14 v4.9 Patches for memoir class v1.618]
848 %
849 % ^^A \ProvidesFile{mempatch.sty}[2007/12/24 v4.9a Patches for memoir class v1.618]
850 % ^^A \ProvidesFile{mempatch.sty}[2007/12/31 v4.9a+ Patches for memoir class v1.618]
851 % ^^A \ProvidesFile{mempatch.sty}[2008/05/26 v5.0 Patches for memoir class v1.61803]
852 % ^^A \ProvidesFile{mempatch.sty}[2008/07/11 v5.1 Patches for memoir class v1.618033]
853 % \begin{macrocode}
854 \ProvidesPackage{mempatch}[2009/07/24 v6.0f Patches for memoir class v1.6180339]
855
856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
857 %%% Version 6.0 was released simultaneously with version 1.6180339
858 %%% of memoir.
859 %%% By definition there were no patches.
860 %%%
861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
862
863 % \end{macrocode}
864 %
865 %
866 % The end of the patch file.
867 %
868 % \begin{macrocode}
869 %</patch>
870 % \end{macrocode}
871 %
872 %
873 % \bibliographystyle{alpha}
874 % \begingroup
875 % \raggedright
876 % \begin{thebibliography}{GMSN94A}
877 %
878 %
879 % \bibitem[GMS94]{GOOSSENS94}
880 % Michel Goossens, Frank Mittelbach, and Alexander Samarin.
881 % \newblock \emph{The LaTeX Companion}.
882 % \newblock Addison-Wesley Publishing Company, 1994.
883 %
884 % \bibitem[Rahtz23a]{NAMEREF}
885 % Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
886 % \newblock \emph{Section name references in LaTeX}.
887 % \newblock 2023.
888 % \newblock (Available from CTAN (the \texttt{nameref} package) via
889 % \texttt{/macros/latex/contrib/hyperref/})
890 %
891 %
892 % \bibitem[Rahtz23b]{HYPERREF}
893 % Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
894 % \newblock \emph{Hypertext marks in LaTeX}.
895 % \newblock 2023.
896 % \newblock (Available from CTAN via
897 % \texttt{/macros/latex/contrib/hyperref/})
898 %
899 % \bibitem[Wil23]{MEMOIR}
900 % Peter Wilson.
901 % \newblock \emph{The LaTeX \Lpack{memoir} class for configurable
902 % typesetting: Source code}.
903 % \newblock July 2023.
904 % \newblock (Available from CTAN in
905 % \texttt{macros/latex/contrib/memoir})
906 %
907 %
908 % \end{thebibliography}
909 % \endgroup
910 %
911 % \ Finale
912 %
913 \endinput
914
915 %% \CharacterTable
916 %% {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
917 %% 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
918 %% Digits \0\1\2\3\4\5\6\7\8\9
919 %% Exclamation \! Double quote \" Hash (number) \#
920 %% Dollar \$ Percent \% Ampersand \&
921 %% Acute accent \' Left paren \( Right paren \)
922 %% Asterisk \* Plus \+ Comma \,
923 %% Minus \- Point \. Solidus \/
924 %% Colon \: Semicolon \; Less than \<
925 %% Equals \= Greater than \> Question mark \?
926 %% Commercial at \@ Left bracket \[ Backslash \\
927 %% Right bracket \] Circumflex \^ Underscore \_
928 %% Grave accent \` Left brace \{ Vertical bar \|
929 %% Right brace \} Tilde \~}
930
931
932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
933