texlive[74481] Master/texmf-dist: memoir (6mar25)

commits+karl at tug.org commits+karl at tug.org
Thu Mar 6 22:32:04 CET 2025


Revision: 74481
          https://tug.org/svn/texlive?view=revision&revision=74481
Author:   karl
Date:     2025-03-06 22:32:04 +0100 (Thu, 06 Mar 2025)
Log Message:
-----------
memoir (6mar25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/memoir/README
    trunk/Master/texmf-dist/doc/latex/memoir/memman.pdf
    trunk/Master/texmf-dist/doc/latex/memoir/memman.tex
    trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty
    trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx
    trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx
    trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty
    trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls

Modified: trunk/Master/texmf-dist/doc/latex/memoir/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/memoir/README	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/doc/latex/memoir/README	2025-03-06 21:32:04 UTC (rev 74481)
@@ -1,4 +1,4 @@
-    Memoir is a flexible class for typesetting poetry, fiction, 
+    Memoir is a flexible class for typesetting poetry, fiction,  
 non-fiction and mathematical works as books, reports, articles or
 manuscripts. Documents can use 9pt, 10pt, 11pt, 12pt, 14pt, or 17pt as the
 normal fontsize and, if you have scalable fonts, 20pt, 25pt, 30pt, 36pt,
@@ -22,6 +22,115 @@
 compatible. Instead we assume that users use updated memoir with an
 updated LaTeX installation.
 
+Changes (2025/03/06)
+
+o memoir v3.8.3
+
+-- A few places we loaded package using \usepackage, now changed to
+   \RequirePackage. Plus under very large font sizes, don't auto load
+   `fontenc` under Xe- and LuaLaTeX.
+
+-- Has started marking some macros and envs as deprecated, to be
+   removed at a later date (2026). Each will give a warning at their
+   first use.  The macros/envs include:
+
+   -- \addtodef(*), \addtoiargdef(*) and \patchcommand They have better
+      alternatives in the etoolbox and xpatch packages (which we already
+      load). Additionally these macros does not preserve robustness, the
+      macros from xpatch does.
+
+   -- \newloglike, \provideloglike
+      Users should use \DeclareMathOperator from amsopn (amsmath)
+
+
+-- The redefinitions of \title, \author, \date, \thanks now done via
+   \xpretocmd and \xapptocmd instead of \addtoiargdef which did not
+   preserve robustness.
+
+-- The provided code for \counterwithin/out and \@removefromreset has
+   fininally been removed. All three macros have been in the
+   LaTeX-kernel since 2018.
+
+-- Internal code cleanup regarding macros that are not used
+
+-- Reimplemented how verse numbers are added thus fixing
+   <https://tex.stackexchange.com/q/609802/3929>
+
+   This is a slight change in behavior, as now line numbers are always
+   added at the start of the line and not the end. Old implementation
+   added the numbers at the end, and thus they are aligned with the
+   last line of a line broken line.
+
+-- Changed the implementation for \cftinserthook. It can have some
+   ordering issuses when \include is used, \cftinserthook* should now
+   help.
+
+   Note that it may force a \clearpage so should only be used between
+   \include's
+
+-- Changed \settocdepth in a similar fashion to \cftinserthook.
+
+-- Memoir will now warn if the fancyhdr package is loaded. Users
+   should use the build in interface instead.
+
+   Additionally warn against titlesec and titlepos 
+
+-- Chose different defaults for \partmark and \bookpagemark.
+
+   Problem reported in <https://tex.stackexchange.com/q/737771/3929>
+
+-- Breaking change: Changed the code for the "article" chapter
+   style. \chapterheadstart was changed to use \addvspace (like
+   \section) instead of \vspace. This will lead to a (small) difference in
+   vertical spacing when the "article" chapter style is used, fx under
+   the "article" class option.
+
+   Problem reported in <https://tex.stackexchange.com/q/732129/3929>
+
+-- changed \cftchapterbreak so it now also contains the vertical skip
+   (similar to what \part and book does). Unsure why it did not
+   already
+
+   Note that this may affect existing documents if users have
+   redefined \cftchapterbreak in order to change the penalty
+
+-- refactored \cftbookbreak, \cftpartbreak and \cftchapterbreak such
+   that the penalty used is now configurable as \cftbeforebookpenalty,
+   \cftbeforepartpenalty and \cftbeforechapterpenalty.
+
+   They all have the same default value of -\@highpenalty
+
+-- In \cftchapterbreak and in all toc entries generated by
+   \newlistentry the macro that executes \cftbeforeXskip has now been
+   factored out into a macro that can be set using
+
+   \setcftvspacecmd{\macro}
+
+   The default is still \vskip, but users might want to change it to
+   \addvspace for new documents.
+
+   Issue reported in private email.
+
+   One can argue that \addvspace would be the best choice going
+   forward, but this also means slightly shifting upwards the first
+   page of the toc for all memoir docs that uses \tableofcontents. For
+   now this has been deemed undesirable.
+
+-- no longer load the mparhack package in twocolumn mode. There are
+   packages there are incomparible with it, thus better for the user
+   to explicitly load it themself if they need it.
+
+   Issue reported in private email.
+
+
+o memhfixc v1.23
+
+-- renamed Hpagenote counter to mem at Hpagenote to avoid hyperef warning.
+
+-- added \bookautorefname support for french, requested in private email.
+
+
+
 Changes (2024/01/26)
 
 o memoir v3.8.2

Modified: trunk/Master/texmf-dist/doc/latex/memoir/memman.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/memoir/memman.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/memoir/memman.tex	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/doc/latex/memoir/memman.tex	2025-03-06 21:32:04 UTC (rev 74481)
@@ -31,7 +31,22 @@
 \usepackage{memlays}     % extra layout diagrams
 \usepackage{dpfloat}     % floats on facing pages
 \usepackage{fonttable}[2009/04/01]   % font tables
-%%%%\usepackage{xr-hyper} \externaldocument{memdesign} Doesn't work, 
+
+% with 2024 updates to array.sty fonttable no longer works, it seems
+% to be missing a \relax:
+\makeatletter
+\patchcmd{\f at tevenlinenonum}
+{\ifnum\f at tn=\f at thigh\\\hline}
+{\ifnum\f at tn=\f at thigh\relax\\\hline}
+  {}
+  {\typeout{Failed patching fonttable}}
+\makeatother
+
+
+
+
+
+%%%% \usepackage{xr-hyper} \externaldocument{memdesign} Doesn't work, 
 %%%%                      Idea won't work in general for memman/memdesign
 %%%%                      as at display time, who knows where everything
 %%%%                      will be located on the individual's computer.
@@ -86,8 +101,8 @@
 
 % \svnidlong
 % {}
-% {$LastChangedDate: 2020-03-25 19:00:55 +0100 (Wed, 25 Mar 2020) $}
-% {$LastChangedRevision: 686 $}
+% {$LastChangedDate: 2025-03-04 12:57:30 +0100 (Tue, 04 Mar 2025) $}
+% {$LastChangedRevision: 831 $}
 % {$LastChangedBy: daleif at math.au.dk $}
 
 
@@ -389,8 +404,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2024-01-26 14:56:06 +0100 (Fri, 26 Jan 2024) $}
-{$LastChangedRevision: 806 $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Remarks from the maintainer}
@@ -451,7 +466,7 @@
 Going forward a main goal of the \LaTeX\ Team is the ability to tag
 PDF files. The \theclass~class will also have to be adapted to become
 compatible with this feature. For version~3.8 this required us to
-rework how \cmd{\titleref} was implemted as we should no longer
+rework how \cmd{\titleref} was implemented as we should no longer
 redefine \cmd{\label}.\footnote{\cmd{\titleref} is now an alias for
   \cmd{\nameref} (from the \Lpack{nameref} package), a package which
   is maintained in close relation with \Lpack{hyperref}.}
@@ -460,15 +475,14 @@
 
 Additionally, going forward I will additionally be starting to look at
 removing certain functionality from \theclass. This will be things
-that does not really belong in \theclass, users should really get this
-functionality from somewhere else (some additional package). Unless it
-is clear that the macro has to go due to reimplemantation of a feature
-or that the feature probably is not used by that many people, the
-removal will be announced in advance (say 12--18 months), by adding a
-warning to the macro (especially if we would like the user to use a
-different macro). It will also be marked in the manual that the
+that does not really belong in \theclass. Things that users ought to
+get from somewhere else (some additional package). Unless it is clear
+that the macro has to go due to reimplemantation of a feature or that
+the feature probably is not used by that many people, the removal will
+be announced in advance (say 12--18 months), by adding a warning to
+the macro (especially if we would like the user to use a different
+macro). It will also be marked in the manual that the
 macro/environment will be removed in a future release.
-
 \begin{flushright}
   Summer 2023
 
@@ -475,11 +489,67 @@
   /daleif
 \end{flushright}
 
+\fancybreak{}
 
+In this over due update we fixed several things. Details are listed in
+the README, which can be found at
+\url{https://mirrors.ctan.org/macros/latex/contrib/memoir/README}. As
+listed below, some macros are not marked for removal. For existing
+documents the redefinition of \cs{cftchapterbreak}, might be of
+interest as it will affect the look of documents that have changed
+this macro. See pages~\pageref{cftbreak-start}--\pageref{cftbreak-end}
+for details, where it is also listed the the most frequent reason to
+redefine \cs{cftchapterbreak} (chanding the penalty) has now neen
+factored out so the penalty can be changed directly. We have also
+started adding warnings against packages that should not be used with
+memoir.
+
+We will probably start at least looking at the tagging of parts of
+memoir documents for the next release.
+\begin{flushright}
+  March 2025
+
+  /daleif
+\end{flushright}
+
+
 \begingroup
 \renewcommand\descriptionlabel[1]{\hspace\labelsep\parbox[t]{\dimexpr\textwidth-5pt\relax}{#1}}
 
+\section*{Macros marked to be removed in 2026}
 
+Each will work, but their first use will issue a warning in the log.
+
+\begin{description}
+\item[\cmd{\addtodef}, \cmd{\addtodef*}, \cmd{\addtoiargdef}, \cmd{\addtoiargdef*}, \cmd{\patchcommand}]
+
+  Their effect can be achived using tools from \Lpack{etoolbox} and
+  \Lpack{xpatch} (both autoloaded by the class).
+\item[\cmd{\newloglike}, \cmd{\provideloglike}] Users should really
+  use \cs{DeclareMathOperator} from \Lpack{amsopn} (autoloaded by
+  \Lpack{amsmath}). Note there is currently no equivalent for
+  \cs{provideloglike}.
+
+\end{description}
+
+
+
+
+\section*{Public interfaces removed/disabled in v3.8.2}
+The following macros were discontinued due to the un-embedding of the \Lpack{verbatim package}
+\begin{description}
+\item[\cmd{\tabson}, \cmd{\tabsoff}] Used to be able to enable/disable
+  tab marking support in verbatim texts. \cs{tabson} issues a warning and does nothing.
+\item[\cmd{\wrappingon}, \cmd{\wrappingoff}] Used to be able to enable
+  automatic line breaking at white space in verbatim
+  texts.\footnote{The implementation had bugs which were never
+    reported, thus probably not used that much.} \cs{wrappingon}
+  issues a warning and does nothing.
+\item[\cmd{\verbatimbreakchar}] Left on a verbatim line broken at
+  white space.
+\end{description}
+
+
 \section*{Public interfaces removed/disabled in v3.8}
 
 The four title macros was disabled due to the \cmd{\titleref} reimplementation.
@@ -498,18 +568,6 @@
   been removed.
 \end{description}
 
-\section*{Public interfaces removed/disabled in v3.8.2}
-The following macros were discontinued due to the un-embedding of the \Lpack{verbatim package}
-\begin{description}
-\item[\cmd{\tabson}, \cmd{\tabsoff}] Used to be able to enable/disable
-  tab marking support in verbatim texts.
-\item[\cmd{\wrappingon}, \cmd{\wrappingoff}] Used to be able to enable
-  automatic line breaking at white space in verbatim
-  texts.\footnote{The implementation had bugs which were never
-    reported, thus probably not used that much.}
-\item[\cmd{\verbatimbreakchar}] Left on a verbatim line broken at
-  white space.
-\end{description}
 
 
 \endgroup
@@ -2424,8 +2482,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2020-02-19 15:38:41 +0100 (Wed, 19 Feb 2020) $}
-{$LastChangedRevision: 679 $}
+{$LastChangedDate: 2024-02-15 12:01:51 +0100 (Thu, 15 Feb 2024) $}
+{$LastChangedRevision: 820 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Starting off} \label{chap:starting}
@@ -2447,6 +2505,14 @@
 included in the tables are commands that will set the stock size or paper size to 
 the same dimensions.
 
+\begin{note}
+  Note that the \cs{stock...} macros set \cs{stockheight} and
+  \cs{stochwidth} if executed. Similarily \cs{page...} commands sets
+  \cs{pageheight} and \cs{pagewidth}.
+\end{note}
+
+
+
 \begin{table}
 \centering
 \caption{Class stock metric paper size options, and commands}\label{tab:sizeoptsmetric}
@@ -2649,7 +2715,9 @@
   {Class option for imperial octavo stock paper size.}%
 \end{table}
 
+\FloatBlock
 
+
 There are two options that don't really fit into the tables.
 
 \begin{itemize}
@@ -3056,8 +3124,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2023-07-27 17:07:49 +0200 (Thu, 27 Jul 2023) $}
-{$LastChangedRevision: 757 $}
+{$LastChangedDate: 2024-02-15 12:01:51 +0100 (Thu, 15 Feb 2024) $}
+{$LastChangedRevision: 820 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Laying out the page} \label{chap:layingpage}
@@ -3113,6 +3181,8 @@
   stock size and does not need trimming.
 \end{adjustwidth}
 
+\fancybreak{}
+
 On the other hand, if, say, you are designing a document, that is to
 be printed on one type of paper (the stock), and then trimmed to
 another, please read on.
@@ -13292,8 +13362,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2021-06-28 13:55:32 +0200 (Mon, 28 Jun 2021) $}
-{$LastChangedRevision: 715 $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -13640,7 +13710,7 @@
          \kern \z@ \par
  \end{lcode}
 which would cause \ltx\ to stop and complain because of the commands
-that included the \texttt{@}\idxatincode\ (\seeatincode).
+that included the \texttt{@}\idxatincode (\seeatincode).
 If you are modifying any command that includes an 
 \texttt{@}\idxatincode\
 sign then this must be done in either a \file{.sty} file or if in the 
@@ -13770,7 +13840,7 @@
 
 \begin{syntax}
 \cmd{\maxtocdepth}\marg{secname} \\
-\cmd{\settocdepth}\marg{secname} \\
+\cmd{\settocdepth}\marg{secname} \qquad \cmd{\settocdepth*}\marg{secname}\\
 \end{syntax}
 \glossary(maxtocdepth)%
   {\cs{maxtocdepth}\marg{secname}}%
@@ -13795,22 +13865,39 @@
 counter and puts it into the \toc{} to (temporarily) modify what will
 appear.  The \cmd{\settocdepth} and \cmd{\maxtocdepth} macros are from
 the \Lpack{tocvsec2} package~\cite{TOCVSEC2}.
+\begin{caveat}[February 2024]
+  In a situation like this
+\begin{verbatim}
+\settocdepth{section}
+\include{fileA}
+\end{verbatim}
+  The TOC data (\verb+section+) may be writen \emph{after} the data from \verb+fileA+!
 
+  In such a case try using \cmd{\settocdepth*} instead. As it may
+  insert a \cmd{\clearpage}, this code is not the default.
+\end{caveat}
 
 \begin{syntax}
 \cmd{\phantomsection} \\
 \end{syntax}
 \glossary(phantomsection)
-  {\cs{phantomsection}}%
-  {A macro to be put before \cs{addcontentsline} when the \Ppack{hyperref} 
-   package is used.}
-\Note{} The \Lpack{hyperref} package~\cite{HYPERREF} appears to dislike 
-authors using 
- \cmd{\addcontentsline}. To get it to work properly with \Lpack{hyperref}
- you normally have to put \cmd{\phantomsection} (a macro defined within
-this class and the \Lpack{hyperref} package) immediately 
- before \cmd{\addcontentsline}.
+{\cs{phantomsection}}%
+{A macro to be put before \cs{addcontentsline} when the \Ppack{hyperref} 
+package is used.}
+  
+This macro is normally provided by \Lpack{hyperref}
+package~\cite{HYPERREF}, we just make sure it is always available.
+Its use is needed whenever we do something that would cause
+\Lpack{hyperref} to create a link, but twhere that link have no natual
+target to latch on to.  A typical example:
+\begin{verbatim}
+\section*{Dedication}
+\phantomsection
+\addcontentsline{toc}{section}{Dedication}
+\end{verbatim}
+The name of the macro has nothing to do with sections.\footnote{\cs{phantomtarget} might have been a better name.}
 
+
  \subsection{Changing the titles} \label{sec:titles}
 
     Commands are provided for controlling the appearance of the
@@ -13831,7 +13918,23 @@
 Following \ltx\ custom, the title texts are the values
 of the \cmd{\contentsname}, \cmd{\listfigurename} and \cmd{\listtablename}
 commands.
+\begin{caveat}
+  Most people use \Lpack{babel} which then controls the actual text
+  storred in, say \cmd{\contentsname}, and therefore if you change
+  \cmd{\contentsname} in the preamble using \cs{renewcommand}, nothing
+  happens as \Lpack{babel} redefines it later on. The proper method to
+  change say a Danish \cmd{\contentsname} to FooBar would be
+\begin{verbatim}
+\addto\captionsdanish{%
+  \renewcommand\contentsname{FooBar}
+}
+\end{verbatim}
+Note the »s« in \cs{captions...}!  
+\end{caveat}
 
+
+
+
  The commands for controlling the typesetting of the \toc, \lof\ and \lot\ 
 titles all follow a similar pattern, so for convenience (certainly mine, 
 and hopefully yours) in the following descriptions I will use \texttt{X},
@@ -14117,11 +14220,19 @@
 \end{tabular}
 \end{table}
 
+\fancybreak{$*{}*{}*$}
 
+The toc macros for \cmd\book, \cmd\part\ and \cmd\chapter\ slightly
+differs from the other. Two ways, firstly the spacing above the entry
+(see \cs{cftbeforeXskip} later on), is factored out into the following
+macros\label{cftbreak-start}
 \begin{syntax}
 \cmd{\cftbookbreak} \\
 \cmd{\cftpartbreak} \\
 \cmd{\cftchapterbreak} \\
+% \cmd{\cftbeforebookpenalty} \\
+% \cmd{\cftbeforepartpenalty} \\
+% \cmd{\cftbeforechapterpenalty} \\
 \end{syntax}
 \glossary(cftbookbreak)%
   {\cs{cftbookbreak}}%
@@ -14132,27 +14243,131 @@
 \glossary(cftchapterbreak)%
   {\cs{cftchapterbreak}}%
   {Starts a \cs{chapter} entry in the \prtoc.}
-When \cmd{\l at book} starts to typeset a \cmd{\book} entry in the
-\toc{} the first thing it does is to call the macro \cmd{\cftbookbreak}.
-This is defined as:
-\begin{lcode}
-\newcommand{\cftbookbreak}{\addpenalty{-\@highpenalty}}
-\end{lcode}
-which encourages a page break before rather than after the entry. As usual,
-you can change \cmd{\cftbookbreak} to do other things that you feel might
-be useful. The macros \cmd{\cftpartbreak} and \cmd{\cftchapterbreak} apply
-to \cmd{\part} and \cmd{\chapter} entries, respectively, and have the same
-default definitions as \cmd{\cftbookbreak}.
+%
+  Besides adding the vertical space they \emph{also} add a penalty to
+  encourage \ltx\ to do page breaking before it rahter than after
+  it. In pseudo code it can be though of as (Y being one of book, part
+  or chapter).
+\begin{verbatim}
+\newcommand\cftYbreak{
+    add a penanalty
+    add \cftbeforeYskip as vertical space
+}
+\end{verbatim}
+The penalty part is \emph{not} present in the other constructions.
 
+% When \cmd{\l at book} starts to typeset a \cmd{\book} entry in the
+% \toc{} the first thing it does is to call the macro \cmd{\cftbookbreak}.
+% This is defined as:
+% \begin{lcode}
+%   \newcommand{\cftbookbreak}{%
+%     \addpenalty{-\@highpenalty}
+%     \addvspace{\cftbeforebookskip}
+%   }
+% \end{lcode}
+% which encourages a page break before rather than after the entry. As
+% usual, you can change \cmd{\cftbookbreak} to do other things that you
+% feel might be useful. The macros \cmd{\cftpartbreak} and
+% \cmd{\cftchapterbreak} apply to \cmd{\part} and \cmd{\chapter}
+% entries, respectively. Whereas \cmd{\cftpartbreak} has the same
+% definition as \cmd{\cftbookbreak}, \cmd{\cftchapterbreak} does not. By
+% default it uses \cs{vskip} instead of \cs{addvspace}, mimicking the
+% \Lclass{book} class.
+\begin{Changed}[March 2025]
+  Where the vertical spacing was already a part of \cmd{\cftbookbreak}
+  and \cmd{\cftpartbreak}, it was not the case for
+  \cmd{\cftchapterbreak}. This discrepancy was fixed in 2025. Please
+  note that this will cause issues with existing documents if you have
+  modified \cs{cftchapterbreak}. Which was one of the reasons for factoring out the penalties, see below.
+\end{Changed}
+
+As of March 2025, we have factored out the penalties used in the to
+entries for \cmd\book, \cmd\part\ and \cmd\chapter. They all have a default value of \verb|-\@highpenalty|, aka
+\makeatletter
+$-\the\@highpenalty$.
+\makeatother
+Negative values will encourage breaking at this point. The macros can be changed using \cs{renewcommand}.
 \begin{syntax}
+\cmd{\cftbeforebookpenalty} \\
+\cmd{\cftbeforepartpenalty} \\
+\cmd{\cftbeforechapterpenalty} \\
+\end{syntax}
+\glossary(cftbeforebookpenalty)%
+  {\cs{cftbeforebookpenalty}}%
+  {Penalty before a book entry in ToC.}
+\glossary(cftbeforepartpenalty)%
+  {\cs{cftbeforepartpenalty}}%
+  {Penalty before a part entry in ToC.}
+\glossary(cftbeforechapterpenalty)%
+  {\cs{cftbeforechapterpenalty}}%
+  {Penalty before a chapter entry in ToC.}
+
+
+\begin{Changed}[March 2025]
+  There is an interesting inheritance from the standard book
+  class. Both \cs{cftbeforebookskip} and \cs{cftbeforepartskip} are
+  applied using \cs{addvspace} whereas \cs{cftbeforechapterskip} uses
+  \cs{vskip}. Nobody really knows why the standard classes split it
+  like this, but it has been like this for more than 35 years.
+
+  Why is this relevant? Because overall \cs{addvspace} would be a better choice. 
+  The difference can be seen with these two documents
+\begin{verbatim}
+\documentclass{memoir}
+\setlength\cftbeforechapterskip{5em} % more noticeable
+\begin{document}
+\tableofcontents*
+\chapter{Foo}
+\end{document}
+%
+\documentclass{memoir}
+\setlength\cftbeforepartskip{5em} % more noticeable
+\begin{document}
+\tableofcontents*
+\part{Foo}
+\end{document}
+\end{verbatim}
+  As we see \cs{cftbeforechapterskip} is always applied when it is the
+  first element in the ToC. But this is not the case for \cs{part}.  The
+  difference is down to \cmd{\addvspace} vs. \cmd{\vskip}. For user
+  convenience we have now made this difference configurable, see below.
+\end{Changed}
+\begin{syntax}
+  \lnc{\setcftvspacecmd}\marg{macro}
+\end{syntax}
+\glossary(setcftvspacecmd)
+{\cs{setcftvspacecmd}}
+{Macro to set which vertical spacing command is by \cs{chapter} and friends that stem from \cs{newlistentry}}
+%
+This macro can set the vertical spacing command used by \cs{chapter}
+and the friends that stem from \cmd{\newlistentry}. The default is
+\cs{vskip}, a better option would be to use \cs{addvspace}. But as the
+comment above shows, changing the command to be \cs{addvspace} by
+default, would change the first page of the ToC for thousands of
+existing documents. Thus we leave it to the user to manually reset the
+macro using
+\begin{verbatim}
+\setcftvspacecmd{\addvspace}
+\end{verbatim}
+in your preamble.\label{cftbreak-end}
+
+\fancybreak{}
+
+Back to the macros that control the look of the entries:
+\begin{syntax}
 \lnc{\cftbeforeKskip} \\
 \end{syntax}
 \glossary(cftbeforeKskip)%
-  {\cs{cftbeforeKskip}}%
-  {Generic vertical space before a `K' entry in a \listofx.}
- This length controls the vertical space before an entry. It can be changed
- by using \cmd{\setlength}. 
+{\cs{cftbeforeKskip}}%
+{Generic vertical space before a `K' entry in a \listofx.}
+This length controls the vertical space before an entry. It can be changed
+by using \cmd{\setlength}. 
 
+
+
+
+
+ 
 \begin{syntax}
 \lnc{\cftKindent} \\
 \end{syntax}
@@ -14216,7 +14431,15 @@
   \Lpack{hyperref} package.
 \end{caveat}
 
+\begin{caveat}
+  In some specialised designs it can be necessary to patch some
+  \cs{l at ...} commands in order to get rid of some of the grouping
+  described in the pseudo code above. How to do this is not described
+  in this manual.
+\end{caveat}
 
+
+
 \begin{syntax}
 \cmd{\cftKname} \\
 \end{syntax}
@@ -14729,7 +14952,8 @@
 \toc\ and you needed some aspects to be formatted differently.
 \begin{syntax}
 \cmd{\cftinsertcode}\marg{name}\marg{code} \\
-\cmd{\cftinserthook}\marg{file}\marg{name} \\
+\cmd{\cftinserthook}\marg{file}\marg{name} \qquad
+\cmd{\cftinserthook*}\marg{file}\marg{name} \\
 \end{syntax}
 \glossary(cftinsertcode)
   {\cs{cftinsertcode}\marg{name}\marg{code}}%
@@ -14742,7 +14966,25 @@
 the (\texttt{toc}, \texttt{lof}, \ldots) file and \meta{name} is the `name'
 of the hook. The \meta{code} for the hook is specified via \cmd{\cftinsertcode}
 where \meta{name} is the name you give to the hook. These can be used to make
-alterations to a \listofx\ on the fly. For example:
+alterations to a \listofx\ on the fly.
+
+\begin{caveat}[February 2024]
+  If \cmd{\cftinserthook} is placed between \cmd{\include}'s, one may experience
+  a timing issue, such that, say,
+\begin{verbatim}
+\cftinserthook{toc}{preB}
+\include{fileB}
+\end{verbatim}
+  inserts \verb+preB+ \emph{after} the data from \verb+fileB+!, making
+  it rather unusable.
+
+In that case use try \cmd{\cftinserthook*}. Given that
+\cmd{\cftinserthook*} may issue a \cmd{\clearpage}, which might be
+undesirable in documents without \cmd{\include}, this code is not the
+default.
+\end{caveat}
+
+For example:
 \begin{lcode}
 \cftinsertcode{A}{%
   \renewcommand*{\cftchapterfont}{\normalfont\scshape}
@@ -15606,8 +15848,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2021-03-22 11:32:59 +0100 (Mon, 22 Mar 2021) $}
-{$LastChangedRevision: 705 $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 
@@ -18292,7 +18534,8 @@
 the \idxatincode\texttt{@} character, and it's not in a class or package 
 file, you have
 to do it within a \cmd{\makeatletter} and \cmd{\makeatother} pairing
-(\seeatincode). So,
+(\seeatincode).
+So,
 if you modify the \cmd{\fnum at figure} command anywhere in your document
 it has to be done as:
 \begin{lcode}
@@ -20516,8 +20759,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2023-07-27 17:07:49 +0200 (Thu, 27 Jul 2023) $}
-{$LastChangedRevision: 757 $}
+{$LastChangedDate: 2025-03-04 12:57:30 +0100 (Tue, 04 Mar 2025) $}
+{$LastChangedRevision: 831 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Page notes} \label{chap:mnotes}
@@ -21371,13 +21614,20 @@
 note fell on the previous page). If this occurs then inserting the
 \cmd{\strictpagecheck} declaration before any \cmd{\marginpar} command
 is used will prevent this, at the cost of at least one additional
-\ltx\ run. Note: In twocolumn mode the \Lpack{mparhack} package is
-automatically loaded as it fixes a bug, there the test for whether one
-is in the first column may fail.\footnote{If you want to use
-  \Lpack{mparhack} with the \Lopt{debug} option, use
-  \cs{RequirePackage[debug]\{mparhack\}} before \cs{documentclass}.}
+\ltx\ run.
+\begin{caveat}[March 2025]
+  In two column mode there is a bug in the output routine where the
+  test for whether you are in the first or the second column may fail.
+  In this case you can load the \Lpack{mparhack} package and see if
+  that helps. As the name suggestes it is a bit of a hack and may be
+  incompatible with other packages.
 
+  Earlier the class would autoload \Ppack{mparhack} in two column
+  mode, but as of March 2025, we no longer do so, as there are
+  relevant packages known to be incompatible with it.
+\end{caveat}
 
+
 \section{Side notes}
 
     The vertical position of margin notes\index{margin note!moved} 
@@ -22965,9 +23215,9 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2013-04-24 17:14:15 +0200 (Wed, 24 Apr 2013) $}
-{$LastChangedRevision: 442 $}
-{$LastChangedBy: daleif $}
+{$LastChangedDate: 2024-02-06 16:53:11 +0100 (Tue, 06 Feb 2024) $}
+{$LastChangedRevision: 817 $}
+{$LastChangedBy: daleif at math.au.dk $}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %\clearpage
@@ -23505,11 +23755,28 @@
 For example, 
 \verb?\linenumberfrequency{5}?
 will number every fifth line. The default is \verb?\linenumberfrequency{0}? 
-which prevents any numbering. The \cmd{\setverselinenums} macro can be
-used to specify that the number of the first line of the following \Ie{verse}
-shall be \meta{first} and the first printed number shall be \meta{startat}.
-For example, perhaps you are quoting part of a numbered poem. The original
-numbers every tenth line but if your extract starts with line 7, then
+which prevents any numbering.
+
+\begin{Changed}[February 2024]
+  Verse line numbers are now added at the start of the line via a
+  paragraph hook.\footnotemark\ This affects how lines with a
+  automatic line break are numbered. They are now always aligned with the
+  first line of a broken line.
+
+  This change also remove the need to have \bs\bs\ after the last line
+  of a poem in order to have it numbered.
+\end{Changed}
+\footnotetext{Internally all the lines of a verse are actually
+  separate paragraphs. The line numbers are added via a hook into the
+  start of paragraphs inside verse and friends.}
+
+
+The \cmd{\setverselinenums} macro can be used to specify that the
+number of the first line of the following \Ie{verse} shall be
+\meta{first} and the first printed number shall be \meta{startat}.
+For example, perhaps you are quoting part of a numbered poem. The
+original numbers every tenth line but if your extract starts with line
+7, then
 \begin{lcode}
 \linenumberfrequency{10}
 \setverselinenums{7}{10}
@@ -28332,8 +28599,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2024-01-25 16:57:21 +0100 (Thu, 25 Jan 2024) $}
-{$LastChangedRevision: 805 $}
+{$LastChangedDate: 2024-02-01 17:25:29 +0100 (Thu, 01 Feb 2024) $}
+{$LastChangedRevision: 813 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -28807,8 +29074,11 @@
 in other orthographies.
 
     The \cmd{\quarkmarks} declaration uses \cmd{\printtime}, so be careful
-if you change it.
+    if you change it.
 
+
+\fancybreak{}
+    
     Nicola Talbot's \Lpack{datetime2} package~\cite{DATETIME2} provides
 a much more comprehensive collection of styles for printing the time;
 also for dates.
@@ -28857,14 +29127,17 @@
 \cmd{\newcounter} command to typeset arabic numerals.
 
 \begin{syntax}
-\cmd{\counterwithin}\marg{ctr}\marg{within} \\
-\cmd{\counterwithin*}\marg{ctr}\marg{within} \\
+\cmd{\counterwithin}\oarg{format}\marg{ctr}\marg{within}\footnotemark \\
+\cmd{\counterwithin*}\marg{ctr}\marg{within}\footnotemark[\thefootnote] \\
 \end{syntax}
+\footnotetext{These have been provided by the kernel since 2018, thus is no longer provided by the class it self. The optional argment was added in 2021.}
 \glossary(counterwithin)%
-  {\cs{counterwithin}\marg{ctr}\marg{within}}%
+  {\cs{counterwithin}\oarg{format}\marg{ctr}\marg{within}}%
   {Makes the counter \Pcn{ctr} (created via \cs{newcounter}) act as though 
-   it had been initially defined to be reset by counter \Pcn{within}.
-   It also redefines \cs{thectr} to include \cs{thewithin}.}
+   it had been initially defined to be reset by counter \Pcn{within} (specifically it resets whenever \meta{within} is stepped).
+   It also redefines \cs{thectr} to 
+   \cs{thewithin.}\meta{format}\texttt\{\meta{within}\texttt\} (default format being \cs{arabic}).
+ }
 \glossary(counterwithin*)%
   {\cs{counterwithin*}\marg{ctr}\marg{within}}%
   {Makes the counter \Pcn{ctr} (created via \cs{newcounter}) act as though 
@@ -28872,20 +29145,21 @@
    the original definition of \cs{thectr}.}
 The \cmd{\counterwithin} macro makes a \meta{ctr} that has been initially
 defined by \verb?\newcounter{ctr}? act as though it had been defined by
-\verb?\newcounter{ctr}[within]?. It also redefines the \cs{thectr} command
-to be \verb?\thewithin.\arabic{ctr}?. The starred version of the command
-does nothing to the original definition of \cs{thectr}.
+\verb?\newcounter{ctr}[within]? (that is it resets whenever \meta{within} is stepped).
+It also redefines the \cs{thectr} command to be \verb?\thewithin.format{ctr}?
+(default format is \cs{arabic}). The starred version of the command does not change 
+he original definition of \cs{thectr}.
 
 \begin{syntax}
-\cmd{\counterwithout}\marg{ctr}\marg{within} \\
-\cmd{\counterwithout*}\marg{ctr}\marg{within} \\
+\cmd{\counterwithout}\oarg{format}\marg{ctr}\marg{within}\footnotemark[\thefootnote] \\
+\cmd{\counterwithout*}\marg{ctr}\marg{within}\footnotemark[\thefootnote] \\
 \end{syntax}
 \glossary(counterwithout)%
   {\cs{counterwithout}\marg{ctr}\marg{within}}%
   {Makes the counter \Pcn{ctr} (created via 
    \cs{newcounter}\marg{ctr}\oarg{within}) act as though 
-   it had been initially defined via \cs{newcounter}\marg{ctr}.
-   It also redefines \cs{thectr} to typeset as arabic numerals.}
+   it had been initially defined via \cs{newcounter}\marg{ctr} (that is removes it from being reset whenever \meta{within} is stepped).
+   It also redefines \cs{thectr} to be \meta{format}\texttt\{\meta{ctr}\texttt\} (default format being \cs{arabic}).}
 \glossary(counterwithout*)%
   {\cs{counterwithout*}\marg{ctr}\marg{within}}%
   {Makes the counter \Pcn{ctr} (created via 
@@ -28895,8 +29169,10 @@
 The \cmd{\counterwithout} macro makes the \Pcn{ctr} counter that has been 
 initially
 defined by \verb?\newcounter{ctr}[within]? act as though it had been defined by
-\verb?\newcounter{ctr}?. It also redefines the \cs{thectr} command
-to be \verb?\arabic{ctr}?. The starred version of the command
+\verb?\newcounter{ctr}?. In other terms, if \meta{ctr} is being reset whenever
+\meta{within} is stepped, \cs{counterwithout} removes \meta{ctr} from this reset.
+Additionally it redefines the \cs{thectr} command
+to be \verb?format{ctr}? (default format is \cs{arabic}). The starred version of the command
 does nothing to the original definition of \verb?\thectr?.
 
     Any number of \verb?\counterwithin{ctr}{...}? and \verb?\counterwithout{ctr}{...}?
@@ -28906,16 +29182,10 @@
 the typesetting style use \cmd{\renewcommand} on \cs{thectr}.
 
 
-\begin{caveat}
-  As of 2018 \cmd{\counterwithout} and \cmd{\counterwithin} will be
-  provided by the \LaTeX-kernel, thus we only provide it if it does
-  not already exist.
-\end{caveat}
 
 
 
 
-
 \LMnote{2010/01/30}{Added \cs{letcountercounter}}
 \begin{syntax}
   \cmd{\letcountercounter}\marg{counterA}\marg{counterB}\\
@@ -29003,8 +29273,8 @@
 \section{Changing macros} \label{sec:addtodef}
 
 \begin{recommended}
-  See also the \Lpack{xpatch} (which extends the patching capabilities
-  of \Lpack{etoolbox}) and \Lpack{letltxmacro} packages.
+  See also the \Lpack{xpatch}/\Lpack{etoolbox} and \Lpack{letltxmacro}
+  packages.\footnotemark
 
   Additionally the LaTeX-format of October 2020 include some new
   hooking features fx to hook into environments, see \cite{LTHOOKS}
@@ -29011,11 +29281,15 @@
   (see section 2.8.1 for some utility macros). The new format also
   adds \cs{NewCommandCopy} and \cs{RenewCommandCopy} which are
   extended versions of what \Lpack{letltxmacro} provides.
+
+  Note that \cs{NewCommandCopy} will be preferred over \cs{let} as
+  more and more macros are made robust which \cs{let} cannot handle
+  easily.
 \end{recommended}
+\footnotetext{\Lpack{xpatch} and thus also \Lpack{etoolbox} are automatically loaded by the class.}
 
 
 
-
      Commands are provided for extending simple macro 
 definitions.\index{extend a macro}\index{add to a macro}
 
@@ -29032,7 +29306,13 @@
   {\cs{addtoiargdef}\marg{macro}\marg{prepend}\marg{append}}%
   {Inserts \meta{prepend} at the start of the current definition of 
    \meta{macro} (which takes a single argument) and \meta{append} at the 
-    end, treating the result as if it had been defined by \cs{renewcommand}.}
+   end, treating the result as if it had been defined by \cs{renewcommand}.}
+\begin{Deprecated}[February 2024]
+  Both macros \cs{addtodef} and \cs{addtoiargdef} will be removed in
+  2025. The same (and better) effect can be done via \cmd{\patchcmd},
+  \cmd{\pretocmd} and \cmd{\apptocmd} from \Lpack{etoolbox} which is
+  already loaded.
+\end{Deprecated}
 The macro \cmd{\addtodef} inserts \meta{prepend} at the start of the
 current definition of \meta{macro} and puts \meta{append} at the end,
 where \meta{macro} is the name of a macro (including the backslash) which 
@@ -29094,6 +29374,11 @@
   {Inserts \meta{prepend} at the start of the current definition of 
    \meta{macro} (which takes a single argument) and \meta{append} at the 
    end, treating the result as if it had been defined by \cs{renewcommand*}.}
+\begin{Deprecated}[February 2024]
+  Both macros \cs{addtodef*} and \cs{addtoiargdef*} will be removed in
+  2025. As mentioned above their effect can be done using tools from
+  \Lpack{etoolbox}.
+\end{Deprecated}
 These starred versions are for use when the original \meta{macro}
 was defined via \cmd{\newcommand*}. Using the starred versions is
 like using \cmd{\renewcommand*} and the unstarred versions are like
@@ -29113,7 +29398,12 @@
   {\cs{patchcommand}\marg{macro}\marg{start-code}\marg{end-code}}%
   {Inserts \meta{start-code} before the current definition of the 
    \meta{macro} and \marg{end-code} at the end of the current definition.}%
+\begin{Deprecated}[February 2024]
+  \cs{patchcommand} will be removed in 2025. Use the various patching
+  macros from \Lpack{etoolbox} or \Lpack{xpatch} instead.
+\end{Deprecated}
 
+ 
 The \cmd{\patchcommand} is from the late 
 Michael Downes'\index{Downes, Michael}
 \Lpack{patchcmd} package~\cite{PATCHCMD}. 
@@ -29187,9 +29477,16 @@
 }
 \end{lcode}
 
-See also the tests available in \Lpack{etoolbox}.
+The \Lpack{etoolbox} package as a simple alternative:
+\begin{syntax}
+  \cs{ifstrequal}\marg{string}\marg{string}\marg{true}\marg{false}
+\end{syntax}
+In the modern \LaTeX\ kernel, the expl3 layer offers a plethora of
+extra string checking macros. For example \verb+\str_case_e:nnTF+
+which compares a string to a list of strings and code for when that
+string is equal. This saves a lot of space compared to nested
+\cs{ifsamename} towers.\footnote{See the current implementation of \cs{settypeoutlayoutunit} for an example.}
 
-
 \section{Odd/even page checking}
 
 It is difficult to check robustly if the current page is odd or even
@@ -29691,9 +29988,15 @@
 In normal text you can typeset superscripts like H\textsuperscript{+} and 
 subscripts like H\textsubscript{2}O without going into math mode.
 \end{egresult}
+Though for chemical compounds packages like \Lpack{mhchem} and
+\Lpack{chemmacros} are worth a time saving look.
 
+
 \section{An array data structure}
 
+\fxnote{This will probably also be deprecated}
+
+
    The class includes some macros for supporting the \Ie{patverse}
 environment which may be more generally useful. 
 
@@ -29796,6 +30099,8 @@
 
 \section{Checking the processor}
 
+\fxnote{recheck this section}
+
 \subsection{Checking for pdfLaTeX}
 
     Both \ltx\ and \pixpdfltx\ can be run on the same document. \ltx\ produces
@@ -30895,8 +31200,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2020-03-25 19:00:55 +0100 (Wed, 25 Mar 2020) $}
-{$LastChangedRevision: 686 $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 
@@ -31446,7 +31751,8 @@
     I have presented the code in this chapter as though it would be  put
 into the preamble\index{preamble}, hence the use of \cmd{\makeatletter} and 
 \cmd{\makeatother} to surround macros that include the 
-\texttt{@}\idxatincode\ character (\seeatincode). The
+\texttt{@}\idxatincode\ character (\seeatincode).
+The
 code could just as easily be put into a package\index{package} called, say, 
 \Lpack{bringhurst}. That is, by putting all the code, except for the
 \cmd{\makeatletter} and \cmd{\makeatother} commands, into a file called
@@ -31476,9 +31782,9 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2014-03-31 11:34:44 +0200 (Mon, 31 Mar 2014) $}
-{$LastChangedRevision: 480 $}
-{$LastChangedBy: daleif $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
+{$LastChangedBy: daleif at math.au.dk $}
 
 \PWnote{2009/07/05}{Added thesis design chapter}
 \PWnote{2009/07/08}{Revised thesis design chapter}
@@ -34913,9 +35219,9 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2014-03-31 11:34:44 +0200 (Mon, 31 Mar 2014) $}
-{$LastChangedRevision: 480 $}
-{$LastChangedBy: daleif $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
+{$LastChangedBy: daleif at math.au.dk $}
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -34923,6 +35229,13 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+
+\begin{note}
+  This appendix will probably disappear in the future or at least be heavily rewritten.
+  \sourceatright{/maintainer, March 2025.}
+\end{note}
+
+
     Strictly speaking, \ltx\ is a set of macros built on top of 
 the \tx\ program originally developed by 
 Donald Knuth~\cite{TEXPROGRAM,TEXBOOK} 
@@ -35171,8 +35484,60 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+% \fancybreak{}
 
 
+% \begin{Changed}[March 2025]
+%   The rest of this chapter has been removed. It contained some low
+%   level explanation about TeX programming, which is not really inside
+%   the scope of this manual. Plus if was so low level that it should
+%   not be used by \ltx\ users.
+
+%   If one really want to do some \ltx\ programming these days it
+%   is probably better to use more high level tools.
+%   \begin{itemize}
+%   \item For some slightly advanced coding for user commands see the
+%     manual (\cite{ETOOLBOX}) for \Lpack{etoolbox} (the package is
+%     autoloaded by \theclass).
+%   \item If you want to use the really impressive programming tools
+%     contained in the modern \ltx\ kernel see \cite{EXPL3}, aka the
+%     fabeled \ltx3 interfaces.\footnotemark\ Nowadays just referred to
+%     as Expl3. It can be a bit daunting to get started with, but once
+%     you understand it, there are a lot of build in tools that can
+%     handle tasks that are hard to do in standard \ltx. A personal
+%     favorite is \verb|\str_case_e:nn| which enables us to do
+%     \setverbatimfont{\footnotesize\ttfamily}
+% \begin{verbatim}
+% \newcommand\settypeoutlayoutunit[1]{
+%   \def\mem at tl@unit{#1}
+%   \str_case_e:nnF{#1}{
+%     {pt}{ \def\mem at tl@unitperpt{1.0}       }
+%     {pc}{ \def\mem at tl@unitperpt{0.083333}  }
+%     {in}{ \def\mem at tl@unitperpt{0.013837}  }
+%     {mm}{ \def\mem at tl@unitperpt{0.351459}  }
+%     {cm}{ \def\mem at tl@unitperpt{0.0351459} }
+%     {bp}{ \def\mem at tl@unitperpt{0.996264}  }
+%     {dd}{ \def\mem at tl@unitperpt{0.9345718} }
+%     {cc}{ \def\mem at tl@unitperpt{0.0778809} }
+%   }{ % or error
+%     \@memerror{Unknown~unit~'#1'~not~suitable~for~layout\MessageBreak listing}{}
+%   }
+% }
+% \end{verbatim}
+%     The original memoir version was 50+ lines of tests. Expl3 also
+%     include tools to create data structures and loop through them etc.
+%   \end{itemize}
+% \end{Changed}
+% \footnotetext{It was once the plan to do a version 3 of the \ltx\
+%   format. As it would be hard to make users switch to a totally new
+%   setup, the interface has instead been moved to the \ltx\ kernel.}
+
+
+
+
+
+
+
 \section{Syntax}
 
     The \ltx\ syntax that you normally see is pretty regular. 
@@ -35993,6 +36358,8 @@
 
 \section{Programming}
 
+
+
     One of the commonest programming operations is to possibly do one thing if
 something is true and to possibly do another thing if it is not true. Generally
 speaking, this is called an `if-then-else'\index{if-then-else} or
@@ -36283,9 +36650,9 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2014-03-31 11:34:44 +0200 (Mon, 31 Mar 2014) $}
-{$LastChangedRevision: 480 $}
-{$LastChangedBy: daleif $}
+{$LastChangedDate: 2025-03-06 13:42:47 +0100 (Thu, 06 Mar 2025) $}
+{$LastChangedRevision: 834 $}
+{$LastChangedBy: daleif at math.au.dk $}
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -38827,7 +39194,7 @@
 \pagestyle{plainmarkruled}
 %%\chapterstyle{section}
 
-\renewcommand*{\begintheglossaryhook}{\small}
+\renewcommand*{\begintheglossaryhook}{\small} 
 %%%\glossaryintoc
 \printglossary
 
@@ -40823,17 +41190,19 @@
 Peter Wilson.
 \newblock {\em The \LaTeX\ memoir class for configurable book typesetting:
   source code}, 2023.
-\newblock \viaCTANurl{/macros/latex/contrib/memoir/}.
+\newblock Maintained by Lars Madsen.
+  \viaCTANurl{/macros/latex/contrib/memoir/}.
 
 \bibitem[Wil23b]{MEMMAN}
 Peter Wilson.
 \newblock {\em The Memoir Class for Configurable Typesetting -- User Guide},
   2023.
-\newblock \viaCTANurl{/macros/latex/contrib/memoir/}.
+\newblock Maintained by Lars Madsen.
+  \viaCTANurl{/macros/latex/contrib/memoir/}.
 
-\bibitem[Wri23]{SIUNITX}
+\bibitem[Wri25]{SIUNITX}
 Joseph Wright.
-\newblock {\em Siunitx — A comprehensive (SI) units package}, 2023.
+\newblock {\em Siunitx — A comprehensive (SI) units package}, 2025.
 \newblock \viaCTANurl{/macros/latex/contrib/siunitx}.
 
 \bibitem[Zan10]{FANCYBOX}

Modified: trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty
===================================================================
--- trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty	2025-03-06 21:32:04 UTC (rev 74481)
@@ -152,18 +152,21 @@
   \let\precistoctext\oldprecistoctext
   \let\cftchapterfillnum\oldcftchapterfillnum
   \let\cftchapterformatpnum\oldcftchapterformatpnum
-  \addtodef{\cftchapterbreak}{\par}{}
+  % \addtodef{\cftchapterbreak}{\par}{}
+  \pretocmd\cftchapterbreak\par
   \renewcommand*{\cftchapterfont}{\normalfont\sffamily}
   \renewcommand*{\cftchapterleader}{\sffamily\cftdotfill{\cftchapterdotsep}}
   \renewcommand*{\cftchapterafterpnum}{}
-  \renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}
+  %\renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}
   \setpnumwidth{2.55em}
   \setrmarg{3.55em}
   \setcounter{tocdepth}{2}
   \let\cftpartformatpnum\oldcftpartformatpnum
-  \addtodef{\cftpartbreak}{\par}{}
+  %\addtodef{\cftpartbreak}{\par}{}
+  \pretocmd\cftpartbreak\par
   \let\cftbookformatpnum\oldcftbookformatpnum
-  \addtodef{\cftbookbreak}{\par}{}
+  % \addtodef{\cftbookbreak}{\par}{}
+  \pretocmd\cftbookbreak\par
 }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1147,8 +1150,11 @@
 \newenvironment{hint}{\par\medskip\noindent\textbf{\textit{Hint.}}\enskip\itshape}{\par\medskip}
 \renewcommand{\cmdprint}[1]{\textup{\texttt{\string#1}}}
 
+\newenvironment{Deprecated}[1][]{\begin{leftbar}\noindent\textbf{\textit{Deprecated.}\@ifmtarg{#1}{}{\Added{#1}}}\enskip}{\end{leftbar}}
 
 
+
+
 \newenvironment{recommended}{%
   \@zeroseps%
   \parskip\z@ \topsep\z@%

Modified: trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx	2025-03-06 21:32:04 UTC (rev 74481)
@@ -20,7 +20,7 @@
 % This work consists of the files listed in the README file.
 % 
 % \fi
-% \CheckSum{28075} 
+% \CheckSum{28340} 
 %
 % \changes{v0.1}{2001/05/20}{First public alpha release}
 % \changes{v0.2}{2001/06/03}{First beta release}
@@ -205,6 +205,7 @@
 % \def\fileversion{v3.8}          \def\filedate{2023/08/08} 
 % \def\fileversion{v3.8.1}          \def\filedate{2023/08/21} 
 % \def\fileversion{v3.8.2}          \def\filedate{2024/01/26} 
+% \def\fileversion{v3.8.3}          \def\filedate{2025/03/06} 
 % \title{The LaTeX \Lpack{memoir} class for configurable book 
 %        typesetting: Source code\thanks{This
 %        file (\texttt{\dtxfile}) has version number \fileversion, last revised
@@ -353,6 +354,8 @@
 \newcommand*{\Lhook}[1]{\meta{#1}}              % name of a hook
 \newenvironment{PW}{\em}{}
 \newenvironment{dlf}{\em}{}
+\newcommand*\MarkedForDeprecation[1]{\par\noindent%
+  \textcolor{red}{#1 is marked for deprecation}\par}
 \newcommand*{\theTeXbook}{\textit{The \TeX book}}
 \let\oldllap\llap
 \def\llap#1{\oldllap{#1\quad}} % might be evil
@@ -437,8 +440,8 @@
 %    Announce the name, option files and version for LaTeX2e files:
 %    \begin{macrocode}
 %<class>\ProvidesClass{memoir}%
-%<class>  [2024/01/26 v3.8.2 configurable book, report, article document class]
-%<class>\newcommand\memversion{v3.8.2, 2024/01/26}
+%<class>  [2025/03/06 v3.8.3 configurable book, report, article document class]
+%<class>\newcommand\memversion{v3.8.3, 2025/03/06}
 %    \end{macrocode}
 %
 % \changes{v3.7m}{2020/08/05}{Added \cs{IfFormatAtLeastTF}}
@@ -468,7 +471,8 @@
 %<class>  \ClassError{memoir}{%
 %<class>    Your LaTeX release is too old.\MessageBreak
 %<class>    The memoir class requires at LaTeX format\MessageBreak
-%<class>    from at least \mem at atleast@kernel\space  onwards. Please update your\MessageBreak
+%<class>    from at least \mem at atleast@kernel\space  onwards.
+%<class>    Please update your\MessageBreak
 %<class>    entire LaTeX installation instead of manually updating\MessageBreak
 %<class>    just memoir}{}
 %<class>    \batchmode\read-1to\@tempa% evil mode engaged
@@ -518,8 +522,48 @@
 \RequirePackage{xpatch}      
 %    \end{macrocode}
 %
+% (2024/01/31): There are a lot of excessive code in the class that
+% probably does not have much use anymore. We will start deprecating
+% stuff set for removal. In order to provide a transition period we
+% provide a few macros to mark such that they give a warning (we only
+% give one per macro).
 %
+% \begin{macro}{\MarkDeprecated}
+%   \changes{v3.8.3}{2024/01/31}{Added this deprecation macro}
+%   \cs{MarkDeprecated(*)}\marg{env or macro}\marg{when comment}, can
+%   be used to add a deprecation warning to macros or envs. We
+%   automatically remove \cs{} from macro names when needed. Normally
+%   er add a marker macro to note that we have shown the warning
+%   once. The starred version shows the warning at all uses.  ^^A It
+%   can be
+% ^^A added to a command either manually or via a hook:
+% ^^A \begin{verbatim}
+% ^^A \AddToHook{cmd/foo/before}{\MarkDeprecated{\foo}{start 2025}}
+% ^^A \AddToHook{env/foo/before}{\MarkDeprecated{foo}{start 2025}}
+% ^^A \end{verbatim}
+% ^^A Note that the hooks are added at the start of the document, so we
+% ^^A cannot use it to add to our own macros and reveil where they are
+% ^^A used. The starred version will warn every time the macro is used.
+%    \begin{macrocode}
+\ExplSyntaxOn
+% note that this is not technically correct expl3 code
+\NewDocumentCommand\MarkDeprecated{smm}{
+  % see if macro exists, if so don't give warning
+  \cs_if_exist:cTF {__memoir_deprecated_\cs_to_str:N #2:}{}{% already showed one warning
+    % marker macro did not exist, globally define it and give warning
+    \IfBooleanF{#1}{\cs_gset:cn {__memoir_deprecated_\cs_to_str:N #2:}{}}
+    \@memwarn{
+      \string#2~is~marked~deprecated~and~will~be\MessageBreak
+      removed~#3
+    }
+  }
+}
+\ExplSyntaxOff
+
+%    \end{macrocode}
+% \end{macro}
 %
+%
 % Note (2001/08/03): Old versions of the \Lpack{amsmath} package did odd
 % things with \cs{@tempa}, \cs{@tempb} and \cs{@tempc}. I have now replaced
 % any use of these with \cs{@memtempa}, etc.
@@ -741,40 +785,10 @@
 % \changes{v0.3}{2001/07/09}{Deleted \cs{fillline} and \cs{makecommand} as
 % they were not used}
 %
+%  
+% \changes{v3.8.3}{2024/02/02}{Deleted \cs{kill at lastcounter} as it is not used}
+% 
 %
-% \begin{macro}{\kill at lastcounter}
-% \cs{kill at lastcounter}\marg{cntr}\footnote{With thanks to Stefan Ulrich
-% (\texttt{ulrich at cis.uni-muenchen.de}) who answered a question on this
-% on \ctt, 2001/07/09. (Also answered by Heiko Oberdiek,
-% \texttt{oberdiek at ruf.uni-freiburg.de}).}
-%  kills the counter \meta{cntr}. This macro is an extension to the
-% suggestions as it also makes the last count register reusable.
-% \emph{The macro must only be used when the last allocated counter is to
-% be killed.}
-% For example with:\\
-% \verb?\newcounter{fred} \kill at lastcounter{fred} \newcounter{fred}? \\
-% there is no error with the second \cs{newcounter}.
-% \changes{v0.3}{2001/07/09}{Added \cs{kill at counter}}
-% \changes{v1.618}{2005/09/02}{Ensured \cs{kill at counter} zeroed the counter}
-%    \begin{macrocode}
-\newcommand{\kill at lastcounter}[1]{%
-%    \end{macrocode}
-% Deallocate the last counter register. From \theTeXbook, \verb?\count10? is
-% the number of the last register. The counter should be zeroed before being
-% deallocated otherwise an immediatally following \cs{newcount} may not
-% be zero when allocated\footnote{Discovered and fix provided by Robert 
-% Schlicht on 2005/08/31.}.
-%    \begin{macrocode}
-  \count\count10 \z@
-  \advance\count10 \m at ne
-%    \end{macrocode}
-% Set the internal counter definition to \cs{relax}.
-%    \begin{macrocode}
-  \expandafter\let\csname c@#1\endcsname\relax}
-
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\@name at p@xdf}
 % \begin{macro}{\@name at unresp@xdef}
 % \begin{macro}{\@namelet}
@@ -981,16 +995,18 @@
 % \end{macro}
 %
 % \begin{macro}{\@emulated at package}
-% The workhorse for the user commands.
+%   The workhorse for the user commands. At some point we might want
+%   to do this differently as many users does not realise that a
+%   package is being blocked by memoir.
 %    \begin{macrocode}
 \def\@emulated at package#1[#2]{%
   \expandafter\xdef\csname ver@#1.\@pkgextension\endcsname{#2}%
   \@ifundefined{opt@#1.\@pkgextension}%
-    {\@namedef{opt@#1.\@pkgextension}{}}{}%
+  {\@namedef{opt@#1.\@pkgextension}{}}{}%
   \wlog{Package #1 \ifx\@empty#2\else[#2] \fi 
-        \if,\csname opt@#1.\@pkgextension\endcsname,\else
-        (with options \csname opt@#1.\@pkgextension\endcsname) \fi
-        emulated by \@currname.}%
+    \if,\csname opt@#1.\@pkgextension\endcsname,\else
+      (with options \csname opt@#1.\@pkgextension\endcsname) \fi
+    emulated by \@currname.}%
 }
 \@onlypreamble\EmulatedPackage
 \@onlypreamble\EmulatedPackageWithOptions
@@ -1006,7 +1022,8 @@
 % \changes{v1.6180339}{2008/07/23}{Fixed \cs{DisemulatePackage} from mempatch v5.1}
 %    \begin{macrocode}
 \newcommand*{\DisemulatePackage}[1]{%
-  \@namelet{ver@#1.\@pkgextension}\relax}
+  \@namelet{ver@#1.\@pkgextension}\relax
+}
 \@onlypreamble\DisemulatePackage
 
 %    \end{macrocode}
@@ -1044,8 +1061,8 @@
 % suggestion from David Carlisle we change the code a little such that
 % \#\ is needed}
 % We add a \cs{temp} trick suggested by David Carlisle as the old code
-% required \#\ doubling and the new does not. To be backwards
-% compatible we force required \#\ doubling.
+% required \texttt{\#} doubling and the new does not. To be backwards
+% compatible we force required \texttt{\#} doubling.
 % \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
 % hook name}
 %    \begin{macrocode}
@@ -1702,8 +1719,14 @@
 %    The kernel \cs{@star at or@long} and \cs{l at ngrel@x} commands 
 % (in \file{ltdefns.dtx}) are used to handle 
 % the potential \verb?*? after the command name.
+% \changes{v3.8.3}{2024/02/01}{Marked \cs{addtodef(*)} as deprecated}
+% \MarkedForDeprecation{\cs{addtodef(*)}}
 %    \begin{macrocode}
-\def\addtodef{\@star at or@long\wo at daddtodef}
+\def\addtodef{%
+   \MarkDeprecated{\addtodef}{in 2026, use instead \string\patchcmd,\MessageBreak%
+   \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+   (which is autoloaded by the class)}
+  \@star at or@long\wo at daddtodef}
 %    \end{macrocode}
 % The \cs{@star at or@long} command dealt with a possible \verb?*? and now
 % \cs{wo at daddtodef} does the work. It picks up the three arguments
@@ -1762,8 +1785,14 @@
 % \end{verbatim}
 % \par\end{small}
 %
+% \changes{v3.8.3}{2024/02/01}{Marked \cs{addtoiargdef(*)} as deprecated}
+% \MarkedForDeprecation{\cs{addtoiargdef(*)}}
 %    \begin{macrocode}
-\def\addtoiargdef{\@star at or@long\wo at daddtoiargdef}
+\def\addtoiargdef{%
+   \MarkDeprecated{\addtoiargdef}{in 2026, use instead \string\patchcmd,\MessageBreak%
+   \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+   (which is autoloaded by the class)}
+  \@star at or@long\wo at daddtoiargdef}
 \long\def\wo at daddtoiargdef#1#2#3{%
   \wo at difmacro@begingroup{#1}{%
     \@temptokena{#2}%
@@ -1797,20 +1826,24 @@
 % would have given me permission to include it here if he had not tragically
 % passed away in 2003. I miss his encouragement, advice, and skills.
 %
-% \begin{macro}{\patchcmd}
-% \cs{patchcmd}\marg{macro}\marg{start-stuff}\marg{end-stuff} inserts
+% \begin{macro}{\patchcommand}
+% \cs{patchcommand}\marg{macro}\marg{start-stuff}\marg{end-stuff} inserts
 % \meta{start-stuff} at the beginning of the definition of \meta{macro}
 % and \meta{end-stuff} at the end of the definition. \meta{macro}
 % can have 0--9 arguments and be defined by \cs{newcommand} (and associates)
 % or with \cs{DeclareRobustCommand}. For macros that use \cs{futurelet}
 % (e.g., those with starred forms or optional arguments) only prepending
-% works --- any non-empty \meta{end-stuff} will mess things up. \cs{patchcmd}
+% works --- any non-empty \meta{end-stuff} will mess things up. \cs{patchcommand}
 % does not work with macros that have delimited arguments.
 % \changes{v1.618}{2005/09/05}{Added \cs{patchcmd}}
-%
+% \changes{v3.8.3}{2024/02/01}{Marked \cs{patchcommand} as deprecated}
+% \MarkedForDeprecation{\cs{patchcommand}}
 %    \begin{macrocode}
 %%%%%%%%%%%%%%%% Michael Downes' patchcmd 2000/07/31 v1.03 %%%%%%%%
 \newcommand{\patchcommand}[1]{%
+  \MarkDeprecated{\patchcommand}{in 2026, use instead \string\patchcmd,\MessageBreak%
+    \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+    (which is autoloaded by the class)}
   \expandafter\patchcmd at a\meaning#1??->@\@nil#1%
 }
 %    \end{macrocode}
@@ -2897,7 +2930,15 @@
   \renewcommand*{\@ptsize}{\@memptsize}
   \usefont{\memfontenc}{\memfontfamily}{m}{n}
   \input{\@nyptclofile}
-  \usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
+%    \end{macrocode}
+% Packages in a class should be loaded via \cs{RequirePackage}. Also
+% don't load \Lpack{fontenc} under Xe- or LuaLaTeX.
+% \changes{v3.8.3}{2024/08/30}{Changed}
+%    \begin{macrocode}
+  \RequirePackage{\memfontpack}
+  \iftutex\else
+    \RequirePackage[\memfontenc]{fontenc}
+  \fi
 \else
 %    \end{macrocode}
 % Now for the fixed pt size options.
@@ -2905,7 +2946,15 @@
   \ifextrafontsizes
     \usefont{\memfontenc}{\memfontfamily}{m}{n}
     \input{mem\@memptsize.clo}
-    \usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
+%    \end{macrocode}
+% Packages in a class should be loaded via \cs{RequirePackage}. Also
+% don't load \Lpack{fontenc} under Xe- or LuaLaTeX.
+% \changes{v3.8.3}{2024/08/30}{Changed}
+%    \begin{macrocode}
+    \RequirePackage{\memfontpack}
+    \iftutex\else
+      \RequirePackage[\memfontenc]{fontenc}
+    \fi
   \else
     \ifnum\@memptsize > 17\relax
       \@memerror{The `extrafontsizes' option is required to use \MessageBreak
@@ -4994,7 +5043,6 @@
 %    \begin{macrocode}
 \newcommand*{\@memznegtest}[1]{%
   \ifdim#1>\z@\else
- %%%%   \@memerror{\protect#1\space is zero or negative}{\@ehd}%
     \@memwarn{\protect#1\space is zero or negative}%
   \fi}
 %    \end{macrocode}
@@ -5006,7 +5054,6 @@
 %    \begin{macrocode}
 \newcommand*{\@memnegtest}[1]{%
   \ifdim#1<\z@
-%%%%    \@memerror{\protect#1\space is negative}{\@ehd}%
     \@memwarn{\protect#1\space is negative}%
   \fi}
 
@@ -5135,9 +5182,7 @@
   \@memznegtest{\stockwidth}
   \@memznegtest{\paperwidth}
   \@memznegtest{\textwidth}
-%%%  \@memznegtest{\spinemargin}
   \@memnegtest{\spinemargin}
-%%%  \@memznegtest{\foremargin}
   \@memnegtest{\foremargin}
   \@memznegtest{\marginparsep}
   \@memznegtest{\marginparwidth}
@@ -5144,15 +5189,10 @@
   \@memznegtest{\stockheight}
   \@memznegtest{\paperheight}
   \@memznegtest{\textheight}
-%%%  \@memznegtest{\uppermargin}
   \@memnegtest{\uppermargin}
-%%%  \@memznegtest{\lowermargin}
   \@memnegtest{\lowermargin}
-%%%  \@memznegtest{\headheight}
   \@memnegtest{\headheight}
-%%%  \@memznegtest{\headsep}
   \@memnegtest{\headsep}
-%%%  \@memznegtest{\footskip}
   \@memnegtest{\footskip}
 %    \end{macrocode}
 %
@@ -5336,58 +5376,77 @@
 % \cs{typeoutlayout} (or more often \cs{checkandfixthelayout}), the
 % user can choose the unit in which the list is typeset. The code is
 % inspired by the \texttt{printlen} package.
+% \changes{v3.8.3}{2024/01/31}{A lot easier to implement \cs{settypeoutlayoutunit} via expl3}
 %    \begin{macrocode}
+\ExplSyntaxOn
 \newcommand\settypeoutlayoutunit[1]{
-  \nametest{#1}{pt}
-  \ifsamename
-    \def\mem at tl@unit{#1}
-    \def\mem at tl@unitperpt{1.0}
-  \else 
-    \nametest{#1}{pc}
-    \ifsamename
-      \def\mem at tl@unit{#1}
-      \def\mem at tl@unitperpt{0.083333}
-    \else
-      \nametest{#1}{in}
-      \ifsamename
-        \def\mem at tl@unit{#1}
-        \def\mem at tl@unitperpt{0.013837}
-      \else
-        \nametest{#1}{mm}
-        \ifsamename
-          \def\mem at tl@unit{#1}
-          \def\mem at tl@unitperpt{0.351459}
-        \else
-          \nametest{#1}{cm}
-          \ifsamename
-            \def\mem at tl@unit{#1}
-            \def\mem at tl@unitperpt{0.0351459}
-          \else
-            \nametest{#1}{bp}
-            \ifsamename
-              \def\mem at tl@unit{#1}
-              \def\mem at tl@unitperpt{0.996264}
-            \else
-              \nametest{#1}{dd}
-              \ifsamename
-                \def\mem at tl@unit{#1}
-                \def\mem at tl@unitperpt{0.9345718}
-              \else
-                \nametest{#1}{cc}
-                \ifsamename
-                  \def\mem at tl@unit{#1}
-                  \def\mem at tl@unitperpt{0.0778809}
-                \else
-                  \@memerror{Unknown unit '#1' not suitable for layout listing}{}
-                \fi
-              \fi
-            \fi
-          \fi
-        \fi
-      \fi
-    \fi
-  \fi
+  \def\mem at tl@unit{#1}
+  \str_case_e:nnF{#1}{
+    {pt}{ \def\mem at tl@unitperpt{1.0}       }
+    {pc}{ \def\mem at tl@unitperpt{0.083333}  }
+    {in}{ \def\mem at tl@unitperpt{0.013837}  }
+    {mm}{ \def\mem at tl@unitperpt{0.351459}  }
+    {cm}{ \def\mem at tl@unitperpt{0.0351459} }
+    {bp}{ \def\mem at tl@unitperpt{0.996264}  }
+    {dd}{ \def\mem at tl@unitperpt{0.9345718} }
+    {cc}{ \def\mem at tl@unitperpt{0.0778809} }
+  }{ % or error
+    \@memerror{Unknown~unit~'#1'~not~suitable~for~layout\MessageBreak listing}{}
+  }
 }
+\ExplSyntaxOff
+
+ %\newcommand\settypeoutlayoutunit[1]{
+ %  \nametest{#1}{pt}
+ %  \ifsamename
+ %    \def\mem at tl@unit{#1}
+ %    \def\mem at tl@unitperpt{1.0}
+ %  \else 
+ %    \nametest{#1}{pc}
+ %    \ifsamename
+ %      \def\mem at tl@unit{#1}
+ %      \def\mem at tl@unitperpt{0.083333}
+ %    \else
+ %      \nametest{#1}{in}
+ %      \ifsamename
+ %        \def\mem at tl@unit{#1}
+ %        \def\mem at tl@unitperpt{0.013837}
+ %      \else
+ %        \nametest{#1}{mm}
+ %        \ifsamename
+ %          \def\mem at tl@unit{#1}
+ %          \def\mem at tl@unitperpt{0.351459}
+ %        \else
+ %          \nametest{#1}{cm}
+ %          \ifsamename
+ %            \def\mem at tl@unit{#1}
+ %            \def\mem at tl@unitperpt{0.0351459}
+ %          \else
+ %            \nametest{#1}{bp}
+ %            \ifsamename
+ %              \def\mem at tl@unit{#1}
+ %              \def\mem at tl@unitperpt{0.996264}
+ %            \else
+ %              \nametest{#1}{dd}
+ %              \ifsamename
+ %                \def\mem at tl@unit{#1}
+ %                \def\mem at tl@unitperpt{0.9345718}
+ %              \else
+ %                \nametest{#1}{cc}
+ %                \ifsamename
+ %                  \def\mem at tl@unit{#1}
+ %                  \def\mem at tl@unitperpt{0.0778809}
+ %                \else
+ %                  \@memerror{Unknown unit '#1' not suitable for layout listing}{}
+ %                \fi
+ %              \fi
+ %            \fi
+ %          \fi
+ %        \fi
+ %      \fi
+ %    \fi
+ %  \fi
+ %}
 %    \end{macrocode}
 % Default value is \texttt{pt}, other supported are \texttt{mm},
 % \texttt{cm}, \texttt{in}, \texttt{bp}, \texttt{dd} and \texttt{cc}.
@@ -8503,34 +8562,69 @@
 % \changes{v1.4}{2003/11/16}{Gobble footnotes in \cs{title}, \cs{author}
 %               and \cs{date} (from patch v1.4)}
 % \changes{v1.6}{2004/01/28}{Added \cs{andnext} handling to \cs{author}}
+% \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}. }
 %    \begin{macrocode}
-\addtoiargdef{\title}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\thetitle{#1}
-  \endgroup\endgroup}
-\addtoiargdef{\author}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\and}{\unskip, }
-    \renewcommand{\andnext}{\unskip, }
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\theauthor{#1}
-  \endgroup\endgroup}
-\addtoiargdef{\date}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\thedate{#1}
-  \endgroup\endgroup}
+ % \addtoiargdef{\title}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\thetitle{#1}
+ %     \endgroup\endgroup}
 
+\xpretocmd\title{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\title\space failed, please inform maintainer}}
+\xapptocmd\title{
+  \begingroup%
+    \renewcommand{\thanks}[1]{}%
+     \renewcommand{\thanksmark}[1]{}%
+     \renewcommand{\thanksgap}[1]{}%
+     \protected at xdef\thetitle{#1}%
+   \endgroup\endgroup%
+}{}{\typeout{patch 2 to \string\title\space failed, please inform maintainer}}
+ 
+ % \addtoiargdef{\author}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\and}{\unskip, }
+ %     \renewcommand{\andnext}{\unskip, }
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\theauthor{#1}
+ %   \endgroup\endgroup}
+
+\xpretocmd\author{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
+\xapptocmd\author{%
+   \begingroup%
+     \renewcommand{\thanks}[1]{}%
+     \renewcommand{\and}{\unskip, }%
+     \renewcommand{\andnext}{\unskip, }%
+     \renewcommand{\thanksmark}[1]{}%
+     \renewcommand{\thanksgap}[1]{}%
+     \protected at xdef\theauthor{#1}%
+   \endgroup\endgroup%
+}{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
+
+ % \addtoiargdef{\date}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\thedate{#1}
+ %   \endgroup\endgroup}
+
+\xpretocmd\date{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\date\space failed, please inform maintainer}}
+\xapptocmd\date{%
+  \begingroup%
+    \renewcommand{\thanks}[1]{}%
+    \renewcommand{\thanksmark}[1]{}%
+    \renewcommand{\thanksgap}[1]{}%
+    \protected at xdef\thedate{#1}%
+  \endgroup\endgroup%
+}{}{\typeout{patch 2 to \string\date\space failed, please inform maintainer}}
+ 
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -8671,12 +8765,17 @@
 % \begin{macro}{\subsubsectionmark}
 % \begin{macro}{\paragraphmark}
 % \begin{macro}{\subparagraphmark}
-%  The default initialisations of the \cs{...mark} commands for use in
-% the pagestyles. Most are already defined in the kernel but they are
-% all noted here.
+%   The default initialisations of the \cs{...mark} commands for use
+%   in the pagestyles. Most are already defined in the kernel but they
+%   are all noted here. In the rare occasion that there are text
+%   between, say, a \cs{part} and a \cs{chapter}, the header from the
+%   previous chapter may spill into this text. Therefore two marks
+%   \cs{bookpagemark} and \cs{partmark} should default to resettting
+%   the marks.
+% \changes{3.8.3}{2025/02/25}{Changed the default for \cs{partmark} and \cs{bookpagemark}}
 %    \begin{macrocode}
-\newcommand*{\bookpagemark}[1]{}
-\newcommand*{\partmark}[1]{}
+\newcommand*{\bookpagemark}[1]{\markboth{}{}}
+\newcommand*{\partmark}[1]{\markboth{}{}}
 \newcommand*{\chaptermark}[1]{}
 % \newcommand*{\sectionmark}[1]{}
 % \newcommand*{\subsectionmark}[1]{}
@@ -10059,11 +10158,12 @@
 % \changes{v1.0a}{2002/01/18}{Made \cs{chapnumfont} change in article chapterstyle explicit}
 % \changes{v1.4}{2003/11/22}{Replaced \cs{space} by \cs{quad} in article chapterstyle
 %               (from patch v1.7)}
+% \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}}
 %    \begin{macrocode}
 \makechapterstyle{article}{%
   \chapterstyle{default}
   \setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
-  \renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
+  \renewcommand*{\chapterheadstart}{\addvspace{\beforechapskip}}
   \setlength{\afterchapskip}{2.3ex \@plus .2ex}
   \renewcommand{\printchaptername}{}
   \renewcommand{\chapternamenum}{}
@@ -14077,11 +14177,16 @@
 % of the \cs{thanks} (from \file{ltsect.dtx}) command, 
 % so that \cs{@bs at thanks} has a copy of the contents
 % of \cs{@thanks}.
+% \changes{v3.8.3}{2024/02/02}{Changed using \cs{addtoiargdef} to \cs{xapptocmd} }
 %    \begin{macrocode}
-\addtoiargdef{\thanks}{}{%
-  \protected at xdef\@bs at thanks{\@bs at thanks
+ % \addtoiargdef{\thanks}{}{%
+ %   \protected at xdef\@bs at thanks{\@bs at thanks
+ %     \protect\footnotetext[\the\c at footnote]{#1}}%
+ %   }
+\xapptocmd\thanks{%
+   \protected at xdef\@bs at thanks{\@bs at thanks
     \protect\footnotetext[\the\c at footnote]{#1}}%
-}
+}{}{\typeout{Patch to \string\thanks\space failed, please inform maintainer}}
 \let\@bs at thanks\@empty
 
 %    \end{macrocode}
@@ -14132,20 +14237,9 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\poemlines}
-% \cs{poemlines}\marg{nth} specifies that every \meta{nth} line of
-% a poem is to be numbered. 
-% \changes{v1.1}{2002/03/10}{Added \cs{poemlines}}
-% \changes{v1.2}{2002/07/27}{\cs{poemlines} now just calls \cs{linenumberfrequency}}
-% \changes{v1.61803}{2008/01/30}{Deleted \cs{poemlines}.}
-%    \begin{macrocode}
-%%%\newcommand{\poemlines}[1]{\linenumberfrequency{#1}%
-%%%  \@memwarn{Use \string\linenumberfrequency\space
-%%%                        instead of \string\poemlines}}
-
-%    \end{macrocode}
-% \end{macro}
-%
+% 
+% \changes{v3.8.3}{2024/02/05}{folly deleted the outcommented code for \cs{poemline}, have been outcommented for years.}
+% 
 % \begin{macro}{\linenumberfont}
 % \begin{macro}{\vlvnumfont}
 %  Set line numbering font(s).
@@ -14410,24 +14504,36 @@
 %
 % \begin{macro}{\@vslnumright}
 % \begin{macro}{\@vslnumleft}
-% Internal code for right/left line numbers.
-% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@vslnumright}
-% and \cs{@vslnumleft}}
-% \changes{v3.7g}{2018/02/28}{Added \cs{nobreak} to both
-% \cs{@vslnumright} and \cs{@vslnumleft}, reported on
-% \protect\url{https://tex.stackexchange.com/a/415939/3929}, to avoid strange
-% double line breaks}
+%   Internal code for right/left line numbers. This was reimplemented in 2024,
+%   to be used in hooks instead of being added at the end of lines.
+%   \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@vslnumright}
+%   and \cs{@vslnumleft}}
+%   \changes{v3.7g}{2018/02/28}{Added \cs{nobreak} to both
+%   \cs{@vslnumright} and \cs{@vslnumleft}, reported on
+%   \protect\url{https://tex.stackexchange.com/a/415939/3929}, to avoid strange
+%   double line breaks}
+%   \changes{v3.8.3}{2024/02/06}{Reimplemented as they are no longer added at the end of the line}
 %    \begin{macrocode}
 \newcommand*{\@vslnumright}{%
-  \nobreak%
-  \hfill\rlap{%\kern\vrightskip\kern\rightmargin%
-              \kern\memRTLvrightskip\kern\rightmargin%
-              \vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
+  %\nobreak%
+  %\hfill\rlap{%\kern\vrightskip\kern\rightmargin%
+  %            \kern\memRTLvrightskip\kern\rightmargin%
+  %            \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
+  \rlap{%
+    \hspace{\dimexpr-\@totalleftmargin+\textwidth+\memRTLvrightskip}%
+    {\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
+  }%
+}
 \newcommand*{\@vslnumleft}{%
-  \nobreak%
-  \hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
-              \kern-\textwidth\kern-\memRTLvrightskip%
-              \vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
+  % \nobreak%
+  % \hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
+  %            \kern-\textwidth\kern-\memRTLvrightskip%
+  %            \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
+  \llap{%
+    \llap{\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
+    \hspace{\dimexpr\@totalleftmargin+\memRTLvrightskip}%
+  }%
+}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -14443,10 +14549,11 @@
 %                linenumbering}
 % \changes{v1.61803}{2008/01/30}{Changed \cs{@vscentercr} for left/right numbers
 %                    (mempatch v4.4)}
+% \changes{v3.8.3}{2024/02/06}{Removed the line numbering from \cs{@vscentercr}, they are now added via hooks}
 %    \begin{macrocode}
 \newcommand{\@vscentercr}{%
   \ifhmode \unskip\else \@nolnerr\fi
-  \@vstypelinenum%
+  % \@vstypelinenum% outcommented 2024/02/06
 %    \end{macrocode}
 % For \verb?>? call \cs{verselinebreak} to process it.
 %    \begin{macrocode}
@@ -14555,6 +14662,17 @@
 
 %    \end{macrocode}
 % \end{environment}
+% Then we use the env and paragraph hooks to add support for line
+% numbers, the idea was suggested by Ulrike Fischer in chat. It is
+% also listed as an example in \cite{SOURCE2E}.
+% 
+% \changes{v3.8.3}{2024/02/06}{Added the hooks to handle line numbers.}
+%    \begin{macrocode}
+\AddToHook{env/verse/begin}{%
+  \AddToHook{para/begin}[memoir/versenum]{\@vstypelinenum}} 
+\AddToHook{env/verse/end}{\RemoveFromHook{para/begin}[memoir/versenum]}
+
+%    \end{macrocode}
 %
 % \begin{environment}{altverse}
 % This sets \cs{altindenttrue} (afterwards false) and initialises the line counter.
@@ -19855,6 +19973,24 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+%
+% \begin{macro}{\setcftvspacecmd}
+% \begin{macro}{\mem at cft@vspace at cmd}
+%   The entries in the ToC adds \cs{cftbeforeXskip} above each
+%   entry. Traditionally the class have always used \cs{vskip}
+%   here,\footnote{We do not know why.} whereas the standard classes
+%   used \cs{addvspace}. It has only been 20 years (2025) before a
+%   user complained that fx the space above the first entry does not
+%   disappear. Since changing the \cs{vskip} to \cs{addvspace} will
+%   change thousands of documents, we instead make it configurable,
+%   then the user can choose what suits them best.
+% \changes{v3.8.3}{2025/03/03}{Added \cs{setcftvspacecmd}}
+%    \begin{macrocode}
+\newcommand\setcftvspacecmd[1]{\def\mem at cft@vspace at cmd{#1}}
+\setcftvspacecmd{\vskip}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
 % 
 %
 % \begin{macro}{\newlistentry}
@@ -19909,8 +20045,10 @@
     \ifnum \@nameuse{c@#3depth} > #4\relax
 %    \end{macrocode}
 % Add some vertical space.
+% \changes{v3.8.3}{2025/03/03}{factoring the vertical space cmd}
 %    \begin{macrocode}
-      \vskip \@nameuse{cftbefore#2skip}
+      % \vskip \@nameuse{cftbefore#2skip}
+      \mem at cft@vspace at cmd \@nameuse{cftbefore#2skip}
 %    \end{macrocode}
 % Start a group to keep paragraphing changes local. Set the \cs{leftskip}
 % to the entry's indentation.
@@ -20130,9 +20268,12 @@
 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l at book}}
 % \changes{v1.61803398d}{2010/02/13}{added hook into the book numberline}
 % \changes{v3.6k}{2012/07/22}{Factored the general box out of \cs{booknumberline}}
+% \changes{v3.8.3}{2025/03/06}{Factored out the penalty}
 %    \begin{macrocode}
-\newcommand*{\cftbookbreak}{\addpenalty{-\@highpenalty}%
-  \addvspace{\cftbeforebookskip}}
+\newcommand*{\cftbookbreak}{%
+  \addpenalty{\cftbeforepartpenalty}%
+  \addvspace{\cftbeforebookskip}%
+}
 \newcommand*{\l at book}[2]{%
   \ifnum\c at tocdepth >-3\relax
     \cftbookbreak
@@ -20178,7 +20319,10 @@
 % \end{macro}
 % \end{macro}
 %
+% \newpage
+%
 % \begin{macro}{\cftbeforebookskip}
+% \begin{macro}{\cftbeforebookpenalty}
 % \begin{macro}{\cftbookindent}
 % \begin{macro}{\cftbooknumwidth}
 % \begin{macro}{\cftbookfont}
@@ -20193,9 +20337,11 @@
 % \begin{macro}{\cftbookformatpnum}
 % \begin{macro}{\cftbookformatpnumhook}
 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftbookformatpnum}}
+% \changes{v3.8.3}{2025/03/06}{added \cs{cftbeforebookpenalty}}
 %    \begin{macrocode}
 \newlength{\cftbeforebookskip}
   \setlength{\cftbeforebookskip}{2.25em \@plus\p@}
+\newcommand\cftbeforebookpenalty{-\@highpenalty}
 \newdimen\cftbookindent
   \setlength{\cftbookindent}{0em}
 \newdimen\cftbooknumwidth
@@ -20234,6 +20380,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 %
 %
@@ -20254,9 +20401,12 @@
 % and the final \cs{nobreak} code.
 % \changes{v1.61803}{2008/01/30}{Added \cs{cftpartbreak}}
 % \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l at part}}
+% \changes{v3.8.3}{2025/03/06}{Factored out the penalty part}
 %    \begin{macrocode}
-\newcommand*{\cftpartbreak}{\addpenalty{-\@highpenalty}%
-  \addvspace{\cftbeforepartskip}}
+\newcommand*{\cftpartbreak}{%
+  \addpenalty{\cftbeforepartpenalty}%
+  \addvspace{\cftbeforepartskip}%
+}
 \newcommand*{\l at part}[2]{%
   \ifnum \c at tocdepth >-2\relax
     \cftpartbreak
@@ -20328,6 +20478,7 @@
 % \end{macro}
 %
 % \begin{macro}{\cftbeforepartskip}
+% \begin{macro}{\cftbeforepartpenalty}
 % \begin{macro}{\cftpartnumwidth}
 % \begin{macro}{\cftpartfont}
 % \begin{macro}{\cftpartpresnum}
@@ -20347,9 +20498,11 @@
 %                            use of \cs{numberline} in the ToC}
 % \changes{v1.61803}{2008/01/30}{Added \cs{cftpartformatpnum} (mempatch v4.9)}
 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftpartformatpnum}}
+% \changes{v3.8.3}{2025/03/06}{Added \cs{cftbeforepartpenalty}}
 %    \begin{macrocode}
   \newlength{\cftbeforepartskip}
     \setlength{\cftbeforepartskip}{2.25em \@plus\p@}
+  \newcommand\cftbeforepartpenalty{-\@highpenalty}
   \newlength{\cftpartindent}
     \setlength{\cftpartindent}{0em}
   \newlength{\cftpartnumwidth}
@@ -20387,6 +20540,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 %
 % \begin{macro}{\cftchaptername}
@@ -20404,13 +20558,19 @@
 %
 % \begin{macro}{\l at chapapp}
 % Generic chapter/appendix ToC entry typesetting.
+% \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak} to
+% \cs{l at chapter} (Peter probably meant \cs{l at chapapp} here, and thus
+% the remark was moved here, /dlf 2025/03/03)}
 % \changes{v1.618}{2005/09/03}{Added \cs{l at chapapp}, courtesy Danie Els (mempatch v3.12)}
-% \changes{v1.61803398}{2009/07/18}{ADded bidi support to \cs{l at chapapp}}
-%    \begin{macrocode}
+% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l at chapapp}}
+%     \begin{macrocode}
 \newcommand*{\l at chapapp}[3]{%
   \ifnum \c at tocdepth >\m at ne
+%    \end{macrocode}
+% 2025/03/03: Factored the vertical skip part into \cs{cftchapterbreak} to mimic \cs{part} and \cs{book}
+%    \begin{macrocode}
     \cftchapterbreak
-    \vskip \cftbeforechapterskip
+    % \vskip \cftbeforechapterskip
     {%\leftskip \cftchapterindent\relax
      \memRTLleftskip \cftchapterindent\relax
 %%%     \rightskip \@tocrmarg
@@ -20446,7 +20606,6 @@
 % \cs{l at chapter}
 % (see \file{classes.dtx} for the original definition). Can't use
 % \cs{newlistentry} for this because of the intial penalty.
-% \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak} to \cs{l at chapter}}
 % \changes{v1.618}{2005/09/03}{Defined \cs{l at chapter} in terms of \cs{l at chapapp} (mempatch v3.12)}
 %    \begin{macrocode}
 \newcommand*{\l at chapter}[2]{%
@@ -20516,6 +20675,7 @@
 % \end{macro}
 %
 % \begin{macro}{\cftbeforechapterskip}
+% \begin{macro}{\cftbeforechapterpenalty}
 % \begin{macro}{\cftchapterindent}
 % \begin{macro}{\cftchapternumwidth}
 % \begin{macro}{\cftchapterfont}
@@ -20533,9 +20693,11 @@
 %  They are initialised to give the standard appearance.
 % \changes{v1.61803}{2008/01/30}{Added \cs{cftchapterformatpnum} (mempatch v4.9)}
 % \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftchapterformatpnum}}
+% \changes{v3.8.3}{2025/03/06}{Added \cs{cftbeforechapterpenalty}}
 %    \begin{macrocode}
   \newlength{\cftbeforechapterskip}
     \setlength{\cftbeforechapterskip}{1.0em \@plus\p@}
+  \newcommand\cftbeforechapterpenalty{-\@highpenalty}
   \newlength{\cftchapterindent}
     \setlength{\cftchapterindent}{0em}
   \newlength{\cftchapternumwidth}
@@ -20572,12 +20734,18 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\cftchapterbreak}
 % Another parameter for \cs{l at chapter}.
 % \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak}}
+% \changes{v3.8.3}{2025/03/03}{Moved the vertical skip part into \cs{cftchapterbreak}}
+% \changes{v3.8.3}{2025/03/06}{Factored the penalty into its own macro}
 %    \begin{macrocode}
-  \newcommand{\cftchapterbreak}{\addpenalty{-\@highpenalty}}
+\newcommand{\cftchapterbreak}{%
+  \addpenalty{\cftbeforechapterpenalty}%
+  \mem at cft@vspace at cmd \cftbeforechapterskip%
+}
 
 %    \end{macrocode}
 % \end{macro}
@@ -20879,12 +21047,25 @@
 % \end{verbatim}
 %
 % \changes{v1.61803}{2008/01/30}{Added \cs{cftinsert} and friends (mempatch v4.9)}
+% \changes{v3.8.3}{2024/02/14}{Better implementation for \cs{cftinserthook}}
 %    \begin{macrocode}
 \newcommand*{\cftinsert}[1]{\@nameuse{cftinsert#1}}
 \newcommand{\cftinsertcode}[2]{\@namedef{cftinsert#1}{#2}}
-\newcommand*{\cftinserthook}[2]{%
-  \addtocontents{#1}{\protect\cftinsert\protect{#2\protect}}}
+\NewDocumentCommand\cftinserthook{smm}{
+  \IfBooleanTF{#1}{
+    \ifdim\pagetotal>\z@
+      \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}
+      \clearpage
+    \else
+      \immediateaddtocontents{#2}{\noexpand\cftinsert{#3}}
+    \fi 
+  }{%
+    \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}%
+  }%
+}
 
+
+
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -20907,156 +21088,235 @@
 %                   (mempatch v4.4)}
 % \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if at tempswa} with 
 %   \cs{@setclcntok} in \cs{@setclcnt} to avoid bad clashes with other uses}
+% \changes{v3.8.3}{2024/02/13}{Reimplemented using expl3}
 %    \begin{macrocode}
+\ExplSyntaxOn
 \newcommand*{\@setclcnt}[2]{%
-  \def\@setclcntok{0}% = false
-  \nametest{#1}{none}%
-  \ifsamename
-    \setcounter{#2}{-10}%
-    \def\@setclcntok{1}% = true
-  \fi
-  \nametest{#1}{book}%
-  \ifsamename
-    \setcounter{#2}{-2}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{part}%
-  \ifsamename
-    \setcounter{#2}{-1}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{chapter}%
-  \ifsamename
-    \setcounter{#2}{0}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{section}%
-  \ifsamename
-    \setcounter{#2}{1}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subsection}%
-  \ifsamename
-    \setcounter{#2}{2}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subsubsection}%
-  \ifsamename
-    \setcounter{#2}{3}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{paragraph}%
-  \ifsamename
-    \setcounter{#2}{4}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subparagraph}%
-  \ifsamename
-    \setcounter{#2}{5}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{all}%
-  \ifsamename
-    \setcounter{#2}{50}%
-    \def\@setclcntok{1}%
-  \fi
-%%  \if at tempswa\else
-    \ifnum \@setclcntok = 0\relax
+  \str_case_e:nnF{#1}{
+    {none}{          \setcounter{#2}{-10}}
+    {book}{          \setcounter{#2}{-2} }
+    {part}{          \setcounter{#2}{-1} }
+    {chapter}{       \setcounter{#2}{0}  }
+    {section}{       \setcounter{#2}{1}  }
+    {subsection}{    \setcounter{#2}{2}  }
+    {subsubsection}{ \setcounter{#2}{3}  }
+    {paragraph}{     \setcounter{#2}{4}  }
+    {subparagraph}{  \setcounter{#2}{5}  }
+    {all}{           \setcounter{#2}{50} }
+  }{
+     \@memerror{%
+       Unknown~document~division~name~(#1)
+     }{%
+      I'll~ignore~it.~
+      Type~<return>~and~I'll~continue.\MessageBreak
+      If~you~haven't~mistyped~the~name~then~ use~
+      \protect\setcounter~instead.}%
+  }
+}
+\ExplSyntaxOff
+ % \newcommand*{\@setclcnt}[2]{%
+ %   \def\@setclcntok{0}% = false
+ %   \nametest{#1}{none}%
+ %   \ifsamename
+ %     \setcounter{#2}{-10}%
+ %     \def\@setclcntok{1}% = true
+ %   \fi
+ %   \nametest{#1}{book}%
+ %   \ifsamename
+ %     \setcounter{#2}{-2}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{part}%
+ %   \ifsamename
+ %     \setcounter{#2}{-1}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{chapter}%
+ %   \ifsamename
+ %     \setcounter{#2}{0}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{section}%
+ %   \ifsamename
+ %     \setcounter{#2}{1}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subsection}%
+ %   \ifsamename
+ %     \setcounter{#2}{2}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subsubsection}%
+ %   \ifsamename
+ %     \setcounter{#2}{3}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{paragraph}%
+ %   \ifsamename
+ %     \setcounter{#2}{4}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subparagraph}%
+ %   \ifsamename
+ %     \setcounter{#2}{5}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{all}%
+ %   \ifsamename
+ %     \setcounter{#2}{50}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ % %%  \if at tempswa\else
+ %     \ifnum \@setclcntok = 0\relax
+ %     \@memerror{%
+ %       Unknown document division name (#1)
+ %     }{%
+ %      I'll ignore it.
+ %      Type \space <return> and I'll continue.\MessageBreak
+ %      If you haven't mistyped the name then use
+ %      \protect\setcounter\space instead.}%
+ %   \fi}
+ % 
+%    \end{macrocode}
+% \end{macro}
+%
+% 
+% \begin{macro}{\settocdepth@}
+%   \cs{settocdepth@}\marg{macro}\marg{sec}\\
+%   This is a utility macro to fuel \cs{settocdepth}, and a
+%   variant. Instead of a \cs{nametest} stack it is implemented using
+%   the expl3 \verb|\str_case_e:nnTF| function. Here \meta{macro} is
+%   the macro to use to write to the toc file.
+% \changes{v3.8.3}{2024/02/13}{Added simpler implementation}
+%    \begin{macrocode}
+ \ExplSyntaxOn
+\newcommand*{\settocdepth@}[2]{%
+  \str_case_e:nnTF{#2}{
+    {none}{          #1{toc}{\changetocdepth{-10}}}
+    {book}{          #1{toc}{\changetocdepth{-2}} }
+    {part}{          #1{toc}{\changetocdepth{-1}} }
+    {chapter}{       #1{toc}{\changetocdepth{0}}  }
+    {section}{       #1{toc}{\changetocdepth{1}}  }
+    {subsection}{    #1{toc}{\changetocdepth{2}}  }
+    {subsubsection}{ #1{toc}{\changetocdepth{3}}  }
+    {paragraph}{     #1{toc}{\changetocdepth{4}}  }
+    {subparagraph}{  #1{toc}{\changetocdepth{5}}  }
+    {all}{           #1{toc}{\changetocdepth{50}} }
+  }{
+    \@ifundefined{toclevel@#2}{%
+      \@memwarn{Unknown~toclevel~for~#2}%
+    }{%
+      \setcounter{tocdepth}{\@nameuse{toclevel@#2}}%
+    }
+  }{
     \@memerror{%
-      Unknown document division name (#1)
+      Unknown~document~division~name~(#2)
     }{%
-     I'll ignore it.
-     Type \space <return> and I'll continue.\MessageBreak
-     If you haven't mistyped the name then use
-     \protect\setcounter\space instead.}%
-  \fi}
-
+     I'll~ignore~ it.~
+     Type~<return>~and~I'll~continue.}%
+  }
+}
+\ExplSyntaxOff
 %    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\settocdepth}
+% \begin{macro}{\immediatesettocdepth}
 % \cs{settocdepth}\marg{sec} is the user command for setting 
 % \Lcount{tocdepth} in the \file{.toc} file to the value corresponding to
-% \meta{sec}. 
+% \meta{sec}. Also added an immediate version, which is rather dangerous,
+% so not mentioned in the manual for now.
 % \changes{v1.3}{2002/11/14}{Changed \cs{settocdepth} to use \cs{changetocdepth}}
 % \changes{v1.61803}{2008/01/30}{Added book to ToC depth setting (mempatch v4.4)}.
 % \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if at tempswa} with 
 %   \cs{@chtocdok} in \cs{settocdepth} to avoid bad clashes with other uses}
+% \changes{v3.8.3}{2024/02/13}{Reimplemented using simpler code}
 %    \begin{macrocode}
-\newcommand*{\settocdepth}[1]{%
-  \def\@chtodok{0}%   false
-  \nametest{#1}{none}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-10}}%
-    \def\@chtodok{1}%   true
-  \fi
-  \nametest{#1}{book}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-2}}%
-    \def\@chtodok{1}%
-  \fi
-  \nametest{#1}{part}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-1}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{chapter}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{0}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{section}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{1}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subsection}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{2}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subsubsection}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{3}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{paragraph}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{4}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subparagraph}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{5}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{all}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{50}}%
-    \def\@chtocdok{1}%
-  \fi
-%  \if at tempswa
-  \ifnum\@chtocdok=1\relax
-%    \end{macrocode}
-% The next bit is from Heiko Oberdiek (CTT {\itshape Re: Memoir, \verb?\settocdepth?
-% and pdflatex \verb?=>? problem with PDF bookmarks}, 2006/07/21) as 
-% \Lpack{hyperref} needs \verb?\tocdepth? set in the body not just in the ToC.
-%    \begin{macrocode}
-    \@ifundefined{toclevel@#1}{%
-      \@memwarn{Unknown toclevel for #1}%
-    }{%
-      \setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
-    }
-  \else
-    \@memerror{%
-      Unknown document division name (#1)
-    }{%
-     I'll ignore it.
-     Type \space <return> and I'll continue.}%
-  \fi}
+% \newcommand*{\settocdepth}[1]{\settocdepth@{\addtocontents}{#1}}
+% \newcommand*{\immediatesettocdepth}[1]{\settocdepth@{\immediateaddtocontents}{#1}}
+\NewDocumentCommand\settocdepth{sm}{%
+  \IfBooleanTF{#1}{%
+    \ifdim\pagetotal>\z@%
+      \settocdepth@{\addtocontents}{#2}%
+      \clearpage%
+    \else%
+      \settocdepth@{\immediateaddtocontents}{#2}%
+    \fi%
+  }{%
+    \settocdepth@{\addtocontents}{#2}%
+  }%
+}
 
+
+
+
+ %   \def\@chtodok{0}%   false
+ %   \nametest{#1}{none}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-10}}%
+ %     \def\@chtodok{1}%   true
+ %   \fi
+ %   \nametest{#1}{book}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-2}}%
+ %     \def\@chtodok{1}%
+ %   \fi
+ %   \nametest{#1}{part}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-1}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{chapter}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{0}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{section}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{1}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subsection}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{2}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subsubsection}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{3}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{paragraph}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{4}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subparagraph}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{5}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{all}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{50}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \ifnum\@chtocdok=1\relax
+ %     \@ifundefined{toclevel@#1}{%
+ %       \@memwarn{Unknown toclevel for #1}%
+ %     }{%
+ %       \setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
+ %     }
+ %   \else
+ %     \@memerror{%
+ %       Unknown document division name (#1)
+ %     }{%
+ %      I'll ignore it.
+ %      Type \space <return> and I'll continue.}%
+ %   \fi}
+ 
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\toclevel at none}
 % \begin{macro}{\toclevel at all}
@@ -26503,8 +26763,37 @@
 }
 
 %    \end{macrocode}
+%
 % \end{macro}
 % 
+% \begin{macro}{\immediateaddtocontents}
+%   This is a rather risky macro, that sometimes is needed in
+%   documents with \cs{include} as things can get out of sequence. The
+%   macro is \emph{not} documented in the manual, as it can be
+%   dangerous. If a \cs{clearpage} is executed right after, then it
+%   should be save to use. Instead of just copying code and edit, we
+%   use a \cs{NewCommandCopy} and patch it. Note that we define
+%   \cs{thepage} to do nothing here.
+%    \begin{macrocode}
+ % \long\def\immediateaddtocontents#1#2{%
+ %  \immediate at protected@write\@auxout% 
+ %  {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble \let\thepage\relax}%
+ %  {\string\@writefile{#1}{#2}}}
+\NewCommandCopy\immediateaddtocontents\addtocontents
+\patchcmd{\immediateaddtocontents}
+  {\protected at write}%
+  {\immediate at protected@write}%
+  {}%
+  {\typeout{patch 1 for \string\immediateaddtocontents\space failed}}
+\patchcmd{\immediateaddtocontents}%
+  {\let\glossary\@gobble}%
+  {\let\glossary\@gobble\let\thepage\relax}%
+  {}%
+  {\typeout{patch 2 for \string\immediateaddtocontents\space failed}}
+
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\m at m@pnwrite} 
 % \begin{macro}{\m at m@pnwrited} 
 % In the old implementation we used \cs{immediate at protected@write}
@@ -31028,8 +31317,12 @@
 % \verb?\newloglike{\fun}{string}? or \verb?\newloglike*{\fun}{string}?.
 % The starred version is for functions with limits (like an integral sign).
 % \changes{v1.6}{2004/01/28}{Added \cs{newloglike}}
+% \MarkedForDeprecation{\cs{newloglike}}
 %    \begin{macrocode}
-\newcommand*{\newloglike}{\@ifstar{\m at mnewlogs}{\m at mnewlog}}
+\newcommand*{\newloglike}{%
+  \MarkDeprecated{\newloglike}{in 2026. We recommand using\MessageBreak%
+    \string\DeclareMathOperator\space from amsopn (amsmath) instead.}%
+  \@ifstar{\m at mnewlogs}{\m at mnewlog}}
 \newcommand*{\m at mnewlogs}[2]{%
   \newcommand*{#1}{\mathop{\operator at font #2}}}
 \newcommand*{\m at mnewlog}[2]{%
@@ -31045,8 +31338,11 @@
 % \begin{macro}{\m at mprovlog}
 %  The provide version of \cs{newloglike}.
 % \changes{v1.6}{2004/01/28}{Added \cs{provideloglike}}
+% \MarkedForDeprecation{\cs{provideloglike}}
 %    \begin{macrocode}
-\newcommand*{\provideloglike}{\@ifstar{\m at mprovlogs}{\m at mprovlog}}
+\newcommand*{\provideloglike}{%
+  \MarkDeprecated*{\provideloglike}{in 2026}
+  \@ifstar{\m at mprovlogs}{\m at mprovlog}}
 \newcommand*{\m at mprovlogs}[2]{%
   \providecommand*{#1}{\mathop{\operator at font #2}}}
 \newcommand*{\m at mprovlog}[2]{%
@@ -31060,120 +31356,15 @@
 %
 % \subsection{Changing counters}
 %
-%     In LaTeX, a new counter called, say `ctr', is created by the command
-% \verb?\newcounter{ctr}[within]?. If the optional within argument is given
-% the the counter `ctr' is reset to zero each time the counter `within'
-% changes. The command \cs{thectr} typesets the value of the counter ctr.
-% This is automatically defined by \cs{newcounter} and is initialised
-% to typeset arabic numerals. Sometimes it may be desireable to change
-% the counter definitions.
+% \changes{v3.8.3}{2024/02/02}{Removed code for \cs{counterwithin},
+% \cs{counterwithout} and \cs{@removefromreset}, they have been
+% `provided' since 2018}
 %
-% The following code is based on the \Lpack{chngcntr} package~\cite{CHNGCNTR}.
+% The class used to have code similar to the package \Lpack{chngcntr}
+% and \Lpack{remreset}. Since 2018 these have been in the
+% \LaTeX-kernel and was just provided by the class. By 2024 the code
+% was removed. 
 %
-% \begin{macro}{\@removefromreset}
-% This code uses David Carlisle's \cs{@removefromreset} command as
-% specified in the remreset package~\cite{REMRESET}.
-% It is provided here as a convenience to the user, and with
-% David Carlisle's permission.
-%
-% START OF DAVID CARLISLE'S CODE
-%    \begin{macrocode}
-\providecommand{\@removefromreset}[2]{{%
-  \expandafter\let\csname c@#1\endcsname\@removefromreset
-  \def\@elt##1{%
-    \expandafter\ifx\csname c@##1\endcsname\@removefromreset
-    \else
-      \noexpand\@elt{##1}%
-    \fi}%
-  \expandafter\xdef\csname cl@#2\endcsname{%
-    \csname cl@#2\endcsname}}}
-
-%    \end{macrocode}
-% END OF DAVID CARLISLE'S CODE
-% \end{macro}
-%
-% \begin{macro}{\@ifbothcntrs}
-% This is called as \\
-% \cs{@ifbothcntrs}\marg{cntr}\marg{within}\marg{code when both are counters}. 
-% This tests if both \meta{cntr} and \meta{within} are counters.
-%    \begin{macrocode} 
-\newcommand{\@ifbothcntrs}[3]{%
-  \@ifundefined{c@#1}{% counter undefined
-    \@memerror{#1 is not a counter}{\@eha}}%
-  {% else counter is defined
-    \@ifundefined{c@#2}{% within undefined
-      \@memerror{#2 is not a counter}{\@eha}}%
-    {% else both counter and within  are defined
-     #3}}}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\counterwithin}
-% \begin{macro}{\counterwithin*}
-% \begin{macro}{\@csinstar}
-% \begin{macro}{\@csin}
-%    It is sometimes desireable to change a counter that has been defined
-% by \verb?\newcounter{ctr}? to act as though it had been defined as 
-% \verb?\newcounter{ctr}[within]?. The command
-% \verb?\counterwithin{ctr}{within}? accomplishes this. By default,
-% it also redefines the \cs{thectr} command so that it typesets values
-% in the style \verb?\thewithin.\arabic{ctr}?. The starred version of the
-% command suppresses the redefinition of \cs{thectr}. 
-% \changes{v3.7g}{2018/03/09}{As of TeXLive 2018 \cs{counterwithin}
-% and \cs{counterwithout} will be moved into the kernel. We therefore
-% change to using \cs{providecommand} instead of \cs{newcommand} to
-% avoid colisions}
-%    \begin{macrocode}
-\providecommand{\counterwithin}{\@ifstar{\@csinstar}{\@csin}}
-\providecommand{\@csinstar}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}}}
-\providecommand{\@csin}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}%
-                        \@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\counterwithout}
-% \begin{macro}{\counterwithout*}
-% \begin{macro}{\@csoutstar}
-% \begin{macro}{\@csout}
-%    Likewise, the command \verb?\counterwithout{ctr}{within}? changes a
-% counter that has been created by \verb?\newcounter{ctr}[within]? to act
-% as though it had been created by \verb?\newcounter{ctr}?. By default it
-% also redefines the \cs{thectr} command so that it just typesets an arabic
-% numeral. The starred version of the command suppresses the redefinition
-% of \cs{thectr}.
-% \changes{v1.618}{2005/09/03}{Deleted chngctr from \cs{@csoutstar} (mempatch v3.4)}
-% \changes{v3.7g}{2018/03/09}{As of TeXLive 2018 \cs{counterwithin}
-% and \cs{counterwithout} will be moved into the kernel. We therefore
-% change to using \cs{providecommand} instead of \cs{newcommand} to
-% avoid colisions}
-%    \begin{macrocode}
-\providecommand{\counterwithout}{\@ifstar{\@csoutstar}{\@csout}}
-\providecommand{\@csoutstar}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}}}
-\providecommand{\@csout}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}%
-                        \@namedef{the#1}{\arabic{#1}}}}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%    Any number of \verb?\counterwithin{ctr}{...}? and \verb?\counterwithout{ctr}{...}?
-% commands can be issued for a given counter, ctr, if you wish to toggle
-% between the two styles. The current value of ctr is unaffected by
-% \cs{counterwithin} and \cs{counterwithout}. If you want to change the value
-% after one of these commands, use \verb?\setcounter{ctr}{...}?, and to change
-% the typeseting style use \verb?\renewcommand{\thectr}{...}?.
-%
 % 
 % \begin{macro}{\letcountercounter}
 % \begin{macro}{\c at m@morig at ctr}
@@ -33430,7 +33621,6 @@
 %                             figure float}
 %    \begin{macrocode}
 \newfloat[chapter]{figure}{lof}{\figurename}
-%%%  \kill at lastcounter{lofdepth}
 \renewcommand{\thefigure}{\thechapter.\@arabic\c at figure}
 
 %    \end{macrocode}
@@ -33448,7 +33638,6 @@
 %                             listoffigures}
 %    \begin{macrocode}
 \newlistof{listoffigures}{lof}{\listfigurename}
-%%%  \kill at lastcounter{lofdepth}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -33461,7 +33650,6 @@
 %    \begin{macrocode}
 \newlistentry[chapter]{figure}{lof}{0}
   \cftsetindents{figure}{0em}{2.3em}
-%%  \kill at lastcounter{lofdepth}
 
 %    \end{macrocode}
 % \end{macro}
@@ -33476,7 +33664,6 @@
 %                             table float}
 %    \begin{macrocode}
 \newfloat[chapter]{table}{lot}{\tablename}
-%%%  \kill at lastcounter{lotdepth}
 \renewcommand{\thetable}{\thechapter.\@arabic\c at table}
 
 %    \end{macrocode}
@@ -33494,7 +33681,6 @@
 %                             list of tables}
 %    \begin{macrocode}
 \newlistof{listoftables}{lot}{\listtablename}
-%%%  \kill at lastcounter{lotdepth}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -33507,7 +33693,6 @@
 %    \begin{macrocode}
 \newlistentry[chapter]{table}{lot}{0}
   \cftsetindents{table}{0em}{2.3em}
-%%  \kill at lastcounter{lotdepth}
 
 %    \end{macrocode}
 % \end{macro}
@@ -33677,13 +33862,15 @@
 \EmulatedPackage{makeidx}[2008/07/23]
 \EmulatedPackage{moreverb}[2008/07/23]
 %    \end{macrocode}
+% \changes{v3.8.2a}{2024/01/29}{shortvrb is no longer emulated. No need to release as it is loaded before the emulation}
 % \changes{v3.7o}{2021/03/22}{removed mparhack emulation, as we don't
 % emulate all of it, especially not the fix for \cs{if at firstcolumn},
 % instead load it if twocolumn }
+% \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.}
 %    \begin{macrocode}
-\if at twocolumn
-  \RequirePackage{mparhack}
-\fi
+ % \if at twocolumn
+ %   \RequirePackage{mparhack}
+ % \fi
   %\EmulatedPackage{mparhack}[2008/07/23]
 \EmulatedPackage{needspace}[2008/07/23]
 \EmulatedPackage{newfile}[2008/07/23]
@@ -33692,12 +33879,17 @@
 \EmulatedPackage{parskip}[2008/07/23]
 \EmulatedPackage{patchcmd}[2008/07/23]
 \EmulatedPackage{setspace}[2008/07/23]
-\EmulatedPackage{shortvrb}[2008/07/23]
+%    \end{macrocode}
+% 
+% \changes{v3.8.3}{2025/03/05}{Forgot to remove shortvrb emulation in 3.8.2}
+%    \begin{macrocode}
+ % \EmulatedPackage{shortvrb}[2008/07/23]
 \EmulatedPackage{showidx}[2008/07/23]
 %    \end{macrocode}
 % \changes{v3.7g}{2018/03/02}{Updated the embedded version of \Lpack{tabularx} to v2.11 2016/02/03}
 % \changes{v3.7h}{2018/09/08}{\Lpack{tabularx} is no longer emulated,
 % but a required package}
+% \changes{v3.8.2a}{2024/01/29}{shortvrb is no longer emulated. No need to release as it is loaded before the emulation}
 %    \begin{macrocode}
  % \EmulatedPackage{tabularx}[2016/02/03]
 \EmulatedPackage{titleref}[2008/07/23]
@@ -33705,7 +33897,7 @@
 \EmulatedPackage{tocbibind}[2008/07/23]
 \EmulatedPackage{tocloft}[2008/07/23]
 \EmulatedPackage{tocvsec2}[2008/07/23]
-\EmulatedPackage{verbatim}[2008/07/23]
+ % \EmulatedPackage{verbatim}[2008/07/23]
 \EmulatedPackage{verse}[2008/07/23]
 
 %    \end{macrocode}
@@ -33742,6 +33934,64 @@
 \AtEndPackage{hyperref}{\RequirePackage{memhfixc}}      
 %    \end{macrocode}
 %
+% \subsection{Package that should not be used with memoir}
+%
+%   Some packages should not be used with the class. Primarily because
+%   we already provide a more well integrated solution, or if the
+%   package break class functionalily. We may add warnings for when
+%   users load certain of these package.
+%
+% \changes{v3.8.3}{2024/02/15}{Added warning about fancyhdr}
+%    \begin{macrocode}
+\AtBeginPackage{fancyhdr}{
+  \@memwarn{The fancyhdr package is not
+    recommended with memoir.\MessageBreak
+    We have our own well integrated interface
+    to handle\MessageBreak headers and footers. See the manual
+    section 7.3\MessageBreak onwards for details.}
+}
+%    \end{macrocode}
+% \changes{v3.8.3}{2024/03/04}{Added warning about titlesec}
+%    \begin{macrocode}
+\AtBeginPackage{titlesec}{
+  \@memwarn{The titlesec package is not
+    recommended with memoir.\MessageBreak
+    With it we loose some of the features provides by the\MessageBreak
+    class. We provide our own interface to adjust how \MessageBreak
+    sections and chapters should look like.\MessageBreak
+    See the manual sections 6.4 through 6.6 for details.
+  }
+}
+%    \end{macrocode}
+% \changes{v3.8.3}{2024/03/04}{Added warning about titleps}
+%    \begin{macrocode}
+\AtBeginPackage{titleps}{
+  \@memwarn{The titleps package is not
+    recommended with memoir.\MessageBreak
+    It cannot really work properly without the titlesec\MessageBreak
+    package, which is already incomparible with memoir.\MessageBreak
+    We have our own well integrated interface to \MessageBreak
+    handle headers and footers.\MessageBreak
+    See the manual section 7.3 onwards for details.
+  }
+}
+%    \end{macrocode}
+%   \changes{v3.8.3}{2024/03/04}{Added warning about sectsty, probably
+%   now needed as sectsty is unusable in modern LaTeX}
+%    \begin{macrocode}
+\AtBeginPackage{sectsty}{
+  \@memwarn{%
+    The sectsty package is super old (has not been updated\MessageBreak
+    since 2002) and is unlikely to be compatible with modern\MessageBreak
+    LaTeX. We provide our own interface to adjust how \MessageBreak
+    sections and chapters should look like.\MessageBreak
+    See the manual sections 6.4 through 6.6 for details.
+  }
+}
+%    \end{macrocode}
+%
+%
+%
 % \subsection{Default page style}
 %    We use the page style \pstyle{headings} by
 %    default and arabic page numbering. But if the \verb?article?
@@ -33855,7 +34105,7 @@
 % Donald Arseneau.
 % \newblock \emph{\Lpack{Placeins} package (version 2.2)}.
 % \newblock May 2005.
-% \newblock (Available from CTN as
+% \newblock (Available from CTAN as
 %            \texttt{macros/latex/contrib/placeins/placeins.sty})
 %  
 %
@@ -33866,7 +34116,15 @@
 % \newblock (Available from CTAN in 
 %            \texttt{/macros/latex/contrib/misc})
 %
+% \bibitem[Source2e]{SOURCE2E}
+%   Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank Mittelbach,
+%   Chris Rowley and Rainer Schöpf (maintained by the \LaTeX\ Project).
+%   \newblock \emph{The \LaTeX2e\ Sources}
+%   \newblock November 2023.
+%   \newblock (Available from CTAN as
+%                  \texttt{/macros/latex/base/source2e.pdf})
 %
+% 
 %  \bibitem[Car94]{DELARRAY}
 %  David Carlisle.
 %  \newblock \emph{The \Lpack{delarray} package}.
@@ -34205,6 +34463,7 @@
 % \endgroup
 %
 %
+%
 % \Finale
 %
 \endinput

Modified: trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx	2025-03-06 21:32:04 UTC (rev 74481)
@@ -3,7 +3,9 @@
 % mempatch.dtx
 % Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
 % Maintainer: Lars Madsen (daleif at math dot au dot dk)
-% Copyright 2001 --- 2010 Peter R. Wilson
+% Copyright 2001 -- 2010 Peter R. Wilson
+% Copyright 2011 -- 2013 Peter R. Wilson
+% Copyright 2013--       Lars Madsen
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either
@@ -20,7 +22,7 @@
 %
 % 
 % \fi
-% \CheckSum{549}
+% \CheckSum{559}
 %
 % \def\dtxfile{\texttt{mempatch.dtx}}
 % \def\fileversion{v1.0} \def\filedate{2003/10/04}
@@ -78,7 +80,9 @@
 %        \filedate.}}
 %
 % \author{%
-% Peter Wilson\thanks{\texttt{herries dot press at earthlink dot net}}\\
+% Peter Wilson
+% ^^A\thanks{\texttt{herries dot press at earthlink dot net}}\\
+% \\ Maintained by Lars Madsen\thanks{daleif at math dot au dot dk} \\
 % The Herries Press
 % }
 % \date{\filedate}
@@ -312,6 +316,7 @@
 %% With the new hooking system from 2020+ memhfixc is automatically
 %% added after loading hyperref with the memoir class
 %%
+%% Version 1.23  2025/03/06
 %% Version 1.22  2023/09/10
 %% Version 1.21  2023/07/28
 %% Version 1.21  2023/07/28
@@ -341,7 +346,7 @@
 % 
 %
 %    \begin{macrocode}
-\ProvidesPackage{memhfixc}[2023/09/10 v1.22 hyperref package fixes for memoir class]
+\ProvidesPackage{memhfixc}[2025/03/06 v1.23 hyperref package fixes for memoir class]
 %    \end{macrocode}
 %
 % \begin{macro}{\M at hfixcfinish}
@@ -436,6 +441,20 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\Hy at captionsfrench}
+% \begin{macro}{\HyLang at french}
+% For completeness, lets add french as well
+% \changes{v1.23}{2025/03/05}{Added french support}
+%    \begin{macrocode}
+\@ifundefined{Hy at captionsfrench}{}{%
+  \g at addto@macro{\Hy at captionsfrench}{\def\bookautorefname{Livre}}}
+\@ifundefined{HyLang at french}{}{%
+  \g at addto@macro{\HyLang at french}{\def\bookautorefname{Livre}}}
+
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% 
 % \begin{macro}{\Hy at captionsspanish}
 % \begin{macro}{\HyLang at spanish}
 %    \begin{macrocode}
@@ -833,13 +852,14 @@
 %    \end{macrocode}  
 % Fill in two hook responsable for turning the note marker in the text
 % into a hyperlink. The code is more or less copied from
-% \Lpack{hyperref}'s footnote handling.
+% \Lpack{hyperref}'s footnote handling. TODO: Redefine this at some point.
+% \changes{1.23}{2025/02/25}{Renaming the Hpagenote counter, to avoid hyperef warning.}
 %    \begin{macrocode}
-  \newcounter{Hpagenote}
+  \newcounter{mem at Hpagenote}
   \@namedef{mem at pnmm@start at hook}{%
-    \stepcounter{Hpagenote}%
+    \stepcounter{mem at Hpagenote}%
     \global\let\Hy at saved@currentHref\@currentHref
-    \hyper at makecurrent{Hpagenote}%
+    \hyper at makecurrent{mem at Hpagenote}%
     \global\let\Hy at pagenote@currentHref\@currentHref 
     \global\let\@currentHref\Hy at saved@currentHref
     \hyper at linkstart{link}{\Hy at pagenote@currentHref}%

Modified: trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty	2025-03-06 21:32:04 UTC (rev 74481)
@@ -44,6 +44,7 @@
 %% With the new hooking system from 2020+ memhfixc is automatically
 %% added after loading hyperref with the memoir class
 %%
+%% Version 1.23  2025/03/06
 %% Version 1.22  2023/09/10
 %% Version 1.21  2023/07/28
 %% Version 1.21  2023/07/28
@@ -69,7 +70,7 @@
 %% Version 1.1  2003/01/22
 %% Version 1.0  2002/10/22
 %%
-\ProvidesPackage{memhfixc}[2023/09/10 v1.22 hyperref package fixes for memoir class]
+\ProvidesPackage{memhfixc}[2025/03/06 v1.23 hyperref package fixes for memoir class]
 \let\M at hfixcfinish\relax
 \@ifclassloaded{memoir}{}%
                        {\let\M at hfixcfinish\endinput
@@ -103,6 +104,11 @@
 \@ifundefined{HyLang at portuges}{}{%
   \g at addto@macro{\HyLang at portuges}{\def\bookautorefname{Livro}}}
 
+\@ifundefined{Hy at captionsfrench}{}{%
+  \g at addto@macro{\Hy at captionsfrench}{\def\bookautorefname{Livre}}}
+\@ifundefined{HyLang at french}{}{%
+  \g at addto@macro{\HyLang at french}{\def\bookautorefname{Livre}}}
+
 \@ifundefined{Hy at captionsspanish}{}{%
   \g at addto@macro{\Hy at captionsspanish}{\def\bookautorefname{Libro}}}
 \@ifundefined{HyLang at spanish}{}{%
@@ -312,11 +318,11 @@
 \ifHy at hyperfootnotes
   \let\m at m@pnwrite at fourtharg\m at m@pnwrite at fourtharg@hyperref
   \let\pagenoteanchor\pagenotehyperanchor
-  \newcounter{Hpagenote}
+  \newcounter{mem at Hpagenote}
   \@namedef{mem at pnmm@start at hook}{%
-    \stepcounter{Hpagenote}%
+    \stepcounter{mem at Hpagenote}%
     \global\let\Hy at saved@currentHref\@currentHref
-    \hyper at makecurrent{Hpagenote}%
+    \hyper at makecurrent{mem at Hpagenote}%
     \global\let\Hy at pagenote@currentHref\@currentHref
     \global\let\@currentHref\Hy at saved@currentHref
     \hyper at linkstart{link}{\Hy at pagenote@currentHref}%

Modified: trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls	2025-03-06 21:31:51 UTC (rev 74480)
+++ trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls	2025-03-06 21:32:04 UTC (rev 74481)
@@ -29,19 +29,34 @@
 \def\mem at atleast@kernel{2021/06/01}
 \NeedsTeXFormat{LaTeX2e}[\mem at atleast@kernel]
 \ProvidesClass{memoir}%
-  [2024/01/26 v3.8.2 configurable book, report, article document class]
-\newcommand\memversion{v3.8.2, 2024/01/26}
+  [2025/03/06 v3.8.3 configurable book, report, article document class]
+\newcommand\memversion{v3.8.3, 2025/03/06}
 \providecommand\IfFormatAtLeastTF{\@ifl at t@r\fmtversion}
 \IfFormatAtLeastTF{\mem at atleast@kernel}{}{
   \ClassError{memoir}{%
     Your LaTeX release is too old.\MessageBreak
     The memoir class requires at LaTeX format\MessageBreak
-    from at least \mem at atleast@kernel\space  onwards. Please update your\MessageBreak
+    from at least \mem at atleast@kernel\space  onwards.
+    Please update your\MessageBreak
     entire LaTeX installation instead of manually updating\MessageBreak
     just memoir}{}
     \batchmode\read-1to\@tempa% evil mode engaged
 }
 \RequirePackage{xpatch}
+\ExplSyntaxOn
+\NewDocumentCommand\MarkDeprecated{smm}{
+  % see if macro exists, if so don't give warning
+  \cs_if_exist:cTF {__memoir_deprecated_\cs_to_str:N #2:}{}{% already showed one warning
+    % marker macro did not exist, globally define it and give warning
+    \IfBooleanF{#1}{\cs_gset:cn {__memoir_deprecated_\cs_to_str:N #2:}{}}
+    \@memwarn{
+      \string#2~is~marked~deprecated~and~will~be\MessageBreak
+      removed~#3
+    }
+  }
+}
+\ExplSyntaxOff
+
 \newcommand*{\@ptsize}{}
 \newcommand*{\@memptsize}{}
 \newlength{\onelineskip}
@@ -84,11 +99,6 @@
 \newif\ifm at m@Or
 \newif\ifm at m@Xor
 
-\newcommand{\kill at lastcounter}[1]{%
-  \count\count10 \z@
-  \advance\count10 \m at ne
-  \expandafter\let\csname c@#1\endcsname\relax}
-
 \newcommand{\@name at p@xdef}[1]{%
   \expandafter\protected at xdef\csname #1\endcsname}
 \newcommand{\@name at unresp@xdef}[1]{%
@@ -153,11 +163,11 @@
 \def\@emulated at package#1[#2]{%
   \expandafter\xdef\csname ver@#1.\@pkgextension\endcsname{#2}%
   \@ifundefined{opt@#1.\@pkgextension}%
-    {\@namedef{opt@#1.\@pkgextension}{}}{}%
+  {\@namedef{opt@#1.\@pkgextension}{}}{}%
   \wlog{Package #1 \ifx\@empty#2\else[#2] \fi
-        \if,\csname opt@#1.\@pkgextension\endcsname,\else
-        (with options \csname opt@#1.\@pkgextension\endcsname) \fi
-        emulated by \@currname.}%
+    \if,\csname opt@#1.\@pkgextension\endcsname,\else
+      (with options \csname opt@#1.\@pkgextension\endcsname) \fi
+    emulated by \@currname.}%
 }
 \@onlypreamble\EmulatedPackage
 \@onlypreamble\EmulatedPackageWithOptions
@@ -164,7 +174,8 @@
 \@onlypreamble\@emulated at package
 
 \newcommand*{\DisemulatePackage}[1]{%
-  \@namelet{ver@#1.\@pkgextension}\relax}
+  \@namelet{ver@#1.\@pkgextension}\relax
+}
 \@onlypreamble\DisemulatePackage
 
 \IfFormatAtLeastTF{2020/10/01}{
@@ -319,7 +330,11 @@
   \fi
 }
 
-\def\addtodef{\@star at or@long\wo at daddtodef}
+\def\addtodef{%
+   \MarkDeprecated{\addtodef}{in 2026, use instead \string\patchcmd,\MessageBreak%
+   \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+   (which is autoloaded by the class)}
+  \@star at or@long\wo at daddtodef}
 \long\def\wo at daddtodef#1#2#3{%
   \wo at difmacro@begingroup{#1}{%
     \@temptokena{#2}%
@@ -330,7 +345,11 @@
   }%
 }
 
-\def\addtoiargdef{\@star at or@long\wo at daddtoiargdef}
+\def\addtoiargdef{%
+   \MarkDeprecated{\addtoiargdef}{in 2026, use instead \string\patchcmd,\MessageBreak%
+   \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+   (which is autoloaded by the class)}
+  \@star at or@long\wo at daddtoiargdef}
 \long\def\wo at daddtoiargdef#1#2#3{%
   \wo at difmacro@begingroup{#1}{%
     \@temptokena{#2}%
@@ -343,6 +362,9 @@
 
 %%%%%%%%%%%%%%%% Michael Downes' patchcmd 2000/07/31 v1.03 %%%%%%%%
 \newcommand{\patchcommand}[1]{%
+  \MarkDeprecated{\patchcommand}{in 2026, use instead \string\patchcmd,\MessageBreak%
+    \string\pretocmd\space or \string\apptocmd\space from the etoolbox package\MessageBreak%
+    (which is autoloaded by the class)}
   \expandafter\patchcmd at a\meaning#1??->@\@nil#1%
 }
 \long\def\patchcmd at a#1#2#3->#4#5\@nil#6{%
@@ -736,12 +758,18 @@
   \renewcommand*{\@ptsize}{\@memptsize}
   \usefont{\memfontenc}{\memfontfamily}{m}{n}
   \input{\@nyptclofile}
-  \usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
+  \RequirePackage{\memfontpack}
+  \iftutex\else
+    \RequirePackage[\memfontenc]{fontenc}
+  \fi
 \else
   \ifextrafontsizes
     \usefont{\memfontenc}{\memfontfamily}{m}{n}
     \input{mem\@memptsize.clo}
-    \usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
+    \RequirePackage{\memfontpack}
+    \iftutex\else
+      \RequirePackage[\memfontenc]{fontenc}
+    \fi
   \else
     \ifnum\@memptsize > 17\relax
       \@memerror{The `extrafontsizes' option is required to use \MessageBreak
@@ -1089,12 +1117,10 @@
 
 \newcommand*{\@memznegtest}[1]{%
   \ifdim#1>\z@\else
- %%%%   \@memerror{\protect#1\space is zero or negative}{\@ehd}%
     \@memwarn{\protect#1\space is zero or negative}%
   \fi}
 \newcommand*{\@memnegtest}[1]{%
   \ifdim#1<\z@
-%%%%    \@memerror{\protect#1\space is negative}{\@ehd}%
     \@memwarn{\protect#1\space is negative}%
   \fi}
 
@@ -1161,9 +1187,7 @@
   \@memznegtest{\stockwidth}
   \@memznegtest{\paperwidth}
   \@memznegtest{\textwidth}
-%%%  \@memznegtest{\spinemargin}
   \@memnegtest{\spinemargin}
-%%%  \@memznegtest{\foremargin}
   \@memnegtest{\foremargin}
   \@memznegtest{\marginparsep}
   \@memznegtest{\marginparwidth}
@@ -1170,15 +1194,10 @@
   \@memznegtest{\stockheight}
   \@memznegtest{\paperheight}
   \@memznegtest{\textheight}
-%%%  \@memznegtest{\uppermargin}
   \@memnegtest{\uppermargin}
-%%%  \@memznegtest{\lowermargin}
   \@memnegtest{\lowermargin}
-%%%  \@memznegtest{\headheight}
   \@memnegtest{\headheight}
-%%%  \@memznegtest{\headsep}
   \@memnegtest{\headsep}
-%%%  \@memznegtest{\footskip}
   \@memnegtest{\footskip}
   \nametest{#1}{classic}%
   \ifsamename
@@ -1296,57 +1315,75 @@
   \mem at reset@used at macros
 }
 
+\ExplSyntaxOn
 \newcommand\settypeoutlayoutunit[1]{
-  \nametest{#1}{pt}
-  \ifsamename
-    \def\mem at tl@unit{#1}
-    \def\mem at tl@unitperpt{1.0}
-  \else
-    \nametest{#1}{pc}
-    \ifsamename
-      \def\mem at tl@unit{#1}
-      \def\mem at tl@unitperpt{0.083333}
-    \else
-      \nametest{#1}{in}
-      \ifsamename
-        \def\mem at tl@unit{#1}
-        \def\mem at tl@unitperpt{0.013837}
-      \else
-        \nametest{#1}{mm}
-        \ifsamename
-          \def\mem at tl@unit{#1}
-          \def\mem at tl@unitperpt{0.351459}
-        \else
-          \nametest{#1}{cm}
-          \ifsamename
-            \def\mem at tl@unit{#1}
-            \def\mem at tl@unitperpt{0.0351459}
-          \else
-            \nametest{#1}{bp}
-            \ifsamename
-              \def\mem at tl@unit{#1}
-              \def\mem at tl@unitperpt{0.996264}
-            \else
-              \nametest{#1}{dd}
-              \ifsamename
-                \def\mem at tl@unit{#1}
-                \def\mem at tl@unitperpt{0.9345718}
-              \else
-                \nametest{#1}{cc}
-                \ifsamename
-                  \def\mem at tl@unit{#1}
-                  \def\mem at tl@unitperpt{0.0778809}
-                \else
-                  \@memerror{Unknown unit '#1' not suitable for layout listing}{}
-                \fi
-              \fi
-            \fi
-          \fi
-        \fi
-      \fi
-    \fi
-  \fi
+  \def\mem at tl@unit{#1}
+  \str_case_e:nnF{#1}{
+    {pt}{ \def\mem at tl@unitperpt{1.0}       }
+    {pc}{ \def\mem at tl@unitperpt{0.083333}  }
+    {in}{ \def\mem at tl@unitperpt{0.013837}  }
+    {mm}{ \def\mem at tl@unitperpt{0.351459}  }
+    {cm}{ \def\mem at tl@unitperpt{0.0351459} }
+    {bp}{ \def\mem at tl@unitperpt{0.996264}  }
+    {dd}{ \def\mem at tl@unitperpt{0.9345718} }
+    {cc}{ \def\mem at tl@unitperpt{0.0778809} }
+  }{ % or error
+    \@memerror{Unknown~unit~'#1'~not~suitable~for~layout\MessageBreak listing}{}
+  }
 }
+\ExplSyntaxOff
+
+ %\newcommand\settypeoutlayoutunit[1]{
+ %  \nametest{#1}{pt}
+ %  \ifsamename
+ %    \def\mem at tl@unit{#1}
+ %    \def\mem at tl@unitperpt{1.0}
+ %  \else
+ %    \nametest{#1}{pc}
+ %    \ifsamename
+ %      \def\mem at tl@unit{#1}
+ %      \def\mem at tl@unitperpt{0.083333}
+ %    \else
+ %      \nametest{#1}{in}
+ %      \ifsamename
+ %        \def\mem at tl@unit{#1}
+ %        \def\mem at tl@unitperpt{0.013837}
+ %      \else
+ %        \nametest{#1}{mm}
+ %        \ifsamename
+ %          \def\mem at tl@unit{#1}
+ %          \def\mem at tl@unitperpt{0.351459}
+ %        \else
+ %          \nametest{#1}{cm}
+ %          \ifsamename
+ %            \def\mem at tl@unit{#1}
+ %            \def\mem at tl@unitperpt{0.0351459}
+ %          \else
+ %            \nametest{#1}{bp}
+ %            \ifsamename
+ %              \def\mem at tl@unit{#1}
+ %              \def\mem at tl@unitperpt{0.996264}
+ %            \else
+ %              \nametest{#1}{dd}
+ %              \ifsamename
+ %                \def\mem at tl@unit{#1}
+ %                \def\mem at tl@unitperpt{0.9345718}
+ %              \else
+ %                \nametest{#1}{cc}
+ %                \ifsamename
+ %                  \def\mem at tl@unit{#1}
+ %                  \def\mem at tl@unitperpt{0.0778809}
+ %                \else
+ %                  \@memerror{Unknown unit '#1' not suitable for layout listing}{}
+ %                \fi
+ %              \fi
+ %            \fi
+ %          \fi
+ %        \fi
+ %      \fi
+ %    \fi
+ %  \fi
+ %}
 \settypeoutlayoutunit{pt}
 \newcommand\mem at typeouttwolengths[4]{
   % #1 = text before
@@ -2667,35 +2704,69 @@
   \global\let\theauthor\relax
   \global\let\thedate\relax}
 
-\addtoiargdef{\title}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\thetitle{#1}
-  \endgroup\endgroup}
-\addtoiargdef{\author}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\and}{\unskip, }
-    \renewcommand{\andnext}{\unskip, }
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\theauthor{#1}
-  \endgroup\endgroup}
-\addtoiargdef{\date}{%
-  \begingroup\let\footnote\@gobble}{%
-  \begingroup
-    \renewcommand{\thanks}[1]{}
-    \renewcommand{\thanksmark}[1]{}
-    \renewcommand{\thanksgap}[1]{}
-    \protected at xdef\thedate{#1}
-  \endgroup\endgroup}
+ % \addtoiargdef{\title}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\thetitle{#1}
+ %     \endgroup\endgroup}
 
-\newcommand*{\bookpagemark}[1]{}
-\newcommand*{\partmark}[1]{}
+\xpretocmd\title{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\title\space failed, please inform maintainer}}
+\xapptocmd\title{
+  \begingroup%
+    \renewcommand{\thanks}[1]{}%
+     \renewcommand{\thanksmark}[1]{}%
+     \renewcommand{\thanksgap}[1]{}%
+     \protected at xdef\thetitle{#1}%
+   \endgroup\endgroup%
+}{}{\typeout{patch 2 to \string\title\space failed, please inform maintainer}}
+
+ % \addtoiargdef{\author}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\and}{\unskip, }
+ %     \renewcommand{\andnext}{\unskip, }
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\theauthor{#1}
+ %   \endgroup\endgroup}
+
+\xpretocmd\author{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
+\xapptocmd\author{%
+   \begingroup%
+     \renewcommand{\thanks}[1]{}%
+     \renewcommand{\and}{\unskip, }%
+     \renewcommand{\andnext}{\unskip, }%
+     \renewcommand{\thanksmark}[1]{}%
+     \renewcommand{\thanksgap}[1]{}%
+     \protected at xdef\theauthor{#1}%
+   \endgroup\endgroup%
+}{}{\typeout{patch 1 to \string\author\space failed, please inform maintainer}}
+
+ % \addtoiargdef{\date}{%
+ %   \begingroup\let\footnote\@gobble}{%
+ %   \begingroup
+ %     \renewcommand{\thanks}[1]{}
+ %     \renewcommand{\thanksmark}[1]{}
+ %     \renewcommand{\thanksgap}[1]{}
+ %     \protected at xdef\thedate{#1}
+ %   \endgroup\endgroup}
+
+\xpretocmd\date{\begingroup\let\footnote\@gobble}{}{\typeout{patch 1 to \string\date\space failed, please inform maintainer}}
+\xapptocmd\date{%
+  \begingroup%
+    \renewcommand{\thanks}[1]{}%
+    \renewcommand{\thanksmark}[1]{}%
+    \renewcommand{\thanksgap}[1]{}%
+    \protected at xdef\thedate{#1}%
+  \endgroup\endgroup%
+}{}{\typeout{patch 2 to \string\date\space failed, please inform maintainer}}
+
+\newcommand*{\bookpagemark}[1]{\markboth{}{}}
+\newcommand*{\partmark}[1]{\markboth{}{}}
 \newcommand*{\chaptermark}[1]{}
 
 \newcommand*{\bibmark}{}
@@ -3197,7 +3268,7 @@
 \makechapterstyle{article}{%
   \chapterstyle{default}
   \setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
-  \renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
+  \renewcommand*{\chapterheadstart}{\addvspace{\beforechapskip}}
   \setlength{\afterchapskip}{2.3ex \@plus .2ex}
   \renewcommand{\printchaptername}{}
   \renewcommand{\chapternamenum}{}
@@ -4950,10 +5021,14 @@
   \begin{@twocolumnfalse}\begin{abstract}}{%
   \end{abstract}\end{@twocolumnfalse}}
 
-\addtoiargdef{\thanks}{}{%
-  \protected at xdef\@bs at thanks{\@bs at thanks
+ % \addtoiargdef{\thanks}{}{%
+ %   \protected at xdef\@bs at thanks{\@bs at thanks
+ %     \protect\footnotetext[\the\c at footnote]{#1}}%
+ %   }
+\xapptocmd\thanks{%
+   \protected at xdef\@bs at thanks{\@bs at thanks
     \protect\footnotetext[\the\c at footnote]{#1}}%
-}
+}{}{\typeout{Patch to \string\thanks\space failed, please inform maintainer}}
 \let\@bs at thanks\@empty
 
 \newcommand{\saythanks}{\begingroup
@@ -4965,10 +5040,6 @@
 \newcounter{modulo at vs}
 \newcounter{memfvsline}
 
-%%%\newcommand{\poemlines}[1]{\linenumberfrequency{#1}%
-%%%  \@memwarn{Use \string\linenumberfrequency\space
-%%%                        instead of \string\poemlines}}
-
 \newcommand{\linenumberfont}[1]{\def\vlvnumfont{#1}}
 %%% \linenumberfont{\small\rmfamily}
 
@@ -5054,18 +5125,28 @@
 \verselinenumbersright
 
 \newcommand*{\@vslnumright}{%
-  \nobreak%
-  \hfill\rlap{%\kern\vrightskip\kern\rightmargin%
-              \kern\memRTLvrightskip\kern\rightmargin%
-              \vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
+  %\nobreak%
+  %\hfill\rlap{%\kern\vrightskip\kern\rightmargin%
+  %            \kern\memRTLvrightskip\kern\rightmargin%
+  %            \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
+  \rlap{%
+    \hspace{\dimexpr-\@totalleftmargin+\textwidth+\memRTLvrightskip}%
+    {\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
+  }%
+}
 \newcommand*{\@vslnumleft}{%
-  \nobreak%
-  \hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
-              \kern-\textwidth\kern-\memRTLvrightskip%
-              \vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
+  % \nobreak%
+  % \hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
+  %            \kern-\textwidth\kern-\memRTLvrightskip%
+  %            \vlvnumfont\getthelinenumber{poemline}{memfvsline}}
+  \llap{%
+    \llap{\vlvnumfont\getthelinenumber{poemline}{memfvsline}}%
+    \hspace{\dimexpr\@totalleftmargin+\memRTLvrightskip}%
+  }%
+}
 \newcommand{\@vscentercr}{%
   \ifhmode \unskip\else \@nolnerr\fi
-  \@vstypelinenum%
+  % \@vstypelinenum% outcommented 2024/02/06
   \@vsifgt{\verselinebreak}{%
     \incr at vsline
     \par\@ifstar{\nobreak\@vsxcentercr}{%
@@ -5109,6 +5190,10 @@
           \fi}
   \item[]}{\endlist}
 
+\AddToHook{env/verse/begin}{%
+  \AddToHook{para/begin}[memoir/versenum]{\@vstypelinenum}}
+\AddToHook{env/verse/end}{\RemoveFromHook{para/begin}[memoir/versenum]}
+
 \newenvironment{altverse}%
   {\starpatternfalse\patternfalse\altindenttrue
    \setcounter{vslineno}{1}}%
@@ -7087,6 +7172,8 @@
 \newcommand{\@cftbsnum}{}
 \newcommand{\@cftasnum}{}
 \newcommand{\@cftasnumb}{}
+\newcommand\setcftvspacecmd[1]{\def\mem at cft@vspace at cmd{#1}}
+\setcftvspacecmd{\vskip}
 \newcommand{\newlistentry}[4][\@empty]{%
   \@ifundefined{c@#2}{%    check & set the counter
     \ifx \@empty#1\relax
@@ -7099,7 +7186,8 @@
   \setcounter{#2}{0}
   \@namedef{l@#2}##1##2{%
     \ifnum \@nameuse{c@#3depth} > #4\relax
-      \vskip \@nameuse{cftbefore#2skip}
+      % \vskip \@nameuse{cftbefore#2skip}
+      \mem at cft@vspace at cmd \@nameuse{cftbefore#2skip}
       {%\leftskip \@nameuse{cft#2indent}\relax
        \newcommand*\cftwhatismyname{#2}%
        \memRTLleftskip \@nameuse{cft#2indent}\relax
@@ -7171,8 +7259,10 @@
 
 \newcommand*{\cftbookname}{}
 
-\newcommand*{\cftbookbreak}{\addpenalty{-\@highpenalty}%
-  \addvspace{\cftbeforebookskip}}
+\newcommand*{\cftbookbreak}{%
+  \addpenalty{\cftbeforepartpenalty}%
+  \addvspace{\cftbeforebookskip}%
+}
 \newcommand*{\l at book}[2]{%
   \ifnum\c at tocdepth >-3\relax
     \cftbookbreak
@@ -7210,6 +7300,7 @@
 
 \newlength{\cftbeforebookskip}
   \setlength{\cftbeforebookskip}{2.25em \@plus\p@}
+\newcommand\cftbeforebookpenalty{-\@highpenalty}
 \newdimen\cftbookindent
   \setlength{\cftbookindent}{0em}
 \newdimen\cftbooknumwidth
@@ -7235,8 +7326,10 @@
 
 \newcommand*{\cftpartname}{}
 
-\newcommand*{\cftpartbreak}{\addpenalty{-\@highpenalty}%
-  \addvspace{\cftbeforepartskip}}
+\newcommand*{\cftpartbreak}{%
+  \addpenalty{\cftbeforepartpenalty}%
+  \addvspace{\cftbeforepartskip}%
+}
 \newcommand*{\l at part}[2]{%
   \ifnum \c at tocdepth >-2\relax
     \cftpartbreak
@@ -7277,6 +7370,7 @@
 
   \newlength{\cftbeforepartskip}
     \setlength{\cftbeforepartskip}{2.25em \@plus\p@}
+  \newcommand\cftbeforepartpenalty{-\@highpenalty}
   \newlength{\cftpartindent}
     \setlength{\cftpartindent}{0em}
   \newlength{\cftpartnumwidth}
@@ -7304,7 +7398,7 @@
 \newcommand*{\l at chapapp}[3]{%
   \ifnum \c at tocdepth >\m at ne
     \cftchapterbreak
-    \vskip \cftbeforechapterskip
+    % \vskip \cftbeforechapterskip
     {%\leftskip \cftchapterindent\relax
      \memRTLleftskip \cftchapterindent\relax
 %%%     \rightskip \@tocrmarg
@@ -7348,6 +7442,7 @@
 
   \newlength{\cftbeforechapterskip}
     \setlength{\cftbeforechapterskip}{1.0em \@plus\p@}
+  \newcommand\cftbeforechapterpenalty{-\@highpenalty}
   \newlength{\cftchapterindent}
     \setlength{\cftchapterindent}{0em}
   \newlength{\cftchapternumwidth}
@@ -7369,7 +7464,10 @@
     {\cftchapterleader}\nobreak
     \cftchapterformatpnum{#1}%
     \cftchapterafterpnum\par}
-  \newcommand{\cftchapterbreak}{\addpenalty{-\@highpenalty}}
+\newcommand{\cftchapterbreak}{%
+  \addpenalty{\cftbeforechapterpenalty}%
+  \mem at cft@vspace at cmd \cftbeforechapterskip%
+}
 
 \newlistentry[chapter]{section}{toc}{0}
   \cftsetindents{section}{1.5em}{2.3em}
@@ -7443,138 +7541,212 @@
                               {\protect\ignorespaces #4}}{#5}}}
 \newcommand*{\cftinsert}[1]{\@nameuse{cftinsert#1}}
 \newcommand{\cftinsertcode}[2]{\@namedef{cftinsert#1}{#2}}
-\newcommand*{\cftinserthook}[2]{%
-  \addtocontents{#1}{\protect\cftinsert\protect{#2\protect}}}
+\NewDocumentCommand\cftinserthook{smm}{
+  \IfBooleanTF{#1}{
+    \ifdim\pagetotal>\z@
+      \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}
+      \clearpage
+    \else
+      \immediateaddtocontents{#2}{\noexpand\cftinsert{#3}}
+    \fi
+  }{%
+    \addtocontents{#2}{\protect\cftinsert\protect{#3\protect}}%
+  }%
+}
 
+\ExplSyntaxOn
 \newcommand*{\@setclcnt}[2]{%
-  \def\@setclcntok{0}% = false
-  \nametest{#1}{none}%
-  \ifsamename
-    \setcounter{#2}{-10}%
-    \def\@setclcntok{1}% = true
-  \fi
-  \nametest{#1}{book}%
-  \ifsamename
-    \setcounter{#2}{-2}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{part}%
-  \ifsamename
-    \setcounter{#2}{-1}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{chapter}%
-  \ifsamename
-    \setcounter{#2}{0}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{section}%
-  \ifsamename
-    \setcounter{#2}{1}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subsection}%
-  \ifsamename
-    \setcounter{#2}{2}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subsubsection}%
-  \ifsamename
-    \setcounter{#2}{3}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{paragraph}%
-  \ifsamename
-    \setcounter{#2}{4}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{subparagraph}%
-  \ifsamename
-    \setcounter{#2}{5}%
-    \def\@setclcntok{1}%
-  \fi
-  \nametest{#1}{all}%
-  \ifsamename
-    \setcounter{#2}{50}%
-    \def\@setclcntok{1}%
-  \fi
-%%  \if at tempswa\else
-    \ifnum \@setclcntok = 0\relax
-    \@memerror{%
-      Unknown document division name (#1)
+  \str_case_e:nnF{#1}{
+    {none}{          \setcounter{#2}{-10}}
+    {book}{          \setcounter{#2}{-2} }
+    {part}{          \setcounter{#2}{-1} }
+    {chapter}{       \setcounter{#2}{0}  }
+    {section}{       \setcounter{#2}{1}  }
+    {subsection}{    \setcounter{#2}{2}  }
+    {subsubsection}{ \setcounter{#2}{3}  }
+    {paragraph}{     \setcounter{#2}{4}  }
+    {subparagraph}{  \setcounter{#2}{5}  }
+    {all}{           \setcounter{#2}{50} }
+  }{
+     \@memerror{%
+       Unknown~document~division~name~(#1)
+     }{%
+      I'll~ignore~it.~
+      Type~<return>~and~I'll~continue.\MessageBreak
+      If~you~haven't~mistyped~the~name~then~ use~
+      \protect\setcounter~instead.}%
+  }
+}
+\ExplSyntaxOff
+ % \newcommand*{\@setclcnt}[2]{%
+ %   \def\@setclcntok{0}% = false
+ %   \nametest{#1}{none}%
+ %   \ifsamename
+ %     \setcounter{#2}{-10}%
+ %     \def\@setclcntok{1}% = true
+ %   \fi
+ %   \nametest{#1}{book}%
+ %   \ifsamename
+ %     \setcounter{#2}{-2}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{part}%
+ %   \ifsamename
+ %     \setcounter{#2}{-1}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{chapter}%
+ %   \ifsamename
+ %     \setcounter{#2}{0}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{section}%
+ %   \ifsamename
+ %     \setcounter{#2}{1}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subsection}%
+ %   \ifsamename
+ %     \setcounter{#2}{2}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subsubsection}%
+ %   \ifsamename
+ %     \setcounter{#2}{3}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{paragraph}%
+ %   \ifsamename
+ %     \setcounter{#2}{4}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{subparagraph}%
+ %   \ifsamename
+ %     \setcounter{#2}{5}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ %   \nametest{#1}{all}%
+ %   \ifsamename
+ %     \setcounter{#2}{50}%
+ %     \def\@setclcntok{1}%
+ %   \fi
+ % %%  \if at tempswa\else
+ %     \ifnum \@setclcntok = 0\relax
+ %     \@memerror{%
+ %       Unknown document division name (#1)
+ %     }{%
+ %      I'll ignore it.
+ %      Type \space <return> and I'll continue.\MessageBreak
+ %      If you haven't mistyped the name then use
+ %      \protect\setcounter\space instead.}%
+ %   \fi}
+ %
+ \ExplSyntaxOn
+\newcommand*{\settocdepth@}[2]{%
+  \str_case_e:nnTF{#2}{
+    {none}{          #1{toc}{\changetocdepth{-10}}}
+    {book}{          #1{toc}{\changetocdepth{-2}} }
+    {part}{          #1{toc}{\changetocdepth{-1}} }
+    {chapter}{       #1{toc}{\changetocdepth{0}}  }
+    {section}{       #1{toc}{\changetocdepth{1}}  }
+    {subsection}{    #1{toc}{\changetocdepth{2}}  }
+    {subsubsection}{ #1{toc}{\changetocdepth{3}}  }
+    {paragraph}{     #1{toc}{\changetocdepth{4}}  }
+    {subparagraph}{  #1{toc}{\changetocdepth{5}}  }
+    {all}{           #1{toc}{\changetocdepth{50}} }
+  }{
+    \@ifundefined{toclevel@#2}{%
+      \@memwarn{Unknown~toclevel~for~#2}%
     }{%
-     I'll ignore it.
-     Type \space <return> and I'll continue.\MessageBreak
-     If you haven't mistyped the name then use
-     \protect\setcounter\space instead.}%
-  \fi}
-
-\newcommand*{\settocdepth}[1]{%
-  \def\@chtodok{0}%   false
-  \nametest{#1}{none}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-10}}%
-    \def\@chtodok{1}%   true
-  \fi
-  \nametest{#1}{book}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-2}}%
-    \def\@chtodok{1}%
-  \fi
-  \nametest{#1}{part}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{-1}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{chapter}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{0}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{section}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{1}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subsection}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{2}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subsubsection}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{3}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{paragraph}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{4}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{subparagraph}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{5}}%
-    \def\@chtocdok{1}%
-  \fi
-  \nametest{#1}{all}%
-  \ifsamename
-    \addtocontents{toc}{\changetocdepth{50}}%
-    \def\@chtocdok{1}%
-  \fi
-  \ifnum\@chtocdok=1\relax
-    \@ifundefined{toclevel@#1}{%
-      \@memwarn{Unknown toclevel for #1}%
-    }{%
-      \setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
+      \setcounter{tocdepth}{\@nameuse{toclevel@#2}}%
     }
-  \else
+  }{
     \@memerror{%
-      Unknown document division name (#1)
+      Unknown~document~division~name~(#2)
     }{%
-     I'll ignore it.
-     Type \space <return> and I'll continue.}%
-  \fi}
+     I'll~ignore~ it.~
+     Type~<return>~and~I'll~continue.}%
+  }
+}
+\ExplSyntaxOff
+\NewDocumentCommand\settocdepth{sm}{%
+  \IfBooleanTF{#1}{%
+    \ifdim\pagetotal>\z@%
+      \settocdepth@{\addtocontents}{#2}%
+      \clearpage%
+    \else%
+      \settocdepth@{\immediateaddtocontents}{#2}%
+    \fi%
+  }{%
+    \settocdepth@{\addtocontents}{#2}%
+  }%
+}
 
+ %   \def\@chtodok{0}%   false
+ %   \nametest{#1}{none}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-10}}%
+ %     \def\@chtodok{1}%   true
+ %   \fi
+ %   \nametest{#1}{book}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-2}}%
+ %     \def\@chtodok{1}%
+ %   \fi
+ %   \nametest{#1}{part}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{-1}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{chapter}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{0}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{section}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{1}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subsection}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{2}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subsubsection}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{3}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{paragraph}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{4}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{subparagraph}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{5}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \nametest{#1}{all}%
+ %   \ifsamename
+ %     \addtocontents{toc}{\changetocdepth{50}}%
+ %     \def\@chtocdok{1}%
+ %   \fi
+ %   \ifnum\@chtocdok=1\relax
+ %     \@ifundefined{toclevel@#1}{%
+ %       \@memwarn{Unknown toclevel for #1}%
+ %     }{%
+ %       \setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
+ %     }
+ %   \else
+ %     \@memerror{%
+ %       Unknown document division name (#1)
+ %     }{%
+ %      I'll ignore it.
+ %      Type \space <return> and I'll continue.}%
+ %   \fi}
+
 \def\toclevel at none{-10}
 \def\toclevel at all{50}
 
@@ -9849,6 +10021,22 @@
   %\if at nobreak\ifvmode\nobreak\fi\fi%
 }
 
+ % \long\def\immediateaddtocontents#1#2{%
+ %  \immediate at protected@write\@auxout%
+ %  {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble \let\thepage\relax}%
+ %  {\string\@writefile{#1}{#2}}}
+\NewCommandCopy\immediateaddtocontents\addtocontents
+\patchcmd{\immediateaddtocontents}
+  {\protected at write}%
+  {\immediate at protected@write}%
+  {}%
+  {\typeout{patch 1 for \string\immediateaddtocontents\space failed}}
+\patchcmd{\immediateaddtocontents}%
+  {\let\glossary\@gobble}%
+  {\let\glossary\@gobble\let\thepage\relax}%
+  {}%
+  {\typeout{patch 2 for \string\immediateaddtocontents\space failed}}
+
 \newcommand{\m at m@pnwrite}[3]{\immediate\write#1{#3}}
 \newcommand{\m at m@pnwrited}[3]{\immediate\write#1{\detokenize{#3}\@percentchar}}
 
@@ -11003,51 +11191,23 @@
     {\newlength{#1}}%
     {\@memwarn{Length #1 already defined}}}
 
-\newcommand*{\newloglike}{\@ifstar{\m at mnewlogs}{\m at mnewlog}}
+\newcommand*{\newloglike}{%
+  \MarkDeprecated{\newloglike}{in 2026. We recommand using\MessageBreak%
+    \string\DeclareMathOperator\space from amsopn (amsmath) instead.}%
+  \@ifstar{\m at mnewlogs}{\m at mnewlog}}
 \newcommand*{\m at mnewlogs}[2]{%
   \newcommand*{#1}{\mathop{\operator at font #2}}}
 \newcommand*{\m at mnewlog}[2]{%
   \newcommand*{#1}{\mathop{\operator at font #2}\nolimits}}
 
-\newcommand*{\provideloglike}{\@ifstar{\m at mprovlogs}{\m at mprovlog}}
+\newcommand*{\provideloglike}{%
+  \MarkDeprecated*{\provideloglike}{in 2026}
+  \@ifstar{\m at mprovlogs}{\m at mprovlog}}
 \newcommand*{\m at mprovlogs}[2]{%
   \providecommand*{#1}{\mathop{\operator at font #2}}}
 \newcommand*{\m at mprovlog}[2]{%
   \providecommand*{#1}{\mathop{\operator at font #2}\nolimits}}
 
-\providecommand{\@removefromreset}[2]{{%
-  \expandafter\let\csname c@#1\endcsname\@removefromreset
-  \def\@elt##1{%
-    \expandafter\ifx\csname c@##1\endcsname\@removefromreset
-    \else
-      \noexpand\@elt{##1}%
-    \fi}%
-  \expandafter\xdef\csname cl@#2\endcsname{%
-    \csname cl@#2\endcsname}}}
-
-\newcommand{\@ifbothcntrs}[3]{%
-  \@ifundefined{c@#1}{% counter undefined
-    \@memerror{#1 is not a counter}{\@eha}}%
-  {% else counter is defined
-    \@ifundefined{c@#2}{% within undefined
-      \@memerror{#2 is not a counter}{\@eha}}%
-    {% else both counter and within  are defined
-     #3}}}
-
-\providecommand{\counterwithin}{\@ifstar{\@csinstar}{\@csin}}
-\providecommand{\@csinstar}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}}}
-\providecommand{\@csin}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}%
-                        \@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}}
-
-\providecommand{\counterwithout}{\@ifstar{\@csoutstar}{\@csout}}
-\providecommand{\@csoutstar}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}}}
-\providecommand{\@csout}[2]{%
-  \@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}%
-                        \@namedef{the#1}{\arabic{#1}}}}
-
 \newcommand*{\letcountercounter}[2]{%
   \expandafter\let\csname c at m@morig at ctr#1\expandafter\endcsname%
                    \csname c@#1\endcsname
@@ -12071,24 +12231,18 @@
 \fi
 
 \newfloat[chapter]{figure}{lof}{\figurename}
-%%%  \kill at lastcounter{lofdepth}
 \renewcommand{\thefigure}{\thechapter.\@arabic\c at figure}
 
 \newlistof{listoffigures}{lof}{\listfigurename}
-%%%  \kill at lastcounter{lofdepth}
 \newlistentry[chapter]{figure}{lof}{0}
   \cftsetindents{figure}{0em}{2.3em}
-%%  \kill at lastcounter{lofdepth}
 
 \newfloat[chapter]{table}{lot}{\tablename}
-%%%  \kill at lastcounter{lotdepth}
 \renewcommand{\thetable}{\thechapter.\@arabic\c at table}
 
 \newlistof{listoftables}{lot}{\listtablename}
-%%%  \kill at lastcounter{lotdepth}
 \newlistentry[chapter]{table}{lot}{0}
   \cftsetindents{table}{0em}{2.3em}
-%%  \kill at lastcounter{lotdepth}
 
 %%%\AtBeginDocument{%
 %%%  \@ifundefined{c at lofdepth}%
@@ -12163,9 +12317,9 @@
 \EmulatedPackage{index}[2008/07/23]
 \EmulatedPackage{makeidx}[2008/07/23]
 \EmulatedPackage{moreverb}[2008/07/23]
-\if at twocolumn
-  \RequirePackage{mparhack}
-\fi
+ % \if at twocolumn
+ %   \RequirePackage{mparhack}
+ % \fi
   %\EmulatedPackage{mparhack}[2008/07/23]
 \EmulatedPackage{needspace}[2008/07/23]
 \EmulatedPackage{newfile}[2008/07/23]
@@ -12174,7 +12328,7 @@
 \EmulatedPackage{parskip}[2008/07/23]
 \EmulatedPackage{patchcmd}[2008/07/23]
 \EmulatedPackage{setspace}[2008/07/23]
-\EmulatedPackage{shortvrb}[2008/07/23]
+ % \EmulatedPackage{shortvrb}[2008/07/23]
 \EmulatedPackage{showidx}[2008/07/23]
  % \EmulatedPackage{tabularx}[2016/02/03]
 \EmulatedPackage{titleref}[2008/07/23]
@@ -12182,12 +12336,47 @@
 \EmulatedPackage{tocbibind}[2008/07/23]
 \EmulatedPackage{tocloft}[2008/07/23]
 \EmulatedPackage{tocvsec2}[2008/07/23]
-\EmulatedPackage{verbatim}[2008/07/23]
+ % \EmulatedPackage{verbatim}[2008/07/23]
 \EmulatedPackage{verse}[2008/07/23]
 
 \AtBeginPackage{float}{\let\newfloat\relax}
 
 \AtEndPackage{hyperref}{\RequirePackage{memhfixc}}
+\AtBeginPackage{fancyhdr}{
+  \@memwarn{The fancyhdr package is not
+    recommended with memoir.\MessageBreak
+    We have our own well integrated interface
+    to handle\MessageBreak headers and footers. See the manual
+    section 7.3\MessageBreak onwards for details.}
+}
+\AtBeginPackage{titlesec}{
+  \@memwarn{The titlesec package is not
+    recommended with memoir.\MessageBreak
+    With it we loose some of the features provides by the\MessageBreak
+    class. We provide our own interface to adjust how \MessageBreak
+    sections and chapters should look like.\MessageBreak
+    See the manual sections 6.4 through 6.6 for details.
+  }
+}
+\AtBeginPackage{titleps}{
+  \@memwarn{The titleps package is not
+    recommended with memoir.\MessageBreak
+    It cannot really work properly without the titlesec\MessageBreak
+    package, which is already incomparible with memoir.\MessageBreak
+    We have our own well integrated interface to \MessageBreak
+    handle headers and footers.\MessageBreak
+    See the manual section 7.3 onwards for details.
+  }
+}
+\AtBeginPackage{sectsty}{
+  \@memwarn{%
+    The sectsty package is super old (has not been updated\MessageBreak
+    since 2002) and is unlikely to be compatible with modern\MessageBreak
+    LaTeX. We provide our own interface to adjust how \MessageBreak
+    sections and chapters should look like.\MessageBreak
+    See the manual sections 6.4 through 6.6 for details.
+  }
+}
 \ifartopt
 \pagestyle{plain}
 \else



More information about the tex-live-commits mailing list.