texlive[67850] Master/texmf-dist: memoir (8aug23)

commits+karl at tug.org commits+karl at tug.org
Tue Aug 8 21:53:20 CEST 2023


Revision: 67850
          http://tug.org/svn/texlive?view=revision&revision=67850
Author:   karl
Date:     2023-08-08 21:53:20 +0200 (Tue, 08 Aug 2023)
Log Message:
-----------
memoir (8aug23)

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/mem9.clo
    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	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/doc/latex/memoir/README	2023-08-08 19:53:20 UTC (rev 67850)
@@ -16,17 +16,97 @@
 Lars Madsen <daleif at math.au.dk> is maintaining memoir.
 
 
-    NOTE: The full User Manual (memman.pdf) is a large document of about
-550 pages in total. You do not need to print all of it, especially if you 
-already have an earlier edition. Roughly speaking, the main portions are:
-o Frontmatter: Preface, Toc, Introduction, Terminology  ~  40 pages
-o Mainmatter: 
-    Class commands and environments, etc.               ~ 380 pages
-o Appendices: (La)Tex programming, Errors and warnings  ~  40 pages
-o Backmatter:
-    Command glossary                                    ~  40 pages
-    Bibliography, indexes                               ~  50 pages
+WORD OF ADVISE: It is not recommended to manually update memoir into
+an old LaTeX installation. Not all changes are compatible with older
+un-updated LaTeX systems and we often make no attempt to be backwards
+compatible. Instead we assume that users use updated memoir with an
+updated LaTeX installation.
 
+Changes (2023/08/08)
+
+o memoir v3.8
+
+-- now requires a LaTeX format from 2021/06/01 or newer.
+
+   The class will halt compilation (in all interaction modes) if the
+   format is too old.
+
+-- \titleref is now an alias for \nameref (autoloaded).
+   The class have been adjusted to provide info for sectionals and
+   normal captions.
+
+   The titleref package will remain marked as being emulated
+   as it shouldn't be used with the class (and haven't been updated in
+   20+ years).
+
+-- nameref paches in the class are no longer needed
+
+-- label handling for subcaptions and friends have been reimplemented.
+
+-- no longer re-defines \label as per request of the LaTeX Team.
+
+-- booktabs is now loaded as a required package instead of being
+   embedded
+
+-- Fixed typo in the caption of figure 2.13. Thanks to Vladimir
+   G. Ivanović for the report.
+
+-- removed etex loading (was only loaded for kernels from before
+   2015). The noetex class option removed as well.
+
+-- reimplemented \pagenumbering(*) as a single macro
+
+-- additions to \@xfloat is now done via a cmd/after hook if the
+   format version supports it.
+
+-- Definition of \theHpoem changed to \providecommand
+
+-- The \theH<counter> macros defined in memoir was modified to use
+   \the\value{counter} instead of just \arabic{counter} as some
+   packages change \arabic.
+
+-- \toclevel at part was actually never fixed in v3.7.19, now it is
+
+-- added \@currentcounter in various places that manually
+   set \@currentlabel (primarily footnote constructions). Reported by
+   Gustavo Barros.
+
+-- replaced hardcoded \footnotesize in \verbfootnote by \foottextfont 
+
+-- made a small change to footnote formatting. Now one can use
+   \raggedright in \footnotetext to get raggedright footnotes. Use
+   with care as \raggedright does change various paragraph settings
+
+-- replaced etoolbox loading by xpatch (which loads etoolbox) as it
+   can patch more.
+
+-- Added a Hook named memoir/subcaption/aftercounter which is executed
+   after \refstepcounter in \subcaption, \subbottom, \subtop
+   etc. Requested by Gustavo Barros.
+
+-- Redefinition of \@setsize removed, was copied from setspace.sty
+   which states that it was only needed for some 209 packages.
+
+
+The following macros have been disabled (to either give a warning or
+an error).
+
+-- \namerefon and \namerefoff => warning (now always on)
+
+-- \currenttitle => error (given that many things are now "titled",
+   relying on this to get the current "title" is too risky, use proper
+   \label+\titleref instead)
+
+-- \theTitleReference => warning (was used in the old implementation
+   of \titleref and \currenttitle)   
+
+
+o memhfixc v1.21
+
+-- All nameref patches have been removed
+-- provided \subfigureautorefname
+
+
 Changes (2022/11/17)
 
 o memoir v3.7.19
@@ -45,14 +125,8 @@
    longer used in memhfixc
 
 
-WORD OF ADVISE: It is not recommended to manually update memoir into
-an old LaTeX installation. Not all changes are compatible with older
-un-updated LaTeX systems and we often make no attempt to be backwards
-compatible. Instead we assume that users use updated memoir with an
-updated LaTeX installation.
 
 
-
 Changes (2022/07/29)
 
 o memoir v3.7r

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	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/doc/latex/memoir/memman.tex	2023-08-08 19:53:20 UTC (rev 67850)
@@ -385,6 +385,143 @@
 %#% extend
 
 
+%#% extstart include maintainer-remarks.tex
+
+\svnidlong
+{$Ignore: $}
+{$LastChangedDate: 2023-08-08 16:33:42 +0200 (Tue, 08 Aug 2023) $}
+{$LastChangedRevision: 772 $}
+{$LastChangedBy: daleif at math.au.dk $}
+
+\chapter{Remarks from the maintainer}
+\label{cha:remarks-from-maint}
+
+
+When Peter Wilson released the first version of \theclass{} (back in
+2021), \LaTeX{} land was very different. Updating packages outside of
+the yearly release (TeXLive) had to be done by hand. Manuals for
+packages was \emph{not} even a requirement for CTAN. Thus it made
+sense to embed the functionality from several packages and provide
+usage information about them in this very manual. Peter even added a
+lot of historical notes as well, that was later spun of as a separate
+document of its own (see \cite{MEMDESIGN}).  As time progressed
+methods were set in place to make it easier to update packages during
+a release cycle and later packages and classes were required to always
+provide a suitable manual.
+
+Over the past five years I have moved several packages out from being
+embedded copies over to simply loading them as packages.\footnote{One
+  of the main reasons to do so was maintance, it is not feasible to
+  keep track of changes to an embedded package and then applying those
+  to \theclass.} As it is useful to have usage description in one
+place, we have kept that in the manual, but users should always refer
+back to the packages original manuals.  Summer 2023, I moved
+\Lpack{booktabs} from embedding to loading.
+
+\fancybreak{}
+
+As of Summer 2023 (begining with \theclass\ version 3.8) things are
+changing a for \theclass. In the past 4 years (begining in 2019) the
+\LaTeX\ Team have added lot of new functionality into the \LaTeX{}
+format.\footnote{Most notably most of the \Lpack{xparse} package, plus
+  the entire \LaTeX3 programming layer.} They will continue to add
+extra features to the kernel that are going to be very useful in the
+future, both at the level of class and package writers, but also at
+user level. As such we would like to begin using these new features
+without having to also provide backwards compatibility for those (few)
+users who manually update \theclass.\footnote{Overleaf users should be
+  aware that Overleaf does not update packages or kernels on their
+  \LaTeX\ images. So if we say the cut off is summer 2021, Overleaf
+  might not have the correct kernel update in their version of TeXLive
+  2021.}
+
+Counting from version 3.8 we will therefore now require users to have
+a modern \LaTeX{} kernel installed. For \theclass\ version 3.8 a user
+who manually updates \theclass\ will need to have a \LaTeX\ format
+released by 2021/06/01 or later. If the version is too old \theclass\
+will halt the compilatiion to force users to react to the error and
+not just ignore it.\footnote{Most \LaTeX\ editors incuding OverLeaf
+  use \texttt{-interaction=nonstopmode}, aka try do make a PDF even if
+  there are compilation errors. On old kernels, \theclass\ will end
+  even this!  } In case we would like to use functionality that are in
+a even newer formats, we will make sure that these macros are provided
+by the class (eventhough they may do nothing unless you have the
+proper kernel).
+
+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
+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}.}
+
+\fancybreak{}
+
+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, 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.
+
+% Macros and environments currently under consideration (but not marked
+% yet) include: \begingroup
+% \renewcommand\descriptionlabel[1]{\hspace\labelsep\parbox[t]{\dimexpr\textwidth-5pt\relax}{#1}}
+% \begin{description}
+% \item[\cmd{\patchcommand}] 
+%   Users should use \cmd{\pretocmd} and \cmd{\apptocmd} from
+%   \Lpack{etoolbox}. The \Lpack{xpatch} package even have extended
+%   versions of them.
+% \item[ctabular]
+%   This is a breakable version of \Pe{tabular} but with not way of
+%   replicating the table header like for example \Lpack{longtable}
+%   can. These days there are several packages to handles tables.
+% \item[\cmd{\newloglike}]
+% \item[\cmd{\provideloglike}]
+%   Users should really use \cmd{\DeclareMathOperator} from
+%   \Lpack{amsopn} (autoloaded by the ever present \Lpack{amsmath}).
+% \end{description}
+% \endgroup
+
+\begin{flushright}
+  Summer 2023
+
+  /daleif
+\end{flushright}
+
+
+\section*{Public interfaces removed/disabled in v3.8}
+
+The four title macros was disabled due to the \cmd{\titleref} reimplementation.
+\begingroup
+\renewcommand\descriptionlabel[1]{\hspace\labelsep\parbox[t]{\dimexpr\textwidth-5pt\relax}{#1}}
+\begin{description}
+\item[\cmd{\currenttitle}] Would have given the title of the current
+  sectional devide. Too risky to rely on, use
+  \cmd{\label}+\cmd{\titleref} instead. Throws an error if used.
+\item[\cmd{\namerefon}, \cmd{\namerefoff}] 
+  These could turn sectional title referencing on/off. As we now load
+  \Lpack{nameref} by default, the value is always on. Both macros now
+  just give a warning.
+\item[\cmd{\theTitleReference}]
+  Could control the look of \cmd{\titleref}. Does nothing but issue a warning.
+\item[\texttt{noetex} (class option)] We only loaded \Lpack{etex} for
+  formats before 2015. The package loading and the class option have
+  been removed.
+\end{description}
+\endgroup
+
+
+
+
+
+
+
+%#% extend
 %#% extstart include preface.tex
 %\chapter{Foreword}
 
@@ -1314,8 +1451,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2019-11-14 18:06:44 +0100 (Thu, 14 Nov 2019) $}
-{$LastChangedRevision: 662 $}
+{$LastChangedDate: 2023-08-06 15:24:34 +0200 (Sun, 06 Aug 2023) $}
+{$LastChangedRevision: 767 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Introduction to the eighth edition}
@@ -1755,7 +1892,7 @@
     \Lpack{array}
   \item \Lpack{dcolumn}
   \item \Lpack{delarray}
-  \item \Lpack{etex}
+%  \item \Lpack{etex}
 %  \item \Lpack{ifetex}
 %  \item \Lpack{ifxetex}
 %  \item \Lpack{ifpdf}
@@ -1763,6 +1900,11 @@
     \item \Lpack{iftex}
   \item \Lpack{tabularx}
   \item \Lpack{textcase}~(with~\texttt{overload}~option)
+  \item \Lpack{xpatch}~(it~autoloads~\Lpack{etoolbox})
+  \item \Lpack{booktabs}
+  \item \Lpack{nameref}
+  \item \Lpack{mparhack}~(if~twocolumn)
+  \item \Lpack{memhfixc}~(if~\Lpack{hyperref}~is~loaded)
   \end{lineitems}
 \end{center}
 
@@ -2054,12 +2196,15 @@
 
 \fancybreak{}
 
-\textit{From the maintainer:} Most \Mname\ related questions
-should go to \url{http://tex.stackexchange.com}, please remember to
-tag them properly, that really helps locating the \Mname\ related
-questions. If no-one comes up with an answer, you can also write me
+Most \Mname\ related questions should go to
+\url{http://tex.stackexchange.com}, please remember to tag them
+properly, that really helps locating the \Mname\ related questions. If
+no-one comes up with an answer, you can also write the maintainer
 directly via \texttt{daleif (at) math dot au dot dk}.
 
+See also \emph{\titleref{cha:remarks-from-maint}} on
+page~\pageref{cha:remarks-from-maint} for furher information from the
+maintainer.
 
 
 %#% extend
@@ -2907,8 +3052,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2020-03-25 19:00:55 +0100 (Wed, 25 Mar 2020) $}
-{$LastChangedRevision: 686 $}
+{$LastChangedDate: 2023-07-27 17:07:49 +0200 (Thu, 27 Jul 2023) $}
+{$LastChangedRevision: 757 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Laying out the page} \label{chap:layingpage}
@@ -3069,7 +3214,8 @@
 \centering
 \oddpagelayoutfalse
 \drawstock
-\caption{The \textsf{memoir} class page layout parameters for a verso page} \label{fig:evenstock}
+\caption{The \textsf{memoir} class page layout parameters for a verso
+  (left hand) page} \label{fig:evenstock}
 \end{figure}
 
 \begin{figure}
@@ -3076,7 +3222,8 @@
 \centering
 %%%\drawmarginparsfalse
 \drawstock
-\caption{The \textsf{memoir} class page layout parameters for a recto page} \label{fig:oddstock}
+\caption{The \textsf{memoir} class page layout parameters for a recto
+  (right hand) page} \label{fig:oddstock}
 \end{figure}
 
 
@@ -4933,7 +5080,7 @@
   \caption{Example of the nine \cs{setpageXX} macros for placing
     a trimmed page on the stock. These are all odd pages, under
     \Lopt{twoside}, even pages will have the left/right trims
-    reversed. The outer fra indicate the stock size. Inside the trim
+    reversed. The outer frames indicate the stock size. Inside the trim
     marks hint at where the page is positioned on the stock.}
   \label{fig:setpage}
 \end{figure}
@@ -18333,8 +18480,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2018-09-06 15:05:23 +0200 (Thu, 06 Sep 2018) $}
-{$LastChangedRevision: 612 $}
+{$LastChangedDate: 2023-08-03 11:37:58 +0200 (Thu, 03 Aug 2023) $}
+{$LastChangedRevision: 765 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 
@@ -18379,8 +18526,14 @@
   We have kept the documentation we had written for the manual (and
   updated it slightly), but refer to \cite{ARRAY}, \cite{DELARRAY}, \cite{TABULARX} and
   \cite{DCOLUMN} for the 100\% up to date documentation.
+
+  As of Summer 2023: The \Lpack{booktabs} package is now loaded
+  instead of embedded. The code was an exact copy.
 \end{note}
 
+
+
+
 \fancybreak{}
 
 
@@ -19228,7 +19381,8 @@
 rules and
 wrote the \Lpack{booktabs} package~\cite{BOOKTABS} to provide
 better horizontal rules. Like many typographers, he abhors vertical rules.
-The following is taken almost verbatim from the \Lpack{booktabs} package.
+The following is taken almost verbatim from the \Lpack{booktabs}
+package which as of Summer 2023 is automatically loaded (was embedded).
 
 \index{table!rule|(}
 
@@ -20358,8 +20512,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2021-03-22 14:24:31 +0100 (Mon, 22 Mar 2021) $}
-{$LastChangedRevision: 706 $}
+{$LastChangedDate: 2023-07-27 17:07:49 +0200 (Thu, 27 Jul 2023) $}
+{$LastChangedRevision: 757 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 \chapter{Page notes} \label{chap:mnotes}
@@ -20596,6 +20750,12 @@
 \cmd{\paragraphfootnotes} declaration. The default style is used after
 the \cmd{\plainfootnotes} declaration. 
 
+\begin{caveat}
+  Following \cmd{\paragraphfootnotes} the footnotes should only be a
+  single paragraph each.
+\end{caveat}
+
+
    The style can be changed at any 
 time but there may be odd effects if the change is made in the middle of
 a page when there are footnotes before and after the declaration. You may
@@ -20865,7 +21025,19 @@
 The text in the footnote\index{footnote!text!font} is typeset using 
 the \cmd{\foottextfont} font. The default is \cmd{\footnotesize}.
 
+\leavevmode\Added{Summer 2023} In case you wanted the footnotes to be
+typeset ragged right you can use 
+\begin{lcode}
+  \renewcommand\foottextfont{\footnotesize\raggedright}
+\end{lcode}
+Just be aware that (1) \cmd{\raggedright} has an effect on paragraph
+settings, so things like \cmd{\parindent} might need to be reset to
+\cmd{\footparindent} after \cmd{\raggedright}. (2) Column footnotes
+are already in ragged right. (3) \cmd{\raggedright} should never be
+used with paragraph footnotes.
 
+
+
     Altogether, the class specifies
 \begin{lcode}
 \footmarkstyle{\textsuperscript{#1}}
@@ -25946,9 +26118,9 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2013-04-24 17:14:15 +0200 (Wed, 24 Apr 2013) $}
-{$LastChangedRevision: 442 $}
-{$LastChangedBy: daleif $}
+{$LastChangedDate: 2023-07-27 17:07:49 +0200 (Thu, 27 Jul 2023) $}
+{$LastChangedRevision: 757 $}
+{$LastChangedBy: daleif at math.au.dk $}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \chapter{Cross referencing} \label{chap:xref}
@@ -26146,72 +26318,95 @@
 \end{lcode}
 The chapter \textit{\titleref{chap:bringhurst}} describes \ldots
 
-    There are two packages, \Lpack{nameref}~\cite{NAMEREF} and 
-\Lpack{titleref}~\cite{TITLEREF},
- that let you refer to things by name instead of number.
+% There are two packages, \Lpack{nameref}~\cite{NAMEREF} and
+% \Lpack{titleref}~\cite{TITLEREF}, that let you refer to things by name
+% instead of number. Over time \Lpack{nameref} has turned out to be the
+% industry standard.
 
-    Name references were added to the class as a consequence of adding
-a second optional argument to the sectioning commands. I found
-that this broke the \Lpack{nameref} package, and hence the
-\Lpack{hyperref} package as well, so they had to be fixed. The change 
-also broke Donald Arseneau's \Lpack{titleref} package, and it turned out
-that \Lpack{nameref} also clobbered \Lpack{titleref}. The class also
-provides titles, like \cmd{\poemtitle}, that are not recognised by
-either of the packages. From my viewpoint the most efficient
-thing to do was to enable the class itself to provide name 
-referencing.
+\begin{Changed}[Summer 2023]
+  We are now autoloading the \Lpack{nameref} (see \cite{NAMEREF}) and
+  uses that for our implementation for \cmd{\titleref} (it is just an
+  alias for \cmd{\nameref}).\footnotemark
+\end{Changed}
+\footnotetext{This change fixes several incompatability issues we've
+  had with the old implementation of \cs{titleref}, which needed a
+  redefinition of \cs{label} to work. For the coming PDF-tagging
+  project such redefinitions of kernel macros like \cs{label} is
+  frowned upon. At their end the kernel team has updated \cmd{\label}
+  for even easier sopport for \Lpack{nameref}.}
 
-
 \begin{syntax}
-\cmd{\titleref}\marg{labstr} \\
+\cmd{\titleref}\marg{labstr} \qquad
+\cmd{\titleref*}\marg{labstr} \\
 \end{syntax}
 \glossary(titleref)%
   {\cs{titleref}\marg{labstr}}%
   {Prints the (section, or other) title of the number associated 
-   with \meta{labstr} from a \cs{label}.}
+   with \meta{labstr} from a \cs{label}.}%
+\glossary(titleref*)%
+  {\cs{titleref*}\marg{labstr}}%
+  {Similar to \cs{titleref}, but if \protect\Lpack{hyperref} is loaded this
+    does \emph{not} add a hyperlink. Mapped onto \cs{nameref*}.}
 The macro \cmd{\titleref} is a class addition to the usual set of
 cross referencing commands. Instead of printing a number it typesets
 the title associated with the labelled number. This is really only useful
 if there \emph{is} a title, such as from a \cmd{\caption} or
-\cmd{\section} command. For example, look at this code 
-and its result.
+\cmd{\section} command. The starred version is for when
+\Lpack{hyperref} is loaded, then the starred version does \emph{not}
+create a hyperlink. If \Lpack{hyperref} is \emph{not} loaded, then the
+two macros does the same thing.
 
-\begin{egsource}{eg:sec:nxref:1}
-Labels may be applied to:
-\begin{enumerate}
-\item Chapters, sections, etc.            \label{sec:nxref:1}
-...
-\item Items in numbered lists, etc. \ldots \label{sec:nxref:5}
-\end{enumerate}
-Item \ref{sec:nxref:1} in section \textit{\titleref{sec:nxref}} 
-mentions sections while item \titleref{sec:nxref:5}, on page 
-\pageref{sec:nxref:5} in the same section, mentions things like
-items in enumerated lists that should not be referenced 
-by \verb?\titleref?.
-\end{egsource}
 
-\begin{egresult}[Named references should be to titled elements]{eg:sec:nxref:1}
-Labels may be applied to:
-\begin{enumerate}
-\item Chapters, sections, etc.            \label{sec:nxref:1}
-\item Captions
-\item Legends
-\item Poem titles
-\item Items in numbered lists, etc. \ldots \label{sec:nxref:5}
-\end{enumerate}
-Item \ref{sec:nxref:1} in section \textit{\titleref{sec:nxref}} 
-mentions sections while item\index{reference!unexpected result} 
-\titleref{sec:nxref:5}, on page 
-\pageref{sec:nxref:5} in the same section, mentions things like
-items in enumerated lists 
-that should not be referenced by \verb?\titleref?.
-\end{egresult}
 
-    As the above example shows, you have to be a little careful in using
-\cmd{\titleref}.
-Generally speaking, \cmd{\titleref}\marg{key} produces the last named 
-thing before the \cmd{\label} that defines the \meta{key}. 
 
+% For an example, look at this code and its result.
+% \begin{egsource}{eg:sec:nxref:1}
+% Labels may be applied to:
+% \begin{enumerate}
+% \item Chapters, sections, etc.            \label{sec:nxref:1}
+% ...
+% \item Items in numbered lists, etc. \ldots \label{sec:nxref:5}
+% \end{enumerate}
+% Item \ref{sec:nxref:1} in section \textit{\titleref{sec:nxref}} 
+% mentions sections while item \titleref{sec:nxref:5}, on page 
+% \pageref{sec:nxref:5} in the same section, mentions things like
+% items in enumerated lists that should not be referenced 
+% by \verb?\titleref?.
+% \end{egsource}
+
+% \begin{egresult}[Named references should be to titled elements]{eg:sec:nxref:1}
+% Labels may be applied to:
+% \begin{enumerate}
+% \item Chapters, sections, etc.            \label{sec:nxref:1}
+% \item Captions
+% \item Legends
+% \item Poem titles
+% \item Items in numbered lists, etc. \ldots \label{sec:nxref:5}
+% \end{enumerate}
+% Item \ref{sec:nxref:1} in section \textit{\titleref{sec:nxref}} 
+% mentions sections while item\index{reference!unexpected result} 
+% \titleref{sec:nxref:5}, on page 
+% \pageref{sec:nxref:5} in the same section, mentions things like
+% items in enumerated lists 
+% that should not be referenced by \verb?\titleref?.
+% \end{egresult}
+
+
+%\newpage
+
+
+There can be three possibilities for the name of a sectional division;
+the full name, the name in the \toc, and the name in the page header.
+Aka
+\begin{verbatim}
+\section[toc][header]{title}
+\end{verbatim}
+Following the tradition used by \Lpack{nameref}\footnote{The old
+  \cmd{\titleref} implementation did the same.} we generally use the
+title for the \toc{}. This corresponds to the default setting
+\cmd{\tocnameref}. Issuing \cmd{\headnameref} we instead use the
+header (if available) when preparing the title for the label.
+
 \begin{syntax}
 \cmd{\headnameref} \cmd{\tocnameref} \\
 \end{syntax}
@@ -26220,90 +26415,27 @@
   {Use header title for sectional title references.}
 \glossary(tocnameref)%
   {\cs{tocnameref}}%
-  {Use \prtoc{} title for sectional title references.}
-There can be three possibilities for the name of a sectional division;
-the full name, the name in the \toc, and the name in the page header.
-As far as \cmd{\titleref} is concerned it does not use the fullname, 
-and so the choice simplifies to the \toc{} or page header. Following
-the declaration \cmd{\headnameref} it uses the page header name.
-Following the opposite declaration \cmd{\tocnameref}, which is the
-default, it uses the \toc\ name.
+  {Use \prtoc{} title for sectional title references (default).}
 
-\Note{} Specifically with the \Lclass{memoir} class, 
-do not put a \cmd{\label} command inside an
-argument to a \cmd{\chapter} or \cmd{\section} or \cmd{\caption}, etc.,
-command. Most likely it will either be ignored or referencing it will
-produce incorrect values. This restriction does not apply to the standard
-classes, but in any case I think it is good practice not to embed any 
-\cmd{\label} commands.
+\fancybreak{}
 
-\begin{syntax}
-\cmd{\currenttitle} \\
-\end{syntax}
-\glossary(currenttitle)%
-  {\cs{currenttitle}}%
-  {Gives the title of the last sectional division command.}
-    If you just want to refer to the current title you can do so with
-\cmd{\currenttitle}. This acts as though there had been a label associated
-with the title and then \cmd{\titleref} had been used to refer to that label.
-For example:
-\begin{egsource}{eg:sec:nxref:2}
-This sentence in the section titled `\currenttitle' is an example of the
-use of the command \verb?\currenttitle?.
-\end{egsource}
+  
+\Note{} In general it is \emph{not} recommended to place
+\cmd{\label} inside an argument for a \cmd{\chapter}, \cmd{\section},
+\cmd{\caption}, etc., command. At that point there is not title data
+available to use for the label.
 
-\begin{egresult}[Current title]{eg:sec:nxref:2}
-This sentence in the section titled `\currenttitle' is an example of the
-use of the command \verb?\currenttitle?.
-\end{egresult}
+% \fancybreak{}
 
-\begin{syntax}
-\cmd{\theTitleReference}\marg{num}\marg{text} \\
-\end{syntax}
-\glossary(theTitleReference)%
-  {\cs{theTitleReference}\marg{num}\marg{text}}
-  {Called by \cs{titleref} and \cs{currenttitle} with the number and
-   text of the title to print the values.}
-Both \cmd{\titleref} and \cmd{\currenttitle} use the \cmd{\theTitleReference}
-to typeset the title. This is called with two arguments --- 
-the number, \meta{num}, and the text, \meta{text}, of the title. The
-default definition is:
-\begin{lcode}
-\newcommand{\theTitleReference}[2]{#2}
-\end{lcode}
-so that only the \meta{text} argument is printed. You could, for example,
-change the definition to
-\begin{lcode}
-\renewcommand{\theTitleReference}[2]{#1\space \textit{#2}}
-\end{lcode}
-to print the number followed by the title in italics. If you do this, only use
-\cmd{\titleref} for numbered titles, as a printed number for an 
-unnumbered title (a) makes no sense, and (b) will in any case be 
-incorrect.
 
-    The commands \cmd{\titleref}, \cmd{\theTitleReference} and 
-\cmd{\currenttitle} are direct equivalents of those in the \Lpack{titleref}
-package~\cite{TITLEREF}.
+\begin{Changed}[Summer 2023]
+  The following macros are no longer used. They will either issue a
+  warning or an error. Users are encouraged to remove them:
+  \cmd{\currenttitle}, \cmd{\namerefon} (is always on),
+  \cmd{\namerefoff} and \cmd{\theTitleReference}.
+\end{Changed}
 
-\begin{syntax}
-\cmd{\namerefon} \cmd{\namerefoff} \\
-\end{syntax}
-\glossary(namerefon)%
-  {\cs{namerefon}}%
-  {Makes \cs{titleref} operative.}
-\glossary(namerefoff)%
-  {\cs{namerefoff}}%
-  {Makes \cs{titleref} inoperative.}
 
-    The capability for referencing by name has one potentially
-unfortunate side effect --- it causes some arguments, such as that
-for \cmd{\legend}, to be moving\index{moving argument} arguments 
-and hence any fragile\index{fragile} command
-in the argument will need \cmd{\protect}ing. However, not every document
-will require the use of \cmd{\titleref} and so the declaration
-\cmd{\namerefoff} is provided to switch it off (the argument to
-\cmd{\legend} would then not be moving). The declaration
-\cmd{\namerefon}, which is the default, enables name referencing.
 
 \index{reference!by name|)}
 
@@ -28158,8 +28290,8 @@
 
 \svnidlong
 {$Ignore: $}
-{$LastChangedDate: 2021-03-22 18:32:04 +0100 (Mon, 22 Mar 2021) $}
-{$LastChangedRevision: 707 $}
+{$LastChangedDate: 2023-08-06 23:23:21 +0200 (Sun, 06 Aug 2023) $}
+{$LastChangedRevision: 768 $}
 {$LastChangedBy: daleif at math.au.dk $}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -28635,7 +28767,7 @@
     The \cmd{\quarkmarks} declaration uses \cmd{\printtime}, so be careful
 if you change it.
 
-    Nicola Talbot's \Lpack{datetime} package~\cite{DATETIME} provides
+    Nicola Talbot's \Lpack{datetime2} package~\cite{DATETIME2} provides
 a much more comprehensive collection of styles for printing the time;
 also for dates.
 
@@ -28953,6 +29085,23 @@
 \meta{macro} has any delimited arguments then \cmd{\patchcommand}
 cannot be used.
 
+\begin{recommended}
+  Again \Lpack{xpatch} and \Lpack{etoolbox} (both loaded by \theclass)
+  are recommended. See the commands
+  \begin{syntax}
+    \cmd{\xpatchcmd}\marg{macro}\marg{search}\marg{replace}\marg{success}\marg{failure} \\
+    \cmd{\xapptocmd}\marg{macro}\marg{code}\marg{success}\marg{failure} \\
+    \cmd{\xpretocmd}\marg{macro}\marg{code}\marg{success}\marg{failure} \\
+    \cmd{\patchcmd}\marg{macro}\marg{search}\marg{replace}\marg{success}\marg{failure} \\
+    \cmd{\apptocmd}\marg{macro}\marg{code}\marg{success}\marg{failure} \\
+    \cmd{\pretocmd}\marg{macro}\marg{code}\marg{success}\marg{failure} \\
+  \end{syntax}
+  Here \cmd{\xpatchcmd} can patch some macros can \cmd{\patchcmd}
+  cannot. The combination of \verb|\(x)pretocmd| and
+  \verb|\(x)apptocmd| give the same result as \cmd{\patchcommand}.
+\end{recommended}
+
+
 \section{String arguments}
 
     In the code for the class I have sometimes used macro arguments
@@ -28996,6 +29145,9 @@
 }
 \end{lcode}
 
+See also the tests available in \Lpack{etoolbox}.
+
+
 \section{Odd/even page checking}
 
 It is difficult to check robustly if the current page is odd or even
@@ -38847,12 +38999,12 @@
              \CTANurl{/macros/latex/contrib/url/})
 
 %%% keep
-\bibitem[Ars01a]{TITLEREF}
-  Donald Arseneau.
-  \newblock \emph{The titleref package}.
-  \newblock April, 2001.
-  \newblock (Available from CTAN via
-             \CTANurl{/macros/latex/contrib/titleref/})
+% \bibitem[Ars01a]{TITLEREF}
+%   Donald Arseneau.
+%   \newblock \emph{The titleref package}.
+%   \newblock April, 2001.
+%   \newblock (Available from CTAN via
+%              \CTANurl{/macros/latex/contrib/titleref/})
 
 %%% keep
 \bibitem[Ars01b]{CHAPTERBIB}
@@ -38977,10 +39129,10 @@
              \CTANurl{/macros/latex/required/tools/})
 
 %%% keep
-\bibitem[Car98b]{LONGTABLE}
+\bibitem[Car21]{LONGTABLE}
   David Carlisle.
   \newblock \emph{The longtable package}.
-  \newblock May, 1998.
+  \newblock May, 2021.
   \newblock (Available from CTAN via
              \CTANurl{/macros/latex/required/tools/})
 
@@ -39643,18 +39795,18 @@
             \CTANurl{/fonts/mathpazo/})
 
 %%% keep
-\bibitem[Rahtz01]{NAMEREF}
-  Sebastian Rahtz.
+\bibitem[Rahtz23a]{NAMEREF}
+  Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
   \newblock \emph{Section name references in LaTeX}.
-  \newblock January, 2001. 
+  \newblock 2023. 
   \newblock (Available from CTAN (the \texttt{nameref} package) via 
             \CTANurl{/macros/latex/contrib/hyperref/})
 
 %%% keep
-\bibitem[Rahtz02]{HYPERREF}
-  Sebastian Rahtz.
+\bibitem[Rahtz23b]{HYPERREF}
+  Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
   \newblock \emph{Hypertext marks in LaTeX}.
-  \newblock May, 2002. Now maintained and frequently updated by Heiko Oberdiek.
+  \newblock 2023. 
   \newblock (Available from CTAN via 
             \CTANurl{/macros/latex/contrib/hyperref/})
 
@@ -39766,12 +39918,12 @@
   \newblock Vrijie Universiteit, Amsterdam, 2004. 
 
 %%% keep
-\bibitem[Tal06]{DATETIME}
+\bibitem[Tal21]{DATETIME2}
   Nicola L. C. Talbot.
-  \newblock \emph{datetime.sty: Formatting Current Date and Time}.
-  \newblock December, 2006.
+  \newblock \emph{datetime2: date and time formats}.
+  \newblock Martch, 2021.
   \newblock (Available from CTAN via
-            \CTANurl{/macros/latex/contrib/datetime/})
+            \CTANurl{/macros/latex/contrib/datetime2/})
 
 %%% keep
 \bibitem[Thi98]{ORNAMENTAL}
@@ -40118,11 +40270,11 @@
   \newblock (Available from CTAN via 
             \CTANurl{/macros/latex/contrib/memoir/})
 
-\bibitem[Wil19b]{MEMMAN}
+\bibitem[Wil23]{MEMMAN}
 Peter Wilson (with the assistance of Lars Madsen).
   \newblock \emph{The Memoir Class for Configurable Typesetting ---
     User Guide} 
-  \newblock November, 2019. Regularly updated.
+  \newblock November, 2023. Regularly updated.
   \newblock (Available from CTAN via 
             \CTANurl{/macros/latex/contrib/memoir/})
 
@@ -40135,16 +40287,16 @@
 
 
 %%% keep
-\bibitem[Wil??]{RUMOUR}
-Peter Wilson.
-\newblock \emph{A Rumour of Humour: A scientist's commonplace book}.
-\newblock To be published.
+% \bibitem[Wil??]{RUMOUR}
+% Peter Wilson.
+% \newblock \emph{A Rumour of Humour: A scientist's commonplace book}.
+% \newblock To be published.
 
 
-\bibitem[Wri19]{SIUNITX}
+\bibitem[Wri23]{SIUNITX}
   Joseph Wright.
   \newblock \emph{Siunitx — A comprehensive (SI) units package}
-  \newblock October, 2019.
+  \newblock October, 2023.
   \newblock (Available from CTAN via \CTANurl{/macros/latex/contrib/siunitx})
 
 

Modified: trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty
===================================================================
--- trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/doc/latex/memoir/memsty.sty	2023-08-08 19:53:20 UTC (rev 67850)
@@ -23,6 +23,7 @@
 \providecommand{\PWnote}[2]{}  
 
 \newcommand\Added[1]{\sidepar{\tiny Added #1}}
+\newcommand\ToBeRemoved[1]{\sidepar{\tiny To be removed #1}}
 
 %%%%%%%%%%%%%%%%%%% kill scale change warning in layouts
 \renewcommand*{\setlayoutscale}[1]{\setlength{\l at youtunitlength}{1pt}
@@ -1133,9 +1134,9 @@
 }
 
 %\newenvironment{caveat}{\par\medskip\noindent\textbf{\textit{Caveat.}}\enskip\itshape}{\par\medskip}
-\newenvironment{caveat}{\begin{leftbar}\noindent\textbf{\textit{Caveat.}}\enskip}{\end{leftbar}}
+\newenvironment{caveat}[1][]{\begin{leftbar}\noindent\textbf{\textit{Caveat.}}\@ifmtarg{#1}{}{\Added{#1}}\enskip}{\end{leftbar}}
 %\newenvironment{Changed}{\par\medskip\noindent\textbf{\textit{Changed.}}\enskip}{\par\medskip}
-\newenvironment{Changed}{\begin{leftbar}\noindent\textbf{\textit{Changed.}}\enskip}{\end{leftbar}}
+\newenvironment{Changed}[1][]{\begin{leftbar}\noindent\textbf{\textit{Changed.}\@ifmtarg{#1}{}{\Added{#1}}}\enskip}{\end{leftbar}}
 \newenvironment{note}{\par\medskip\noindent\textbf{\textit{Note.}}\enskip\itshape}{\par\medskip}
 \newenvironment{note*}[1]{\par\medskip\noindent\textbf{\textit{#1.}}\enskip\itshape}{\par\medskip}
 \newenvironment{hint}{\par\medskip\noindent\textbf{\textit{Hint.}}\enskip\itshape}{\par\medskip}

Modified: trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/source/latex/memoir/memoir.dtx	2023-08-08 19:53:20 UTC (rev 67850)
@@ -20,7 +20,7 @@
 % This work consists of the files listed in the README file.
 % 
 % \fi
-% \CheckSum{31045}
+% \CheckSum{28676} 
 %
 % \changes{v0.1}{2001/05/20}{First public alpha release}
 % \changes{v0.2}{2001/06/03}{First beta release}
@@ -130,6 +130,7 @@
 % \changes{v3.7q}{2022/02/20}{Maintenance}
 % \changes{v3.7r}{2022/07/29}{Maintenance}
 % \changes{v3.7.19}{2022/11/17}{Maintenance}
+% \changes{v3.8}{2023/08/08}{Maintenance, see the README for details}
 % 
 % \def\dtxfile{memoir.dtx}
 %
@@ -197,6 +198,7 @@
 % \def\fileversion{v3.7q}          \def\filedate{2022/02/20} 
 % \def\fileversion{v3.7r}          \def\filedate{2022/07/29} 
 % \def\fileversion{v3.7.19}          \def\filedate{2022/11/17} 
+% \def\fileversion{v3.8}          \def\filedate{2023/08/08} 
 % \title{The LaTeX \Lpack{memoir} class for configurable book 
 %        typesetting: Source code\thanks{This
 %        file (\texttt{\dtxfile}) has version number \fileversion, last revised
@@ -342,6 +344,7 @@
 \newcommand*{\Lenv}[1]{\texttt {#1}}            % typeset an environment
 \newcommand*{\Lpack}[1]{\textsf {#1}}           % typeset a package
 \newcommand*{\ctt}{\textsc{ctt}}                % comp.text.tex
+\newcommand*{\Lhook}[1]{\meta{#1}}              % name of a hook
 \newenvironment{PW}{\em}{}
 \newenvironment{dlf}{\em}{}
 \newcommand*{\theTeXbook}{\textit{The \TeX book}}
@@ -411,12 +414,13 @@
 %
 % \section{Identification} \label{sec:id}
 %
-%    The \Lpack{memoir} document class can only be used with LaTeX2e, 
-% so we make
-%    sure that an appropriate message is displayed when another \TeX{}
-%    format is used.
+% The \Lpack{memoir} document class can only be used with LaTeX2e, so
+% we make sure that an appropriate message is displayed when another
+% \TeX{} format is used.
+% \changes{v3.8}{2023/08/02}{Added requirement on the kernel}
 %    \begin{macrocode}
-%<class>\NeedsTeXFormat{LaTeX2e}
+%<class>\def\mem at atleast@kernel{2021/06/01}
+%<class>\NeedsTeXFormat{LaTeX2e}[\mem at atleast@kernel]
 %    \end{macrocode}
 %
 % ^^A Use the Golden Section as the version number (1.6180339887 4989484820 4586834365)
@@ -427,12 +431,45 @@
 %    Announce the name, option files and version for LaTeX2e files:
 %    \begin{macrocode}
 %<class>\ProvidesClass{memoir}%
-%<class>  [2022/11/17 v3.7.19 configurable book, report, article document class]
+%<class>  [2023/08/08 v3.8 configurable book, report, article document class]
+%<class>\newcommand\memversion{v3.8, 2023/08/08}
 %    \end{macrocode}
-%  In the manual it is useful to know the current version.
+%
+% \changes{v3.7m}{2020/08/05}{Added \cs{IfFormatAtLeastTF}}
+% \changes{v3.8}{2023/08/02}{Moved up earlier so we can use it to
+% issue an error if the kernel is too old.}
+% \begin{macro}{\IfFormatAtLeastTF}
+% Credit to Frank Mittelbach. Using
+% \cs{IfFormatAtLeastTF}\marg{date}\marg{true}\marg{false} we can
+% execute \meta{true} if the format is dated after the given
+% \meta{date} (in {\scriptsize\ttfamily YYYY/MM/DD} format) and
+% \meta{false} otherwise. The main use is for when we get info that
+% certain features are being added to the \LaTeX\ format, features
+% that we want to base class features on. Then this is an easy method
+% for providing the code only avaiable on newer formats and code left
+% over for those still using the older \LaTeX\ formats.\footnote{The \dots TF is a
+% nice \LaTeX3 convention.}
 %    \begin{macrocode}
-%<class>\newcommand\memversion{v3.7.19, 2022/11/17}
-%<9pt>\ProvidesFile{mem9.clo}%
+%<class>\providecommand\IfFormatAtLeastTF{\@ifl at t@r\fmtversion}
+%    \end{macrocode}
+% \end{macro}
+%
+% Stop the loading if the kernel is too old (as \cs{NeedsTeXFormat}
+% only issues a warning). Though we cannot do much about nonstopmode.
+%    \begin{macrocode}
+%<class>\IfFormatAtLeastTF{\mem at atleast@kernel}{}{
+%<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>    entire LaTeX installation instead of manually updating\MessageBreak
+%<class>    just memoir}{}
+%<class>  % \batchmode\read-1to\@tempa% evil mode engaged
+%<class>}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<9pt> \ProvidesFile{mem9.clo}%
 %<9pt>              [2022/07/29 v0.5 memoir class 9pt size option]
 %<10pt>\ProvidesFile{mem10.clo}%
 %<10pt>             [2022/07/29 v0.5 memoir class 10pt size option]
@@ -467,18 +504,22 @@
 %
 % (2022/02/20): In order to be able to use a patching approach instead
 % of overwriting kernel macros, we will now require the
-% \Lpack{etoolbox} package.
+% \Lpack{etoolbox} package. (2023/07/28) changed to \Lpack{xpatch} as
+% it supports a little more.
+% \changes{v3.8}{2023/07/28}{replaced etoolbox by xpatch}
 %    \begin{macrocode}
-\RequirePackage{etoolbox}      
+\RequirePackage{xpatch}      
 %    \end{macrocode}
 %
+%
+%
 % 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.
 %
+% \medskip\noindent
+% In this part we define a few commands that are used later on.
 %
-%    In this part we define a few commands that are used later on.
-%
 % \begin{macro}{\@ptsize}
 % \begin{macro}{\@memptsize}
 %    The \cs{@ptsize} control sequence is normally used to store the 
@@ -601,26 +642,6 @@
 % \end{macro}
 % \end{macro}
 %
-% 
-% \changes{v3.7m}{2020/08/05}{Added \cs{IfFormatAtLeastTF}}
-% \begin{macro}{\IfFormatAtLeastTF}
-% Credit to Frank Mittelbach. Using
-% \cs{IfFormatAtLeastTF}\marg{date}\marg{true}\marg{false} we can
-% execute \meta{true} if the format is dated after the given
-% \meta{date} (in {\scriptsize\ttfamily YYYY/MM/DD} format) and
-% \meta{false} otherwise. The main use is for when we get info that
-% certain features are being added to the \LaTeX\ format, features
-% that we want to base class features on. Then this is an easy method
-% for providing the code only avaiable on newer formats and code left
-% over for those still using the older \LaTeX\ formats.\footnote{The \dots TF is a
-% \LaTeX3 convention.}
-%    \begin{macrocode}
-\providecommand\IfFormatAtLeastTF{\@ifl at t@r\fmtversion}
-
-%    \end{macrocode}
-% \end{macro}
-%
-%
 % \begin{macro}{\ifsamename}
 % \begin{macro}{\nametest}
 %    The macro \cs{nametest}\marg{name1}\marg{name2} tests whether the
@@ -848,6 +869,69 @@
 % \end{macro}
 % \end{macro}
 %
+% \subsection{Hooks and provided kernel commands}
+% 
+% \changes{v3.8}{2023/07/28}{Section added}
+%
+% First we make sure a few kernel commands are present, providing variants if needed.
+% \begin{macro}{\ExpandArgs}
+%   The macro \cs{ExpandArgs}\marg{list} is an alias for
+%   \verb|\exp_args:Nlist|, can for example be used as
+%   \begin{verbatim}
+%   \ExpandArgs{c}\newcommand{\foo bar}
+% \end{verbatim}
+%   to do argument manipulation to the argument \emph{after}
+%   \cs{newcommand}, \emph{before} \cs{newcommand} gets access to it.
+%   The \meta{list} arg specification need to comply with expl3
+%   standards, see \cite{LTX3}.
+%    \begin{macrocode}
+\ExplSyntaxOn
+\IfFormatAtLeastTF{ 2022-06-01 }
+{}
+{
+  \RequirePackage { xparse }
+  \providecommand \ExpandArgs [1]
+  { \cs_if_exist_use:c { exp_args:N #1 } }
+}
+\ExplSyntaxOff
+  
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\NewHookWithArguments}
+% \begin{macro}{\UseHookWithArguments}
+%   These is a fairly new addition to \cite{LTHOOKS}, but it will
+%   become super usefull in the future. If not already in the kernel,
+%   we provide it and have it do nothing at all. Credit to
+%   Phelype Oleinik. The various hooks the class has will over time be
+%   supplemented by \cs{UseHookWithArguments} and the older non-Hook
+%   ones will then slowly be phased out.
+%    \begin{macrocode}
+\providecommand\NewHookWithArguments[2]{}
+\ExplSyntaxOn
+\@ifundefined{UseHookWithArguments}{
+  \cs_new:Npn \UseHookWithArguments #1 #2 {
+    \cs:w use_none: \prg_replicate:nn {#2} { n } \cs_end:
+  }
+}{}
+\ExplSyntaxOff
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% As we now require a kernel that have support for the new kernel
+% hooks, we'll use this area to define the hooks and provide commands
+% that are useful in even newer kernels, but might not be in the
+% kernels we'd like to support.
+%
+% The \Lhook{memoir/subcaption} hook is executed after
+% \cs{refstepcounter} in \cs{subcaption}, \cs{subbottom}, \cs{subtop}
+% and similar.
+%    \begin{macrocode}
+\NewHook{memoir/subcaption/aftercounter}
+
+%    \end{macrocode}
+%
+%
 % \subsection{Classes, Packages and Files}
 %
 % \begin{macro}{\@memfakeusepackage}
@@ -936,7 +1020,7 @@
 % the latter via our definition of the file hook. We will now instead
 % use the separate hooks. Note that we will \emph{not} be adding any
 % extra labels to these hooks and will provide no interface to do
-% so. If more control is needed, please use the kernel interface directly. 
+% so. If more control is needed, please use the kerel interface directly. 
 % \begin{macro}{\AtBeginFile}
 % \begin{macro}{\AtEndFile}
 % \cs{AtBeginFile}\marg{file}\marg{code} inserts \meta{code}
@@ -943,6 +1027,7 @@
 % just before \meta{file} is input. Similarly \cs{AtEndFile} inserts
 % just after input.
 %
+% \medskip\noindent
 % \textbf{Breaking change:} In the old implemenation
 % \verb!\AtEndFile{file}! worked for \texttt{file.tex} even if one
 % did not speficy the extension. Now you will need to use
@@ -1218,14 +1303,18 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-} % end of els part of format check
+
+ % end of else part of format check
+} 
+
 %    \end{macrocode}
 %
 %
 %
 % \begin{macro}{\phantomsection}
-% A command needed if the \Lpack{hyperref} package is used, for putting
-% before certain \cs{addcontentsline} commands.
+%   Whenever \Lpack{hyperref} is used and one uses fx
+%   \cs{addcontentsline} at a place that has to hypertarget (e.g. a
+%   counter being stepped) one adds \cs{phantomsection}.
 %    \begin{macrocode}
 \newcommand{\phantomsection}{}
 
@@ -1232,6 +1321,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% ^^A dlf note: kernal macro redefinition
 % \begin{macro}{\nofiles}
 % The kernel's \cs{nofiles}, which surprisingly may be called \emph{before} 
 % the class is loaded, lets \cs{makeindex} to \cs{relax}. This could 
@@ -1903,6 +1993,19 @@
 %
 % \section{Declaration of Options} \label{sec:opt}
 %
+% \changes{v3.8}{2023/08/03}{Added secret option}
+%    \begin{macrocode}
+ % secret extra option for testing stuff in the wild
+ % caution 1: patching inside \ifmem at devmode ... \fi requires that all
+ % if statements in the patch are blanced
+ % caution 2: pathing inside \mem at devmode@run{ ... }{} does not work
+ % if the search pattern contains #<num>
+ % thus added both variants
+\newif\ifmem at devmode
+\let\mem at devmode@run\@secondoftwo
+\DeclareOption{dev-mode}{\let\mem at devmode@run\@firstoftwo\mem at devmodetrue}
+
+%    \end{macrocode}
 %
 % \subsection{Setting Paper Sizes}
 %
@@ -2617,34 +2720,7 @@
 % \end{macro}
 %
 %
-% \changes{v1.6180339f}{2009/07/12}{Added dead man switch for etex}
-% \subsection{ETeX}
-% 
-% If found we automatically load the eTeX package right after
-% executing the class options. Though, some odd \LaTeX\ installations
-% may have the eTeX pacakge, but is not based on eTeX (eventhough that
-% is what the LaTeX-project have recommended for several years now),
-% so we add a dead mans switch to disable the loading.
 %
-% \medskip\noindent 
-% Update 2015: Since the 2015 LaTeX kernel automatically takes care of
-% allocating extra registers, the \Lpack{etex} package is no longer
-% needed with newer kernels. Therefore automatic loading \Lpack{etex}
-% now only happen if the kernel is pre 2015.
-% \begin{macro}{\ifmem at noetex}
-% \begin{macro}{\mem at noetextrue}
-% \begin{macro}{\mem at noetexfalse}
-%    \begin{macrocode}
-\newif\ifmem at noetex
-  \mem at noetexfalse
-\DeclareOption{noetex}{\mem at noetextrue}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
 % \section{Executing Options} \label{sec:xopt}
 %
 %    Here we execute the default options to initialize certain
@@ -2670,30 +2746,18 @@
 %                       option after \cs{ProcessOptions*}}
 %    \begin{macrocode}
 \ProcessOptions*
-  \ifmemlandscape
-    \setlength\@tempdima  {\stockheight}
-    \setlength\stockheight{\stockwidth}
-    \setlength\stockwidth {\@tempdima}
-  \fi
 
 %    \end{macrocode}
-% Load the eTeX package if found, and if the user has not explicitly
-% asked us not to.
-%
-% \medskip\noindent
-% Update 2015: Since 2015 the LaTeX kernel automatically
-% allocate extra registers, thus that part of the \Lpack{etex}
-% package is no longer needed for newer \LaTeX\ kernels. At the
-% request of the LaTeX Team, we now only load \Lpack{etex} on older
-% kernels. 
-% \changes{v3.7e}{2015/07/08}{Only load \Lpack{etex} on older kernels}
+% Execute the delayed landscape switch if given
 %    \begin{macrocode}
-\ifmem at noetex\relax\else
-  \ifx\e at alloc\@undefined
-    \IfFileExists{etex.sty}{\RequirePackage{etex}}{}
-  \fi
+\ifmemlandscape
+  \setlength\@tempdima  {\stockheight}
+  \setlength\stockheight{\stockwidth}
+  \setlength\stockwidth {\@tempdima}
 \fi
+
 %    \end{macrocode}
+
 % \begin{macro}{\memoirpostopthook}
 % A user could define this \emph{before} the \cs{documentclass} command
 % to do something at this point. For example, to set up a new stock size: \\
@@ -2727,7 +2791,9 @@
 % \end{macro}
 %
 
-%    Set \cs{clearforchapter} according to the options.
+%    Set the macro \cs{clearforchapter} according to the options (via
+%    \cs{openleft}, \cs{openright} or \cs{openany} defined
+%    earlier)
 %    \begin{macrocode}
 \if at openleft
   \openleft
@@ -3688,7 +3754,8 @@
 % \end{macro}
 %
 % \begin{macro}{\interlinepenalty}
-%    Allow the breaking of a page in the middle of a paragraph.
+%    Allow the breaking of a page in the middle of a paragraph. Using
+%    the kernel default and here just showing it.
 %    \begin{macrocode}
 % \interlinepenalty 0
 %    \end{macrocode}
@@ -3696,7 +3763,8 @@
 %
 %
 % \begin{macro}{\brokenpenalty}
-%    We allow the breaking of a page after a hyphenated line.
+%    We allow the breaking of a page after a hyphenated line. Using
+%    the kernel default and here just showing it.
 %    \begin{macrocode}
 % \brokenpenalty 100
 %    \end{macrocode}
@@ -3711,22 +3779,23 @@
 % \begin{macro}{\headsep}
 % \begin{macro}{\topskip}
 % \begin{macro}{\footskip}
-%    The \cs{headheight} is the height of the box that will contain the
-%    running head. In this class it is point size dependent --- 
-% \cs{onelineskip} (normally it is a constant 12pt). 
+%   The \cs{headheight} is the height of the box that will contain the
+%   running head. In this class it is point size dependent ---
+%   \cs{onelineskip} (normally it is a constant 12pt).
 %
-% The \cs{headsep} is the distance between the bottom
-%    of the running head and the top of the text. For the larger sizes
-% this is 1.8 times the fontsize.
+%   The \cs{headsep} is the distance between the bottom of the running
+%   head and the top of the text. For the larger sizes this is 1.8
+%   times the fontsize.
 %
-% The \cs{topskip} is the \cs{baselineskip} for the first line on a page; 
-%    \LaTeX's output routine will not work properly if it has the
-%    value 0pt, so do not do that! For the lareger sizes this is the font size.
+%   The \cs{topskip} is the \cs{baselineskip} for the first line on a
+%   page; \LaTeX's output routine will not work properly if it has the
+%   value 0pt, so do not do that! For the larger sizes this is the
+%   font size.
 %
-%    The distance from the baseline of the box which contains the
-%    running footer to the baseline of last line of text is controlled
-%    by the \cs{footskip}. For the larger sizes this is 2.5 times the
-% font size.
+%   The distance from the baseline of the box which contains the
+%   running footer to the baseline of last line of text is controlled
+%   by the \cs{footskip}. For the larger sizes this is 2.5 times the
+%   font size.
 % \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed \cs{headheight} from 16pt to 17.5pt}
 % \changes{v0.11 (mem11.clo)}{2002/03/10}{Changed \cs{headheight} from 13pt to 13.6pt}
 % \changes{v0.4b (mem12.clo)}{2010/10/19}{Changed \cs{headheight} from 14pt to 14.5pt}
@@ -5426,7 +5495,7 @@
 % the various engines do not quite agree on which variables to use. As
 % of 2018 we will be using this: First of \cs{pdfpageheight/width} is
 % used by pdf(e)tex based enginges. We set them if they are
-% defined. Just incase someone need to be able to patch this, we make
+% defined. Just in case someone need to be able to patch this, we make
 % it into a macro and just run it at the start of the cocument
 %    \begin{macrocode}
 \newcommand\mem at fixpagelayout{%
@@ -7465,25 +7534,16 @@
 % \cs{pagenumbering}\marg{style} is the normal version whereas
 % the starred version does not reset the counter.
 % \changes{v1.0}{2001/09/21}{Added \cs{pagenumbering} and \cs{pagenumbering*} }
+% \changes{v3.8}{2023/05/08}{Reimplemented as a single macro via \RenewDocumentCommand}
 %    \begin{macrocode}
-\renewcommand{\pagenumbering}{%
-  \@ifstar{\@smempnum}{\@mempnum}}
-%    \end{macrocode}
-% \begin{macro}{\@smempnum}
-%    \begin{macrocode}
-\newcommand{\@smempnum}[1]{%
-  \gdef\thepage{\csname @#1\endcsname \c at page}}
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@mempnum}
-%    \begin{macrocode}
-\newcommand{\@mempnum}[1]{%
-  \@smempnum{#1}\global\c at page \@ne}
+\RenewDocumentCommand\pagenumbering{sm}{%
+  \gdef\thepage{\csname @#2\endcsname \c at page}%
+  \IfBooleanF{#1}{\global\c at page \@ne}% reset counter unless starred
+}
 
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
-% \end{macro}
 %
 % \begin{macro}{\c at storedpagenumber}
 % A counter to store the page number.
@@ -7662,20 +7722,23 @@
 %
 % \begin{macro}{\@setsize}
 % Modify the kernel command.
+% \changes{v3.8}{2023/08/08}{\cs{@setsize} redef removed. It came from
+% setspace.sty which note that it was needed for some 209 packages. In
+% the kernel it is just defined to use \cs{@setfontsize}. We remove it}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check what this does!!!!!!!!
 %    \begin{macrocode}
-\renewcommand*{\@setsize}[4]{%
-  \@nomath#1%
-  \let\@currsize#1%
-  \baselineskip #2%
-  \baselineskip \baselinestretch\baselineskip
-  \parskip \baselinestretch\parskip
-  \setbox\strutbox \hbox{%
-    \vrule height.7\baselineskip
-           depth .3\baselineskip
-           width \z@}%
-  \skip\footins \baselinestretch\skip\footins
-  \normalbaselineskip\baselineskip#3#4}
+ % \renewcommand*{\@setsize}[4]{%
+ %   \@nomath#1%
+ %   \let\@currsize#1%
+ %   \baselineskip #2%
+ %   \baselineskip \baselinestretch\baselineskip
+ %   \parskip \baselinestretch\parskip
+ %   \setbox\strutbox \hbox{%
+ %     \vrule height.7\baselineskip
+ %            depth .3\baselineskip
+ %            width \z@}%
+ %   \skip\footins \baselinestretch\skip\footins
+ %   \normalbaselineskip\baselineskip#3#4}
 
 %    \end{macrocode}
 % \end{macro}
@@ -7804,24 +7867,45 @@
 % \end{macro}
 %
 % \begin{macro}{\@xfloat}
-%   Reset \cs{baselinestretch} in floats. Because of a package like
-%   \Lpack{fixltx2e} (recommended package), we have to delay the
-%   addition.
-%   \changes{v3.7d}{2014/07/28}{Delayed addition to
-%   \cs{@xfloat}. Reported by Ulrike Fischer}.
+%   Reset \cs{baselinestretch} in floats. If the format version
+%   supports it we add it via a cmd hook, if not, we delay until the
+%   start of the document and use the older definition. Note that the
+%   hook cannot access the arguments given to \cs{@xfloat}, luckily it
+%   stores \#1 in \cs{@captype}.
+%   \changes{v3.7d}{2014/07/28}{Delayed addition to  \cs{@xfloat}. Reported by Ulrike Fischer}
 %   \changes{v3.7g}{2017/05/08}{Delayed the addition of the adjustment
 %   to the float until after \cs{normalsize}. Reported at \protect\url{https://tex.stackexchange.com/q/368422/3929}}
+%   \changes{v3.8}{2023/05/08}{Additions to \cs{@xfloat} now added
+%   via a cmd/after hook if the format supports it}
 %    \begin{macrocode}
-\AtBeginDocument{
-  \let\m at m@xfloat\@xfloat
-  \def\@xfloat #1[#2]{%
-    \m at m@xfloat #1[#2]%
+\IfFormatAtLeastTF{2021/04/20}{%
+  \AddToHook{cmd/@xfloat/after}{%
     \def\baselinestretch{\m at m@float at spacing}%
     \normalsize%
-    \@nameuse{#1adjustment}%
-  }
+    \@nameuse{\@captype adjustment}% \@xfloat stores its #1 arg in \@captype
+  }%
+}{%
+  \AtBeginDocument{%
+    % \typeout{Old kernel, redefining \string\@xfloat\ instead of using a hook}
+    \let\m at m@xfloat\@xfloat%
+    \def\@xfloat #1[#2]{%
+      \m at m@xfloat #1[#2]%
+      \def\baselinestretch{\m at m@float at spacing}%
+      \normalsize%
+      \@nameuse{#1adjustment}%
+    }%
+  }%
 }
+% The code can also be made (slightly modified) using a cmd hook
+% eliminating the explicit \AtBeginDocument, note that we probably
+% need a format check in order to be able to use the cmd hook
+% \AddToHook{cmd/@xfloat/after}{%
+%  \def\baselinestretch{\m at m@float at spacing}%
+%    \normalsize%
+%    \@nameuse{\@captype adjustment}% \@xfloat stores its #1 arg in \@captype
+% }
 
+
 %    \end{macrocode}
 % \end{macro}
 %
@@ -7989,7 +8073,8 @@
 % \begin{macro}{\maketitlehookc}
 % \begin{macro}{\maketitlehookd}
 % The four hooks which will be called by \cs{maketitle}. These are initially
-% vacuous.
+% vacuous. The hooks are placed before title, before author, before
+% date and after date respectively.
 %    \begin{macrocode}
 \newcommand{\maketitlehooka}{}
 \newcommand{\maketitlehookb}{}
@@ -8146,11 +8231,8 @@
 \newcommand{\makethanksmark}{%
   \leavevmode%
   \parindent 1em\noindent
-%%%  \leftskip\thanksmarksep\relax
   \memRTLleftskip\thanksmarksep\relax
-%%%  \advance\leftskip\thanksmarkwidth 
   \advance\memRTLleftskip\thanksmarkwidth
-%%%  \null\nobreak\hskip-\leftskip\relax
   \null\nobreak\hskip-\memRTLleftskip\relax
   \makethanksmarkhook\relax
   \thanksfootmark}
@@ -8206,7 +8288,8 @@
 % \begin{macro}{\maketitle}
 % The following is a
 % modification of \cs{maketitle} as in the \Lpack{article}, \Lpack{report},
-% and \Lpack{book} classes. It sets the pagestyle to \pstyle{title}.
+% and \Lpack{book} classes. It sets the pagestyle to \pstyle{title}
+% and as a default sets \pstyle{title} to point to \pstyle{plain}.
 % \changes{v1.4}{2004/01/21}{Removed the \cs{rlap} from \cs{@makefnmark}
 %                            in \cs{maketitle} so multiple \cs{thanks}
 %                            work per \cs{footnote}}
@@ -8557,6 +8640,7 @@
 % \begin{table}
 % \centering
 % \caption{Document division levels}\label{tab:levels}
+% \medskip
 % \begin{tabular}{lr} \hline
 % Division & Level \\ \hline
 % book          & -2 \\
@@ -8662,8 +8746,8 @@
 %
 %    Book, part and chapter are the top level document divisions.
 %    \begin{macrocode}
-\newcounter{book} \setcounter{book}{0}
-\newcounter{part} \setcounter{part}{0}
+\newcounter{book}    \setcounter{book}{0}
+\newcounter{part}    \setcounter{part}{0}
 \newcounter{chapter} \setcounter{chapter}{0}
 %    \end{macrocode}
 %    The lower level divisions get reset by higher level divisions.
@@ -8916,7 +9000,7 @@
 % \subsection{Book}
 %
 % This was added at the request of Frederic Connes who said that in
-% Frency typography there was often a division above the \cs{part} level.
+% French typography there was often a division above the \cs{part} level.
 %
 % \begin{macro}{\theHbook}
 % \begin{macro}{\toclevel at book}
@@ -8923,8 +9007,11 @@
 % These are needed if the \Lpack{hyperref} is used.
 % \changes{v3.7.19}{2022/10/25}{Changing \cs{theH...} definitions to
 % \cs{def} for better compability with future hyperref}
+% \changes{v3.8}{2023/06/20}{Changed \cs{theHbook} to use
+% \cs{the}\cs{value\{counter\}} as packages can mess up \cs{arabic}
+% advise from Ulrike}
 %    \begin{macrocode}
-\def\theHbook{\arabic{book}}
+\def\theHbook{\the\value{book}}
 \def\toclevel at book{-2}
 
 %    \end{macrocode}
@@ -9016,6 +9103,10 @@
 %
 % \begin{macro}{\membookinfo}
 % \begin{macro}{\membookstarinfo}
+%   Hooks. Arguments given for \cs{membookinfo} will be \cs{thebook}
+%   (unless secnumdepth), the data for the toc and the title. The
+%   argument for \cs{membookstarinfo} (starred version) will just be
+%   the title.
 %    \begin{macrocode}
 \newcommand{\membookinfo}[3]{}
 \newcommand{\membookstarinfo}[1]{}
@@ -9256,6 +9347,10 @@
 %
 % \begin{macro}{\mempartinfo}
 % \begin{macro}{\mempartstarinfo}
+% Hooks for the part data. Arguments as listed. Though first arg for
+% \cs{mempartinfo} might be empty if secnumdepth say so.
+%
+% \medskip\noindent
 % \verb?\mempartinfo{\thepart}{short}{long}? \\
 % \verb?\mempartstarinfo{long}? \\
 % \changes{v1.61803}{2008/01/30}{Made \cs{mempartinfo} long (mempatch v4.9).}
@@ -9614,6 +9709,7 @@
 %    \begin{macrocode}
   \@nameuse{chapter at f@rtoc at before@write at hook}%     
 %    \end{macrocode}
+%
 % Vittorio De Martino (\texttt{demartino.vittoria at grtn.it}) on
 % 31 March 2003 reported that for articled chapters, which do not do
 % any \cs{clearpage}, \cs{addcontents} had to come after the title.
@@ -9646,8 +9742,10 @@
 % \changes{v3.6k}{2013/04/24}{Added \cs{memendofchapterhook}}.
 % The hook at the very end can be used to automatically add a new page
 % right after \cs{chapter}.
+% \changes{v3.70.20}{2023/07/24}{Redef of \cs{M at gettitle} requires
+% expansion for macro arguments}
 %    \begin{macrocode}
-  \ifheadnameref\M at gettitle{\f at rhdr}\else\M at gettitle{\f at rtoc}\fi%
+  \ifheadnameref\ExpandArgs{V}\M at gettitle\f at rhdr\else\ExpandArgs{V}\M at gettitle\f at rtoc\fi%
   \memendofchapterhook%
 }
 
@@ -9746,9 +9844,9 @@
 % \begin{macro}{\afterchapskip}
 % Lengths separating the various parts of a chapter heading.
 %    \begin{macrocode}
-\newlength{\beforechapskip}\setlength{\beforechapskip}{50pt}
-\newlength{\midchapskip}\setlength{\midchapskip}{20pt}
-\newlength{\afterchapskip}\setlength{\afterchapskip}{40pt}
+\newlength{\beforechapskip} \setlength{\beforechapskip}{50pt}
+\newlength{\midchapskip}    \setlength{\midchapskip}{20pt}
+\newlength{\afterchapskip}  \setlength{\afterchapskip}{40pt}
 
 %    \end{macrocode}
 % \end{macro}
@@ -9812,6 +9910,8 @@
 %
 % \begin{macro}{\@m at mschapter}
 % This deals with the new optional argument for starred chapters.
+% \changes{v3.70.20}{2023/07/24}{Redef of \cs{M at gettitle} requires
+% expansion for macro arguments}
 %    \begin{macrocode}
 \newcommand{\@m at mschapter}[2][\@empty]{%
   \@schapter{#2}%
@@ -9828,7 +9928,7 @@
   \else
     \memchapstarinfo{\f at rhdr}{#2}%
   \fi
-  \ifheadnameref\M at gettitle{\f at rhdr}\else\M at gettitle{#2}\fi}
+  \ifheadnameref\ExpandArgs\M at gettitle\f at rhdr\else\M at gettitle{#2}\fi}
 
 %    \end{macrocode}
 % \end{macro}
@@ -9894,8 +9994,9 @@
 % \begin{macro}{\makechapterstyle}
 % \begin{macro}{\chapterstyle}
 % \cs{chapterstyle}\marg{style} is like \cs{pagestyle}, except it's for 
-% chapters. 
+% chapters.
 %
+% \medskip\noindent
 % \cs{makechapterstyle}\marg{style}\marg{text} creates
 % or overrides the \meta{style} chapter style defining it as \meta{text}
 % So, \verb?\makechapterstyle{fred}{code}? specifies that the chapter style 
@@ -10895,7 +10996,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
-%
+% \begin{macro}{\@sect}
+% \changes{v3.8}{2023/07/24}{Added patch.}
+% The \Lpack{pdfpages} package assumes \cs{@sect} in order to add
+% stuff to say \cs{@currentlabelname}. So in case others use it we map \cs{@sect}.
+%    \begin{macrocode}
+\def\@sect#1#2#3#4#5#6[#7]#8{\M at sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#7}]{#8}}
+
+%    \end{macrocode}
+% \end{macro}
+% 
 % \begin{macro}{\@ssect}
 % Add hook for name reference to \cs{section*} etc. \\
 % \cs{@ssect}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{title}
@@ -12225,9 +12335,12 @@
 % We end by redefining \cs{theHsection} introduced in \cs{@resets at ppsub}
 % \changes{v3.7p}{2021/06/16}{Moved redef of \cs{theHsection} here instead
 % of in \Lpack{memhfixc}}
+% \changes{v3.8}{2023/06/20}{Changed \cs{theHsection} to use
+% \cs{the}\cs{value\{counter\}} as packages can mess up \cs{arabic}
+% advise from Ulrike}
 %    \begin{macrocode}
 }{%
-  \def\theHsection{\theHchapter.\arabic{section}}
+  \def\theHsection{\theHchapter.\the\value{section}}
 }
 
 %    \end{macrocode}
@@ -12458,9 +12571,7 @@
 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{centerlastline}}
 %    \begin{macrocode}
 \newcommand*{\centerlastline}{%
-%%%  \leftskip\@flushglue
   \memRTLleftskip\@flushglue
-%%%  \rightskip=\z@ plus -1fil
   \memRTLrightskip=\z@ plus -1fil
   \parfillskip=\z@ plus 2fil}
 
@@ -12530,9 +12641,7 @@
   \setlength{\ragrparindent}{\parindent}
 \newcommand{\raggedyright}[1][2em]{%
   \let\\\@centercr\@rightskip \z@ \@plus #1\relax 
-%%%  \rightskip\@rightskip
   \memRTLrightskip\@rightskip
-%%%  \leftskip\z at skip
   \memRTLleftskip\z at skip
   \parindent\ragrparindent}
 
@@ -12547,9 +12656,7 @@
 % \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{justlastraggedleft}}
 %    \begin{macrocode}
 \newcommand*{\justlastraggedleft}{%
-%%%  \leftskip\@flushglue
   \memRTLleftskip\@flushglue
-%%%  \rightskip-\leftskip
   \memRTLrightskip-\memRTLleftskip
   \parfillskip\leftskip
   \parindent \z@}
@@ -14782,10 +14889,12 @@
 % \begin{macro}{\thepoem}
 % \begin{macro}{\theHpoem}
 % Counter for poem titles.
+% \changes{v3.8}{2023/06/20}{Changed \cs{theHpoem} to
+% \cs{providecommand} per request of the kernel team}
 %    \begin{macrocode}
 \newcounter{poem}\setcounter{poem}{0}
-  \renewcommand*{\thepoem}{\@arabic\c at poem}
-\newcommand*{\theHpoem}{\arabic{poem}}
+\renewcommand*{\thepoem}{\@arabic\c at poem}
+\providecommand*{\theHpoem}{\the\value{poem}}
 
 %    \end{macrocode}
 % \end{macro}
@@ -14899,8 +15008,10 @@
   \fi
 %    \end{macrocode}
 % Add hook for title referencing.
+% \changes{v3.70.20}{2023/07/24}{Redef of \cs{M at gettitle} requires
+% expansion for macro arguments}
 %    \begin{macrocode}
-  \ifheadnameref\M at gettitle{\poemf at rhdr}\else\M at gettitle{\poemf at rtoc}\fi}
+  \ifheadnameref\ExpandArgs{V}\M at gettitle\poemf at rhdr\else\ExpandArgs{V}\M at gettitle\poemf at rtoc\fi}
 
 %    \end{macrocode}
 % \end{macro}
@@ -15186,2076 +15297,7 @@
 %    \begin{macrocode}
 \RequirePackage{array}[2018/04/30]
 %    \end{macrocode}
-% The embeded copy is outcommented for now and will be removed in a
-% later version.
 %
-% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
-% \Lpack{array} and replaced it with requiring the \Lpack{array} package
-% instead.}
-%
-% ^^A % The description and code are essentially copied from the \Lpack{array}
-% ^^A package~\cite{ARRAY}.
-% ^^A
-%    \begin{macrocode}
- % 
- % %%%%%%%%%% Array package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% Frank Mittelbach & David Carlisle %%%%%%%%%%%%%%%%%%%%%
- % 
- % %%%%%%%%%% Copy corresponds to array.sty 2016/10/06 v2.4d %%%%%%%%% 
-%    \end{macrocode}
-% ^^A \changes{v3.7g}{2018/03/05}{Updated the embedded copy of the
-% ^^A \Lpack{array} package to version 2.4d, 2016/10/06}
-% ^^A \begin{dlf}
-% ^^A  dlf: The \Lpack{array} package has redundant code (caused by a
-% ^^A  quick mashing of and earlier \Lpack{array} version and the
-% ^^A  \Lpack{newaray} package). In thus update (2018/03/05) this
-% ^^A  redundant code is \emph{not} removed as it makes it very hard to
-% ^^A  see where there are class changes to the \Lpack{array} code, and
-% ^^A  when stuff is simply removed. We'll leave it up to the LaTeXteam to
-% ^^A  clean up the \Lpack{array} code at some point.
-% ^^A
-% ^^A The following is a carbon copy of the DTX code from
-% ^^A \verb|array.dtx|, package specific \cs{changes} lines have been
-% ^^A removed, and we have made any error/warning messages class specific,
-% ^^A instead of package specific.
-% ^^A \end{dlf}
-% ^^A
-% ^^A 
-% ^^A \subsubsection{The construction of the preamble}
-% ^^A
-% ^^A It is obvious that those environments will consist mainly of an
-% ^^A \verb=\halign=, because \TeX\ typesets tables using this primitive.
-% ^^A That is why we will now take a look at the algorithm which determines
-% ^^A a preamble for a \verb=\halign= starting with a given user preamble
-% ^^A using the options mentioned above.
-% ^^A
-% ^^A The most interesting macros of this implementation are without doubt
-% ^^A those which are responsible for the construction of the preamble for
-% ^^A the \verb=\halign=. The underlying algorithm was developed by
-% ^^A \textsc{Lamport} (resp.\ \textsc{Knuth}, see texhax V87\#??), and it
-% ^^A has been extended and improved.
-% ^^A
-% ^^A The user preamble will be read \textsf{token} by \textsf{token}.  A
-% ^^A \textsf{token} is a single character like \texttt{c} or a block
-% ^^A enclosed in \verb={...}=. For example the preamble of
-% ^^A \verb=\begin{tabular}=\linebreak[0]\verb={lc||c@{\hspace{1cm}}}= consists of
-% ^^A the \textsf{token} \texttt{l}, \texttt{c}, \texttt{|}, \texttt{|},
-% ^^A \texttt{@} and \verb=\hspace{1cm}=.
-% ^^A
-% ^^A The currently used \textsf{token} and the one, used before, are needed
-% ^^A to decide on how the construction of the preamble has to be
-% ^^A continued.
-% ^^A In the example mentioned above the \texttt{l} causes the preamble
-% ^^A to begin with \verb=\hskip\tabcolsep=. Furthermore
-% ^^A \verb=# \hfil= would be appended to define a flush left column.
-% ^^A The next \textsf{token} is a \texttt{c}. Because it was preceded by an
-% ^^A \texttt{l} it generates a new column. This is done with
-% ^^A \verb=\hskip \tabcolsep & \hskip \tabcolsep=. The column which is to
-% ^^A be centered will be appended with \verb=\hfil # \hfil=.
-% ^^A The \textsf{token} \texttt{|} would then add a space of
-% ^^A \verb=\hskip \tabcolsep=
-% ^^A and a vertical line because the last
-% ^^A \textsf{tokens} was a \texttt{c}.
-% ^^A The following \textsf{token} \texttt{|} would only add a space
-% ^^A \verb=\hskip \doublerulesep= because it was preceded by the
-% ^^A \textsf{token} \texttt{|}. We will not discuss our example further but
-% ^^A  rather take a look at the general case of constructing preambles.
-% ^^A
-% ^^A The example shows that the desired preamble for the
-% ^^A \verb=\halign= can be constructed as soon as the action of all
-% ^^A combinations
-% ^^A of the preamble \textsf{tokens} are specified. There are 18 such
-% ^^A \textsf{tokens}
-% ^^A so we have $19 \cdot 18 = 342$ combinations if we count the
-% ^^A beginning of
-% ^^A the preamble as a special \textsf{token}. Fortunately, there are many
-% ^^A combinations which generate the same spaces, so we can define
-% ^^A \textsf{token} classes. We will identify a
-% ^^A \textsf{token} within a class with a number, so we can insert the
-% ^^A formatting (for example of a column).
-% ^^A Table~\ref{tab:Klassen} lists all \textsf{token} classes and
-% ^^A their corresponding numbers.
-% ^^A \begin{table}[ht]
-% ^^A \begin{center}
-% ^^A       \begin{tabular}[t]{>{\ttfamily}ccc}
-% ^^A       \textsf{token} & \verb=\@chclass= & \verb=\@chnum= \\[2mm]
-% ^^A       c   & 0  & 0 \\
-% ^^A       l   & 0  & 1 \\
-% ^^A       r   & 0  & 2 \\
-% ^^A       p-arg    & 0  & 3 \\
-% ^^A       t-arg    & 0  & 4 \\
-% ^^A       b-arg    & 0  & 5 \\
-% ^^A       |   & 1  & 0 \\
-% ^^A       !-arg    & 1  & 1 \\
-% ^^A       <-arg    & 2  & --- \\
-% ^^A       >-arg    & 3  & ---
-% ^^A    \end{tabular}
-% ^^A    \kern3mm \vrule \kern3mm%
-% ^^A    \begin{tabular}[t]{>{\ttfamily}ccc}
-% ^^A       \textsf{token} & \verb=\@chclass= & \verb=\@chnum= \\[2mm]
-% ^^A       Start    & 4  & --- \\
-% ^^A       @-arg    & 5  & --- \\
-% ^^A       !   & 6  & --- \\
-% ^^A       @   & 7  & --- \\
-% ^^A       <   & 8  & --- \\
-% ^^A       >   & 9  & --- \\
-% ^^A       p   & 10 & 3 \\
-% ^^A       t   & 10 & 4 \\
-% ^^A       b   & 10 & 5
-% ^^A    \end{tabular}
-% ^^A \end{center}
-% ^^A \caption{Classes of preamble \textsf{tokens}}
-% ^^A \label{tab:Klassen}
-% ^^A \end{table}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@chclass}
-% ^^A \begin{macro}{\@chnum}
-% ^^A \begin{macro}{\@lastchclass}
-% ^^A    The class and the number of the current \textsf{token} are saved in
-% ^^A    the
-% ^^A    \textsf{count} registers \verb=\@chclass=
-% ^^A    and \verb=\@chnum=, while the class of the previous
-% ^^A    \textsf{token} is stored in the
-% ^^A    \textsf{count} register \verb=\@lastchclass=.
-% ^^A    All of the mentioned registers are already allocated in
-% ^^A    \texttt{latex.tex},
-% ^^A    which is the reason why the following three lines of code are
-% ^^A    commented out.
-% ^^A    Later throughout the text I will not mention it again explicitly
-% ^^A    whenever I use a \verb=%= sign. These parts are already defined in
-% ^^A    \texttt{latex.tex}.
-%    \begin{macrocode}
- % % \newcount \@chclass
- % % \newcount \@chnum
- % % \newcount \@lastchclass
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@addtopreamble}
-% ^^A    We will save the already constructed preamble for
-% ^^A    the \verb=\halign=
-% ^^A    in the global macro \verb=\@preamble=. This will then be
-% ^^A     enlarged with
-% ^^A    the command \verb=\@addtopreamble=.
-%    \begin{macrocode}
- % \def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection{The character class of a \textsf{token}}
-% ^^A
-% ^^A \begin{macro}{\@testpach}
-% ^^A    With the help of \verb=\@lastchclass= we can now define a macro
-% ^^A    which determines the class and the number of a given preamble
-% ^^A    \textsf{token}
-% ^^A    and assigns them to the registers
-% ^^A    \verb=\@chclass= and \verb=\@chnum=.
-%    \begin{macrocode}
- % \def\@testpach{\@chclass
-%    \end{macrocode}
-% ^^A    First we deal with the cases in which the \textsf{token}
-% ^^A    (\verb=#1=) is the argument of \texttt{!}, \texttt{@}, \texttt{<} or
-% ^^A    \texttt{>}. We can see this from the value of \verb=\@lastchclass=:
-%    \begin{macrocode}
- %  \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
- %   \ifnum \@lastchclass=7 5 \else
- %    \ifnum \@lastchclass=8 \tw@ \else
- %     \ifnum \@lastchclass=9 \thr@@
-%    \end{macrocode}
-% ^^A    Otherwise we will assume that the \textsf{token} belongs to the
-% ^^A    class $0$
-% ^^A    and assign the corresponding number to \verb=\@chnum= if our
-% ^^A    assumption is correct.
-%    \begin{macrocode}
- %    \else \z@
-%    \end{macrocode}
-% ^^A    If the last \textsf{token} was a \texttt{p}, \texttt{m} or a
-% ^^A    \texttt{b}, \verb=\@chnum= already has the right value. This is the
-% ^^A    reason for the somewhat curious choice of the \textsf{token}
-% ^^A    numbers in class $10$.
-%    \begin{macrocode}
- %    \ifnum \@lastchclass = 10 \else
-%    \end{macrocode}
-% ^^A    Otherwise we will check if \verb=\@nextchar= is either a \texttt{c},
-% ^^A    \texttt{l} or an \texttt{r}.  Some applications change the
-% ^^A    catcodes of certain characters like ``\texttt{@}'' in
-% ^^A    \texttt{amstex.sty}. As a result the tests below would fail since
-% ^^A    they assume non-active character tokens. Therefore we evaluate
-% ^^A    \verb=\@nextchar= once thereby turning the first token of its
-% ^^A    replacement text into a char. At this point here this should have
-% ^^A    been the only char present in \verb=\@nextchar= which put into via a
-% ^^A    \verb=\def=.
-%    \begin{macrocode}
- %    \edef\@nextchar{\expandafter\string\@nextchar}%
- %    \@chnum
- %    \if \@nextchar c\z@ \else
- %     \if \@nextchar l\@ne \else
- %      \if \@nextchar r\tw@ \else
-%    \end{macrocode}
-% ^^A    If it is a different \textsf{token}, we know that the class was
-% ^^A    not $0$. We assign the value $0$ to \verb=\@chnum= because this value
-% ^^A    is needed for the \texttt{|}--\textsf{token}. Now we must check
-% ^^A    the remaining classes.  Note that the value of \verb=\@chnum= is
-% ^^A    insignificant here for most classes.
-%    \begin{macrocode}
- %    \z@ \@chclass
- %    \if\@nextchar |\@ne \else
- %     \if \@nextchar !6 \else
- %      \if \@nextchar @7 \else
- %       \if \@nextchar <8 \else
- %        \if \@nextchar >9 \else
-%    \end{macrocode}
-% ^^A    The remaining permitted \textsf{tokens} are \texttt{p},
-% ^^A    \texttt{m} and \texttt{b} (class $10$).
-%    \begin{macrocode}
- %   10
- %   \@chnum
- %   \if \@nextchar m\thr@@\else
- %    \if \@nextchar p4 \else
- %     \if \@nextchar b5 \else
-%    \end{macrocode}
-% ^^A    Now the only remaining possibility is a forbidden \textsf{token},
-% ^^A    so we choose class $0$ and number $0$ and give an error message.
-% ^^A    Then we finish the macro by closing all \verb=\if='s.
-%    \begin{macrocode}
- %    \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi
- %    \fi \fi  \fi  \fi  \fi  \fi  \fi \fi \fi \fi \fi \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection{Multiple columns ($*$--form)}
-% ^^A
-% ^^A \begin{macro}{\@xexpast}
-% ^^A \begin{macro}{\the at toks}
-% ^^A \begin{macro}{\the at toksz}
-% ^^A    \label{@xexpast} Now we discuss the macro that deletes all forms
-% ^^A    of type \verb=*{=\textit{N\/}\verb=}{=\textit{String\/}\verb=}= from a user
-% ^^A    preamble and replaces them with \textit{N} copies of
-% ^^A    \textit{String}.  Nested $*$--expressions are dealt with
-% ^^A    correctly, that means $*$--expressions are not substituted if
-% ^^A    they are in explicit braces, as in \verb=@{*}=.
-% ^^A
-% ^^A    This macro is called via
-% ^^A    \verb=\@xexpast=\meta{preamble}\verb=*0x\@@=.
-% ^^A    The $*$--expression \verb=*0x= is being used to terminate the
-% ^^A    recursion,
-% ^^A    as we shall see later, and \verb=\@@= serves as an argument
-% ^^A    delimiter. \verb=\@xexpast= has four arguments. The first
-% ^^A    one is the part of the
-% ^^A    user preamble before the first $*$--expression while the second
-% ^^A    and third ones are the arguments of the first $*$--expression
-% ^^A    (that is \textit{N} and \textit{String} in the notation mentioned
-% ^^A    above).
-% ^^A    The fourth argument is the rest of the preamble.
-%    \begin{macrocode}
- % \def\@xexpast#1*#2#3#4\@@{%
-%    \end{macrocode}
-% ^^A    The number of copies of \textit{String} (\verb=#2=) that are to be
-% ^^A    produced will be saved in a \textsf{count} register.
-%    \begin{macrocode}
- %    \@tempcnta #2
-%    \end{macrocode}
-% ^^A    We save the part of the preamble which does not
-% ^^A    contain a $*$--form (\verb=#1=)
-% ^^A    in a \PlainTeX\ \textsf{token} register.
-% ^^A    We also save \textit{String} (\verb=#3=) using a \LaTeX\
-% ^^A    \textsf{token} register.
-%    \begin{macrocode}
- %    \toks@={#1}\@temptokena={#3}%
-%    \end{macrocode}
-% ^^A    Now we have to use a little trick to produce \textit{N} copies of
-% ^^A    \textit{String}.
-% ^^A    We could try \verb=\def\@tempa{#1}= and then
-% ^^A    \textit{N} times \verb=\edef\@tempa{\@tempa#3}=. This would have the
-% ^^A    undesired effect that all macros within \verb=#1= and \verb=#3=
-% ^^A    would be expanded, although, for example, constructions like
-% ^^A    \verb=@{..}= are not supposed to be changed.
-% ^^A    That is why we \verb=\let= two control sequences to
-% ^^A    be equivalent to \verb=\relax=.
-%    \begin{macrocode}
- %    \let\the at toksz\relax \let\the at toks\relax
-%    \end{macrocode}
-% ^^A    Then we ensure that \verb=\@tempa= contains
-% ^^A    \verb={\the at toksz\the at toks...\the at toks}= (the macro
-% ^^A    \verb=\the at toks= exactly \textit{N\/} times) as substitution text.
-%    \begin{macrocode}
- %    \def\@tempa{\the at toksz}%
- %    \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do
- %      {\edef\@tempa{\@tempa\the at toks}\advance \@tempcnta \m at ne}%
-%    \end{macrocode}
-% ^^A    If \textit{N\/} was greater than zero we prepare for another call
-% ^^A    of \verb=\@xexpast=. Otherwise we assume we have reached the end of
-% ^^A    the user preamble, because we had appended \verb=*0x\@@= when we first
-% ^^A    called \verb=\@xexpast=.  In other words: if the user inserts
-% ^^A    \verb=*{0}{..}= in his preamble, \LaTeX\ ignores the rest of it.
-%    \begin{macrocode}
- %        \let \@tempb \@xexpast \else
- %        \let \@tempb \@xexnoop \fi
-%    \end{macrocode}
-% ^^A    Now we will make sure that the part of the user preamble, which
-% ^^A    was already dealt with, will be saved again in \verb=\@tempa=.
-%    \begin{macrocode}
- %    \def\the at toksz{\the\toks@}\def\the at toks{\the\@temptokena}%
- %    \edef\@tempa{\@tempa}%
-%    \end{macrocode}
-% ^^A    We have now evaluated the first $*$--expression, and the user
-% ^^A    preamble up to this point
-% ^^A    is saved in \verb=\@tempa=. We will put the contents of
-% ^^A    \verb=\@tempa= and the rest of the user preamble together and work
-% ^^A    on the result with \verb=\@tempb=. This macro either corresponds
-% ^^A    to \verb=\@xexpast=, so that the next
-% ^^A    $*$--expression is handled, or to the macro \verb=\@xexnoop=,
-% ^^A    which only ends the recursion by deleting its argument.
-%    \begin{macrocode}
- %    \expandafter \@tempb \@tempa #4\@@}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@xexnoop}
-% ^^A    So the first big problem is solved. Now it is easy to
-% ^^A    specify \verb=\@xexnoop=.
-% ^^A    Its argument is delimited by \verb=\@@= and it simply expands to
-% ^^A    nothing.
-%    \begin{macrocode}
- % %  \def\@xexnoop#1\@@{}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection{The insertion of declarations
-% ^^A           (\texttt{>}, \texttt{<}, \texttt{!}, \texttt{@})}
-% ^^A
-% ^^A
-% ^^A The preamble will be enlarged with the help of \verb=\xdef=, but the
-% ^^A arguments of \texttt{>}, \texttt{<},~\texttt{!}\ and \texttt{@} are
-% ^^A not supposed to be expanded during the construction (we want an
-% ^^A implementation that doesn't need a \verb=\protect=). So we have to find a
-% ^^A way to inhibit the expansion of those arguments.
-% ^^A
-% ^^A We will solve this problem with \textsf{token} registers. We need
-% ^^A one register for every \texttt{!}\ and \texttt{@}, while we need two
-% ^^A for every \texttt{c}, \texttt{l}, \texttt{r}, \texttt{m}, \texttt{p}
-% ^^A or \texttt{b}. This limits the number of columns of a table because
-% ^^A there are only 256 \textsf{token} registers. But then, who needs
-% ^^A tables with more than 100 columns?
-% ^^A
-% ^^A One could also find a solution which only needs two or three
-% ^^A \textsf{token} registers by proceeding similarly as in the macro
-% ^^A \verb=\@xexpast= (see page \pageref{@xexpast}). The advantage of our
-% ^^A approach is the fact that we avoid some of the problems that arise
-% ^^A with the other method\footnote{Maybe there are also historical
-% ^^A  reasons.}.
-% ^^A
-% ^^A So how do we proceed? Let us assume that we had \verb=!{foo}= in the
-% ^^A user preamble and say we saved \texttt{foo} in
-% ^^A \textsf{token} register $5$. Then we call
-% ^^A \verb=\@addtopreamble{\the at toks5}= where
-% ^^A \verb=\the at toks= is defined in a way that it does not expand
-% ^^A (for example it could be equivalent to \verb=\relax=). Every
-% ^^A following call
-% ^^A of \verb=\@addtopreamble= leaves \verb=\the at toks5= unchanged in
-% ^^A \verb=\@preamble=. If the construction of the preamble is completed
-% ^^A we change the definition of \verb=\the at toks= to
-% ^^A \verb=\the\toks= and expand \verb=\@preamble= for the last time.
-% ^^A During this process all parts of the form
-% ^^A    \verb=\the at toks=\meta{Number}
-% ^^A will be substituted by the contents of the respective \textsf{token}
-% ^^A registers.
-% ^^A
-% ^^A As we can see from this informal discussion the construction of the
-% ^^A preamble has to take place within a group, so that the
-% ^^A \textsf{token} registers we use will be freed later on. For that
-% ^^A reason we keep all assignments to \verb=\@preamble= global; therefore the
-% ^^A replacement text of this macro will remain the same after we leave
-% ^^A the group.
-% ^^A
-% ^^A \begin{macro}{\count@}
-% ^^A    We further need a \textsf{count} register to remember which
-% ^^A    \textsf{token} register is to be used next. This will be
-% ^^A    initialized with $-1$ if we want to begin with the \textsf{token}
-% ^^A    register $0$. We use the \PlainTeX\ scratch register \verb=\count@=
-% ^^A    because everything takes place locally. All we have to do is
-% ^^A    insert \verb=\the at toks= \verb=\the= \verb=\count@= into the preamble.
-% ^^A    \verb=\the at toks= will remain unchanged and \verb=\the\count@= expands into
-% ^^A    the saved number.
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\prepnext at tok}
-% ^^A    The macro \verb=\prepnext at tok= is in charge of preparing the next
-% ^^A    \textsf{token} register. For that purpose we increase
-% ^^A    \verb=\count@= by $1$:
-%    \begin{macrocode}
- % \def\prepnext at tok{\advance \count@ \@ne
-%    \end{macrocode}
-% ^^A    Then we locally delete any contents the
-% ^^A    \textsf{token} register might have.
-%    \begin{macrocode}
- %    \toks\count@{}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\save at decl}
-% ^^A    During the construction of the preamble the current
-% ^^A    \textsf{token} is always saved in the macro \verb=\@nextchar= (see the
-% ^^A    definition of \verb=\@mkpream= on page \pageref{@mkpream}). The macro
-% ^^A    \verb=\save at decl= saves it into the next free \textsf{token} register,
-% ^^A    i.e.\ in \verb=\toks\count@=.
-%    \begin{macrocode}
- % \def\save at decl{\toks\count@ \expandafter{\@nextchar}}
-%    \end{macrocode}
-% ^^A    The reason for the  use of \verb=\relax= is the following
-% ^^A    hypothetical situation in the preamble:
-% ^^A    \quad \verb=..\the\toks1\the\toks2..= \quad \TeX\ expands
-% ^^A    \verb=\the\toks2= first in order to find out if the digit \verb=1=
-% ^^A    is followed by other digits. E.g.\ a \verb=5= saved in the
-% ^^A    \textsf{token} register $2$ would lead \TeX\ to insert the contents
-% ^^A    of \textsf{token} register $15$ instead of $1$ later on.
-% ^^A
-% ^^A The example above referred to an older version of \verb=\save at decl= which
-% ^^A inserted a \verb=\relex= inside the token register. This is now moved to
-% ^^A the places where the actual token registers are inserted (look for
-% ^^A \verb=\the at toks=) because the old version would still make= @=
-% ^^A expressions to moving arguments since after expanding the second
-% ^^A register while looking for the end of the number the contents of the
-% ^^A token register is added so that later on the whole register will be
-% ^^A expanded.  This serious bug was found after nearly two years
-% ^^A international use of this package  by Johannes Braams.
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A How does the situation look like, if we want to add another column
-% ^^A to the preamble, i.e.\ if we have found a \texttt{c}, \texttt{l},
-% ^^A \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in the user
-% ^^A preamble?  In this case we have the problem of the \textsf{token}
-% ^^A register from \verb=>{..}= and \verb=<{..}= having to be inserted at this
-% ^^A moment because formatting instructions like \verb=\hfil= have to be set
-% ^^A around them. On the other hand it is not known yet, if any \verb=<{..}=
-% ^^A instruction will appear in the user preamble at all.
-% ^^A
-% ^^A We solve this problem by adding two \textsf{token} registers at a
-% ^^A time.  This explains, why we have freed the \textsf{token} registers
-% ^^A in \verb=\prepnext at tok=.
-% ^^A
-% ^^A \begin{macro}{\insert at column}
-% ^^A \begin{macro}{\@sharp}
-% ^^A    We now define the macro \verb=\insert at column= which will do
-% ^^A    this work for us.
-%    \begin{macrocode}
- % \def\insert at column{%
-%    \end{macrocode}
-% ^^A    Here, we assume that the \textsf{count} register
-% ^^A    \verb=\@tempcnta= has saved the value $\verb=\count@= - 1$.
-%    \begin{macrocode}
- %    \the at toks \the \@tempcnta
-%    \end{macrocode}
-% ^^A    Next follows the \verb=#= sign which specifies the place
-% ^^A    where the text of the column shall be inserted. To avoid
-% ^^A    errors during the expansions in
-% ^^A    \verb=\@addtopreamble= we hide this sign in the command
-% ^^A    \verb=\@sharp= which is temporarily occupied with
-% ^^A    \verb=\relax= during the build-up of the preamble.
-% ^^A    To remove unwanted spaces before and after the column text, we set
-% ^^A    an \verb=\ignorespaces=  in front and a \verb=\unskip= afterwards.
-%    \begin{macrocode}
- %    \ignorespaces \@sharp \unskip
-%    \end{macrocode}
-% ^^A    Then the second \textsf{token} register follows whose number should
-% ^^A    be saved in \verb=\count@=.
-% ^^A    We make sure that there will be no further expansion after reading
-% ^^A    the number, by finishing with \verb=\relax=. The case above is not
-% ^^A    critical since it is ended by \verb=\ignorespaces=.
-%    \begin{macrocode}
- %    \the at toks \the \count@ \relax}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection{The separation of columns}
-% ^^A
-% ^^A \begin{macro}{\@addamp}
-% ^^A    In the preamble a \verb=&= has to be inserted between any two columns;
-% ^^A    before the first column there should not be a \verb=&=. As the user
-% ^^A    preamble may start with a \texttt{|} we have to remember somehow
-% ^^A    if we have already inserted a \verb=#= (i.e.\ a column). This is done
-% ^^A    with the boolean variable \verb=\if at firstamp= that we test in
-% ^^A    \verb=\@addamp=, the macro that inserts the \verb=&=.
-%    \begin{macrocode}
- % %    \newif \@iffirstamp
- % %    \def\@addamp{\if at firstamp \@firstampfalse
- % %                 \else \@addtopreamble &\fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@acol}
-% ^^A \begin{macro}{\@acolampacol}
-% ^^A \begin{macro}{\col at sep}
-% ^^A    We will now define some abbreviations for the extensions,
-% ^^A    appearing most often in the preamble build-up.
-% ^^A    Here \verb=\col at sep= is a \textsf{dimen} register which is set
-% ^^A    equivalent to \verb=\arraycolsep= in an \textsf{array}--environment,
-% ^^A    otherwise it is set equivalent to \verb=\tabcolsep=.
-%    \begin{macrocode}
- % \newdimen\col at sep
- % \def\@acol{\@addtopreamble{\hskip\col at sep}}
- % %    \def\@acolampacol{\@acol\@addamp\@acol}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \subsubsection{The macro \texttt{\textbackslash @mkpream}}
-% ^^A
-% ^^A \begin{macro}{\@mkpream}
-% ^^A \begin{macro}{\the at toks}
-% ^^A    \label{@mkpream}
-% ^^A    Now we can define the macro which builds up the preamble for the
-% ^^A    \verb=\halign=.
-% ^^A    First we initialize \verb=\@preamble=, \verb=\@lastchclass=
-% ^^A    and the boolean variable \verb=\if at firstamp=.
-%    \begin{macrocode}
- % \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
-%    \end{macrocode}
-% ^^A    During the build-up of the preamble we cannot directly use the
-% ^^A    \verb=#= sign; this would lead to an error message in the next
-% ^^A    \verb=\@addtopreamble= call.
-% ^^A    Instead, we use the command \verb=\@sharp= at places where later
-% ^^A    a \verb=#= will be.
-% ^^A    This command is at first given the meaning \verb=\relax=;
-% ^^A    therefore it will not be expanded when the preamble
-% ^^A    is extended.
-% ^^A    In the macro \verb=\@array=, shortly before the \verb=\halign=
-% ^^A    is carried out, \verb=\@sharp= is given its final meaning.
-% ^^A
-% ^^A    In a similar way,
-% ^^A    we deal with the commands \verb=\@startpbox= and
-% ^^A    \verb=\@endpbox=, although the reason is different here: these
-% ^^A    macros expand in many \textsf{tokens} which would delay the
-% ^^A    build-up of the preamble.
-%    \begin{macrocode}
- %    \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
-%    \end{macrocode}
-% ^^A    Now we remove possible  $*$-forms in the user preamble with the
-% ^^A    command \verb=\@xexpast=.  As we already know, this command saves
-% ^^A    its result in the macro \verb=\@tempa=.
-%    \begin{macrocode}
- %    \@xexpast #1*0x\@@
-%    \end{macrocode}
-% ^^A    Afterwards we initialize all registers and macros, that we need
-% ^^A    for the build-up of the preamble.
-% ^^A    Since we want to start with the \textsf{token} register $0$,
-% ^^A    \verb=\count@= has to contain the value $-1$.
-%    \begin{macrocode}
- %    \count@\m at ne
- %    \let\the at toks\relax
-%    \end{macrocode}
-% ^^A    Then we call up \verb=\prepnext at tok= in order to prepare the
-% ^^A    \textsf{token} register $0$ for use.
-%    \begin{macrocode}
- %    \prepnext at tok
-%    \end{macrocode}
-% ^^A    To evaluate the user preamble (without stars) saved in
-% ^^A    \verb=\@tempa= we use the \LaTeX--macro \verb=\@tfor=.
-% ^^A    The strange appearing construction with \verb=\expandafter= is
-% ^^A    based on the fact that we have to put the replacement text of
-% ^^A    \verb=\@tempa= and not the macro \verb=\@tempa= to this
-% ^^A    \LaTeX--macro.
-%    \begin{macrocode}
- %    \expandafter \@tfor \expandafter \@nextchar
- %     \expandafter :\expandafter =\@tempa \do
-%    \end{macrocode}
-% ^^A    The body of this loop (the group after the \verb=\do=)
-% ^^A    is executed for one \textsf{token} at a time, whereas
-% ^^A    the current \textsf{token} is saved in \verb=\@nextchar=.
-% ^^A    At first we evaluate the current \textsf{token} with the already
-% ^^A    defined macro \verb=\@testpach=, i.e.\ we assign to
-% ^^A    \verb=\@chclass= the character class and to \verb=\@chnum=
-% ^^A    the character number of this \textsf{token}.
-%    \begin{macrocode}
- %    {\@testpach
-%    \end{macrocode}
-% ^^A    Then we branch out depending on the value of \verb=\@chclass= into
-% ^^A    different macros that extend the preamble respectively.
-%    \begin{macrocode}
- %    \ifcase \@chclass \@classz \or \@classi \or \@classii
- %      \or \save at decl \or \or \@classv \or \@classvi
- %      \or \@classvii \or \@classviii  \or \@classix
- %      \or \@classx \fi
-%    \end{macrocode}
-% ^^A    Two cases deserve our special attention: Since the current
-% ^^A    \textsf{token} cannot have the character class $4$ (start) we
-% ^^A    have skipped this possibility. If the character class is $3$,
-% ^^A    only the content of \verb=\@nextchar= has to be saved into the current
-% ^^A    \textsf{token} register; therefore we call up \verb=\save at decl=
-% ^^A    directly and save a macro name.  After the preamble has been
-% ^^A    extended we assign the value of \verb=\@chclass= to the counter
-% ^^A    \verb=\@lastchclass= to assure that this information will be available
-% ^^A    during the next run of the loop.
-%    \begin{macrocode}
- %    \@lastchclass\@chclass}%
-%    \end{macrocode}
-% ^^A    After the loop has been finished space must still be added to
-% ^^A    the created preamble, depending on the last \textsf{token}.
-% ^^A    Depending on the value of \verb=\@lastchclass= we perform
-% ^^A    the necessary operations.
-%    \begin{macrocode}
- %    \ifcase\@lastchclass
-%    \end{macrocode}
-% ^^A    If the last class equals $0$ we add a
-% ^^A    \verb=\hskip \col at sep=.
-%    \begin{macrocode}
- %    \@acol \or
-%    \end{macrocode}
-% ^^A    If it equals $1$ we do not add any additional space so that the
-% ^^A    horizontal lines do not exceed the vertical ones.
-%    \begin{macrocode}
- %    \or
-%    \end{macrocode}
-% ^^A    Class $2$ is treated like class $0$ because a \verb=<{...}=  can
-% ^^A    only directly follow after class $0$.
-%    \begin{macrocode}
- %    \@acol \or
-%    \end{macrocode}
-% ^^A    Most of the other possibilities can only appear if the user
-% ^^A    preamble was defective. Class $3$ is not allowed since after a
-% ^^A    \verb=>{..}= there must always follow a \texttt{c}, \texttt{l},
-% ^^A    \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an
-% ^^A    error and ignore the declaration given by \verb={..}=.
-%    \begin{macrocode}
- %    \@preamerr \thr@@ \or
-%    \end{macrocode}
-% ^^A    If \verb=\@lastchclass= is $4$ the user preamble has been empty.
-% ^^A    To continue, we insert a \verb=#= in the preamble.
-%    \begin{macrocode}
- %    \@preamerr \tw@ \@addtopreamble\@sharp \or
-%    \end{macrocode}
-% ^^A    Class $5$ is allowed again. In this case
-% ^^A    (the user preamble ends with \verb=@{..}=) we need not
-% ^^A    do anything.
-%    \begin{macrocode}
- %    \or
-%    \end{macrocode}
-% ^^A    Any other case means that the arguments to \verb=@=, \texttt{!},
-% ^^A    \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have
-% ^^A    been forgotten. So we report an error and ignore the last
-% ^^A    \textsf{token}.
-%    \begin{macrocode}
- %    \else  \@preamerr \@ne \fi
-%    \end{macrocode}
-% ^^A    Now that the build-up of the preamble is almost finished we can
-% ^^A    insert the \textsf{token} registers and therefore redefine
-% ^^A    \verb=\the at toks=. The actual insertion, though, is performed
-% ^^A    later.
-%    \begin{macrocode}
- %    \def\the at toks{\the\toks}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A  \subsubsection{The macros \texttt{\textbackslash @classz}
-% ^^A           to \texttt{\textbackslash @classx}}
-% ^^A
-% ^^A The preamble is extended by the macros \verb=\@classz= to
-% ^^A \verb=\@classx= which are called by \verb=\@mkpream=
-% ^^A  depending on \verb=\@lastchclass=
-% ^^A (i.e. the character class of the last \textsf{token}).
-% ^^A \begin{macro}{\@classx}
-% ^^A    First we define =\@classx= because of its important r\^ole.
-% ^^A    When it is called we find that the current
-% ^^A    \textsf{token} is \texttt{p}, \texttt{m} or \texttt{b}.
-% ^^A    That means that a new column has to start.
-%    \begin{macrocode}
- % \def\@classx{%
-%    \end{macrocode}
-% ^^A    Depending on the value of \verb=\@lastchclass= different actions
-% ^^A    must take place:
-%    \begin{macrocode}
- %   \ifcase \@lastchclass
-%    \end{macrocode}
-% ^^A    If the last character class was $0$ we separate the columns by
-% ^^A    \verb=\hskip\col at sep= followed by \verb=&= and another
-% ^^A    \verb=\hskip\col at sep=.
-%    \begin{macrocode}
- %   \@acolampacol \or
-%    \end{macrocode}
-% ^^A    If the last class was class $1$ --- that means that a vertical
-% ^^A    line was
-% ^^A    drawn, --- before this line a \verb=\hskip\col at sep= was inserted.
-% ^^A    Therefore there has to be only a \verb=&= followed by
-% ^^A    \verb=\hskip\col at sep=. But this \verb=&= may be inserted only
-% ^^A    if this is not the first column. This process is controlled
-% ^^A    by \verb=\if at firstamp= in the macro \verb=\addamp=.
-%    \begin{macrocode}
- %   \@addamp \@acol \or
-%    \end{macrocode}
-% ^^A    Class $2$ is treated like class $0$ because \verb=<{...}= can only
-% ^^A    follow after class $0$.
-%    \begin{macrocode}
- %   \@acolampacol \or
-%    \end{macrocode}
-% ^^A    Class $3$ requires no actions because all things necessary have
-% ^^A    been done by the preamble \textsf{token} \texttt{>}.
-%    \begin{macrocode}
- %   \or
-%    \end{macrocode}
-% ^^A    Class $4$ means that we are at the beginning of the preamble.
-% ^^A    Therefore we start the preamble with \verb=\hskip\col at sep= and
-% ^^A    then call \verb=\@firstampfalse=. This makes sure that a later
-% ^^A    \verb=\@addamp= inserts the character
-% ^^A    \verb=&= into the preamble.
-%    \begin{macrocode}
- %   \@acol \@firstampfalse \or
-%    \end{macrocode}
-% ^^A    For class $5$ \textsf{tokens} only the character \verb=&= is inserted
-% ^^A    as a column separator. Therefore we call \verb=\@addamp=.
-%    \begin{macrocode}
- %   \@addamp
-%    \end{macrocode}
-% ^^A    Other cases are impossible. For an example
-% ^^A    $\verb=\@lastchclass= = 6$---as it might appear in a
-% ^^A    preamble of the form \verb=...!p...=---\texttt{p} would have
-% ^^A    been taken as an  argument of \texttt{!}\ by \verb=\@testpach=.
-%    \begin{macrocode}
- %   \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@classz}
-% ^^A    If the character class of the last \textsf{token} is $0$ we have
-% ^^A    \texttt{c}, \texttt{l}, \texttt{r} or an argument of \texttt{m},
-% ^^A    \texttt{b} or\ \texttt{p}. In the first three cases the preamble
-% ^^A    must be extended the same way as if we had class $10$. The
-% ^^A    remaining two cases do not require any action because the space
-% ^^A    needed was generated by the last \textsf{token} (i.e.\
-% ^^A    \texttt{m}, \texttt{b} or \texttt{p}). Since \verb=\@lastchclass= has
-% ^^A    the value $10$ at this point nothing happens when \verb=\@classx= is
-% ^^A    called. So the macro \verb=\@chlassz= may start like this:
-%    \begin{macrocode}
- % \def\@classz{\@classx
-%    \end{macrocode}
-% ^^A    According to the definition of \verb=\insert at column= we must store
-% ^^A    the number of the \textsf{token} register in which a preceding
-% ^^A    \verb=>{..}= might have stored its argument into
-% ^^A    \verb=\@tempcnta=.
-%    \begin{macrocode}
- %    \@tempcnta \count@
-%    \end{macrocode}
-% ^^A    To have $\verb=\count@= = \verb=\@tmpcnta= + 1$ we prepare
-% ^^A    the next \textsf{token} register.
-%    \begin{macrocode}
- %    \prepnext at tok
-%    \end{macrocode}
-% ^^A    Now the preamble must be extended with the column whose format
-% ^^A    can be determined by \verb=\@chnum=.
-%    \begin{macrocode}
- %    \@addtopreamble{\ifcase \@chnum
-%    \end{macrocode}
-% ^^A    If \verb=\@chnum= has the value $0$ a centered column has to be
-% ^^A    generated.
-% ^^A    So we begin with stretchable space.
-%    \begin{macrocode}
- %       \hfil
-%    \end{macrocode}
-% ^^A    The command \verb=\d at llarbegin= follows expanding into \verb=\begingroup=
-% ^^A    (in the \textsf{tabular}--environment) or into \verb=$=.  Doing this
-% ^^A    (provided an appropriate setting of \verb=\d at llarbegin=) we achieve
-% ^^A    that the contents of the columns of an \textsf{array}--environment
-% ^^A    are set in math mode while those of a \textsf{tabular}--environment
-% ^^A    are set in LR mode.
-%    \begin{macrocode}
- %       \d at llarbegin
-%    \end{macrocode}
-% ^^A    Now we insert the contents of the two \textsf{token} registers
-% ^^A    and the symbol
-% ^^A    for the column entry (i.e.\ \verb=#= or
-% ^^A    more precise \verb=\@sharp=) using \verb=\insert at column=.
-%    \begin{macrocode}
- %       \insert at column
-%    \end{macrocode}
-% ^^A    We end this case with \verb=\d at llarend= and \verb=\hfil= where \verb=\d at llarend=
-% ^^A    again is either \verb=$= or \verb=\endgroup=.
-%    \begin{macrocode}
- %       \d at llarend \hfil \or
-%    \end{macrocode}
-% ^^A    The templates for \texttt{l} and \texttt{r} (i.e.\ \verb=\@chnum= $1$
-% ^^A    or $2$) are generated the same way. Since one  \verb=\hfil= is
-% ^^A    missing the text is moved to the relevant side.
-% ^^A    The \verb=\kern\z@= is needed in case of an empty column
-% ^^A    entry. Otherwise
-% ^^A    the \verb=\unskip= in \verb=\insert at column= removes the
-% ^^A    \verb=\hfil=. Changed to \verb=\hskip1sp= so that it interacts better with
-% ^^A    \verb=\@bsphack=.
-%    \begin{macrocode}
- %       \hskip1sp\d at llarbegin \insert at column \d at llarend \hfil \or
- %       \hfil\hskip1sp\d at llarbegin \insert at column \d at llarend \or
-%    \end{macrocode}
-% ^^A    The templates for \texttt{p}, \texttt{m} and \texttt{b} mainly
-% ^^A    consist of a \textsf{box}. In case of \texttt{m} it is generated
-% ^^A    by \verb=\vcenter=.  This command is allowed only in math
-% ^^A    mode. Therefore we start with a~\verb=$=.
-%    \begin{macrocode}
- %    $\vcenter%$ emacs
-%    \end{macrocode}
-% ^^A    The part of the templates which is the same in all three cases
-% ^^A    (\texttt{p}, \texttt{m} and \texttt{b})
-% ^^A    is built by the macros \verb=\@startpbox= and
-% ^^A    \verb=\@endpbox=. \verb=\@startpbox= has an argument:
-% ^^A    the width of the column which is stored in the current
-% ^^A    \textsf{token} (i.e.\ \verb=\@nextchar=).
-% ^^A    Between these two macros we find the well known
-% ^^A    \verb=\insert at column=.
-%    \begin{macrocode}
- %    \@startpbox{\@nextchar}\insert at column \@endpbox $\or%$ emacs
-%    \end{macrocode}
-% ^^A    The templates for \texttt{p} and \texttt{b} are generated in the
-% ^^A    same way though we do not need the \verb=$= characters because we use
-% ^^A    \verb=\vtop= or \verb=\vbox=.
-%    \begin{macrocode}
- %    \vtop \@startpbox{\@nextchar}\insert at column \@endpbox \or
- %    \vbox \@startpbox{\@nextchar}\insert at column \@endpbox
-%    \end{macrocode}
-% ^^A    Other values for \verb=\@chnum= are impossible. Therefore we
-% ^^A    end the arguments to \verb=\@addtopreamble= and \verb=\ifcase=.
-% ^^A    Before we come to the end of \verb=\@classz= we have to
-% ^^A    prepare the next \textsf{token} register.
-%    \begin{macrocode}
- %   \fi}\prepnext at tok}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@classix}
-% ^^A    In case of class $9$ (\texttt{>}--\textsf{token}) we first check
-% ^^A    if the character class of the last
-% ^^A    \textsf{token} was $3$. In this case we have a
-% ^^A    user preamble of the form \verb=..>{...}>{...}..= which
-% ^^A    is not allowed. We only give an error message and continue.
-% ^^A    So the declarations defined by the first  \verb=>{...}=
-% ^^A    are ignored.
-%    \begin{macrocode}
- % \def\@classix{\ifnum \@lastchclass = \thr@@
- %        \@preamerr \thr@@ \fi
-%    \end{macrocode}
-% ^^A    Furthermore, we call up \verb=\@class10= because afterwards always a
-% ^^A    new column is started by \texttt{c}, \texttt{l}, \texttt{r},
-% ^^A    \texttt{p}, \texttt{m} or \texttt{b}.
-%    \begin{macrocode}
- %        \@classx}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@classviii}
-% ^^A    If the current \textsf{token} is a \texttt{<} the last character
-% ^^A    class must be $0$. In this case it is not necessary to extend the
-% ^^A    preamble. Otherwise we output an error message, set \verb=\@chclass=
-% ^^A    to $6$ and call \verb=\@classvi=.  By doing this we achieve that
-% ^^A    \texttt{<} is treated like \texttt{!}.
-%    \begin{macrocode}
- % \def\@classviii{\ifnum \@lastchclass >\z@
- %       \@preamerr 4\@chclass 6 \@classvi \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@arrayrule}
-% ^^A    There is only one incompatibility with the original definition:
-% ^^A    the definition of \verb=\@arrayrule=. In the original a line without
-% ^^A    width\footnote{So the space between \texttt{cc} and \texttt{c|c}
-% ^^A    is equal.}  is created by multiple insertions of
-% ^^A \verb=\hskip .5\arrayrulewidth=.
-% ^^A    We only insert a vertical line into the
-% ^^A    preamble.  This is done to prevent problems with \TeX's main
-% ^^A    memory when generating tables with many vertical lines in them
-% ^^A    (especially in the case of \textsf{floats}).
-%    \begin{macrocode}
- % \def\@arrayrule{\@addtopreamble \vline}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classvii}
-% ^^A    As a consequence it follows that in case of class $7$
-% ^^A    (\verb=@= \textsf{token})  the preamble need not to be extended.
-% ^^A    In the original definition $\verb=\@lastchclass= = 1$
-% ^^A    is treated by inserting \verb=\hskip .5\arrayrulewidth=.
-% ^^A    We only check if the last \textsf{token} was of class $3$ which is
-% ^^A    forbidden.
-%    \begin{macrocode}
- % \def\@classvii{\ifnum \@lastchclass = \thr@@
-%    \end{macrocode}
-% ^^A    If this is true we output an error message and
-% ^^A    ignore the declarations stored
-% ^^A    by the last  \verb=>{...}=, because these are overwritten
-% ^^A    by the argument of \texttt{@}.
-%    \begin{macrocode}
- %    \@preamerr \thr@@ \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@classvi}
-% ^^A    If the current \textsf{token} is a regular \texttt{!}\ and the
-% ^^A    last class was $0$ or $2$ we extend the preamble with
-% ^^A    \verb=\hskip\col at sep=.  If the last \textsf{token} was of class $1$
-% ^^A    (for instance \texttt{|}) we extend with \verb=\hskip \doublerulesep=
-% ^^A    because the construction \verb=!{...}= has to be treated like
-% ^^A    \texttt{|}.
-%    \begin{macrocode}
- % \def\@classvi{\ifcase \@lastchclass
- %       \@acol \or
- %       \@addtopreamble{\hskip \doublerulesep}\or
- %       \@acol \or
-%    \end{macrocode}
-% ^^A    Now \verb=\@preamerr...= should follow because a
-% ^^A    user preamble of the form \verb=..>{..}!.= is not allowed.
-% ^^A    To save memory we call \verb=\@classvii= instead which also
-% ^^A    does what we want.
-%    \begin{macrocode}
- %       \@classvii
-%    \end{macrocode}
-% ^^A    If \verb=\@lastchclass= is $4$ or $5$ nothing has to be done.
-% ^^A    Class $6$ to $10$ are not possible.
-% ^^A    So we finish the macro.
-%    \begin{macrocode}
- %       \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classii}
-% ^^A \begin{macro}{\@classiii}
-% ^^A    In the case of character classes $2$ and $3$ (i.e.\ the argument
-% ^^A    of \texttt{<} or \texttt{>}) we only have to store the current
-% ^^A    \textsf{token} (\verb=\@nextchar=) into the corresponding
-% ^^A    \textsf{token} register since the preparation and
-% ^^A    insertion of these registers
-% ^^A    are done by the macro \verb=\@classz=.
-% ^^A    This is equivalent to calling \verb=\save at decl= in the case of
-% ^^A    class $3$. To save command identifiers we do this call up
-% ^^A     in the macro \verb=\@mkpream=.
-% ^^A
-% ^^A    Class $2$ exhibits a more complicated situation: the
-% ^^A    \textsf{token} registers have already been inserted by
-% ^^A    \verb=\@classz=. So the value of \verb=\count@= is too high
-% ^^A    by one. Therefore we decrease \verb=\count@= by $1$.
-%    \begin{macrocode}
- % \def\@classii{\advance \count@ \m at ne
-%    \end{macrocode}
-% ^^A    Next we store the current \textsf{token} into the correct
-% ^^A    \textsf{token} register by calling \verb=\save at decl= and then
-% ^^A    increase the value of \verb=\count@= again. At this point we
-% ^^A    can save memory once more (at the cost of time) if we use the
-% ^^A     macro \verb=\prepnext at tok=.
-%    \begin{macrocode}
- %    \save at decl\prepnext at tok}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@classv}
-% ^^A    If the current \textsf{token} is of class $5$ then it is an
-% ^^A    argument of a \texttt{@} \textsf{token}. It must be stored into a
-% ^^A    \textsf{token} register.
-%    \begin{macrocode}
- % \def\@classv{\save at decl
-%    \end{macrocode}
-% ^^A    We extend the preamble with a command which inserts this
-% ^^A    \textsf{token} register into the preamble when its construction
-% ^^A    is finished. The user expects that this argument is worked out in
-% ^^A    math mode if it was used in an
-% ^^A    \textsf{array}--environment. Therefore we surround it with
-% ^^A    \verb=\d at llar...='s.
-%    \begin{macrocode}
- %    \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
-%    \end{macrocode}
-% ^^A    Finally we must prepare the next \textsf{token} register.
-%    \begin{macrocode}
- %    \prepnext at tok}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classi}
-% ^^A    In the case of class $0$ we were able to generate the necessary
-% ^^A    space between columns by using the macro \verb=\@classx=.
-% ^^A    Analogously the macro \verb=\@classvi= can be used for class $1$.
-%    \begin{macrocode}
- % \def\@classi{\@classvi
-%    \end{macrocode}
-% ^^A    Depending on \verb=\@chnum= a vertical line
-%    \begin{macrocode}
- %    \ifcase \@chnum \@arrayrule \or
-%    \end{macrocode}
-% ^^A    or (in case of \verb=!{...}=) the current \textsf{token} --- stored
-% ^^A    in \verb=\@nextchar= --- has to be inserted into the preamble.
-% ^^A    This corresponds to calling \verb=\@classv=.
-%    \begin{macrocode}
- %       \@classv \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@startpbox}
-% ^^A    In \verb=\@classz=  the macro \verb=\@startpbox= is used.
-% ^^A    The width of the \textsf{parbox} is passed as an argument.
-% ^^A    \verb=\vcenter=, \verb=\vtop= or \verb=\vbox= are already in the
-% ^^A    preamble. So we start with the braces for the wanted box.
-%    \begin{macrocode}
- % \def\@startpbox#1{\bgroup
-%    \end{macrocode}
-% ^^A    The argument is the width of the box. This information has to be
-% ^^A    assigned to \verb=\hsize=.
-% ^^A    Then we assign default values to several parameters used in a
-% ^^A    \textsf{parbox}.
-%    \begin{macrocode}
- %   \setlength\hsize{#1}\@arrayparboxrestore
-%    \end{macrocode}
-% ^^A    Our main problem is to obtain the same distance between succeeding
-% ^^A    lines of the \textsf{parbox}.
-% ^^A    We have to remember that the distance between two \textsf{parboxes}
-% ^^A    should be defined by \verb=\@arstrut=. That means that it can be
-% ^^A    greater than the distance in a \textsf{parbox}.
-% ^^A    Therefore it is not enough to set a \verb=\@arstrut= at the
-% ^^A    beginning and at the end of the \textsf{parbox}. This would
-% ^^A    dimension the distance
-% ^^A    between first and second line and the distance between the two
-% ^^A    last lines of the \textsf{parbox} wrongly.
-% ^^A    To prevent this we set an invisible rule of height
-% ^^A    \verb=\@arstrutbox=
-% ^^A    at the beginning of the \textsf{parbox}. This has no effect on the
-% ^^A    depth of the first line. At the end of the \textsf{parbox} we set
-% ^^A    analogously another invisible rule which only affects the depth
-% ^^A    of the last line. It is necessary to wait inserting this strut
-% ^^A    until the paragraph actually starts to allow for things like
-% ^^A    \verb=\parindent= changes via \verb=>{...}=.
-%    \begin{macrocode}
- %    \everypar{%
- %       \vrule \@height \ht\@arstrutbox \@width \z@
- %       \everypar{}}%
- %    }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@endpbox}
-% ^^A    If there are any declarations defined by \verb=>{...}=
-% ^^A    and \verb=<{...}=
-% ^^A    they now follow in the macro \verb=\@classz= --- the contents
-% ^^A    of the column in between.
-% ^^A    So the macro \verb=\@endpbox= must insert the \textsf{specialstrut}
-% ^^A    mentioned earlier and then close the group opened by
-% ^^A    \verb=\@startpbox=.
-%    \begin{macrocode}
- % \def\@endpbox{\@finalstrut\@arstrutbox \egroup\hfil}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \subsubsection{Building and calling \texttt{\textbackslash halign}}
-% ^^A
-% ^^A \begin{macro}{\@array}
-% ^^A    After we have discussed the macros needed for the evaluation
-% ^^A    of the user preamble we can define the macro \verb=\@array=
-% ^^A    which uses these macros to create a \verb=\halign=.
-% ^^A    It has two arguments. The first one is a position argument
-% ^^A    which can be \texttt{t}, \texttt{b} or \texttt{c}; the
-% ^^A    second one describes the wanted preamble,
-% ^^A    e.g.\ it has the form \verb=|c|c|c|=.
-%    \begin{macrocode}
- % \def\@array[#1]#2{%
-%    \end{macrocode}
-% ^^A    First we define a \textsf{strut} whose size basically corresponds
-% ^^A     to a normal \textsf{strut} multiplied by the factor
-% ^^A    \verb=\arraystretch=.
-% ^^A    This \textsf{strut} is then  inserted into every row and enforces
-% ^^A     a minimal distance between two rows.
-% ^^A    Nevertheless, when using horizontal lines, large letters
-% ^^A    (like accented capital letters) still collide with such lines.
-% ^^A    Therefore at first we add to the height of a normal \textsf{strut}
-% ^^A    the value of the parameter \verb=\extrarowheight=.
-%    \begin{macrocode}
- %   \@tempdima \ht \strutbox
- %   \advance \@tempdima by\extrarowheight
- %   \setbox \@arstrutbox \hbox{\vrule
- %              \@height \arraystretch \@tempdima
- %              \@depth \arraystretch \dp \strutbox
- %              \@width \z@}%
-%    \end{macrocode}
-% ^^A    Then we open a group, in which the user preamble is evaluated by
-% ^^A    the macro \verb=\@mkpream=. As we know this must happen locally.
-% ^^A    This macro creates a preamble for a \verb=\halign= and saves
-% ^^A    its result globally in the control sequence \verb=\@preamble=.
-%    \begin{macrocode}
- %   \begingroup
- %   \@mkpream{#2}%
-%    \end{macrocode}
-% ^^A    We again redefine \verb=\@preamble= so that a call up of \verb=\@preamble=
-% ^^A    now starts the \verb=\halign=. Thus also the arguments of \texttt{>},
-% ^^A    \texttt{<}, \texttt{@} and \texttt{!}, saved in the
-% ^^A    \textsf{token} registers are inserted into the preamble.  The
-% ^^A    \verb=\tabskip= at the beginning and end of the preamble is set to
-% ^^A    \textsf{0pt} (in the beginning by the use of \verb=\ialign=). Also the
-% ^^A    command \verb=\@arstrut= is build in, which inserts the
-% ^^A    \verb=\@arstrutbox=, defined above. Of course, the opening brace after
-% ^^A    \verb=\ialign= has to be implicit as it will be closed in \verb=\endarray=
-% ^^A    or another macro.
-% ^^A
-% ^^A    The \verb=\noexpand= in front of \verb=\ialign= does no harm in standard \LaTeX{}
-% ^^A    and was added since some experimental support for using text glyphs in math
-% ^^A    redefines \verb=\halign= with the result that is becomes expandable with
-% ^^A    disastrous results in cases like this.
-% ^^A    In the kernel definition for this macro the problem does
-% ^^A    not surface because there \verb=\protect= is set (which is not necessary in this
-% ^^A    implementation as there is no arbitrary user input that can get expanded) and
-% ^^A    the experimental code made the redefinition robust. Whether this is the right
-% ^^A    approach is open to question; consider the \verb=\noexpand= a courtesy to allow an
-% ^^A    unsupported redefinition of a \TeX{} primitive for the moment (as people rely
-% ^^A    on that experimental code).
-%    \begin{macrocode}
- %   \xdef\@preamble{\noexpand \ialign \@halignto
- %                   \bgroup \@arstrut \@preamble
- %                           \tabskip \z@ \cr}%
-%    \end{macrocode}
-% ^^A    What we have not explained yet is the macro \verb=\@halignto=
-% ^^A    that was just used. Depending on its replacement text the
-% ^^A    \verb=\halign= becomes a \verb=\halign= \texttt{to} \meta{dimen}.
-% ^^A    Now we close the group again. Thus
-% ^^A    \verb=\@startpbox= and \verb=\@endpbox= as well as all
-% ^^A    \textsf{token} registers get their former meaning back.
-%    \begin{macrocode}
- %   \endgroup
-%    \end{macrocode}
-% ^^A     To support the \texttt{delarray.sty} package  we include a hook
-% ^^A     into this part of the code which is a no-op in the main package.
-%    \begin{macrocode}
- %   \@arrayleft
-%    \end{macrocode}
-% ^^A    Now we decide depending on the position argument in which
-% ^^A    \textsf{box} the \verb=\halign= is to be put. (\verb=\vcenter= may be used
-% ^^A    because we are in math mode.)
-%    \begin{macrocode}
- %   \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
-%    \end{macrocode}
-% ^^A    Now another implicit opening brace appears; then definitions
-% ^^A    which shall stay local follow. While constructing the
-% ^^A    \verb=\@preamble= in \verb=\@mkpream= the \verb=#= sign must be
-% ^^A    hidden in the macro \verb=\@sharp= which is \verb=\let= to
-% ^^A    \verb=\relax= at that moment (see definition of \verb=\@mkpream=
-% ^^A    on page~\pageref{@mkpream}).
-% ^^A    All these now get their actual meaning.
-%    \begin{macrocode}
- %   \bgroup
- %   \let \@sharp ##\let \protect \relax
-%    \end{macrocode}
-% ^^A    With the above defined \textsf{struts} we fix down the distance
-% ^^A    between rows by setting \verb=\lineskip= and \verb=\baselineskip=
-% ^^A    to \textsf{0pt}. Since there have to be set \verb=$='s
-% ^^A    around every column in the \textsf{array}--environment
-% ^^A     the parameter \verb=\mathsurround= should
-% ^^A    also be set to \textsf{0pt}. This prevents additional space between
-% ^^A    the rows. The
-% ^^A    \PlainTeX--macro \verb=\m at th= does this.
-%    \begin{macrocode}
- %   \lineskip \z@
- %   \baselineskip \z@
- %   \m at th
-%    \end{macrocode}
-% ^^A    Beside, we have to assign a special meaning (which we still have
-% ^^A    to specify) to the line separator \verb=\\=. We also have to
-% ^^A    redefine the command \verb=\par= in such a way that empty lines in
-% ^^A    \verb=\halign= cannot do any damage. We succeed in doing  so
-% ^^A    by choosing something that will disappear when expanding.
-% ^^A    After that we only have to call up \verb=\@preamble= to
-% ^^A    start the wanted \verb=\halign=.
-%    \begin{macrocode}
- %   \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\arraybackslash}
-% ^^A Restore \verb=\\= for use in array and tabular environment (after
-% ^^A \verb=\raggedright= etc.).
-%    \begin{macrocode}
- % \def\arraybackslash{\let\\\tabularnewline}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\extrarowheight}
-% ^^A    The \textsf{dimen} parameter used above also needs to be
-% ^^A    allocated.  As a default value we use \textsf{0pt}, to ensure
-% ^^A    compatibility with standard \LaTeX.
-%    \begin{macrocode}
- % \newdimen \extrarowheight
- % \extrarowheight=0pt
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@arstrut}
-% ^^A    Now the insertion of \verb=\@arstrutbox= through \verb=\@arstut=
-% ^^A    is easy since we know exactly in which mode \TeX\ is while working
-% ^^A    on the \verb=\halign= preamble.
-%    \begin{macrocode}
- % \def\@arstrut{\unhcopy\@arstrutbox}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \subsubsection{The line separator \texttt{\textbackslash\textbackslash}}
-% ^^A
-% ^^A \begin{macro}{\@arraycr}
-% ^^A    In the macro \verb=\@array= the line separator \verb=\\= is
-% ^^A    \verb=\let= to the command \verb=\@arraycr=.
-% ^^A    Its definition starts with a special brace which I have directly
-% ^^A    copied from the original definition. It is
-% ^^A    necessary, because the \verb=\futurlet= in \verb=\@ifnextchar=
-% ^^A    might
-% ^^A    expand a  following \verb=&= \textsf{token} in a construction like
-% ^^A    \verb=\\ &=. This would otherwise end the alignment template at a
-% ^^A    wrong time. On the other hand we have to be careful to avoid
-% ^^A    producing a real group, i.e.\ \verb={}=, because the command will also
-% ^^A    be used for the array environment, i.e.\ in math mode. In that
-% ^^A    case an extra \verb={}= would produce an ord atom which could mess up
-% ^^A    the spacing. For this reason we use a combination that does not
-% ^^A    really produce a group at all but modifies the master counter so
-% ^^A    that a \verb=&= will not be considered belonging to the current
-% ^^A    \verb=\halign= while we are looking for a \verb=*= or \verb=[=.
-% ^^A    For further information see
-% ^^A    \cite[Appendix D]{bk:knuth}.
-%    \begin{macrocode}
- % \def\@arraycr{\relax\iffalse{\fi\ifnum 0=`}\fi
-%    \end{macrocode}
-% ^^A    Then we test whether the user is using the star form and ignore
-% ^^A    a possible star (I also disagree with this procedure, because a
-% ^^A    star does not make any sense here).
-%    \begin{macrocode}
- %   \@ifstar \@xarraycr \@xarraycr}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@xarraycr}
-% ^^A    In the command \verb=\@xarraycr= we test if an optional argument
-% ^^A    exists.
-%    \begin{macrocode}
- % \def\@xarraycr{\@ifnextchar [%
-%    \end{macrocode}
-% ^^A    If it does, we branch out into the macro \verb=\@argarraycr= if
-% ^^A    not we close the special brace (mentioned above) and end the row
-% ^^A    of the \verb=\halign= with a \verb=\cr=.
-%    \begin{macrocode}
- %   \@argarraycr {\ifnum 0=`{}\fi\cr}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@argarraycr}
-% ^^A    If additional space is requested by the user this case is treated
-% ^^A    in the macro \verb=\@argarraycr=. First we close the special brace
-% ^^A    and then we test if the additional space is positive.
-%    \begin{macrocode}
- % \def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@
-%    \end{macrocode}
-% ^^A    If this is the case we create an invisible vertical rule with
-% ^^A    depth \verb=\dp\@arstutbox=${}+{}$\meta{wanted\ space}.
-% ^^A    Thus we achieve that all vertical lines specified
-% ^^A    in the user preamble by a \texttt{|} are now
-% ^^A    generally drawn.
-% ^^A    Then the row ends with a \verb=\cr=.
-% ^^A
-% ^^A    If the space is negative we end the row at once with a \verb=\cr=
-% ^^A    and move back up with a \verb=\vskip=.
-% ^^A
-% ^^A    While testing these macros I found out that the
-% ^^A    \verb=\endtemplate=
-% ^^A    created by \verb=\cr= and \verb=&= is something like an
-% ^^A    \verb=\outer= primitive and therefore it should not appear in
-% ^^A    incomplete \verb=\if= statements. Thus the following solution was
-% ^^A    chosen which hides the \verb=\cr= in other macros when \TeX\
-% ^^A    is skipping conditional text.
-%    \begin{macrocode}
- %   \expandafter\@xargarraycr\else
- %   \expandafter\@yargarraycr\fi{#1}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@xargarraycr}
-% ^^A \begin{macro}{\@yargarraycr}
-% ^^A    The following macros were already explained above.
-%    \begin{macrocode}
- % \def\@xargarraycr#1{\unskip
- %   \@tempdima #1\advance\@tempdima \dp\@arstrutbox
- %   \vrule \@depth\@tempdima \@width\z@ \cr}
- % \def\@yargarraycr#1{\cr\noalign{\vskip #1}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection{Spanning several columns}
-% ^^A
-% ^^A \begin{macro}{\multicolumn}
-% ^^A    If several columns should be held together with a special format
-% ^^A    the command \verb=\multicolumn= must be used. It has three
-% ^^A    arguments: the number of columns to be covered; the format for
-% ^^A    the result column and the actual column entry.
-%    \begin{macrocode}
- % \long\def\multicolumn#1#2#3{%
-%    \end{macrocode}
-% ^^A    First we combine the given number of columns into a single one;
-% ^^A    then we start a new block so that the following definition is kept
-% ^^A    local.
-%    \begin{macrocode}
- %    \multispan{#1}\begingroup
-%    \end{macrocode}
-% ^^A    Since a \verb=\multicolumn= should only describe the format of a
-% ^^A    result column, we redefine \verb=\@addamp= in such a way that one gets
-% ^^A    an error message if one uses more than one \texttt{c},
-% ^^A    \texttt{l}, \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in
-% ^^A    the second argument. One should consider that this definition is
-% ^^A    local to the build-up of the preamble; an \textsf{array}-- or
-% ^^A    \textsf{tabular}--environment in the third argument of the
-% ^^A    \verb=\multicolumn= is therefore worked through correctly as well.
-%    \begin{macrocode}
- %    \def\@addamp{\if at firstamp \@firstampfalse \else
- %                 \@preamerr 5\fi}%
-%    \end{macrocode}
-% ^^A    Then we evaluate the second argument with the help of
-% ^^A    \verb=\@mkpream=.
-% ^^A    Now we still have to insert the contents of the \textsf{token}
-% ^^A    register into the \verb=\@preamble=, i.e.\ we have to say
-% ^^A    \verb=\xdef\@preamble{\@preamble}=. This is achieved shorter by
-% ^^A    writing:
-%    \begin{macrocode}
- %    \@mkpream{#2}\@addtopreamble\@empty
-%    \end{macrocode}
-% ^^A    After the \verb=\@preamble= is created we forget all local
-% ^^A    definitions and occupations of the \textsf{token} registers.
-%    \begin{macrocode} 
- %    \endgroup
-%    \end{macrocode}
-% ^^A    In the special situation of  \verb=\multicolumn= \verb=\@preamble=
-% ^^A    is not needed as preamble for a \verb=\halign= but it is directly
-% ^^A    inserted into our table. Thus instead of \verb=\sharp=
-% ^^A    there has to be the column entry (\verb=#3=) wanted by the user.
-%    \begin{macrocode}
- %    \def\@sharp{#3}%
-%    \end{macrocode}
-% ^^A    Now we can pass the \verb=\@preamble= to \TeX\ . For safety
-% ^^A    we start with an \verb=\@arstrut=. This should usually be in the
-% ^^A    template for the first column however we do not know if this
-% ^^A    template was overwritten by our \verb=\multicolumn=.
-% ^^A    We also add a \verb=\null= at the right end to prevent any following
-% ^^A    \verb=\unskip= (for example from \verb=\\[..]=) to remove the \verb=\tabcolsep=.
-%    \begin{macrocode}
- %    \@arstrut \@preamble
- %    \null
- %    \ignorespaces}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A   \subsubsection{The Environment Definitions}
-% ^^A
-% ^^A After these preparations we are able to define the environments. They
-% ^^A only differ in the initialisations of \verb=\d at llar...=, \verb=\col at sep=
-% ^^A  and \verb=\@halignto=.
-% ^^A
-% ^^A \begin{macro}{\@halignto}
-% ^^A \begin{macro}{\d at llarbegin}
-% ^^A \begin{macro}{\d at llarend}
-% ^^A    \verb=\d at llar= has to be
-% ^^A    locally asigned since otherwise nested \textsf{tabular} and \textsf{array}
-% ^^A    environments (via \verb=\multicolumn=) are impossible.
-% ^^A    For 25 years or so \verb=\@halignto= was set globally (to save space on the
-% ^^A    save stack, but that was a mistake: if there is a tabular in the
-% ^^A    output routine (e.g., in the running header) then that tabular is 
-% ^^A    able overwrite the \verb=\@halignto=
-% ^^A    setting of a tabular in the main text resulting in a very weird error.
-% ^^A    When the new font selection scheme is in force we have to
-% ^^A    we surround all \verb=\halign= entries
-% ^^A    with braces. See remarks in TUGboat 10\#2. Actually we are going
-% ^^A    to use \verb=\begingroup= and \verb=\endgroup=. However, this is only
-% ^^A    necessary when we are in text mode. In math the surrounding
-% ^^A    dollar signs will already serve as the necessary extra grouping
-% ^^A    level. Therefore we switch the settings of \verb=\d at llarbegin= and
-% ^^A    \verb=\d at llarend= between groups and dollar signs.
-%    \begin{macrocode}
- % \let\d at llarbegin\begingroup
- % \let\d at llarend\endgroup
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\array}
-% ^^A    Our new definition of \verb=\array= then reads:
-%    \begin{macrocode}
- % \def\array{\col at sep\arraycolsep
- %   \def\d at llarbegin{$}\let\d at llarend\d at llarbegin\def\@halignto{}%$ emacs
-%    \end{macrocode}
-% ^^A    Since there might be an optional argument we call another
-% ^^A    macro which is also used by the other environments.
-%    \begin{macrocode}
- %   \@tabarray}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@tabarray}
-% ^^A    This macro tests for a optional bracket and then calls up
-% ^^A    \verb=\@array= or \verb=\@array[c]= (as default).
-%    \begin{macrocode}
- % \def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\tabular}
-% ^^A \begin{macro}{\tabular*}
-% ^^A    The environments \textsf{tabular} and \textsf{tabular$*$} differ
-% ^^A    only in the initialisation of the command \verb=\@halignto=. Therefore
-% ^^A    we define
-%    \begin{macrocode}
- % \def\tabular{\def\@halignto{}\@tabular}
-%    \end{macrocode}
-% ^^A     and analogously for the star form. We evaluate the argument first
-% ^^A     using =\setlength= so that users of the \texttt{calc} package can
-% ^^A     write code like\\ \verb=\begin{tabular*}{(\columnwidth-1cm)/2}...=
-% ^^A     \begin{macrocode}
- % \expandafter\def\csname tabular*\endcsname#1{%
- %        \setlength\dimen@{#1}%
- %        \edef\@halignto{to\the\dimen@}\@tabular}
-% ^^A    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@tabular}
-% ^^A    The rest of the job is carried out by the \verb=\@tabular= macro:
-%    \begin{macrocode}
- % \def\@tabular{%
-%    \end{macrocode}
-% ^^A    First of all we have to make sure that we start out in
-% ^^A    \textsf{hmode}.  Otherwise we might find our table dangling by
-% ^^A    itself on a line.
-%    \begin{macrocode}
- %   \leavevmode
-%    \end{macrocode}
-% ^^A    It should be taken into consideration that the macro \verb=\@array=
-% ^^A    must be called in math mode. Therefore we open a \textsf{box},
-% ^^A    insert a \verb=$= and then assign the correct values to \verb=\col at sep= and
-% ^^A    \verb=\d at llar...=.
-%    \begin{macrocode}
- %   \hbox \bgroup $\col at sep\tabcolsep \let\d at llarbegin\begingroup% $ emacs
- %                                     \let\d at llarend\endgroup
-%    \end{macrocode}
-% ^^A    Now everything \textsf{tabular} specific is done and we are able to
-% ^^A    call the \verb=\@tabarray= macro.
-%    \begin{macrocode}
- %   \@tabarray}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\endarray}
-% ^^A    When the processing of \textsf{array} is finished we have to
-% ^^A    close the \verb=\halign=
-% ^^A    and afterwards the surrounding \textsf{box} selected by
-% ^^A    \verb=\@array=. To save \textsf{token} space we then redefine
-% ^^A    \verb=\@preamble=
-% ^^A    because its replacement text isn't longer needed.
-%    \begin{macrocode}
- % \def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\endtabular}
-% ^^A \begin{macro}{\endtabular*}
-% ^^A    To end a \textsf{tabular} or \textsf{tabular$*$} environment we
-% ^^A    call up \verb=\endarray=, close the math mode and then the surrounding
-% ^^A    \verb=\hbox=.
-%    \begin{macrocode}
- % \def\endtabular{\endarray $\egroup}%$ emacs
- % \expandafter\let\csname endtabular*\endcsname=\endtabular
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A   \subsubsection{Last minute definitions}
-% ^^A
-% ^^A
-% ^^A If this file is used as a package file we should \verb=\let= all macros
-% ^^A to \verb=\relax= that were used in the original but are no longer
-% ^^A  necessary.
-%    \begin{macrocode}
- % \let\@ampacol=\relax        \let\@expast=\relax
- % \let\@arrayclassiv=\relax   \let\@arrayclassz=\relax
- % \let\@tabclassiv=\relax     \let\@tabclassz=\relax
- % \let\@arrayacol=\relax      \let\@tabacol=\relax
- % \let\@tabularcr=\relax      \let\@@endpbox=\relax
- % \let\@argtabularcr=\relax   \let\@xtabularcr=\relax
-%    \end{macrocode}
-% ^^A
-% ^^A \begin{macro}{\@preamerr}
-% ^^A    We also have to redefine the error routine \verb=\@preamerr= since
-% ^^A    new kind of errors are possible.
-% ^^A    The code for this macro is not perfect yet;
-% ^^A    it still needs too much memory.
-%    \begin{macrocode}
- % \def\@preamerr#1{\def\@tempd{{..} at wrong position: }%
- %    %\PackageError{array}{%
- %    \ClassError{memoir}{% changed in menoir
- %    \ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0
- %     Missing arg: token ignored\or                           %1
- %     Empty preamble: `l' used\or                             %2
- %     >\@tempd token ignored\or                               %3
- %     <\@tempd changed to !{..}\or                            %4
- %     Only one column-spec. allowed.\fi}\@ehc}                %5
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A
-% ^^A \subsubsection
-% ^^A   [Defining your own column specifiers]
-% ^^A   {Defining your own column specifiers\footnotemark}
-% ^^A
-% ^^A \footnotetext{The code and the documentation in this section was
-% ^^A   written by David. So far only the code from newarray was plugged
-% ^^A   into array so that some parts of the documentation still claim
-% ^^A   that this is newarray and even worse, some parts of the code are
-% ^^A   unnecessarily doubled. This will go away in a future release. For
-% ^^A   the moment we thought it would be more important to bring both
-% ^^A   packages together.}
-% ^^A
-% ^^A  \begin{macro}{\newcolumn}
-% ^^A    In \texttt{newarray.sty} the macro for specifying new columns was
-% ^^A    named \verb"\newcolumn". When the functionality was added to
-% ^^A    \texttt{array.sty} the command was renamed \verb"\newcolumntype".
-% ^^A    Initially both names were supported, but now (In versions of this
-% ^^A    package distributed for \LaTeXe) the old name is not defined.
-% ^^A  \end{macro}
-% ^^A
-% ^^A \begin{macro}{\newcolumntype}
-% ^^A  As
-% ^^A described above, the \verb"\newcolumntype" macro gives users the chance
-% ^^A to define letters, to be used in the same way as the primitive
-% ^^A column specifiers, `c' `p' etc.
-%    \begin{macrocode}
- % \def\newcolumntype#1{%
-%    \end{macrocode}
-% ^^A \verb"\NC at char" was added in V2.01 so that active characters, like "@" in
-% ^^A AMS\LaTeX\ may be used. This trick was stolen from \texttt{array.sty}
-% ^^A 2.0h. Note that we need to use the possibly active token,
-% ^^A \verb"#1", in several places, as that is the token that actually
-% ^^A appears in the preamble argument.
-%    \begin{macrocode}
- %   \edef\NC at char{\string#1}%
-%    \end{macrocode}
-% ^^A First we check whether there is already a definition for this column.
-% ^^A Unlike \verb"\newcommand" we give a warning rather than an error if it is
-% ^^A defined. If it is a new column, add \verb"\NC at do" \meta{column} to
-% ^^A the list \verb"\NC at list".
-%    \begin{macrocode}
- %   \@ifundefined{NC at find@\NC at char}%
- %     {\@tfor\next:=<>clrmbp@!|\do{\if\noexpand\next\NC at char
- %         %\PackageWarning{array}%
- %           \@memwarn{Redefining primitive column \NC at char}\fi}% memoir change
- %      \NC at list\expandafter{\the\NC at list\NC at do#1}}%
- %    {%\PackageWarning{array}
- %       \@memwarn{Column \NC at char\space is already defined}}% memoir change
-%    \end{macrocode}
-% ^^A Now we define a macro with an argument delimited by the new column
-% ^^A specifier, this is used to find occurrences of this specifier in the
-% ^^A user preamble.
-%    \begin{macrocode}
- %   \@namedef{NC at find@\NC at char}##1#1{\NC@{##1}}%
-%    \end{macrocode}
-% ^^A If an optional argument was not given, give a default argument of 0.
-%    \begin{macrocode}
- %   \@ifnextchar[{\newcol@{\NC at char}}{\newcol@{\NC at char}[0]}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\newcol@}
-% ^^A We can now define the macro which does the rewriting,
-% ^^A \verb"\@reargdef" takes the same arguments as \verb"\newcommand", but
-% ^^A does not check that the command is new. For a column, say `D' with
-% ^^A one argument, define a command \verb"\NC at rewrite@D" with one
-% ^^A argument, which recursively calls \verb"\NC at find" on the user preamble
-% ^^A after replacing the first token or group with the replacement text
-% ^^A specified in the \verb"\newcolumntype" command. \verb"\NC at find" will find the
-% ^^A next occurrence of `D' as it will be \verb"\let" equal to
-% ^^A \verb"\NC at find@D" by \verb"\NC at do".
-%    \begin{macrocode}
- % \def\newcol@#1[#2]#3{\expandafter\@reargdef
- %      \csname NC at rewrite@#1\endcsname[#2]{\NC at find#3}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC@}
-% ^^A Having found an occurrence of the new column, save the preamble
-% ^^A before the column in \verb"\@temptokena", then check to see if we
-% ^^A are at the end of the preamble. (A dummy occurrence of the column
-% ^^A specifier will be placed at the end of the preamble by \verb"\NC at do".
-%    \begin{macrocode}
- % \def\NC@#1{%
- %   \@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC at ifend}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC at ifend}
-% ^^A We can tell that we are at the end as \verb"\NC at do" will place a \verb"\relax"
-% ^^A after the dummy column.
-%    \begin{macrocode}
- % \def\NC at ifend{%
-%    \end{macrocode}
-% ^^A If we are at the end, do nothing. (The whole preamble will now be in
-% ^^A \verb"\@temptokena".)
-%    \begin{macrocode}
- %   \ifx\next\relax
-%    \end{macrocode}
-% ^^A Otherwise set the flag \verb"\if at tempswa", and rewrite the column.
-% ^^A \verb"\expandafter" introduced 1n V2.01
-%    \begin{macrocode}
- %     \else\@tempswatrue\expandafter\NC at rewrite\fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC at do}
-% ^^A If the user has specified `C' and `L' as new columns, the list of
-% ^^A rewrites (in the token register \verb"\NC at list") will look like
-% ^^A \verb"\NC at do *" \verb"\NC at do C" \verb"\NC at do L".
-% ^^A So we need to define \verb"\NC at do" as a one argument macro which
-% ^^A initialises the rewriting of the specified column. Let us assume that
-% ^^A `C' is the argument.
-%    \begin{macrocode}
- % \def\NC at do#1{%
-%    \end{macrocode}
-% ^^A First we let \verb"\NC at rewrite" and \verb"\NC at find" be
-% ^^A \verb"\NC at rewrite@C" and \verb"\NC at find@C" respectively.
-%    \begin{macrocode}
- %   \expandafter\let\expandafter\NC at rewrite
- %     \csname NC at rewrite@\string#1\endcsname
- %   \expandafter\let\expandafter\NC at find
- %     \csname NC at find@\string#1\endcsname
-%    \end{macrocode}
-% ^^A Clear the token register \verb"\@temptokena" after putting the present
-% ^^A contents of the register in front of the token \verb"\NC at find". At the
-% ^^A end we place the tokens `\verb"C\relax"' which \verb"\NC at ifend" will use
-% ^^A to detect the end of the user preamble.
-%    \begin{macrocode}
- %   \expandafter\@temptokena\expandafter{\expandafter}%
- %         \expandafter\NC at find\the\@temptokena#1\relax}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\showcols}
-% ^^A This macro is useful for debugging \verb"\newcolumntype" specifications,
-% ^^A it is the equivalent of the primitive \verb"\show" command for macro
-% ^^A definitions.  All we need to do is locally redefine \verb"\NC at do" to take
-% ^^A its argument (say `C') and then \verb"\show" the (slightly modified)
-% ^^A definition of \verb"\NC at rewrite@C". Actually as the the list always
-% ^^A starts off with \verb"\NC at do *" and we do not want to print the
-% ^^A definition of the $*$-form, define \verb"\NC at do" to throw away the first
-% ^^A item in the list, and then redefine itself to print the rest of the
-% ^^A definitions.
-%    \begin{macrocode}
- % \def\showcols{{\def\NC at do##1{\let\NC at do\NC at show}\the\NC at list}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC at show}
-% ^^A If the column `C' is defined as above, then
-% ^^A \verb"\show\NC at rewrite@C" would output\\
-% ^^A \verb"\long macro: ->\NC at find >{$}c<{$}".
-% ^^A We want to strip the \verb"long macro: ->" and the \verb"\NC at find". So first we
-% ^^A use \verb"\meaning" and then apply the macro \verb"\NC at strip" to the tokens so
-% ^^A produced and then \verb"\typeout" the required string.
-%    \begin{macrocode}
- % \def\NC at show#1{%
- %   \typeout{Column #1\expandafter\expandafter\expandafter\NC at strip
- %   \expandafter\meaning\csname NC at rewrite@#1\endcsname\@@}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC at strip}
-% ^^A Delimit the arguments to \verb"\NC at strip" with `\texttt{:}', `\texttt{->}',
-% ^^A a space, and \verb"\@@" to pull out the required parts of the output from
-% ^^A \verb"\meaning".
-%    \begin{macrocode}
- % \def\NC at strip#1:#2->#3 #4\@@{#2 -> #4}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\NC at list}
-% ^^A Allocate the token register used for the rewrite list.
-%    \begin{macrocode}
- % \newtoks\NC at list
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \subsubsection{The $*$--form}
-% ^^A We view the $*$-form as a slight generalisation of the system
-% ^^A described in the previous subsection. The idea is to define a $*$
-% ^^A column by a command of the form:
-% ^^A \begin{verbatim}
-% ^^A \newcolumntype{*}[2]{%
-% ^^A    \count@=#1\ifnum\count@>0
-% ^^A       \advance\count@ by -1 #2*{\count@}{#2}\fi}
-% ^^A \end{verbatim}
-% ^^A \begin{macro}{\NC at rewrite@*}\label{NC at rewrite@*}
-% ^^A This does not work however as \verb"\newcolumntype" takes great care not
-% ^^A to expand anything in the preamble, and so the \verb"\if" is never
-% ^^A expanded. \verb"\newcolumntype" sets up various other parts of the
-% ^^A rewrite correctly though so we can define:
-%    \begin{macrocode}
- % \newcolumntype{*}[2]{}
-%    \end{macrocode}
-% ^^A Now we must correct the definition of \verb"\NC at rewrite@*". The
-% ^^A following is probably more efficient than a direct translation of
-% ^^A the idea sketched above, we do not need to put a $*$ in the preamble
-% ^^A and call the rewrite recursively, we can just put \verb"#1" copies of
-% ^^A \verb"#2" into \verb"\@temptokena". (Nested $*$ forms will be expanded
-% ^^A when the whole rewrite list is expanded again, see \verb"\@mkpream")
-%    \begin{macrocode}
- % \long\@namedef{NC at rewrite@*}#1#2{%
-%    \end{macrocode}
-% ^^A Store the number.
-%    \begin{macrocode}
- %   \count@#1\relax
-%    \end{macrocode}
-% ^^A Put \verb"#1" copies of \verb"#2" in the token register.
-%    \begin{macrocode}
- %   \loop
- %   \ifnum\count@>\z@
- %   \advance\count@\m at ne
- %   \@temptokena\expandafter{\the\@temptokena#2}%
- %   \repeat
-%    \end{macrocode}
-% ^^A \verb"\NC at do" will ensure that \verb"\NC at find" is \verb"\let" equal
-% ^^A to \verb"\NC at find@*".
-%    \begin{macrocode}
- %   \NC at find}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \subsubsection{Modifications to internal macros of \texttt{array.sty}}
-% ^^A
-% ^^A \begin{macro}{\@xexpast}
-% ^^A \begin{macro}{\@xexnoop}
-% ^^A    These macros are used to expand $*$-forms in
-% ^^A    \texttt{array.sty}. \verb"\let" them to \verb"\relax" to save space.
-%    \begin{macrocode}
- % \let\@xexpast\relax
- % \let\@xexnoop\relax
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\save at decl}
-% ^^A We do not assume that the token register is free, we add the new
-% ^^A declarations to the front of the register. This is to allow user
-% ^^A preambles of the form, \verb">{foo}>{bar}..". Users are not encouraged to
-% ^^A enter such expressions directly, but they may result from the
-% ^^A rewriting of \verb"\newcolumntype"'s.
-%    \begin{macrocode}
- % \def\save at decl{\toks \count@ = \expandafter\expandafter\expandafter
- %                   {\expandafter\@nextchar\the\toks\count@}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\@mkpream}
-% ^^A    The main modification to \verb"\@mkpream" is to replace the call to
-% ^^A    \verb"\@xexpast" (which expanded $*$-forms) by a loop which expands
-% ^^A    all \verb"\newcolumntype" specifiers.
-%    \begin{macrocode}
- % \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
- %    \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
-%    \end{macrocode}
-% ^^A    Now we remove possible  $*$-forms and user-defined column
-% ^^A    specifiers in the user preamble by repeatedly executing the list
-% ^^A    \verb"\NC at list" until the re-writes have no more effect. The
-% ^^A    expanded preamble will then be in the token register
-% ^^A    \verb"\@temptokena". Actually we need to know at this point that
-% ^^A    this is not \verb"\toks0".
-%    \begin{macrocode}
- %    \@temptokena{#1}\@tempswatrue
- %    \@whilesw\if at tempswa\fi{\@tempswafalse\the\NC at list}%
-%    \end{macrocode}
-% ^^A    Afterwards we initialize all registers and macros, that we need
-% ^^A    for the build-up of the preamble.
-%    \begin{macrocode}
- %    \count@\m at ne
- %    \let\the at toks\relax
- %    \prepnext at tok
-%    \end{macrocode}
-% ^^A Having expanded all tokens defined using \verb"\newcolumntype" (including
-% ^^A \verb"*"), we evaluate the remaining tokens, which are saved in
-% ^^A \verb"\@temptokena".  We use the \LaTeX--macro \verb"\@tfor" to inspect each
-% ^^A token in turn.
-%    \begin{macrocode}
- %    \expandafter \@tfor \expandafter \@nextchar
- %     \expandafter :\expandafter =\the\@temptokena \do
-%    \end{macrocode}
-% ^^A \verb"\@testpatch" does not take an argument since \texttt{array.sty} 2.0h.
-%    \begin{macrocode}
- %    {\@testpach
- %    \ifcase \@chclass \@classz \or \@classi \or \@classii
- %      \or \save at decl \or \or \@classv \or \@classvi
- %      \or \@classvii \or \@classviii
-%    \end{macrocode}
-% ^^A    In \texttt{newarray.sty} class 9 is equivalent to class 10.
-%    \begin{macrocode}
- %      \or \@classx
- %      \or \@classx \fi
- %    \@lastchclass\@chclass}%
- %    \ifcase\@lastchclass
- %    \@acol \or
- %    \or
- %    \@acol \or
- %    \@preamerr \thr@@ \or
- %    \@preamerr \tw@ \@addtopreamble\@sharp \or
- %    \or
- %    \else  \@preamerr \@ne \fi
- %    \def\the at toks{\the\toks}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classix}
-% ^^A    \texttt{array.sty} does not allow repeated \texttt{>}
-% ^^A    declarations for the same column. This is allowed in
-% ^^A    \texttt{newarray.sty} as documented in the introduction. Removing
-% ^^A    the test for this case makes class 9 equivalent to class 10, and
-% ^^A    so this macro is redundant. It is \verb"\let" to \verb"\relax" to save
-% ^^A    space.
-%    \begin{macrocode}
- % \let\@classix\relax
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classviii}
-% ^^A    In \texttt{newarray.sty} explicitly allow class 2, as repeated
-% ^^A    \texttt{<} expressions are accepted by this package.
-%    \begin{macrocode}
- % \def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else
- %       \@preamerr 4\@chclass 6 \@classvi \fi\fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\@classv}
-% ^^A Class 5 is \texttt{@}-expressions (and is also called by class 1)
-% ^^A This macro was incorrect in Version~1. Now we do not expand the
-% ^^A \verb"@"-expression, but instead explicitly replace an
-% ^^A \verb"\extracolsep" command by an assignment to \verb"\tabskip" by a
-% ^^A method similar to the \verb"\newcolumntype" system described above.
-% ^^A \verb"\d at llarbegin" \verb"\d at llarend" were introduced in V2.01 to match
-% ^^A \texttt{array.sty} 2.0h.
-%    \begin{macrocode}
- % \def\@classv{\save at decl
- %    \expandafter\NC at ecs\@nextchar\extracolsep{}\extracolsep\@@@
- %    \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
- %    \prepnext at tok}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\NC at ecs}
-% ^^A Rewrite the first occurrence of \verb"\extracolsep{1in}" to
-% ^^A \verb"\tabskip1in\relax". As a side effect discard any tokens after a
-% ^^A second \verb"\extracolsep", there is no point in the user entering two of
-% ^^A these commands anyway, so this is not really a restriction.
-%    \begin{macrocode}
- % \def\NC at ecs#1\extracolsep#2#3\extracolsep#4\@@@{\def\@tempa{#2}%
- %   \ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \subsubsection{Support for the \texttt{delarray.sty}}
-% ^^A
-% ^^A The \texttt{delarray.sty} package  extends the array syntax by
-% ^^A supporting the notation of delimiters. To this end we extend the
-% ^^A array parsing mechanism to include a hook which can be used by this
-% ^^A (or another) package to do some additional parsing.
-% ^^A
-% ^^A \begin{macro}{\@tabarray}
-% ^^A    This macro tests for an optional bracket and then calls up
-% ^^A    \verb"\@@array" or \verb"\@@array[c]" (as default).
-%    \begin{macrocode}
- % \def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\@@array}
-% ^^A    This macro tests could then test an optional delimiter before the
-% ^^A    left brace of the main preamble argument. Here in the main package
-% ^^A    it simply is let to be \verb"\@array".
-%    \begin{macrocode}
- % \let\@@array\@array
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\endarray}
-% ^^A \begin{macro}{\@arrayright}
-% ^^A    We have to declare the hook we put into \verb"\@array" above.
-% ^^A    A similar hook `\verb"\@arrayright"' will be inserted into the
-% ^^A    \verb"\endarray" to gain control. Both defaults to empty.
-%    \begin{macrocode}
- % \def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}}
- % \let\@arrayleft\@empty
- % \let\@arrayright\@empty
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A \subsubsection{Support for \texttt{\textbackslash firsthline} and
-% ^^A             \texttt{\textbackslash lasthline}}
-% ^^A
-% ^^A The Companion~\cite[p.137]{GOOSSENS94} suggests two additional
-% ^^A commands to control the alignments in case of tabulars with
-% ^^A horizontal lines. They are now added to this package.
-% ^^A
-% ^^A  \begin{macro}{\extratabsurround}
-% ^^A    The extra space around a table when \verb"\firsthline" or \verb"\lasthline"
-% ^^A    are used.
-%    \begin{macrocode}
- % \newlength{\extratabsurround}
- % \setlength{\extratabsurround}{2pt}
-%    \end{macrocode}
-% ^^A  \end{macro}
-% ^^A
-% ^^A \begin{macro}{\backup at length}
-% ^^A    This register will be used internally by \verb"\firsthline" and
-% ^^A    \verb"\lasthline".
-%    \begin{macrocode}
- % \newlength{\backup at length}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\firsthline}
-% ^^A    This code can probably be improved but for the moment it should
-% ^^A    serve.
-% ^^A
-% ^^A    We start by producing a single tabular row without any visible
-% ^^A    content that will produce the external reference point in case
-% ^^A    \verb"[t]" is used.
-%    \begin{macrocode}
- % \newcommand{\firsthline}{%}} emacs
- %   \multicolumn1c{% 
-%    \end{macrocode}
-% ^^A    Within this row we calculate \verb"\backup at length" to be the height
-% ^^A    plus depth of a standard line. In addition we have to add the
-% ^^A    width of the \verb"\hline", something that was forgotten in the
-% ^^A    original definition.
-%    \begin{macrocode}
- %     \global\backup at length\ht\@arstrutbox
- %     \global\advance\backup at length\dp\@arstrutbox
- %     \global\advance\backup at length\arrayrulewidth
-%    \end{macrocode}
-% ^^A    Finally we do want to make the height of this first line be a bit
-% ^^A    larger than usual, for this we place the standard array strut
-% ^^A    into it but raised by \verb"\extratabsurround"
-%    \begin{macrocode}
- %      \raise\extratabsurround\copy\@arstrutbox
-%    \end{macrocode}
-% ^^A    Having done all this we end the line and back up by the value of
-% ^^A    \verb"\backup at length" and then finally place our \verb"\hline". This should
-% ^^A    place the line exactly at the right place but keep the reference
-% ^^A    point of the whole tabular at the baseline of the first row.
-%    \begin{macrocode}
- %     }\\[-\backup at length]\hline
- % }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\lasthline}
-% ^^A    For \verb"\lasthline" the situation is even worse and I got it
-% ^^A    completely wrong initially.
-% ^^A
-% ^^A    The problem in this case is that if the optional argument \verb"[b]"
-% ^^A    is used we do want the reference point of the tabular be at the
-% ^^A    baseline of the last row but at the same time do want the the
-% ^^A    depth of this last line increased by \verb"\extratabsurround" without
-% ^^A    changing the placement \verb"\hline".
-% ^^A
-% ^^A    We start by placing the rule followed by an invisible row.
-%    \begin{macrocode}
- % \newcommand{\lasthline}{\hline\multicolumn1c{%}} emacs
-%    \end{macrocode}
-% ^^A    We now calculate \verb"\backup at length" to be the height and depth of
-% ^^A    two lines plus the width of the rule.
-%    \begin{macrocode}
- %     \global\backup at length2\ht\@arstrutbox
- %     \global\advance\backup at length2\dp\@arstrutbox
- %     \global\advance\backup at length\arrayrulewidth
-%    \end{macrocode}
-% ^^A    This will bring us back to the baseline of the second last row:
-%    \begin{macrocode}
- %     }\\[-\backup at length]%
-%    \end{macrocode}
-% ^^A    Thus if we now add another invisible row the reference point of
-% ^^A    that row will be at the baseline of the last row (and will be the
-% ^^A    reference for the whole tabular). Since this row is invisible we
-% ^^A    can enlarge its depth by the desired amount.
-%    \begin{macrocode}
- %     \multicolumn1c{%
- %        \lower\extratabsurround\copy\@arstrutbox
- %        }%
- % }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \subsubsection{Getting the spacing around rules right}
-% ^^A
-% ^^A    Beside a larger functionality \texttt{array.sty} has one
-% ^^A    important difference to the standard \texttt{tabular} and
-% ^^A    \texttt{array} environments: horizontal and vertical rules make a
-% ^^A    table larger or wider, e.g., \verb=\doublerulesep= really denotes
-% ^^A    the space between two rules and isn't measured from the middle of
-% ^^A    the rules.
-% ^^A
-% ^^A  \begin{macro}{\@xhline}
-% ^^A    For vertical rules this is implemented by the definitions above,
-% ^^A    for horizontal rules we have to take out the backspace.
-%    \begin{macrocode}
- % \CheckCommand*\@xhline{\ifx\reserved at a\hline
- %                \vskip\doublerulesep
- %                \vskip-\arrayrulewidth
- %              \fi
- %       \ifnum0=`{\fi}}
- % \renewcommand*\@xhline{\ifx\reserved at a\hline
- %                \vskip\doublerulesep
- %              \fi
- %       \ifnum0=`{\fi}}
-%    \end{macrocode}
-% ^^A  \end{macro}
-% ^^A
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% end array.sty 2016/10/06 v2.4d %%%%%%%%% 
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A
-%
 % \subsubsection{Class additions to Array}
 % 
 % \begin{macro}{\m at mold@addamp}
@@ -17316,173 +15358,6 @@
 % \Lpack{dcolumn} and replaced it with requiring the \Lpack{dcolumn} package
 % instead.}
 %
-% ^^A The description and code are essentially copied from the 
-% ^^A \Lpack{dcolumn} package~\cite{DCOLUMN}.
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A
-% ^^A The \Lpack{dcolumn} package~\cite{DCOLUMN} defines \texttt{D} 
-% ^^A to be a column specifier
-% ^^A with three arguments.\\
-% ^^A \verb?D?\marg{sep.tex}\marg{sep.dvi}\marg{decimal places}
-% ^^A for columns which are to be aligned on a `decimal point'.
-% ^^A 
-% ^^A
-% ^^A The basic ideas behind these macros have been explained earlier.
-% ^^A However they use three
-% ^^A tricks which may be useful in other contexts.
-% ^^A \begin{itemize}
-% ^^A \item The separator is surrounded in extra \verb?{ }?, so that it is set
-% ^^A with \cs{mathord} spacing, otherwise, for instance a `,' would have
-% ^^A extra space after it.
-% ^^A \item The separator is not given its special definition by making it
-% ^^A active, as this would not work for an entry such as \verb?& .5 &?, as the
-% ^^A first token of an alignment entry is read \emph{before} the preamble
-% ^^A part, incase it is an \cs{omit}, in which case the preamble is to be
-% ^^A omitted. Instead we switch the mathcode to (hex) 8000, which makes the
-% ^^A token act as if it were active.
-% ^^A \item Although \verb?\mathcode`.="8000?  makes \texttt{.} act as if it
-% ^^A were active, it is still not allowed in constructions such as
-% ^^A \verb?\def.{}?, even in math-mode, so we have to construct an active
-% ^^A version of the separator, this is done by making it the uppercase of
-% ^^A \verb?~?, and then using the construct\\
-% ^^A \verb?\uppercase{\def~}?\marg{definition}.\\
-% ^^A Note that the \meta{definition} is not uppercased, so the definition
-% ^^A can refer to the standard, non-active use of the separator.
-% ^^A \end{itemize}
-% ^^A
-% ^^A \begin{macro}{\DC@}
-% ^^A Set up uppercase tables as required, and then grab the first part of
-% ^^A the numerical argument into \cs{count@}.
-%    \begin{macrocode}
- % \def\DC@#1#2#3{%
- %   \uccode`\~=`#1\relax
- %   \m at th
- %   \afterassignment\DC at x\count@#3\relax{#1}{#2}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\DC at x}
-% ^^A If \cs{count@} is negative, centre on the decimal point. If it is
-% ^^A positive either \verb?#1? will be empty in which case bad out decimal
-% ^^A part to the number of digits specified by \cs{count@} or 
-% ^^A it is none empty in which case \cs{count@} contains the
-% ^^A number of digits to the left of the point, and \verb?#1? contains a junk
-% ^^A token (probably \verb?.?) followed by the number of digits to the right
-% ^^A of the point. In either of these latter cases, \cs{DC at right} is used.
-%    \begin{macrocode}
- % \def\DC at x#1\relax#2#3{%
- %   \ifnum\z@>\count@
- %     \expandafter\DC at centre
- %   \else
- %     \expandafter\DC at right
- %   \fi
- %   {#2}{#3}{#1}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\DC at centre}
-% ^^A If centering on the decimal point, just need to box up the two halves.
-%    \begin{macrocode}
- % \def\DC at centre#1#2#3{%
- %   \let\DC at end\DC at endcentre
- %   \uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}%$
- %   \setbox\tw@=\hbox{${\phantom{{#2}}}$}%
- %   \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 }%$
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\DC at endcentre}
-% ^^A and then pad out the smaller of the two boxes so there is the same
-% ^^A amount of stuff either side of the point.
-%    \begin{macrocode}
- % \def\DC at endcentre{$\egroup%$
- %     \ifdim \wd\z@>\wd\tw@
- %       \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}%
- %     \else
- %       \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi
- %     \box\z@\box\tw@}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\DC at right}
-% ^^A This deals with both the cases where a specified number of decimal
-% ^^A places is given.
-%    \begin{macrocode}
- % \def\DC at right#1#2#3{%
- %   \ifx\relax#3\relax
-%    \end{macrocode}
-% ^^A If \verb?#3? is empty, add \cs{hfill} to right align the column, and 
-% ^^A Just set \cs{DC at rl} to begin a group, so nothing fancy is done with
-% ^^A the whole number part.
-%    \begin{macrocode}
- %     \hfill
- %     \let\DC at rl\bgroup
- %   \else
-%    \end{macrocode}
-% ^^A Otherwise  set \cs{DC at rl} so that the whole number part is put in a
-% ^^A box \cs{count@} times as wide as a digit.
-% ^^A In order to share code with the other branch, then move \verb?#3? (the
-% ^^A number of decimal places) into \cs{count@} throwing away the `.' from
-% ^^A the user syntax.
-%    \begin{macrocode}
- %     \edef\DC at rl{to\the\count@\dimen at ii\bgroup\hss\hfill}%
- %     \count@\@gobble#3\relax
- %   \fi
-%    \end{macrocode}
-% ^^A
-%    \begin{macrocode}
- %   \let\DC at end\DC at endright
-%    \end{macrocode}
-% ^^A Box 2 contains the decimal part, set to \cs{dimen@} which is
-% ^^A calculated below to be \cs{count@} times the width of a digit, plus
-% ^^A the width of the `decimal point'.
-%    \begin{macrocode}
- %   \uppercase{\def~}{$\egroup\setbox\tw@\hbox to\dimen@\bgroup${#2}}%
- %    \setbox\z@\hbox{$1$}\dimen at ii\wd\z@
- %    \dimen@\count@\dimen at ii
- %    \setbox\z@\hbox{${#2}$}\advance\dimen@\wd\z@
- %    \setbox\tw@\hbox to\dimen@{}%
-%    \end{macrocode}
-% ^^A Box 0 contains the whole number part, either just at its natural
-% ^^A size for right aligned columns, or set to (the old value of)
-% ^^A \cs{count@} times the width of a digit. \cs{DC at rl} defined above
-% ^^A determines the two cases.
-%    \begin{macrocode}
- %    \setbox\z@\hbox\DC at rl$\mathcode`#1="8000 }%$
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\DC at endright}
-% ^^A Just finish off the second box, and then put out both boxes.
-%    \begin{macrocode}
- % \def\DC at endright{$\hfil\egroup\box\z@\box\tw@}%$
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{D}
-% ^^A The user interface, define the {\tt D} column to take three arguments.
-% ^^A For special purposes, you may need to directly access \cs{DC@} rather
-% ^^A than the \verb?D? column, eg to get a bold version you could use
-% ^^A\begin{verbatim}
-% ^^A \newcolumntype{E}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC at end}}
-% ^^A\end{verbatim}
-%    \begin{macrocode}
- % \newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC at end}}
- % 
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% end Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
- % 
-%    \end{macrocode}
-% ^^A
 %
 %
 % \subsection{Support for delimeters}
@@ -17495,103 +15370,6 @@
 % The embeded copy is outcommented for now and will be removed in a
 % later version.
 %
-% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
-% \Lpack{delarray} and replaced it with requiring the \Lpack{delarray} package
-% instead.}
-% ^^A
-% ^^A The description and code are essentially from the 
-% ^^A \Lpack{delarray} package~\cite{DELARRAY}, v1.01 1994/03/14.
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% Delarray package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A
-% ^^A The array syntax is extended by
-% ^^A supporting the notation of delimiters. To this end we extend the
-% ^^A array parsing mechanism to include a hook which can be used by this
-% ^^A (or another) package to do some additional parsing.
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\@@array}
-% ^^A    This macro tests for an optional delimiter before the left brace
-% ^^A    of the main preamble argument. If there is no delimiter,
-% ^^A    \cs{@arrayleft} and \cs{@arrayright} are made a no-ops, and
-% ^^A    \cs{@array} is called with the positional argument. Otherwise
-% ^^A    call \cs{@del at array}.
-%    \begin{macrocode}
- % \def\@@array[#1]{\@ifnextchar\bgroup
- %   {\let\@arrayleft\relax\let\@arrayright\relax\@array[#1]}%
- %   {\@del at array[#1]}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\@del at array}
-% ^^A    We now know that we have an {\tt array} (or {\tt tabular}) with
-% ^^A    delimiters.
-%    \begin{macrocode}
- % \def\@del at array[#1]#2#3#4{%
-%    \end{macrocode}
-% ^^A The following line is completely redundant but it does catch errors
-% ^^A involving delimiters  before the processing of the alignment begins.
-% ^^A A common error is likely to be omiting the `.' in a
-% ^^A \cs{cases}-type construction. This causes the first token of the
-% ^^A alignment to be gobbled, possibly causing lots of spurious errors
-% ^^A before the cause of the error, the missing delimiter, is discovered as
-% ^^A \cs{@arrayright} puts the alignment and the delimiters together.
-%    \begin{macrocode}
- %   \setbox\z@\hbox{$\left#2\right#4$}%
-%    \end{macrocode}
-% ^^A In the case of a `c' argument we do not need to rebox the alignment,
-% ^^A so we can define \cs{@arrayleft} and \cs{@arrayright} just to
-% ^^A insert the delimiters.
-%    \begin{macrocode}
- %   \if#1c\def\@arrayleft{\left#2}\def\@arrayright{\right#4}%
-%    \end{macrocode}
-% ^^A Otherwise we (should) have a {\tt[t]} or {\tt[b]} argument, so first we
-% ^^A store the alignment, without delimiters in box0.
-%    \begin{macrocode}
- %   \else\def\@arrayleft{\setbox\z@}%
-%    \end{macrocode}
-% ^^A Then after the alignment is finished:
-%    \begin{macrocode}
- %   \def\@arrayright{%
-%    \end{macrocode}
-% ^^A Calculate the amount the box needs to be lowered (this will be
-% ^^A negative in the case of \verb?[b]?). A little bit of arithmetic cf.\
-% ^^A \theTeXbook, Appendix G, rule 8. We calculate the amount this
-% ^^A way, rather than just taking the difference between the depth of box0
-% ^^A and the depth of the box defined below, as the depth of that box may
-% ^^A be affected by the delimiters if \cs{delimitershortfall} or
-% ^^A \cs{delimiterfactor} have non-standard values.
-%    \begin{macrocode}
- %      \dimen@=\dp\z@
- %      \advance\dimen at -\ht\z@
- %      \divide \dimen@ by \tw@
- %      \advance\dimen@ by\fontdimen22 \textfont\tw@
-%    \end{macrocode}
-% ^^A Now lower the alignment and the delimiters into place.
-%    \begin{macrocode}
- %      \lower\dimen@\hbox{$\left#2\vcenter{\unvbox\z@}\right#4$}}%
-%    \end{macrocode}
-% ^^A End the \verb?\if#1c?
-%    \begin{macrocode}
- %   \fi
-%    \end{macrocode}
-% ^^A Now that we have defined \cs{@arrayleft} and \cs{@arrayright}, call
-% ^^A \cs{@array}.
-%    \begin{macrocode}
- %   \@array[#1]{#3}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% end Delarray package code %%%%%%%%%%%%%%%%%%%%%
- % 
-%    \end{macrocode}
-% ^^A
 %
 %
 % \subsection{The tabularx environment}
@@ -17601,702 +15379,6 @@
 %    \begin{macrocode}
 \RequirePackage{tabularx}[2016/02/03]
 %    \end{macrocode}
-% The embeded copy is outcommented for now and will be removed in a
-% later version.
-%
-% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
-% \Lpack{tabularx} and replaced it with requiring the \Lpack{tabularx} package
-% instead.}
-
-%
-% ^^A The code and description are essentially from David Carlisle's  
-% ^^A \Lpack{tabularx} package~\cite{TABULARX}, v2.07 1999/01/07.
-% ^^A
-%    \begin{macrocode}
- % %%%%%%%%%% Tabularx package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- % 
- % %%% This is a carbon copy of the tabularx dtx sources for v2.11,
- % %%% 2016/02/03 with two changes: error messages mention the class
- % %%% instead of tabularx. 
- % 
- % %%%%%%%%%% Tabularx package code v2.11 2016/02/03 %%%%%%%%%%%%%%%%%%%%%
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A
-% ^^A
-% ^^A The \Lpack{tabularx} package~\cite{TABULARX} implements a version of the \texttt{tabular}
-% ^^A environment in which the widths of certain columns are calculated so
-% ^^A that the table is is a specified width. The columns that may stretch are
-% ^^A marked by an \texttt{X} in the preamble argument.
-% ^^A
-% ^^A What follows is a carbon copy of the contents of \texttt{tabularx.dtx} with small changes: (1) We make errors/warnings
-% ^^A mention the class instead of \texttt{tabularx}, (2) we strip \texttt{tabularx} related \cs{changes} macros, (3) we
-% ^^A remove loading the \Lpack{array} package, as we already come with a copy.
-% ^^A
-% ^^A First some registers etc.\ that we need.
-%    \begin{macrocode}
- % \newdimen\TX at col@width
- % \newdimen\TX at old@table
- % \newdimen\TX at old@col
- % \newdimen\TX at target
- % \newdimen\TX at delta
- % \newcount\TX at cols
- % \newif\ifTX@
-%    \end{macrocode}
-% ^^A
-% ^^A Now a trick to get the body of an environment into a token register, without doing any expansion. This does not do any
-% ^^A real checking of nested environments, so if you should need to nest one {\ttfamily tabularx} inside another, the inner
-% ^^A one must be surrounded by \verb+{ }+.
-% ^^A
-% ^^A \begin{macro}{\tabularx}
-% ^^A Prior to (\texttt{tabularx}) v1.06, this macro took two arguments, which were saved in
-% ^^A separate registers before the table body was saved by \verb+\TX at get@body+.
-% ^^A Unfortunately this disables the \verb|[t]| optional argument. Now just save
-% ^^A the width specification separately, then clear the token register
-% ^^A \verb|\toks@|.
-% ^^A Finally call \verb|\TX at get@body| to begin saving the body of the table.
-% ^^A The \verb|{\ifnum0=`}\fi| was added at (tabularx) v1.03, to allow \Lenv{tabularx} to appear
-% ^^A inside a \verb|\halign|.^^A
-% ^^A \setbox0=\hbox{\footnotesize"\iffalse{\fi\ifnum0=`}\fi"}^^A
-% ^^A \setbox2=\hbox{\footnotesize"\ifnum0=`{}\fi"}^^A
-% ^^A \footnote{This adds an extra level of grouping,
-% ^^A which is not really needed. Instead, I could use \box0\ here, and
-% ^^A \box2\ below, however the code here would then have to be moved after
-% ^^A the first line, because of the footnote to page 386 of the \TeX{}Book,
-% ^^A and I do not think I should be writing code that is so obscure as to
-% ^^A be documented in a footnote in an appendix called ``Dirty Tricks''!}
-% ^^A
-% ^^A This mechanism of grabbing an environment body does have the
-% ^^A disadvantage (shared with the AMS alignment environments) that you
-% ^^A can not make extension environments by code such as
-% ^^A\begin{verbatim}
-% ^^A\newenvironment{foo}{\begin{tabularx}{XX}}{\end{tabularx}}
-% ^^A\end{verbatim}
-% ^^A as the code is looking for a literal string \verb"\end{tabularx}" to stop
-% ^^A scanning. Since version (tabularx) 2.02, one may avoid this problem by using
-% ^^A \verb|\tabularx| and \verb|\endtabularx| directly in the definition:
-% ^^A\begin{verbatim}
-% ^^A\newenvironment{foo}{\tabularx{XX}}{\endtabularx}
-% ^^A\end{verbatim}
-% ^^A The scanner now looks for the end of the current environment (\verb|foo| in
-% ^^A this example.) There are some restrictions on this usage, the
-% ^^A principal one being that \verb|\endtabularx| must not be inside any \verb"{ }" pairs
-% ^^A ao that the code before \verb"\endtabularx"  may be extracted and added to the table body
-% ^^A (prior to version (tabularx) 2.09  \verb"\endtabularx" had to be
-% ^^A the \emph{first} token of the `end code' of the environment).
-%    \begin{macrocode}
- % \def\tabularx#1{%
-%    \end{macrocode}
-% ^^A Allow \verb"\tabularx" \verb"\endtabularx" (but not \verb"\begin{tabularx}"
-% ^^A \verb"\end{tabularx}") to be used in \verb"\newenvironment" definitions.
-%    \begin{macrocode}
- % \edef\TX@{\@currenvir}%
- %   {\ifnum0=`}\fi
-%    \end{macrocode}
-% ^^A \verb"\relax" added at v1.05 so that non-expandable length tokens, like
-% ^^A \verb"\textwidth" do not generate an extra space, and an overfull box.
-% ^^A \verb"\relax" removed again at v4.09 in favour of \verb"\setlength" so if you
-% ^^A use the calc package you can use a width of \verb"(\textwidth-12pt)/2".
-%    \begin{macrocode}
- %   \setlength\TX at target{#1}%
- %   \TX at typeout{Target width: #1 = \the\TX at target.}%
- %   \toks@{}\TX at get@body}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A 
-% ^^A  \begin{macro}{\endtabularx}
-% ^^A This does not do very much\ldots
-%    \begin{macrocode}
- % \let\endtabularx\relax
-%    \end{macrocode}
-% ^^A  \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at get@body}
-% ^^A Place all tokens as far as the first \verb"\end" into a token register.
-% ^^A Then call \verb"\TX at find@end" to see if we are at \verb"\end{tabularx}".
-%    \begin{macrocode}
- % \long\def\TX at get@body#1\end
- %   {\toks@\expandafter{\the\toks@#1}\TX at find@end}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at find@end}
-% ^^A If we are at \verb"\end{tabularx}", call \verb"\TX at endtabularx", otherwise
-% ^^A add \verb"\end{...}" to the register, and call \verb"\TX at get@body" again.
-%    \begin{macrocode}
- % \def\TX at find@end#1{%
- %   \def\@tempa{#1}%
- %   \ifx\@tempa\TX@\expandafter\TX at endtabularx
- %   \else\toks@\expandafter
- %     {\the\toks@\end{#1}}\expandafter\TX at get@body\fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at find@endtabularxa}
-% ^^A split up the end code, and extract the part that lives in the table body.
-%    \begin{macrocode}
- % \long\def\TX at find@endtabularxa
- %        #1\endtabularx#2\endtabularx#3\TX at find@endtabularxa{%
- %   \ifx\TX@#2\relax\else
- %   \toks@\expandafter{\the\toks@#1}%
- %   \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \begin{macro}{\TX at find@endtabularxb}
-% ^^A split up the end code, and extract the part that lives outside the table body.
-%    \begin{macrocode}
- % \long\def\TX at find@endtabularxb
- %        #1\endtabularx#2\endtabularx#3\TX at find@endtabularxb{%
- %   \ifx\TX@#2%
- %     \expandafter\@firstoftwo
- %   \else
- %      \expandafter\@secondoftwo
- %   \fi
- %   {#1}{#2}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at find@endtabularxbb}
-% ^^A Helper to avoid needing 15 consecutive \verb"\expandafter"
-%    \begin{macrocode}
- % \def\TX at find@endtabularxbb{%
- %   \expandafter\expandafter\expandafter
- %   \TX at find@endtabularxb
- % }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX@}
-% ^^A The string {\ttfamily tabularx} as a macro for testing with \verb"\ifx".
-%    \begin{macrocode}
- % \def\TX@{tabularx}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A Now that all the parts of the table specification are stored in
-% ^^A registers, we can begin the work of setting the table.
-% ^^A
-% ^^A The algorithm for finding the correct column widths is as follows.
-% ^^A Firstly set the table with each {\ttfamily X} column the width of the
-% ^^A final table. Assuming that there is at least one {\ttfamily X} column,
-% ^^A this will produce a table that is too wide. Divide the excess width by
-% ^^A the number of {\ttfamily X} columns, and reduce the column width by
-% ^^A this amount. Reset the table. If the table is not now the correct
-% ^^A width, a \verb"\multicolumn" entry must be `hiding' one of the {\ttfamily
-% ^^A X} columns, and so there is one less {\ttfamily X} column affecting
-% ^^A the width of the table. So we reduce by 1 the number of X columns and
-% ^^A repeat the process.
-% ^^A
-% ^^A \begin{macro}{\TX at endtabularx}
-% ^^A Although I have tried to make {\ttfamily tabularx} look like an
-% ^^A environment, it is in fact a command, all the work is done by this
-% ^^A macro.
-%    \begin{macrocode}
- % \def\TX at endtabularx{%
- %    \expandafter\expandafter\expandafter
- %      \TX at find@endtabularxa\csname end\TX@\endcsname
- %      \endtabularx\TX@\endtabularx\TX at find@endtabularxa
-%    \end{macrocode}
-% ^^A Define the {\ttfamily X} column, with an internal version of the
-% ^^A \verb"\newcolumntype" command. The \verb"\expandafter" commands enable
-% ^^A \verb"\NC at newcol"  to get the {\em expansion} of\\
-% ^^A \verb"\tabularxcolumn{\TX at col@width}" as its
-% ^^A argument. This will be the definition of an {\ttfamily X} column, as
-% ^^A discussed in section 4.
-%    \begin{macrocode}
- %   \expandafter\TX at newcol\expandafter{\tabularxcolumn{\TX at col@width}}%
-%    \end{macrocode}
-% ^^A Initialise the column width, and the number of {\ttfamily X} columns.
-% ^^A The number of {\ttfamily X} columns is set to one, which means that
-% ^^A the initial count will be one too high, but this value is decremented
-% ^^A before it is used in the main loop.
-% ^^A
-% ^^A Since v1.02, switch the definition of \verb"\verb".
-%    \begin{macrocode}
- %   \let\verb\TX at verb
-%    \end{macrocode}
-% ^^A Since v1.05, save the values of all \LaTeX\ counters, the list
-% ^^A \verb"\cl@@ckpt" contains the names of all the \LaTeX\ counters that have
-% ^^A been defined so far. We expand \verb"\setcounter" at this point, as it
-% ^^A results in fewer tokens being stored in \verb"\TX at ckpt", but the actual
-% ^^A resetting of the counters occurs when \verb"\TX at ckpt" is expanded after
-% ^^A each trial run.
-% ^^A Actually since v1.07, use something equivalent to the expansion of the
-% ^^A original definition of \verb"\setcounter", so that \verb"tabularx" works in
-% ^^A conjunction with \verb"calc.sty".
-%    \begin{macrocode}
- %   \def\@elt##1{\global\value{##1}\the\value{##1}\relax}%
- %   \edef\TX at ckpt{\cl@@ckpt}%
- %   \let\@elt\relax
- %   \TX at old@table\maxdimen
- %   \TX at col@width\TX at target
- %   \global\TX at cols\@ne
-%    \end{macrocode}
-% ^^A Typeout some headings (unless this is disabled).
-%    \begin{macrocode}
- %   \TX at typeout@
- %     {\@spaces Table Width\@spaces Column Width\@spaces X Columns}%
-%    \end{macrocode}%
-% ^^A First attempt. Modify the {\ttfamily X} definition to count {\ttfamily
-% ^^A X} columns.
-%    \begin{macrocode}
- %   \TX at trial{\def\NC at rewrite@X{%
- %           \global\advance\TX at cols\@ne\NC at find p{\TX at col@width}}}%
-%    \end{macrocode}
-% ^^A Repeatedly decrease column width until table is the correct width,
-% ^^A or stops shrinking, or the columns become two narrow.
-% ^^A If there are no multicolumn entries, this will only take one attempt.
-%    \begin{macrocode}
- %   \loop
- %     \TX at arith
- %     \ifTX@
- %     \TX at trial{}%
- %   \repeat
-%    \end{macrocode}
-% ^^A One last time, with warnings back on (see appendix D)
-% ^^A use {\ttfamily tabular*} to put it in a box of the right size, in case
-% ^^A the algorithm failed to find the correct size.
-% ^^A
-% ^^A Since v1.04, locally make \verb"\footnotetext" save its argument in a token
-% ^^A register.
-% ^^A Since v1.06, \verb"\toks@" contains the preamble specification,
-% ^^A and possible optional argument, as well as the table body.
-%    \begin{macrocode}
- %   {\let\@footnotetext\TX at ftntext\let\@xfootnotenext\TX at xftntext
- %     \csname tabular*\expandafter\endcsname\expandafter\TX at target
- %       \the\toks@
- %     \csname endtabular*\endcsname}%
-%    \end{macrocode}
-% ^^A Now the alignment is finished, and the \verb"}" has restored the original
-% ^^A meaning of \verb"\@footnotetext" expand the register \verb"\TX at ftn" which will
-% ^^A execute a series of\\
-% ^^A \verb"\footnotetext["\meta{num}\verb"]{"\meta{note}\verb"}"\\
-% ^^A commands. We need to be careful about clearing the register as we may
-% ^^A be inside a nested {\ttfamily tabularx}.
-%    \begin{macrocode}
- %   \global\TX at ftn\expandafter{\expandafter}\the\TX at ftn
-%    \end{macrocode}
-% ^^A Now finish off the {\ttfamily tabularx} environment. Note that we need
-% ^^A \verb"\end{tabularx}" here as the \verb"\end{tabularx}" in the user's
-% ^^A file is never expanded. Now use \verb"\TX@" rather than \verb"tabularx".
-% ^^A
-% ^^A We also need to finish off the group started by \verb"{\ifnum0=`}\fi" in
-% ^^A the macro \verb"\tabularx".
-%    \begin{macrocode}
- %   \ifnum0=`{\fi}%
- %    \expandafter\expandafter\expandafter
- %    \TX at find@endtabularxbb
- %     \expandafter\end\expandafter{\TX@}%
- %     \endtabularx\TX@\endtabularx\TX at find@endtabularxb
- % }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A
-% ^^A \begin{macro}{\TX at arith}
-% ^^A Calculate the column width for the next try, setting the flag
-% ^^A \verb"\ifTX@" to false if the loop should be aborted.
-%    \begin{macrocode}
- % \def\TX at arith{%
- %   \TX at false
- %   \@tempdimb\maxdimen
- %   \divide\@tempdimb\TX at cols
- %   \ifdim\TX at col@width>\@tempdimb
- %     \TX at typeout@{Don't exceed \maxdimen}%
- %     \wd\@tempboxa\maxdimen
- %   \fi
- %   \ifdim\TX at old@table=\wd\@tempboxa
-%    \end{macrocode}
-% ^^A If we have reduced the column width, but the table width has not
-% ^^A changed, we stop the loop, and output the table (which will cause an
-% ^^A over-full alignment) with the previous value of \verb"\TX at col@width".
-%    \begin{macrocode}
- %     \TX at col@width\TX at old@col
- %     \TX at typeout@{Reached minimum width, backing up.}%
- %   \else
-%    \end{macrocode}
-% ^^A Otherwise calculate the amount by which the current table is too wide.
-%    \begin{macrocode}
- %     \dimen@\wd\@tempboxa
- %     \advance\dimen@ -\TX at target
- %     \ifdim\dimen@<\TX at delta
-%    \end{macrocode}
-% ^^A If this amount is less than \verb"\TX at delta", stop. (\verb"\TX at delta"
-% ^^A should be non-zero otherwise we may miss the target due to rounding
-% ^^A error.)
-%    \begin{macrocode}
- %       \TX at typeout@{Reached target.}%
- %     \else
-%    \end{macrocode}
-% ^^A Reduce the number of effective {\ttfamily X} columns by one. (Checking
-% ^^A that we do not get 0, as this would produce an error later.) Then
-% ^^A divide excess width by the number of effective columns, and calculate
-% ^^A the new column width. Temporarily store this value (times $-1$) in
-% ^^A \verb"\dimen@".
-%    \begin{macrocode}
- %       \ifnum\TX at cols>\@ne
- %         \advance\TX at cols\m at ne
- %       \fi
- %       \divide\dimen@\TX at cols
- %       \advance\dimen@ -\TX at col@width
- %       \ifdim \dimen@ >\z@
-%    \end{macrocode}
-% ^^A If the new width would be too narrow, abort the loop. At the moment
-% ^^A too narrow, means less than 0\,pt!
-% ^^A
-% ^^A Prior to v2.03, if the loop was aborted here, the X columns were left
-% ^^A with the width of the previous run, but this may make the table far
-% ^^A too wide as initial guesses are always too big. Now force to
-% ^^A \verb"\TX at error@width" which defaults to be 1em. If you want to
-% ^^A get the old behaviour stick\\
-% ^^A  \verb"\renewcommand\TX at error@width{\TX at col@width}"\\
-% ^^A  in a package file loaded after \textsf{tabularx}.
-%    \begin{macrocode}
- %         %\PackageWarning{tabularx}%
- %          \@memwarn{X Columns too narrow (table too wide)\MessageBreak}% <-- change here
- %         \TX at col@width\TX at error@width\relax
- %       \else
-%    \end{macrocode}
-% ^^A Otherwise save the old settings, and set the new column width. Set the
-% ^^A flag to true so that the table will be set, and the loop will be
-% ^^A executed again.
-%    \begin{macrocode}
- %         \TX at old@col\TX at col@width
- %         \TX at old@table\wd\@tempboxa
- %         \TX at col@width-\dimen@
- %         \TX at true
- %       \fi
- %     \fi
- %   \fi}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at error@width}
-% ^^A If the calculated width is negative, use this instead.
-%    \begin{macrocode}
- % \def\TX at error@width{1em}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at delta}
-% ^^A Accept a table that is within \verb"\hfuzz" of the correct width.
-%    \begin{macrocode}
- % \TX at delta\hfuzz
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A Initialise the {\ttfamily X} column. The definition can be empty here,
-% ^^A as it is set for each {\ttfamily tabularx} environment.
-%    \begin{macrocode}
- % \newcolumntype{X}{}
-%    \end{macrocode}
-% ^^A
-% ^^A \begin{macro}{\tabularxcolumn}
-% ^^A The default definition of {\ttfamily X} is \verb"p{#1}".
-%    \begin{macrocode}
- % \def\tabularxcolumn#1{p{#1}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at newcol}
-% ^^A A little macro just used to cut down the number of \verb"\expandafter"
-% ^^A commands needed.
-%    \begin{macrocode}
- % \def\TX at newcol{\newcol@{X}[0]}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at trial}
-% ^^A Make a test run.
-%    \begin{macrocode}
- % \def\TX at trial#1{%
- %   \setbox\@tempboxa\hbox{%
-%    \end{macrocode}
-% ^^A Any extra commands. This is used on the first run to count the number
-% ^^A of {\ttfamily X} columns.
-%    \begin{macrocode}
- %     #1\relax
-%    \end{macrocode}
-% ^^A Since v1.04, make \verb"\footnotetext" gobble its arguments. Also locally
-% ^^A clear \verb"\TX at vwarn" so that the warning is generated by the {\ttfamily
-% ^^A final} run, and does not appear in the middle of the table if
-% ^^A \verb"\tracingtabularx".
-%    \begin{macrocode}
- %   \let\@footnotetext\TX at trial@ftn
- %   \let\TX at vwarn\@empty
-%    \end{macrocode}
-% ^^A Do not nest {\ttfamily tabularx} environments during trial runs. This
-% ^^A would waste time, and the global setting of \verb"\TX at cols" would break the
-% ^^A algorithm.
-%    \begin{macrocode}
- %    \expandafter\let\expandafter\tabularx\csname tabular*\endcsname
- %    \expandafter\let\expandafter\endtabularx\csname endtabular*\endcsname
-%    \end{macrocode}
-% ^^A Added at v1.05: disable \verb"\write"s during a trial run. This trick is
-% ^^A from the \TeX{}Book.\footnote{Actually the \TeX{}Book trick does
-% ^^A not work correctly, so changed for v2.05.}
-%    \begin{macrocode}
- %    \def\write{\begingroup
- %      \def\let{\afterassignment\endgroup\toks@}%
- %         \afterassignment\let\count@}%
-%    \end{macrocode}
-% ^^A Turn off warnings (see appendix D). Also prevent them being turned
-% ^^A back on by setting the parameter names to be registers.
-%    \begin{macrocode}
- %     \hbadness\@M
- %     \hfuzz\maxdimen
- %     \let\hbadness\@tempcnta
- %     \let\hfuzz\@tempdima
-%    \end{macrocode}
-% ^^A Make the table, and finish the hbox.
-% ^^A Since v1.06, \verb"\toks@" contains the preamble specification,
-% ^^A and possible optional argument, as well as the table body.
-%    \begin{macrocode}
- %     \expandafter\tabular\the\toks@
- %     \endtabular}%
-%    \end{macrocode}
-% ^^A Since v1.05 reset all \LaTeX\ counters, by executing \verb"\TX at ckpt".
-%    \begin{macrocode}
- %   \TX at ckpt
-%    \end{macrocode}
-% ^^A Print some statistics.
-% ^^A Added \verb"\TX at align" in v1.05, to line up the columns.
-%    \begin{macrocode}
- %   \TX at typeout@{\@spaces
- %      \expandafter\TX at align
- %         \the\wd\@tempboxa\space\space\space\space\space\@@
- %      \expandafter\TX at align
- %         \the\TX at col@width\space\space\space\space\space\@@
- %      \@spaces\the\TX at cols}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at align}
-% ^^A Macro added at v1.05, to improve the printing of the tracing info.
-%    \begin{macrocode}
- % \def\TX at align#1.#2#3#4#5#6#7#8#9\@@{%
- %   \ifnum#1<10 \space\fi
- %   \ifnum#1<100 \space\fi
- %   \ifnum#1<\@m\space\fi
- %   \ifnum#1<\@M\space\fi
- %   #1.#2#3#4#5#6#7#8\space\space}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\arraybackslash}
-% ^^A \verb"\\" hack.
-%    \begin{macrocode}
- % \ifx\arraybackslash\@undefined
- % \def\arraybackslash{\let\\\tabularnewline}
- % \fi
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\tracingtabularx}
-% ^^A Print statistics on column and table widths.
-%    \begin{macrocode}
- % \def\tracingtabularx{%
- %   %\def\TX at typeout{\PackageWarningNoLine{tabularx}}%
- %   \def\TX at typeout{\ClassWarningNoLine{memoir}}% <--- changed
- %   \def\TX at typeout@##1{\typeout{(tabularx) ##1}}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at typeout}
-% ^^A The default is to be to be quiet
-%    \begin{macrocode}
- % \let\TX at typeout\@gobble
- % \let\TX at typeout@\@gobble
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at ftn}
-% ^^A A token register for saving footnote texts.
-%    \begin{macrocode}
- % \newtoks\TX at ftn
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at ftntext}
-% ^^A \begin{macro}{\TX at xftntext}
-% ^^A Inside the alignment just save up the footnote text in a token
-% ^^A register.
-%    \begin{macrocode}
- % \long\def\TX at ftntext#1{%
- %   \edef\@tempa{\the\TX at ftn\noexpand\footnotetext
- %                     [\the\csname c@\@mpfn\endcsname]}%
- %   \global\TX at ftn\expandafter{\@tempa{#1}}}%
- % \long\def\TX at xftntext[#1]#2{%
- %   \global\TX at ftn\expandafter{\the\TX at ftn\footnotetext[#1]{#2}}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at trial@ftn}
-% ^^A On trial runs, gobble footnote texts.
-%    \begin{macrocode}
- % \long\def\TX at trial@ftn#1{}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A This last section was added at Version 1.02. Previous versions
-% ^^A documented the fact that \verb"\verb" did not work inside {\ttfamily
-% ^^A tabularx}, but that did not stop people using it! This usually put
-% ^^A \LaTeX\ into an irrecoverable error position, with error messages that
-% ^^A did not mention the cause of the error. The `poor man's \verb"\verb"' (and
-% ^^A \verb"\verb*") defined here is based on page 382 of the \TeX{}Book. As
-% ^^A explained there, doing verbatim this way means that spaces are not
-% ^^A treated correctly, and so \verb"\verb*" may well be useless, however I
-% ^^A consider this section of code to be error-recovery, rather than a real
-% ^^A implementation of verbatim.
-% ^^A
-% ^^A The mechanism is quite general, and any macro which wants to allow a
-% ^^A form of \verb"\verb" to be used within its argument may
-% ^^A \verb"\let\verb=\TX at verb". (Making sure to restore the real definition
-% ^^A later!)
-% ^^A
-% ^^A \verb"\verb" and \verb"\verb*" are subject to the following restrictions:
-% ^^A \begin{enumerate}
-% ^^A \item Spaces in the argument are not read verbatim, but may be skipped
-% ^^A       according to \TeX's usual rules.
-% ^^A \item Spaces will be added to the output after control words, even if
-% ^^A       they were not present in the input.
-% ^^A \item Unless the argument is a single space, any trailing space,
-% ^^A       whether in the original argument, or added as in (2),
-% ^^A       will be omitted.
-% ^^A \item The argument must not end with \verb"\", so \verb"\verb|\|" is not
-% ^^A      allowed, however, because of (3), \verb"\verb|\ |" produces
-% ^^A      \verb"\".
-% ^^A \item The argument must be balanced with respect to \verb"{" and \verb"}". So
-% ^^A      \verb"\verb|{|" is not allowed.
-% ^^A \item A comment character like \verb"%" will not appear verbatim. It will
-% ^^A       act as usual, commenting out the rest of the input line!
-% ^^A \item The combinations \verb"?`" and \verb"!`" will appear as
-% ^^A       {\ttfamily?`} and {\ttfamily!`} if the {\ttfamily cmtt} font is
-% ^^A       being used.
-% ^^A \end{enumerate}
-% ^^A
-% ^^A \begin{macro}{\TX at verb}
-% ^^A The internal definition of \verb"\verb". Spaces will be replaced by \verb"~", so
-% ^^A for the star-form, \verb"\let" \verb"~" be \verb*| |, which we obtain as
-% ^^A \verb"\uppercase{*}". Use \verb"{\ifnum0=`}\fi" rather than \verb"\bgroup" to allow
-% ^^A \verb"&" to appear in the argument.
-%    \begin{macrocode}
- % {\uccode`\*=`\ %
- % \uppercase{\gdef\TX at verb{%
- %   \leavevmode\null\TX at vwarn
- %   {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
- %   \@ifstar{\let~*\TX at vb}{\TX at vb}}}}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at vb}
-% ^^A Get the `almost verbatim' text using \verb"\meaning". The `\verb"!"' is added to
-% ^^A the front of the user supplied text, to ensure that the whole argument
-% ^^A does not consist of a single \verb"{ }" group. \TeX\ would strip the outer
-% ^^A braces from such a group. The `\verb"!"' will be removed later.
-% ^^A
-% ^^A Originally I followed Knuth, and had \verb"\def\@tempa{##1}", however this
-% ^^A did not allow \verb"#" to appear in the argument. So in v1.04, I changed
-% ^^A this to to use a token register, and \verb"\edef". This allows \verb"#" appear,
-% ^^A but makes each one appear twice!, so later we loop through, replacing
-% ^^A \verb"##" by \verb"#".
-%    \begin{macrocode}
- % \def\TX at vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
- %     \expandafter\TX at v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at v}
-% ^^A Strip the initial segment of the \verb"\meaning", including the `\verb"!"'
-% ^^A added earlier.
-%    \begin{macrocode}
- % \def\TX at v#1!{\afterassignment\TX at vfirst\let\@tempa= }
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A As explained above we are going to replace \verb"##" pairs by \verb"#". To do
-% ^^A this we need non-special \verb"#" tokens.  Make \verb"*" into a parameter
-% ^^A token so that we can define macros with arguments. The normal meanings
-% ^^A will be restored by the \verb"\endgroup" later.
-%    \begin{macrocode}
- % \begingroup
- % \catcode`\*=\catcode`\#
- % \catcode`\#=12
-%    \end{macrocode}
-% ^^A
-% ^^A \begin{macro}{\TX at vfirst}
-% ^^A As a special case, prevent the first character from being dropped.
-% ^^A This makes \verb"\verb*| |" produce \verb*| |. Then call \verb"\TX at v@".
-% ^^A This is slightly tricky since v1.04, as I have to ensure that an
-% ^^A actual \verb"#" rather than a command \verb"\let" to \verb"#" is passed on if the
-% ^^A first character is \verb"#".
-%    \begin{macrocode}
- % \gdef\TX at vfirst{%
- %   \if\@tempa#%
- %     \def\@tempb{\TX at v@#}%
- %   \else
- %     \let\@tempb\TX at v@
- %     \if\@tempa\space~\else\@tempa\fi
- %   \fi
- %   \@tempb}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at v@}
-% ^^A Loop through the \verb"\meaning", replacing all spaces by \verb"~". If the last
-% ^^A character is a space it is dropped, so that \verb"\verb*|\LaTeX|" produces
-% ^^A \verb"\LaTeX" not \verb*|\LaTeX |. The rewritten tokens are then further
-% ^^A processed to replace \verb"##" pairs.
-%    \begin{macrocode}
- % \gdef\TX at v@*1 *2{%
- %   \TX at v@hash*1##\relax\if*2\\\else~\expandafter\TX at v@\fi*2}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A \begin{macro}{\TX at v@hash}
-% ^^A The inner loop, replacing \verb"##" by \verb"#".
-%    \begin{macrocode}
- % \gdef\TX at v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX at v@hash\fi*2}
-%    \end{macrocode}
-% ^^A \end{macro}
-% ^^A
-% ^^A As promised, we now restore the normal meanings of \verb"#" and \verb"*".
-%    \begin{macrocode}
- % \endgroup
-%    \end{macrocode}
-% ^^A
-% ^^A \begin{macro}{\TX at vwarn}
-% ^^A Warn the user the first time this \verb"\verb" is used.
-%    \begin{macrocode}
- % \def\TX at vwarn{%
- %   \@warning{\noexpand\verb may be unreliable inside tabularx}%
- %   \global\let\TX at vwarn\@empty}
-%    \end{macrocode}
-% ^^A \end{macro}
-%    \begin{macrocode}
- % 
- % %%%%%%%%%% end Tabularx package code v2.11 %%%%%%%%%%%%%%%%%%%%%
- % 
- % 
- % 
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A    At this point we had better stop anyone trying to load the several
-% ^^A tabular-related packages (as effectively they are already loaded).
-%    \begin{macrocode}
- % %%\@memfakeusepackage{array}
- % %%\@memfakeusepackage{dcolumn}
- % %%\@memfakeusepackage{delarray}
- % %%\@memfakeusepackage{tabularx}
- % 
-%    \end{macrocode}
-% ^^A
-% ^^A
 %  
 % \subsection{Fear's rules}
 %
@@ -18317,514 +15399,17 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% The following is taken almost verbatim from the \Lpack{booktabs} package,
-% version~1.618, March 2003.
-%
+% As of Summer 2023 we instead load \Lpack{booktabs} directly and
+% remove it from emulation. The only change from the class code and
+% the current \Lpack{booktabs} code was using \cmd{\bktabrule} which
+% never seem to be changed at all.
+% \changes{v3.8}{2023/07/28}{Replaced booktabs embedding by loading
+% \Lpack{booktabs}}
 %    \begin{macrocode}
-%%%%%%%%%% Booktabs package code       %%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% slightly modified by PRW    %%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% by permission of Simon Fear %%%%%%%%%%%%%%%%%%%%%
-
+\RequirePackage{booktabs}[2020/01/12]
 %    \end{macrocode}
-% Danie Els is now (2005) the official maintainer of the \Lpack{booktabs} package. He provided me with
-% some updates to synchronize \Lpack{memoir}, \Lpack{booktabs} and support for \Lpack{colortbl} with \Lpack{booktabs}. I made the appropriate changes/extensions
-% on 2005/09/03 as part of version 1.618 of \Lpack{memoir}.
-%
-% \begin{macro}{\CT at arc@}
-% This supports the \Lpack{bookhands}/\Lpack{colortbl} package combination.
-%    \begin{macrocode}
-\AtBeginDocument{%
-  \providecommand*{\CT at arc@}{}}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\heavyrulewidth}
-% \begin{macro}{\lightrulewidth}
-% \begin{macro}{\cmidrulewidth}
-% \begin{macro}{\belowrulesep}
-% \begin{macro}{\belowbottomsep}
-% \begin{macro}{\aboverulesep}
-% \begin{macro}{\abovetopsep}
-% \begin{macro}{\cmidrulesep}
-% \begin{macro}{\cmidrulekern}
-% \begin{macro}{\defaultaddspace}
-% First we set up some new dimensions.
-%    \begin{macrocode}
-\newdimen\heavyrulewidth 
-\newdimen\lightrulewidth 
-\newdimen\cmidrulewidth  
-\newdimen\belowrulesep   
-\newdimen\belowbottomsep   
-\newdimen\aboverulesep   
-\newdimen\abovetopsep   
-\newdimen\cmidrulesep    
-\newdimen\cmidrulekern   
-\newdimen\defaultaddspace
-\heavyrulewidth=.08em
-\lightrulewidth=.05em
-\cmidrulewidth=.03em
-\belowrulesep=.65ex
-\belowbottomsep=\z@
-\aboverulesep=.4ex
-\abovetopsep=\z@
-\cmidrulesep=\doublerulesep
-\cmidrulekern=.5em
-\defaultaddspace=.5em
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % 
-% \begin{macro}{\@cmidla}
-% \begin{macro}{\@cmidlb}
-% \begin{macro}{\@aboverulesep}
-% \begin{macro}{\@belowrulesep}
-% \begin{macro}{\@thisruleclass}
-% \begin{macro}{\@lastruleclass}
-% \begin{macro}{\@thisrulewidth}
-% And some internal counters and other things of no interest to the end user:
-%    \begin{macrocode}
-\newcount\@cmidla
-\newcount\@cmidlb
-\newdimen\@aboverulesep
-\newdimen\@belowrulesep
-\newcount\@thisruleclass
-\newcount\@lastruleclass
-\@lastruleclass=0
-\newdimen\@thisrulewidth
-
-%    \end{macrocode}
-% which will be described as needed below.
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
 %
-% \begin{macro}{\futurenonspacelet}
-% \begin{macro}{\@BTfnslone}
-% \begin{macro}{\@BTfnsltwo}
-% \begin{macro}{\@BTfnslthree}
-% Next we define a very useful macro (more-or-less straight from the
-% \theTeXbook's Dirty Tricks chapter; documented there). Use
-% \cs{futurenonspacelet} instead of \cs{futurelet} when looking for the next
-% (non-space) token after a macro that has an argument. (After a macro
-% without an argument, space is ignored anyway, so \cs{futurenonspacelet}
-% wouldn't be needed.) This hack allows users to type white
-% space between successive rule commands.
-%    \begin{macrocode}
-\def\futurenonspacelet#1{\def\@BTcs{#1}%
- \afterassignment\@BTfnslone\let\nexttoken= }
-\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
-\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
- \else\let\next=\nexttoken\fi \next}
-\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \subsubsection{Full width  rules}
-%
-% When we are not in a \texttt{longtable} environment, we can simply
-% implement the full width rules as a \cs{hrule} in  a \verb?\noalign{}?
-% group. But within a \texttt{longtable}, the rule has to be drawn like a
-% \verb?\cmidrule{1-\LT at cols}? (the rationale for this is explained in the
-% \texttt{longtable} documentation).
-
-% In order to allow for both, all the rule macros have to
-% open a \cs{noalign} group immediately, while they work out whether
-% they have been called within a \texttt{longtable}; if you don't do this,
-% \TeX's underlying \cs{halign} process gets hiccups.
-% I use \LaTeX's
-% dirty trick (\verb?\ifnum=0`}?) to fool the parser that the bracket
-% count is OK. The bracket really gets closed after all the skipping
-% at the end of the \cs{@BTendrule} macro.
-
-% The class 1 rules, and \cs{specialrule}, really only differ in the
-% defaults for space above and
-% below, and the width, passed to a common routine, \cs{@BTrule},
-% described below. The spaces, \cs{@aboverulesep} and \cs{@belowrulesep},
-% are set within the \cs{noalign} group, so are inherited by
-% \cs{@BTrule}. Similarly, \cs{@BTrule} knows as much as it needs to
-% about the routine that called it by examining the inherited
-% \cs{@thisruleclass}. The optional width argument is parsed by
-% \cs{@BTrule} after being set to default if absent.
-
-%
-% \begin{macro}{\toprule}
-% \begin{macro}{\midrule}
-% \begin{macro}{\bottomrule}
-% \begin{macro}{\specialrule}
-%    \begin{macrocode}
-\def\toprule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\abovetopsep
-  \global\@belowrulesep=\belowrulesep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
-
-\def\midrule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\aboverulesep
-  \global\@belowrulesep=\belowrulesep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\lightrulewidth]}}
-
-\def\bottomrule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\aboverulesep
-  \global\@belowrulesep=\belowbottomsep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
-
-\def\specialrule#1#2#3{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=#2\global\@belowrulesep=#3\global\@thisruleclass=\tw@
-  \@BTrule[#1]}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \begin{macro}{\addlinespace}
-% An \cs{addlinespace} is essentially a zero-width rule with
-% zero space above and argument (or default) space below. But because
-%  the rule is not actually drawn, but is just a \cs{vskip}, there is no
-%  need to check if we're in a longtable, so we don't need to call
-%  \cs{@BTrule} as for `real' rules. But we do share the \cs{@BTendrule}
-%  lookahead and flagsetting code (described below), and the \cs{vskip} is done there.
-%    \begin{macrocode}
-\def\addlinespace{\noalign{\ifnum0=`}\fi
-  \@ifnextchar[{\@addspace}{\@addspace[\defaultaddspace]}}
-\def\@addspace[#1]{\global\@belowrulesep=#1\global\@thisruleclass=\tw@
-  \futurelet\@tempa\@BTendrule}
-
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\@BTrule}
-% All the rules (except \cs{addlinespace}) share this code.
-%    \begin{macrocode}
-\def\@BTrule[#1]{%
-%    \end{macrocode}
-% Note (2016/05/16): code rearranged a bit to come back into sync with
-% \Lpack{booktabs} v1.618033.
-%
-% \changes{v3.7f}{2016/05/16}{changed the order so the \cs{ifx} lines
-% come first. From booktabs 2016/04/27 v1.618033}
-% \changes{v3.7k}{2020/02/06}{changed to be in sync with booktabs
-% datad 2020/01/12. The comments are a carbon copy from booktabs.dtx}
-%  Now we work out, by a very nasty hack, if we're within a
-%  \verb|longtable|. It's easy if \verb=\longtable= isn't even defined: then we
-%  can't be. But it is not enough just to check if \verb=longtable= is
-%  loaded --- we might be within an ordinary table rather than a
-%  longtable. So we look to see if \verb=\hline= has been re-defined
-%  from its \LaTeX\ definition to be the same as
-%  \verb=\LT at hline=. (Longtable currently does this redefinition when it opens a
-%  \verb=longtable= environment, but not globally, so it is
-%  cleared it when the environment closes.) Another
-%  package could potentially do this! And \verb=longtable= might change the
-%  way it implements this! So, it is not entirely safe, but I have
-%  found no better way so far.
-%
-%  We set up \verb=\@BTswitch= to call \verb=\@BTnormal= or \verb=\@BLTrule=, as
-%  appropriate, then call it.
-%    \begin{macrocode}
-  \ifx\longtable\undefined
-    \let\@BTswitch\@BTnormal
-  \else\ifx\hline\LT at hline
-    \nobreak
-    \let\@BTswitch\@BLTrule
-  \else
-    \let\@BTswitch\@BTnormal
-  \fi\fi
-%    \end{macrocode}
-% Call \verb=\@BTswitch= at end of macro
-%    \begin{macrocode}
-  \global\@thisrulewidth=#1\relax
-%    \end{macrocode}
-% Save the width argument (if the user didn't give one, then the
-% calling routine will have called \cs{@BTrule} with the default) in a global
-% variable for later use when drawing the rule.
-%    \begin{macrocode}
-  \ifnum\@thisruleclass=\tw@\vskip\@aboverulesep\else
-%    \end{macrocode}
-% Specialrules always insert specified space above. (Note: addlinespaces
-% don't come here).
-%    \begin{macrocode}
-  \ifnum\@lastruleclass=\z@\vskip\@aboverulesep\else
-  \ifnum\@lastruleclass=\@ne\vskip\doublerulesep\fi\fi\fi
-%    \end{macrocode}
-% After text (last rule class 0), precede the rule by \cs{aboverulesep};
-% but if immediately after a
-% previous rule, insert a \cs{doublerulesep}.
-%
-%    \begin{macrocode}
-  \@BTswitch}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@BTnormal}
-% This is when we're \emph{not} within a longtable. We are already in a
-%  \cs{noalign} group, all we need do is draw an \cs{hrule} and gobble any
-%  trailing spaces, then call the closing routine with \cs{@tempa} set
-%  equal to the next token in the document.
-%    \begin{macrocode}
-% \def\@BTnormal{\hrule
-%   \@height \@thisrulewidth\futurenonspacelet\@tempa\@BTendrule}
-\def\@BTnormal{%
-%%  \bktabrule{\@thisrulewidth}
-  {\CT at arc@\bktabrule{\@thisrulewidth}}%
-  \futurenonspacelet\@tempa\@BTendrule}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@BLTrule}
-% This is for full width rule within a \texttt{longtable}. First we check if
-%  a kerning argument has been used; if so let \cs{@@BLTrule} read it,
-%  else call \cs{@@BLTrule} with an empty string:
-%    \begin{macrocode}
-\def\@BLTrule{\@ifnextchar({\@@BLTrule}{\@@BLTrule()}}
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@@BLTrule}
-%    \begin{macrocode}
-\def\@@BLTrule(#1){\@setrulekerning{#1}%
-\global\@cmidlb\LT at cols
-%    \end{macrocode}
-% The \cs{@setrulekerning} routine parses the kerning argument tokens
-% and sets global kerning widths accordingly (or to defaults, if user
-% hasn't set them explicitly). The global assignment to \cs{@cmidlb}
-% sets up the column count for the \cs{@cmidruleb} macro, which is
-% shared with \verb?cmidrules?.
-%    \begin{macrocode}
-\ifnum0=`{\fi}%
-%    \end{macrocode}
-% Close the currently open \cs{noalign} group. Within a \texttt{longtable},
-% rules are all to be drawn as leaders within a text box that is
-% \cs{LT at cols} columns wide.
-%    \begin{macrocode}
-\@cmidruleb
-%    \end{macrocode}
-% Draw the rule. We share the \cs{@cmidruleb} code with ordinary \cs{cmidrule}s.
-%    \begin{macrocode}
-\noalign{\ifnum0=`}\fi
-%    \end{macrocode}
-% We have to open a new noalign immediately else \TeX{} will start a new
-%    text box where we don't want one. Then, after gobbling any
-%    unwanted white space, we call the closing routine.
-%    \begin{macrocode}
-\futurenonspacelet\@tempa\@BTendrule}
-
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@BTendrule}
-% We look one step ahead (token is in \cs{@tempa}) to see if another
-% rule follows (shame on user!). If so, we set \cs{@lastruleclass} equal
-% to \cs{@thisruleclass} (thus setting it up for the following rule). If
-% there isn't a following rule, we clear \cs{@lastruleclass} (ie set it
-% to zero), which isn't technically true since we have just drawn a
-% rule, but sets it up correctly for the next rule encountered, which
-% must be following some intervening text.
-%    \begin{macrocode}
-\def\@BTendrule{%
-  \ifx\@tempa\toprule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\midrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\bottomrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\cmidrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\specialrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\addlinespace\global\@lastruleclass=\@thisruleclass
-  \else\global\@lastruleclass=\z@\fi\fi\fi\fi\fi\fi
-  \ifnum\@lastruleclass=\@ne\relax\else\vskip\@belowrulesep\fi
-  \ifnum0=`{\fi}}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \subsubsection{Special subrules}
-%
-% \begin{macro}{\@setrulekerning}
-% The following code parses the trimming arguments (if there are any)
-%    for \cs{cmidrule} or a \cs{BLTrule}. The rule
-%     will be trimmed left and right by \cs{cmrkern at l} and \cs{cmrkern at l},
-%     which are zero by default, set to \cs{cmidrulekern} by the plain
-%     \verb?(lr)? arguments, or user set as in \verb?(r{.5em})?. We parse token by
-%     token through the arguments. The
-%     tokens \verb?r? and \verb?l? cause \cs{cmrkern at r} or \cs{cmrkern at l} to be set to
-%     \cs{cmidrulekern}. There is no lookahead to see if a width is the
-%     next token; this strategy is efficient for the plain commands,
-%     while inefficient for the qualified commands, but more importantly
-%     it is much easier to program. Tokens \verb?r? and \verb?l? also set
-%     \cs{cmrswitch} so that if the next token turns out to be
-%     \marg{wd} then the kerning will be done on the side
-%     currently specified. I have been too lazy to program an error
-%     message should one encounter tokens other than \verb?r?, \verb?l? or
-%     \marg{wd}.
-% \changes{v1.618}{2005/09/03}{Fixed bug in booktabs trim command by improving character comparison code in \cs{@setrulekerning} (mempatch v3.8)}
-%    \begin{macrocode}
-\def\@setrulekerning#1{%
-  \global\let\cmrkern at l\z@
-  \global\let\cmrkern at r\z@
-  \@tfor\@tempa :=#1\do
-  {\def\@tempb{r}%
-   \ifx\@tempa\@tempb
-     \global\let\cmrkern at r\cmidrulekern
-      \def\cmrsideswitch{\cmrkern at r}%
-   \else
-     \def\@tempb{l}%
-     \ifx\@tempa\@tempb
-       \global\let\cmrkern at l\cmidrulekern
-       \def\cmrsideswitch{\cmrkern at l}%
-     \else
-       \global\expandafter\let\cmrsideswitch\@tempa
-     \fi
-   \fi}}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\cmidrule}
-% \begin{macro}{\@cmidrule}
-% \begin{macro}{\@@cmidrule}
-% The \cs{cmidrule} re-uses \cs{@lastruleclass} in an entirely different
-%  way from the full width rules. (Maybe I should have used a
-%  different flag; it seemed efficient at the time \ldots). This
-% is (left) set to one if you are in the middle of a row of
-% \cs{cmidrules}, or starting a new one (with \cs{morecmidrules}).
-% Otherwise, when \cs{@lastruleclass} is zero, we precede the
-% rule with \cs{aboverulesep}.
-%    \begin{macrocode}
-\def\cmidrule{\noalign{\ifnum0=`}\fi
-    \@ifnextchar[{\@cmidrule}{\@cmidrule[\cmidrulewidth]}}
-\def\@cmidrule[#1]{\@ifnextchar({\@@cmidrule[#1]}{\@@cmidrule[#1]()}}
-\def\@@cmidrule[#1](#2)#3{\@@@cmidrule[#3]{#1}{#2}}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@@cmidrule}
-% The above is fiddling around to set defaults for missing optional
-% arguments. We also pass to \cs{@@@cmidrule} in a different order,
-% namely =[a-b]=\verb?{width required}= \verb?{kerning commands}= (this being
-% the order in which the arguments are actually processed):
-%    \begin{macrocode}
-\def\@@@cmidrule[#1-#2]#3#4{\global\@cmidla#1\relax
-    \global\advance\@cmidla\m at ne
-    \ifnum\@cmidla>0\global\let\@gtempa\@cmidrulea\else
-    \global\let\@gtempa\@cmidruleb\fi
-    \global\@cmidlb#2\relax
-    \global\advance\@cmidlb-\@cmidla
-%    \end{macrocode}
-% This has set up a switch (\cs{@gtempa}) to call the relevant routine,
-% \cs{@cmidrulea} or \cs{@cmidruleb}, depending on whether we start
-% from column one or not.
-%    \begin{macrocode}
-    \global\@thisrulewidth=#3
-%    \end{macrocode}
-% That is, set per default or given argument. Then parse any trimming
-% arguments to set, globally, \cs{cmrkern at r} and \cs{cmrkern at l} accordingly:
-%    \begin{macrocode}
-    \@setrulekerning{#4}
-%    \end{macrocode}
-% Now insert space above if needed, close the \cs{noalign},
-% then switch to appropriate rule drawing routine as determined
-% above (\cs{let} to \cs{@gtempa}):
-%    \begin{macrocode}
-    \ifnum\@lastruleclass=\z@\vskip \aboverulesep\fi
-    \ifnum0=`{\fi}\@gtempa
-%    \end{macrocode}
-% Having now drawn the rule,
-% open another \cs{noalign}, and call the closing routine:
-%    \begin{macrocode}
-    \noalign{\ifnum0=`}\fi\futurenonspacelet\@tempa\@xcmidrule}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@xcmidrule}
-% In this closing routine, see if another \cs{cmidrule} follows;
-% if so, backspace
-% vertical so it will line up with the one you just drew,
-% and setting \cs{@lastruleclass} to 1 will suppress
-% adding space above the next. If a \cs{morecimdrules} follows,
-% we add (positive) \cs{cmidrulesep} (and again set \cs{@lastruleclass}
-% to one). Otherwise this is the last rule of the current group
-% and we can just add \cs{belowrulesep}. Finally, we close the \cs{noalign}.
-%    \begin{macrocode}
-\def\@xcmidrule{\ifx\@tempa\cmidrule\vskip-\@thisrulewidth
-    \global\@lastruleclass=\@ne\else
-    \ifx\@tempa\morecmidrules\vskip \cmidrulesep
-    \global\@lastruleclass=\@ne\else
-    \vskip \belowrulesep\global\@lastruleclass=\z@\fi\fi
-    \ifnum0=`{\fi}}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@cmidrulea}
-% \begin{macro}{\@cmidruleb}
-% This code (called below) actually draws the rules. They are drawn
-% as boxes in text, rather than in a \cs{noalign} group, which permits
-% the left and right kerning.
-% \changes{v3.7f}{2016/05/16}{Added \cs{kern}\cs{z@} to comply to
-% latest booktabs updates. In Booktabs they were added to protect
-% against unskips.}
-%    \begin{macrocode}
-\def\@cmidrulea{%
-  \multispan\@cmidla&\multispan\@cmidlb
-%%    \unskip\hskip \cmrkern at l\leaders\bktabrule{\@thisrulewidth}\hfill
-    \unskip\hskip \cmrkern at l{%
-    \CT at arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
-    \hskip \cmrkern at r\cr}
-\def\@cmidruleb{%
-  \multispan\@cmidlb
-%%    \unskip\hskip \cmrkern at l\leaders\bktabrule{\@thisrulewidth}\hfill
-  \unskip\hskip \cmrkern at l{%
-    \CT at arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
-    \hskip \cmrkern at r\cr}
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\morecmidrules}
-% This is really a dummy command; all the work is done above
-% within the \cs{cmidrule} routine. We look one step ahead there
-% to see if a \cs{morecmidrules} follows the current \cs{cmidrule},
-% and if so set the flag. Otherwise,  \cs{morecmidrules} itself
-% does nothing.
-%    \begin{macrocode}
-\def\morecmidrules{\noalign{\relax}}
-
-%%%%%%%%%% end of Booktabs package code %%%%%%%%%%%%%%%%%%%%%
-
-%    \end{macrocode}
-% \end{macro}
-%
-% Ensure that the real \Lpack{booktabs} package can't get called.
-% \changes{v1.618}{2005/09/03}{Killed use of real booktabs package (mempatch v3.12)}
-%    \begin{macrocode}
-%%\@memfakeusepackage{booktabs}
-
-%    \end{macrocode}
-%
-%
-%
 % \subsection{Continuous tabulars}
 %
 %    The standard \texttt{tabular} environment is wrapped inside a box
@@ -19472,7 +16057,7 @@
 \newcommand{\newfloat}[4][\@empty]{%
 %    \end{macrocode}
 % \begin{macro}{\ftype at X}
-%  Define the float type, set it to the float counter, and double
+%  Define the float type, set it to the float counter, and increase
 % the counter afterwards.
 %    \begin{macrocode}
 %%%  \@namedef{ftype@#2}{\value{newflo at tctr}}
@@ -19555,18 +16140,8 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \changes{v3.6i}{2011/02/18}{Added this instead of inserting the
-% adjustment code directly into the environment definitions}
-% \changes{v3.7g}{2017/05/08}{Moved into delayed \cs{@xfloat} redef as
-% we need it to run after \cs{normalsize}}
 % \begin{macro}{\@xfloat}
-%   In order to inject adjustment code into the core of the floats we
-%   will need to patch the code float macros a little.
-%    \begin{macrocode}
-  %\let\mem at old@xfloat\@xfloat
-  %\def\@xfloat#1[#2]{\mem at old@xfloat{#1}[#2]\@nameuse{#1adjustment}}
-%    \end{macrocode}
-%   
+%   Was adjusted earlier.
 % \end{macro}
 %
 % \begin{macro}{\setfloatlocations}
@@ -20781,6 +17356,8 @@
 % 
 % \changes{v3.7i}{2019/10/24}{Added a \cs{par} to the start. This can
 % get rid of sporadic spaces caused by hyperref changing \cs{refstepcounter}}
+% \changes{v3.8}{2023/08/02}{Added \cs{mem at step@subcounter} instead
+% of refstep}
 %    \begin{macrocode}
 \newcommand{\subcaption}{%
   \par
@@ -20789,7 +17366,7 @@
     \ifdonemaincaption\else
       \advance\csname c@\@captype\endcsname\@ne
     \fi
-    \refstepcounter{sub\@captype}\@contkeep
+    \mem at step@subcounter%
     \@ifnextchar [%
       {\@memsubcap{sub\@captype}}%
       {\@memsubcap{sub\@captype}[\@empty]}}
@@ -20840,12 +17417,14 @@
 % \begin{macro}{\contsubcaption}
 % \cs{contsubcaption}\oarg{caption} is the continued version of
 % \cs{subcaption}.
+% \changes{v3.8}{2023/08/02}{Added \cs{mem at step@subcounter} instead
+% of refstep}
 %    \begin{macrocode}
 \newcommand{\contsubcaption}{%
-  \bgroup
+  \bgroup%
     \let\label=\memsub at label
-    \@contset
-    \refstepcounter{sub\@captype}\@contkeep
+    \@contset%
+    \mem at step@subcounter%
     \@ifnextchar [%
       {\@memsubcap{sub\@captype}}%
       {\@memsubcap{sub\@captype}[\@empty]}}
@@ -20867,9 +17446,12 @@
 % \begin{macro}{\mem at step@subcounter}
 %   \changes{v3.7i}{2019/10/24}{Added}
 %  Utility macro to save some typing.
+% \changes{v3.8}{2023/08/02}{Added
+% \Lhook{memoir/subcaption/aftercounter} hook}
 %    \begin{macrocode}
 \newcommand\mem at step@subcounter{%
   \refstepcounter{sub\@captype}\@contkeep%
+  \UseHook{memoir/subcaption/aftercounter}%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -21131,7 +17713,10 @@
 % \end{macro}
 % 
 % \begin{macro}{\memsub at label}
-% These are copies of \cs{sub at label} and \cs{subref}.
+% Basically we want a \cmd{\label} inside the caption to set
+% \emph{two} labels with different values of
+% \cmd{\@currentlabel}. First locally \cmd{\label} is set to
+% \cmd{\mem at sublabel} defined as
 %    \begin{macrocode}
 \newcommand{\memsub at label}{%
   \@ifnextchar (%
@@ -21142,11 +17727,18 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% As of summer 2023 we are autoloading \Lpack{nameref}, thus the code
+% for \cmd{\sf@@memsub at label} can be greatly reduced plus we can use
+% the \cmd{\label} that has the \Lpack{nameref} extensions, then we
+% don't have to look out for changes in say \Lpack{hyperref} etc.
+% 
 % \begin{macro}{\sf at memsub@label}
-% This is a copy of \cs{sf at sub@label}.
+% \changes{v3.8}{2023/07/31}{Set \cs{@currentlabelname} directly
+% instad of using \cs{mem at currentlabelname}}
 %    \begin{macrocode}
 \def\sf at memsub@label(#1)#2{%
-  \protected at edef\mem at currentlabelname{#1}%
+  \protected at edef\@currentlabelname{#1}%
+  % if available we can also use %  \ExpandArgs{x}\mem at set@cln{#1}
   \sf@@memsub at label{#2}}
 
 %    \end{macrocode}
@@ -21153,96 +17745,45 @@
 % \end{macro}
 %
 % \begin{macro}{\sf@@memsub at label}
-% This is an expanded copy of \cs{sf@@sub at label} processed after any packages may
-% have been loaded.
-% An added complexity here is when \Lpack{showkeys} is used. It
-% redefines \cs{label} to write it in the margins. But the
-% \cs{sf@@memsub at label} writes the label to aux directly. So in order
-% to support \Lpack{showkeys}, we add a hook, and define this hook if
-% \Lpack{showkeys} is loaded.
-% \changes{v3.7g}{2018/02/28}{Added hook into \cs{sf@@memsub at label},
-% issue reported via \texttt{https://tex.stackexchange.com/q/374301/3929}}
+% \changes{v3.8}{2023/07/31}{reimplemented}
+% This sets two labels, the user given one an one prefixed by
+% \verb?sub@?. The difference between them is the value of
+% \cmd{\@currentlabel}. For the latter we will aditionally locally
+% disable showkeys.
+%
+% First we'd like to have a copy of the ``kernel'' \cmd{\label}
+% command. Packages may have added stuff to make a copy at begin doc.
+% \begin{macro}{\mem at kernel@label}
 %    \begin{macrocode}
-\newcommand\sf@@memsub at label@hook[1]{}
+\AtBeginDocument{
+  \let\mem at kernel@label\label
+}
 
-\AtBeginDocument{%
-  \@ifpackageloaded{nameref}{%
 %    \end{macrocode}
-% The \Lpack{nameref} package is loaded.
+% Next we define the macro it self in terms of this
 %    \begin{macrocode}
-    \newcommand*{\sf@@memsub at label}[1]{%
-      \@bsphack
-      \sf@@memsub at label@hook{#1}%
-      \protected at write\@auxout{}{%
-        \string\newlabel{#1}%
-          {{\@nameuse{p at sub\@captype}\@nameuse{@@thesub\@captype}}%
-          {\thepage}%
-          {\mem at currentlabelname\relax}%
-          {\@currentHref}{}}}%
-      \protected at write\@auxout{}{%
-        \string\newlabel{sub@#1}%
-          {{\@nameuse{@@thesub\@captype}}%
-          {\thepage}%
-          {\mem at currentlabelname\relax}%
-          {\@currentHref}{}}}%
-  \@esphack}
-  }{% no nameref
-    \@ifpackageloaded{hyperref}{%
+\newcommand\sf@@memsub at label[1]{%
+  \@bsphack%
+  \mem at kernel@label{#1}% normal label
 %    \end{macrocode}
-% The \Lpack{hyperref} package is loaded, but not \Lpack{nameref}.
+%  Next locally redefine \cmd{\@currentlabel} so the next label only
+%  gets the sub number. TODO: make the format
+%  configurable. Additionally disable showkeys for this extra
+%  label. This way we do not need a hook into the construction to
+%  support \Lpack{showkeys} that just comes from the normal \cmd{\label}.
 %    \begin{macrocode}
-      \newcommand*{\sf@@memsub at label}[1]{%
-        \@bsphack
-        \sf@@memsub at label@hook{#1}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{#1}%
-            {{\@nameuse{p at sub\@captype}\@nameuse{@@thesub\@captype}}%
-            {\thepage}%
-            {\mem at currentlabelname\relax}%
-            {\@currentHref}{}}}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{sub@#1}%
-            {{\@nameuse{@@thesub\@captype}}%
-            {\thepage}%
-            {\mem at currentlabelname\relax}%
-            {\@currentHref}{}}}%
-    \@esphack}
-    }{% no hyperref
-%    \end{macrocode}
-% Neither the \Lpack{hyperref} nor the \Lpack{nameref}
-% package is loaded.
-%    \begin{macrocode}
-      \let\@memoldlabel\label
-      \newcommand*{\sf@@memsub at label}[1]{%
-        \@bsphack
-        \sf@@memsub at label@hook{#1}%
-        \@memoldlabel{#1}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{sub@#1}%
-            {{\@nameuse{@@thesub\@captype}}%
-            {\thepage}}}%
-    \@esphack}
-    }{}%
-  }% end no nameref
-%    \end{macrocode}
-% Next add the hook redefinition if \Lpack{showkeys} is loaded. Please
-% note that the placement of the \Lpack{showkeys} label, might be a
-% little strange.
-% \changes{v3.7g}{2018/02/28}{added}
-% \changes{v3.7k}{2020/02/06}{Added a check on \cs{SK@}, if not
-% defined showkeys is running under final mode}
-%    \begin{macrocode}
-   \@ifpackageloaded{showkeys}{%
-     \ifdefined\SK@\relax 
-       \renewcommand\sf@@memsub at label@hook[1]{%
-        \SK@\SK@@label{#1}%
-      }
-     \fi 
-  }{}
-} % end AtBeginDocument
+  \begingroup%
+  % \ExpandArgs{x}\mem at set@cln{\@nameuse{@@thesub\@captype}}
+  \protected at edef\@currentlabel{\@nameuse{@@thesub\@captype}}% sub at label
+  \def\showkeyslabelformat##1{}% disable showkeys for this extra label
+  \mem at kernel@label{sub@#1}% internally generated sub at label
+  \endgroup%
+  \@esphack%
+}
 
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\subcaptionref}
 % This is a copy of the \cs{subref} macro.
@@ -22465,7 +19006,7 @@
 % \begin{macro}{\eminnershape}
 % \begin{macro}{\emph}
 % The old emphasis font command (the original \cs{em} is defined in the
-% kernel file \file{ltfssini.dtx}, coded here as \cs{@m at m@m}).
+% kernel file \file{ltfssini.dtx}).
 % \changes{v0.2}{2001/06/03}{Redid coding for \cs{emph} and \cs{em}}
 % \changes{v1.618}{2005/09/03}{Dont' deprecate \cs{em} and deleted \cs{@mem at emwarn} (mempatch v3.0)}
 % \changes{v1.618}{2005/09/03}{Completely redid \cs{em} and \cs{emph}, matching latest fixltx2e package (mempatch v3.3)}
@@ -22534,51 +19075,63 @@
 %
 % \subsection{Title referencing}
 %
-% This is based on DA's \Lpack{titleref} package~\cite{TITLEREF}. 
-% The following 
-% remarks are taken from that package.
+% \changes{v3.8}{2023/07/25}{Entire section rewritten}
+% As of Summer 2023 this has been redone by directly loading the
+% \Lpack{nameref} package instead. It is loaded without changing the
+% sectional macros, which are in turn updated to set
+% \cs{@currentlabelname} for the new kernel label system to
+% pickup. The new kernel label system also requires us not to modify
+% \cs{label} so the switch was required.
 %
+% \begin{macro}{\titleref}
+%   Instead of defining our own macro we now let \cs{titleref} be an
+%   alias for \cs{nameref}. Do remember that it also have a starred
+%   version.
+%    \begin{macrocode}
+% disable nameref sectional patches (the macro just needs to be defined)
+\def\NR at nopatch@sectioning{set}
+\def\NR at nopatch@caption{set}
+\RequirePackage{nameref}
+\newcommand\titleref{\nameref}
+
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mem at set@cln}
+%  We'll need to set \cs{@currentlabelname} in various places. The
+%  title may need to be cleaned. \Lpack{nameref} provides
+%  \cs{NR at gettitle} and we just use our own name for it.
+%    \begin{macrocode}
+\def\mem at set@cln{\NR at gettitle}
+%    \end{macrocode}
+% \end{macro}
 %
-%  Titles for numbered sectioning units and for floats with captions are
-%  the same as the respective TOC, LOF, or LOT entry (even when no TOC is
-%  printed).  When a short title is provided (\verb?\section[short]{long}?)
-%  it will be used for the \cs{titleref}.  This is especially useful for
-%  figure captions.  Unnumbered sections take their title reference from
-%  the printed title.  Beware!  This turns the title into a moving argument
-%  when it normally is not, and will cause weird errors if there are
-%  `fragile' commands present.
+% \begin{macro}{\M at gettitle}
+%   All the sectional macros in memoir has been using \cs{M at gettitle}
+%   for years to access the title to use for \cs{titleref}. We simply
+%   change its definition to use our simpler case. Do remember that if
+%   the argument for \cs{M at gettitle} is a macro, it needs to be
+%   expanded once.
+%    \begin{macrocode}
+\newcommand\M at gettitle[1]{\mem at set@cln{#1}}      
+%    \end{macrocode}
+% \end{macro}
 %
-%  Enumerated lists do not have titles and simply inherit the title of
-%  their section.
-%
-%  The format of the title reference is controlled by the command
-%  \cs{theTitleReference}, which can be redefined with \cs{renewcommand}.
-%  It takes two parameters: the number and the title. The number is
-%  just the regular \cs{ref} and it is WRONG in unnumbered sections.
-%  Beware!  The default definition is the unadorned title.  You could
-%  do, for example, \\
-%  \verb?\renewcommand{\theTitleReference}[2]{#1\ \emph{#2}}?.
-%
-%  The title of the current section is also available without \cs{label}:
-%  Use the command \cs{currenttitle} to generate a \cs{titleref} to the current
-%  section.  If you have redefined \cs{theTitleReference} to print the number
-%  with the title, be aware that the two may not correspond:  In a numbered
-%  list the number will show the current item but the title will show the
-%  current section, but in an unnumbered section the number will show
-%  some previous section number.
-%
-%  The big problem with the \verb?[usetoc]? method is that \cs{titleref} will
-%  not refer to a \cs{label} which was given in the title or caption itself;
-%  the label must be placed after the sectioning command or the caption.
-%  If you make a title-reference to a label given in a title, you will get
-%  a warning message.
-%
+% In the sectional macros the title we will be giving to
+% \cs{@currentlabelname} will be the title for the toc or if requested
+% (and avaiable) the title for the header. That is
+% \begin{verbatim}
+% \chapter{title}               % sends title to toc and header, so use title
+% \chapter[toc]{title}          % sends toc to toc and header, so use toc
+% \chapter[toc][header]{title}  % data depends on \headnameref and
+%                               % \tocnameref (default)
+% \end{verbatim}
 % \changes{v1.4}{2003/11/16}{Added title referencing (from patch v1.4)}
 %
 % \begin{macro}{\ifheadnameref}
 % \begin{macro}{\headnameref}
 % \begin{macro}{\tocnameref}
-% \cs{ifheadnameref}: FALSE use ToC entry, TRUE use header entry
+% \cs{ifheadnameref}: FALSE use ToC entry, TRUE use header entry. Used
+% inside the sectional macros that support two optional arguments.
 % \changes{v1.61803}{2008/01/30}{Added \cs{headnameref} and \cs{tocnameref}}
 %    \begin{macrocode}
 \newif\ifheadnameref
@@ -22590,120 +19143,52 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\theTitleReference}
-% \cs{theTitleReference}\marg{num}\marg{title} is the style for typesetting
-%  a referenced (number and) title.
+% Following the 2023 reimplementation of \cmd{\titleref} the following
+% public macros are no longer used and are redefined to either do
+% nothing or give an error.
+% \begin{macro}{\namerefon}
+% \begin{macro}{\namerefoff}
+% Was used to enable (default) or disable support for
+% \cmd{\titleref}. Now does nothing.
 %    \begin{macrocode}
-\newcommand{\theTitleReference}[2]{#2}
-
+\providecommand\namerefon{\@memwarn{\protect\namerefon\space no longer does anything}}     
+\providecommand\namerefoff{\@memwarn{\protect\namerefoff\space no longer does anything}}     
 %    \end{macrocode}
 % \end{macro}
-%
-% \begin{macro}{\label}
-% This redefinition of \cs{label} is intended to work with other redirections
-% of \cs{label}, if they record extra information in a similar way.
-%    \begin{macrocode}
-\let\@mem at old@label\label
-\def\label#1{\@bsphack\begingroup
-  \protected at edef\@currentlabel{\protect\M at TitleReference
-      {\@currentlabel}{\M at currentTitle}}%
-  \@mem at old@label{#1}%
-  \endgroup \@esphack}%
-
-%    \end{macrocode}
 % \end{macro}
-%
-% \begin{macro}{\@mem@@gettitle}
-% \cs{@mem@@gettitle}\marg{title} grabs a title text.
-%    \begin{macrocode}
-\def\@mem@@gettitle#1{\begingroup \let\protect\@unexpandable at protect
-    \let\label\@mem at nestwarn 
-    \let\index\@gobble \let\glossary\@gobble
-    \let\markboth\@gobbletwo \let\@mkboth\@gobbletwo 
-    \let\markright\@gobble
-    \edef\@tempa{\noexpand\def\noexpand\M at currentTitle{#1}}%
-  \expandafter\endgroup\@tempa}
-
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@mem at nestwarn}
-% \begin{macro}{\M at TitleReference}
-%    \begin{macrocode}
-\let\@mem at nestwarn\@gobble
-\let\M at TitleReference\@firstoftwo
-
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\titleref}
 % \begin{macro}{\currenttitle}
-% \begin{macro}{\@mem at titleref}
-% \begin{macro}{\@mem at titlerefnolink}
-%   \cs{titleref}\marg{key} prints the title corresponding to
-%   \verb?\label{key}?.  \cs{currenttitle} prints the latest title.
-% \cs{titleref} extended to support a starred version that will not
-% provide hyperlinks when using  \Lpack{hyperref}. The
-% \Lpack{hyperref} definition of \cs{@mem at titlerefnolink} is found
-% in \Lpack{memhfixc}.
-% \changes{v1.6180339c}{2009/01/18}{Extended \cs{titleref}, suggestion
-% on ctt by martin at helios.de}
+%   \cmd{\currenttitle} was advertised to give the most recent
+%   sectional title. It is better to be more specific and use a label
+%   and \cmd{\titleref}. Now defined to give an error.
 %    \begin{macrocode}
-\newcommand*\@mem at titleref[1]{\begingroup 
-  \let\numberline\@gobble
-  \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
-  \ref{#1}\endgroup}
-\let\@mem at titlerefnolink\@mem at titleref
-
-\DeclareRobustCommand\titleref{\@ifstar{\@mem at titlerefnolink}{\@mem at titleref}}
-
-\DeclareRobustCommand{\currenttitle}{\begingroup
-  \let\numberline\@gobble
-  \theTitleReference\@currentlabel\M at currentTitle\endgroup}
-
+\providecommand\currenttitle{%
+  \@memerror{The \protect\currenttitle\space command is no longer\MessageBreak
+    available}{%
+    Place a label and use \protect\titleref{label} instead
+  }
+}
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
-% \begin{verbatim}
-% % \DeclareRobustCommand\@mem at nestwarn[1]{\@memwarn%
-% %  {Label \string"#1\string" was put in a title,\MessageBreak
-% %   so the \noexpand\titleref is incorrect}}
-% \end{verbatim}
-%
-% \begin{macro}{\M at currentTitle}
+% \begin{macro}{\theTitleReference}
+%   Was used to define the output of \cmd{\titleref}. Now just gives a
+%   warning.
 %    \begin{macrocode}
-\let\M at currentTitle\@empty
-
+\providecommand\theTitleReference[2]{%
+  \@memwarn{\protect\theTitleReference\space is no longer available}
+}
 %    \end{macrocode}
 % \end{macro}
-%
-% \begin{macro}{\@mem at theTR}
-% proper definition:
+% \begin{macro}{\M at TitleReference}
+%   This was used in the old implementation as a part of the data inside
+%   \verb|\newlabel| in the \verb|.aux|-files. Deleting it will cause
+%   the first compilation after a memoir update to fail. We'll
+%   just define it to gobble two args.
 %    \begin{macrocode}
-\def\@mem at theTR{\let\M at TitleReference\@firstoftwo \theTitleReference}
-
+\let\M at TitleReference\@gobbletwo
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\namerefon}
-% \begin{macro}{\namerefoff}
-% Named references has turned some arguments (e.g., \verb?\legend{text}?) into
-%  moving ones (Sven.Hartrumpf at FernUni-Hagen.de reported a problem but 
-%  not a cause, March 2003). Not everyone needs named references.
-%    \begin{macrocode}
-\newcommand*{\namerefon}{\let\M at gettitle\@mem@@gettitle}
-\newcommand*{\namerefoff}{\let\M at gettitle\@gobble}
-  \namerefon
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
 %
-%
 % \section{Table of Contents, etc.}
 %
 %     A \cs{section} command writes a
@@ -22770,7 +19255,7 @@
 %    We define two lengths and a utility command.
 %    \begin{macrocode}
 \newlength{\tocentryskip} \setlength{\tocentryskip}{1em}
-\newlength{\tocbaseline} \setlength{\tocbaseline}{20pt}
+\newlength{\tocbaseline}  \setlength{\tocbaseline}{20pt}
 \newcommand{\tocskip}[1]{%
     \addtocontents{toc}{\protect\vspace{#1}}}
 %    \end{macrocode}
@@ -23695,7 +20180,7 @@
 % \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel at part} definition to
 % \cs{def} for better compability with future hyperref}
 %    \begin{macrocode}
-\newcommand*{\toclevel at part}{-1}
+\def\toclevel at part{-1}
 
 %    \end{macrocode}
 % \end{macro}
@@ -23897,7 +20382,7 @@
 % \changes{v1.3}{2002/11/14}{Added \cs{chapternumberline}}
 % \changes{v1.618}{2005/09/03}{Added \cs{@chapapp at head} to \cs{chapternumberline} (mempatch v3.12)}
 % \changes{v1.61803398d}{2010/02/13}{added hook into chapter numberline}
-% changes{v3.6k}{2012/07/22}{Factored out the box command}
+% \changes{v3.6k}{2012/07/22}{Factored out the box command}
 %    \begin{macrocode}
 \newcommand*\chapternumberlinehook[1]{}
 \newcommand{\chapternumberline}[1]{%
@@ -24285,7 +20770,11 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-%
+% \paragraph{Caveat:} In certain cases an immediate verson of
+% \cs{cftinserthook} might be needed due to race conditions. We might
+% add such a version at some point.
+% 
+% 
 % \subsection{ToC and divisional numbering}
 %
 %  Commands are provided, based on the \Lpack{tocvsec2} package, for changing
@@ -25408,12 +21897,14 @@
 % \cs{flushbottom} than just let \cs{@texttop}. We also add a switch
 % macro to see if \cs{flushbottom} is active. \cs{raggedbottom} and
 % \cs{sloppybottom} sets the switch to false}
+% \changes{v3.8}{2023/08/08}{The kernel defined these as robust, we'd
+% better too}
 %    \begin{macrocode}
-\renewcommand{\raggedbottom}{%
+\DeclareRobustCommand{\raggedbottom}{%
   \def\mem at flshbot{01}%
   \def\@textbottom{\vskip\z@ plus.0001fil}%
   \let\@texttop\@mkidx}
-\renewcommand{\flushbottom}{%
+\DeclareRobustCommand{\flushbottom}{%
   \def\mem at flshbot{00}%
   \let\@textbottom\relax
   \let\@texttop\@mkidx}
@@ -26825,6 +23316,7 @@
 %     \splittopskip\footnotesep
 %     \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
 %     \hsize\columnwidth \@parboxrestore
+%     \def\@currentcounter{footnote}% added later
 %     \protected at edef\@currentlabel{%
 %       \csname p at footnote\endcsname\@thefnmark}%
 %     \color at begingroup
@@ -26916,6 +23408,7 @@
 %     \reset at font\footnotesize
 %     \hsize\columnwidth
 %     \@parboxrestore
+%     \def\@currentcounter{mpfootnote}% forgotten
 %     \protected at edef\@currentlabel{%
 %       \csname p at mpfootnote\endcsname\@thefnmark}%
 %     \color at begingroup
@@ -27252,14 +23745,18 @@
 %
 % I'm not at all sure about the color bits, though!
 % \changes{v1.618}{2005/09/02}{Fixed colors in \cs{verbfootnote} (mempatch v2.3)}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{replaced hardcoded \cs{foornotesize}
+% by \cs{foottextfont}}
 %    \begin{macrocode}
 \long\def\@verbfootnotetext{%
   \insert\footins\bgroup
-    \footnotesize
+    \foottextfont%
     \interlinepenalty\interfootnotelinepenalty
     \splittopskip\footnotesep
     \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{footnote}%
     \edef\@currentlabel{\csname p at footnote\endcsname\@thefnmark}%
 %%%%    \color at begingroup    
     \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
@@ -27298,14 +23795,18 @@
 % \begin{macro}{\@verbmpfootnotetext}
 %    Footnotes in minipages are a little different, so another
 % version of \cs{...footnotetext}. 
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{replaced hardcoded \cs{foornotesize}
+% by \cs{foottextfont}}
 %    \begin{macrocode}
 \long\def\@verbmpfootnotetext{%
   \global\setbox\@mpfootins\vbox{%
-    \reset at font\footnotesize
+    \reset at font\foottextfont
     \unvbox\@mpfootins
     \bgroup
     \hsize\columnwidth
     \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \edef\@currentlabel{\csname p at mpfootnote\endcsname\@thefnmark}%
     \color at begingroup
     \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
@@ -27426,6 +23927,8 @@
 % \changes{v1.6180}{2006/06/12}{Stop font changes leaking into footnotes.
 %                  The v1.618 change was too early}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable'}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
 \renewcommand{\@mpfootnotetext}[1]{%
   \global\setbox\@mpfootins\vbox{%
@@ -27432,12 +23935,13 @@
     \unvbox\@mpfootins
     \def\baselinestretch{\m at m@footnote at spacing}%
     \foottextfont \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
   \reset at font%        
     \@makefntext{%
-      \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+      \rule\z@\footnotesep\ignorespaces\foottextfont #1%
       \@finalstrut\strutbox}%
   \color at endgroup}}
 
@@ -27644,6 +24148,8 @@
 %     \cs{m at make@footnotetext} and \cs{m at make@mpfootnotetext} 
 %     (courtesy David Wilson)}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
 %    \begin{macrocode}
 \newcommand{\m at make@footnotetext}[1]{%
   \@namelongdef{@footnotetext#1}##1{%
@@ -27652,11 +24158,12 @@
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
   \hsize\columnwidth
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname\@nameuse{@thefnmark#1}}% 
   \color at begingroup
     \@nameuse{@makefntext#1}{%
-      \rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
+      \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1 ##1}%
       \@finalstrut\strutbox}%
   \color at endgroup}%
   \m at mmf@prepare}}
@@ -27667,6 +24174,8 @@
 % \begin{macro}{\m at make@mpfootnotetext}
 % \cs{m at make@mpfootnotetext}\marg{series} creates \cs{@mpfootnotetext<series>}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
 %    \begin{macrocode}
 \newcommand{\m at make@mpfootnotetext}[1]{%
   \@namelongdef{@mpfootnotetext#1}##1{%
@@ -27675,11 +24184,12 @@
       \def\baselinestretch{\m at m@footnote at spacing}%  
       \reset at font\@nameuse{foottextfont#1}%
       \hsize\columnwidth \@parboxrestore
+      \def\@currentcounter{mpfootnote}%
       \protected at edef\@currentlabel{%
         \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
     \color at begingroup
       \@nameuse{@makefntext#1}{%
-        \rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
+        \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1}##1%
         \@finalstrut\strutbox}%
     \color at endgroup}%
     \m at mmf@prepare}}
@@ -28010,11 +24520,13 @@
 % \cs{@footnotetext} for the \verb?v at r? series.
 % \changes{v1.618}{2005/09/03}{Added missing percent to \cs{@twocolfootnotetext} (mempatch v3.1)}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@twocolfootnotetext}[1]{\insert\footinsv at r{%
   \def\baselinestretch{\m at m@footnote at spacing}%   
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -28040,10 +24552,11 @@
 %
 % \begin{macro}{\@twocolfootfmt}
 % \cs{@twocolfootfmt}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
 \newcommand{\@twocolfootfmt}[1]{%
   \@preamtwofmt
-  {\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
+  {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
 
 %    \end{macrocode}
 % \end{macro}
@@ -28052,6 +24565,7 @@
 % \cs{@mptwocolfootnotetext}\marg{text} is the two column version
 % of \cs{@mpfootnotetext} for the \verb?v at r? series for minipages.
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@mptwocolfootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -28059,6 +24573,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\foottextfont 
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -28096,6 +24611,7 @@
 % \cs{m at make@twocolfootnotetext}\marg{series} creates 
 % \cs{@twocolfootnotetext}\meta{series}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@twocolfootnotetext}[1]{%
   \@namelongdef{@twocolfootnotetext#1}##1{%
@@ -28103,6 +24619,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\@nameuse{foottextfont#1}%
     \@preamfntext
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
     \color at begingroup
@@ -28117,6 +24634,7 @@
 % \cs{m at make@mptwocolfootnotetext}\marg{series} creates
 % \cs{@mptwocolfootnotetext}\meta{series}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@mptwocolfootnotetext}[1]{%
 \@namelongdef{@mptwocolfootnotetext#1}##1{%
@@ -28125,6 +24643,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -28138,12 +24657,13 @@
 % \cs{m at make@twocolfootfmt}\marg{series} creates
 % \cs{@twocolfootfmt}\meta{series} 
 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m at make@twocolfootfmt} [RS]}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
 %    \begin{macrocode}
 \newcommand{\m at make@twocolfootfmt}[1]{%
   \@namedef{@twocolfootfmt#1}##1{%
     \@preamtwofmt
     {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
+      \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
 
 %    \end{macrocode}
 % \end{macro}
@@ -28197,11 +24717,13 @@
 % \cs{@threecolfootnotetext}\marg{text} is the three column version of
 % \cs{@footnotetext}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@threecolfootnotetext}[1]{\insert\footinsv at r{%
   \def\baselinestretch{\m at m@footnote at spacing}%   
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -28226,10 +24748,11 @@
 %
 % \begin{macro}{\@threecolfootfmt}
 %
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
 \newcommand{\@threecolfootfmt}[1]{%
   \@preamthreefmt
-  {\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
+  {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
 
 %    \end{macrocode}
 % \end{macro}
@@ -28238,6 +24761,7 @@
 % \cs{@mpthreecolfootnotetext}\marg{text} is the three column version of
 % \cs{@mpfootnotetext}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@mpthreecolfootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -28245,6 +24769,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%  
     \reset at font\foottextfont 
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -28283,6 +24808,7 @@
 % \cs{m at make@threecolfootnotetext}\marg{series} creates
 % \cs{@threecolfootnotetext}\meta{series}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@threecolfootnotetext}[1]{%
 \@namelongdef{@threecolfootnotetext#1}##1{%
@@ -28290,6 +24816,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%  
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -28303,6 +24830,7 @@
 % \cs{m at make@mpthreecolfootnotetext}\marg{series} creates
 % \cs{@mpthreecolfootnotetext}\meta{series}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@mpthreecolfootnotetext}[1]{%
 \@namelongdef{@mpthreecolfootnotetext#1}##1{%
@@ -28311,6 +24839,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -28324,12 +24853,13 @@
 % \cs{m at make@threecolfootfmt}\marg{series} creates
 % \cs{@threecolfootfmt}\meta{series}
 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m at make@threecolfootfmt} [RS]}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
 \newcommand{\m at make@threecolfootfmt}[1]{%
 \@namelongdef{@threecolfootfmt#1}##1{%
   \@preamthreefmt
   {\@nameuse{footfootmark#1}\strut 
-   {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
+    \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
 
 %    \end{macrocode}
 % \end{macro}
@@ -28476,11 +25006,13 @@
 % \cs{@parafootnotetext}\marg{text} is a paragraph version of
 % \cs{@footnotetext}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@parafootnotetext}[1]{\insert\footinsv at r{
   \def\baselinestretch{\m at m@footnote at spacing}%  
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \setbox0=\vbox{\hsize=\maxdimen
@@ -28495,11 +25027,12 @@
 % \begin{macro}{\@parafootfmt}
 % \cs{@parafootfmt}\marg{text} is a paragraph version of
 % \cs{@footfmt}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
 \newcommand{\@parafootfmt}[1]{%
   \parindent=\z@
   \parfillskip=0pt \@plus 1fil
-  {\footfootmark\strut {\foottextfont #1}\penalty-10}}
+  {\footfootmark\strut \foottextfont #1\penalty-10}}
 
 %    \end{macrocode}
 % \end{macro}
@@ -28508,6 +25041,7 @@
 % \cs{@mpparafootnotetext}\marg{text} is a paragraph version of
 % \cs{@mpfootnotetext}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{adding the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@mpparafootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -28515,6 +25049,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\foottextfont 
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
     \setbox0=\vbox{\hsize=\maxdimen
@@ -28569,6 +25104,7 @@
 % \cs{m at make@parafootnotetext}\marg{series} creates
 % \cs{@parafootnotetext}\meta{series} 
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@parafootnotetext}[1]{%
 \@namelongdef{@parafootnotetext#1}##1{%
@@ -28576,6 +25112,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%   
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
   \setbox0=\vbox{\hsize=\maxdimen
@@ -28591,6 +25128,7 @@
 % \cs{m at make@mpparafootnotetext}\marg{series} creates
 % \cs{@mpparafootnotetext}\meta{series} 
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\m at make@mpparafootnotetext}[1]{%
 \@namelongdef{@mpparafootnotetext#1}##1{%
@@ -28599,6 +25137,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%   
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
     \setbox0=\vbox{\hsize=\maxdimen
@@ -28614,6 +25153,7 @@
 % \cs{m at make@parafootfmt}\marg{series} creates
 % \cs{@parafootfmt}\meta{series} 
 % \changes{v1.61}{2004/03/14}{Removed space from \cs{m at make@parafootfmt} [RS]}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetextX}}
 %    \begin{macrocode}
 \newcommand{\m at make@parafootfmt}[1]{%
 \@namelongdef{@parafootfmt#1}##1{%
@@ -28620,7 +25160,7 @@
   \parindent=\z@
   \parfillskip=0pt \@plus 1fil
   {\@nameuse{footfootmark#1}\strut 
-   {\@nameuse{foottextfont#1}##1}\penalty-10}}}
+   \@nameuse{foottextfont#1}##1\penalty-10}}}
 
 %    \end{macrocode}
 % \end{macro}
@@ -29061,11 +25601,13 @@
 %    \end{macrocode}
 % Use \cs{marginpar} for placing the footnote.
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
     \marginpar{%
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font
     \foottextfont
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote\endcsname\@thefnmark}%
     \color at begingroup
@@ -29077,6 +25619,8 @@
 % \changes{v1.618033988c}{2010/02/20}{sporadic spaces removed, error
 % reported on texlive mailinglist}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
+% \changes{v3.8}{2023/07/27}{removed group around \cs{footnotetext}}
 %    \begin{macrocode}
     \insert\footins{%
     \def\baselinestretch{\m at m@footnote at spacing}%
@@ -29084,11 +25628,12 @@
     \foottextfont
     \@preamfntext
     \hsize\columnwidth
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote\endcsname\@thefnmark}%
     \color at begingroup
       \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+        \rule\z@\footnotesep\ignorespaces\foottextfont #1%
         \@finalstrut\strutbox}%
     \color at endgroup}%
   \fi%
@@ -29494,6 +26039,7 @@
 % \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont} 
 % to \cs{sidefoottextfont}}
 % \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
+% \changes{v3.8}{2023/07/26}{added the missing \cs{@currentcounter}}
 %    \begin{macrocode}
 \newcommand{\@sidefootnotetext}[1]{\insert\sidefootins{%
   \hsize\sidefootwidth
@@ -29505,6 +26051,7 @@
   \allowbreak
   \prevdepth=\dp\strutbox
   \vskip-\parskip
+  \def\@currentcounter{sidefootnote}%
   \protected at edef\@currentlabel{%
     \csname p at sidefootnote\endcsname\@thesidefnmark}%
 \color at begingroup
@@ -30261,11 +26808,15 @@
 %   \changes{v3.6k}{2013/05/17}{Forgot about labels in the note text.}
 %   \changes{v3.7g}{2018/01/03}{Added \cs{phantomsection}, otherwise
 %   \cs{label} does not work correctly. Reported in \texttt{https://tex.stackexchange.com/q/408448/3929}}
+%  \changes{v3.8}{2023/07/26}{added \cs{@currentcounter} and
+%  defined that \cs{@currentlabel} points to}
 %    \begin{macrocode}
-\newcommand\startnoteentrystart[4]{%
+\newcommand\startnoteentrystart[4]{% number; manual id; auto label; href anchor
   \prenoteinnotes%
   \noteidinnotes{#1}{#2}%
-  \@ifmtarg{#2}{\phantomsection\def\@currentlabel{#1}}{}%
+  \phantomsection%
+  \@ifmtarg{#2}{\def\@currentlabel{#1}}{\def\@currentlabel{#2}}%
+  \def\@currentcounter{pagenote}%
   \pagenoteanchor{#4}%
   \pageinnotes{#3}%
   \prenotetext%
@@ -34738,7 +31289,7 @@
 % \subsection{Fractions and subscripts}
 %
 %
-% Styles for fractions like 3/4.
+% Styles for fractions like 3/4 (but better).
 %
 % \begin{macro}{\slashfracstyle}
 % \cs{slashfracstyle} based on the kernel \cs{textsuperscript} macro
@@ -36630,9 +33181,10 @@
 % \Lpack{array} package}
 % \changes{v3.7h}{2018/09/06}{\Lpack{array} no longer embedded,
 % required instead}
+% \changes{v3.8}{2023/07/28}{booktabs no longer emulated}
 %    \begin{macrocode}
  % \EmulatedPackage{array}[2016/10/06]
-\EmulatedPackage{booktabs}[2016/05/16]
+ % \EmulatedPackage{booktabs}[2016/05/16]
 \EmulatedPackage{ccaption}[2008/07/23]
 \EmulatedPackage{changepage}[2008/07/23]
 \EmulatedPackage{chngcntr}[2008/07/23]
@@ -36919,6 +33471,12 @@
 % \newblock (Available from CTAN in
 %            \texttt{/macros/latex/contrib/patchcmd})
 %
+%  \bibitem[LTX3]{LTX3}
+%  The \LaTeX{} Project.
+% \newblock \emph{The \LaTeX3 sources}
+% \newblock June, 2023.
+% \newblock (Available from CTAN in \texttt{/macros/latex/contrib/l3kernel})
+%
 % \bibitem[Fai98]{MOREVERB}
 % Robin Fairbairns.
 % \newblock \emph{The moreverb package}.
@@ -37002,10 +33560,10 @@
 %   \newblock \emph{The ltfilehook package}
 %    \newblock July 2020. 
 %
-%  \bibitem[Mit2020b]{LTHOOKS}
+%  \bibitem[Mit2023]{LTHOOKS}
 %   Frank Mittelbach
-%   \newblock \emph{The lthooks package}
-%    \newblock July 2020. 
+%   \newblock \emph{\LaTeX's hook management}
+%    \newblock June 2023. 
 %
 %  \bibitem[Mit2020c]{LTSHIPOUT}
 %   Frank Mittelbach
@@ -37020,10 +33578,10 @@
 %            \texttt{/macros/latex/contrib/fancyhdr})
 %
 %
-% \bibitem[Rah01]{NAMEREF}
-% Sebastian Rahtz.
+% \bibitem[Rah23]{NAMEREF}
+% Sebastian Rahtz, Heiko Oberdiek, The \LaTeX{} project.
 % \newblock \emph{Section name references in LaTeX}.
-% \newblock January 2001.
+% \newblock 2023.
 % \newblock (Available from CTAN in
 %            \texttt{/macros/latex/contrib/hyperref})
 %

Modified: trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/source/latex/memoir/mempatch.dtx	2023-08-08 19:53:20 UTC (rev 67850)
@@ -20,7 +20,7 @@
 %
 % 
 % \fi
-% \CheckSum{610}
+% \CheckSum{562}
 %
 % \def\dtxfile{\texttt{mempatch.dtx}}
 % \def\fileversion{v1.0} \def\filedate{2003/10/04}
@@ -312,6 +312,7 @@
 %% With the new hooking system from 2020+ memhfixc is automatically
 %% added after loading hyperref with the memoir class
 %%
+%% Version 1.21  2023/07/28
 %% Version 1.20  2022/11/17
 %% Version 1.19  2021/06/16
 %% Version 1.18  2019/10/24
@@ -338,7 +339,7 @@
 % 
 %
 %    \begin{macrocode}
-\ProvidesPackage{memhfixc}[2022/11/17 v1.20 nameref/hyperref package fixes for memoir class]
+\ProvidesPackage{memhfixc}[2023/07/28 v1.21 hyperref package fixes for memoir class]
 %    \end{macrocode}
 %
 % \begin{macro}{\M at hfixcfinish}
@@ -355,87 +356,14 @@
 %
 % \subsection{Patches for nameref}
 %
-% \changes{v1.13}{2010/04/19}{Rewritten to help fix a race condition}
 % 
-% The nameref package changes \cs{@sect} and \cs{label} so we bring
-% back the memoir stuff. We have earlier been using
-% \verb?\AtBeginDocument? plus \verb?\@ifpackageloaded{nameref}? to
-% add our changes to \Lpack{nameref}. But this is not a good solution,
-% as \Lpack{hyperref} can delay \Lpack{nameref} loading using
-% \verb?\AtBeginDocument{\usepackage{nameref}}? \emph{and} add thiis
-% \emph{after} \Lpack{memhfixc} is loaded. A better solution is to use
-% \verb?\AtEndPackage?, then it does not matter how far after
-% \Lpack{memhfixc} \Lpack{nameref} is loaded.
+% \changes{v1.21}{2023/07/25}{Patches removed}
 %
-% \changes{v1.13}{2010/04/19}{Code in the next part have been changed
-% to match \cs{AtEndPackage}}
-%    \begin{macrocode}
-\AtEndPackage{nameref}{%
-%    \end{macrocode}
-
-% \begin{macro}{\M at sect}
-% \begin{macro}{\NR at sectm@m}
-% The \Lpack{nameref} package~\cite{NAMEREF} fiddles with \cs{@sect} (which memoir replaces
-%  by \cs{M at sect}). 
-%    \begin{macrocode}
-  \@ifundefined{NR at sectm@m}{% haven't fiddled with \M at sect
-    \typeout{Redoing nameref's sectioning}
-    \let\NR at sectm@m\M at sect
-    \def\M at sect##1##2##3##4##5##6[##7][##8]##9{%
-      \setcounter{section at level}{##2}%
-      \def\@currentlabelname{##7}%
-      \NR at sectm@m{##1}{##2}{##3}{##4}{##5}{##6}[{##7}][{##8}]{\Sectionformat{##9}{##2}}}%
-  }%
-  {% \NR at sectm@m has already been defined
-  }%
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
+% As of Summer 2023, memoir now autoloads \Lpack{nameref} and adjusts
+% it self to it. Thus no patches needed.
 %
 %
 %
-% \begin{macro}{\label}
-% \begin{macro}{\MNR at label}
-% The \Lpack{nameref} package replaces \cs{label}, which (which memoir has added to).
-%  Make the memoir addition again.
-%
-%    \begin{macrocode}
-  \@ifundefined{MNR at label}{% haven't fiddled with \label
-    \typeout{Redoing nameref's label}
-    \let\MNR at label\label
-    \def\label##1{\@bsphack\begingroup
-      \protected at edef\@currentlabel{\protect\M at TitleReference
-        {\@currentlabel}{\M at currentTitle}}%
-      \MNR at label{##1}%
-      \endgroup \@esphack}%
-    \let\MNR at old@caption\@caption
-    \long\def\@caption##1[##2]##3{%
-      \MNR at old@caption{##1}[{##2}]{##3}%
-      \def\@currentlabelname{##2}%
-      \M at gettitle{##2}%
-    }%
-  }%
-  {% \MNR at label has already been defined
-  }%
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\nameref}
-%   We use \cs{titleref} to provide the same functionality as
-%   \cs{nameref}, so as not to confuse users, we let \cs{nameref} be
-%   an alias for \cs{titleref}.
-%    \begin{macrocode}
-\DeclareRobustCommand\nameref{\@ifstar{\@mem at titlerefnolink}{\@mem at titleref}}
-%    \end{macrocode}
-% \end{macro}
-%
-%    \begin{macrocode}
-}% end of AtEndPackage
-%    \end{macrocode}
-
-
-%
 % We are done unless the \Lpack{hyperref} package has been loaded
 %    \begin{macrocode}
 %% We are done unless the hyperref package has been loaded
@@ -531,11 +459,15 @@
 % \end{macro}
 %
 % \begin{macro}{\bookautorefname}
+% \begin{macro}{\subfigureautorefname}
+% \changes{v1.21}{2023/07/28}{Added \cs{subfigureautorefname}}
 %    \begin{macrocode}
 \providecommand{\bookautorefname}{Book}
+\providecommand{\subfigureautorefname}{Subfigure}
 
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\@@writetorep}
 % Change \Lpack{hyperref}'s \cs{@@writetorep} as memoir uses \cs{partnumberline} and 
@@ -774,10 +706,11 @@
 %   \Lpack{hyperref} provide a \cs{ref*} command that does not give a
 %   hyperlink under \Lpack{hyperref}, we extend \cs{titleref} to
 %   support it.
+%   \changes{v1.21}{2023/08/07}{removed}
 %    \begin{macrocode}
-\def\@mem at titlerefnolink#1{\begingroup \let\numberline\@gobble
-  \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
-  \ref*{#1}\endgroup}
+ %\def\@mem at titlerefnolink#1{\begingroup \let\numberline\@gobble
+ % \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
+ % \ref*{#1}\endgroup}
 
 %    \end{macrocode}
 % \end{macro}
@@ -1027,26 +960,26 @@
 % \newblock \emph{The LaTeX Companion}.
 % \newblock Addison-Wesley Publishing Company, 1994.
 %
+% \bibitem[Rahtz23a]{NAMEREF}
+%  Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
+%  \newblock \emph{Section name references in LaTeX}.
+%  \newblock 2023. 
+%  \newblock (Available from CTAN (the \texttt{nameref} package) via 
+%            \texttt{/macros/latex/contrib/hyperref/})
 %
-% \bibitem[Rah01]{NAMEREF}
-% Sebastian Rahtz.
-% \newblock \emph{Section name references in LaTeX}.
-% \newblock January 2001.
-% \newblock (Available from CTAN in
-%            \texttt{/macros/latex/contrib/hyperref})
 %
-% \bibitem[Rah02]{HYPERREF}
-% Sebastian Rahtz.
-% \newblock \emph{Hypertext marks in LaTeX}.
-% \newblock March 2002.
-% \newblock (Available from CTAN in
-%            \texttt{/macros/latex/contrib/hyperref})
+% \bibitem[Rahtz23b]{HYPERREF}
+%  Sebastian Rahtz, Heiko Oberdiek, The \LaTeX3 Project.
+%  \newblock \emph{Hypertext marks in LaTeX}.
+%  \newblock 2023. 
+%  \newblock (Available from CTAN via 
+%            \texttt{/macros/latex/contrib/hyperref/})
 %
-% \bibitem[Wil08]{MEMOIR}
+% \bibitem[Wil23]{MEMOIR}
 % Peter Wilson.
 % \newblock \emph{The LaTeX \Lpack{memoir} class for configurable 
 %                 typesetting: Source code}.
-% \newblock July 2008.
+% \newblock July 2023.
 % \newblock (Available from CTAN in
 %            \texttt{macros/latex/contrib/memoir})
 %

Modified: trunk/Master/texmf-dist/tex/latex/memoir/mem9.clo
===================================================================
--- trunk/Master/texmf-dist/tex/latex/memoir/mem9.clo	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/tex/latex/memoir/mem9.clo	2023-08-08 19:53:20 UTC (rev 67850)
@@ -26,7 +26,7 @@
 %% 
 %%   This work consists of the files listed in the README file.
 %% 
-\ProvidesFile{mem9.clo}%
+ \ProvidesFile{mem9.clo}%
               [2022/07/29 v0.5 memoir class 9pt size option]
 \renewcommand{\normalsize}{%
    \@setfontsize\normalsize\@ixpt\@xpt

Modified: trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/tex/latex/memoir/memhfixc.sty	2023-08-08 19:53:20 UTC (rev 67850)
@@ -44,6 +44,7 @@
 %% With the new hooking system from 2020+ memhfixc is automatically
 %% added after loading hyperref with the memoir class
 %%
+%% Version 1.21  2023/07/28
 %% Version 1.20  2022/11/17
 %% Version 1.19  2021/06/16
 %% Version 1.18  2019/10/24
@@ -66,7 +67,7 @@
 %% Version 1.1  2003/01/22
 %% Version 1.0  2002/10/22
 %%
-\ProvidesPackage{memhfixc}[2022/11/17 v1.20 nameref/hyperref package fixes for memoir class]
+\ProvidesPackage{memhfixc}[2023/07/28 v1.21 hyperref package fixes for memoir class]
 \let\M at hfixcfinish\relax
 \@ifclassloaded{memoir}{}%
                        {\let\M at hfixcfinish\endinput
@@ -73,38 +74,6 @@
                         \typeout{No memoir class: memhfixc does nothing}}
 \M at hfixcfinish
 
-\AtEndPackage{nameref}{%
-
-  \@ifundefined{NR at sectm@m}{% haven't fiddled with \M at sect
-    \typeout{Redoing nameref's sectioning}
-    \let\NR at sectm@m\M at sect
-    \def\M at sect##1##2##3##4##5##6[##7][##8]##9{%
-      \setcounter{section at level}{##2}%
-      \def\@currentlabelname{##7}%
-      \NR at sectm@m{##1}{##2}{##3}{##4}{##5}{##6}[{##7}][{##8}]{\Sectionformat{##9}{##2}}}%
-  }%
-  {% \NR at sectm@m has already been defined
-  }%
-  \@ifundefined{MNR at label}{% haven't fiddled with \label
-    \typeout{Redoing nameref's label}
-    \let\MNR at label\label
-    \def\label##1{\@bsphack\begingroup
-      \protected at edef\@currentlabel{\protect\M at TitleReference
-        {\@currentlabel}{\M at currentTitle}}%
-      \MNR at label{##1}%
-      \endgroup \@esphack}%
-    \let\MNR at old@caption\@caption
-    \long\def\@caption##1[##2]##3{%
-      \MNR at old@caption{##1}[{##2}]{##3}%
-      \def\@currentlabelname{##2}%
-      \M at gettitle{##2}%
-    }%
-  }%
-  {% \MNR at label has already been defined
-  }%
-\DeclareRobustCommand\nameref{\@ifstar{\@mem at titlerefnolink}{\@mem at titleref}}
-}% end of AtEndPackage
-
 %% We are done unless the hyperref package has been loaded
 \@ifpackageloaded{hyperref}{}{\let\M at hfixcfinish\endinput}
 \M at hfixcfinish
@@ -143,6 +112,7 @@
   \g at addto@macro{\HyLang at afrikaans}{\def\bookautorefname{Boek}}}
 
 \providecommand{\bookautorefname}{Book}
+\providecommand{\subfigureautorefname}{Subfigure}
 
 \@ifpackagelater{hyperref}{2006/11/15}{%
 }{%
@@ -281,9 +251,9 @@
   \end{lrbox}%
   \m at mscapopboxes}
 
-\def\@mem at titlerefnolink#1{\begingroup \let\numberline\@gobble
-  \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
-  \ref*{#1}\endgroup}
+ %\def\@mem at titlerefnolink#1{\begingroup \let\numberline\@gobble
+ % \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
+ % \ref*{#1}\endgroup}
 
 \AtBeginDocument{%
     \let\printpageinnotes\printpageinnoteshyperref%

Modified: trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls	2023-08-08 19:53:11 UTC (rev 67849)
+++ trunk/Master/texmf-dist/tex/latex/memoir/memoir.cls	2023-08-08 19:53:20 UTC (rev 67850)
@@ -26,11 +26,22 @@
 %% 
 %%   This work consists of the files listed in the README file.
 %% 
-\NeedsTeXFormat{LaTeX2e}
+\def\mem at atleast@kernel{2021/06/01}
+\NeedsTeXFormat{LaTeX2e}[\mem at atleast@kernel]
 \ProvidesClass{memoir}%
-  [2022/11/17 v3.7.19 configurable book, report, article document class]
-\newcommand\memversion{v3.7.19, 2022/11/17}
-\RequirePackage{etoolbox}
+  [2023/08/08 v3.8 configurable book, report, article document class]
+\newcommand\memversion{v3.8, 2023/08/08}
+\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
+    entire LaTeX installation instead of manually updating\MessageBreak
+    just memoir}{}
+  % \batchmode\read-1to\@tempa% evil mode engaged
+}
+\RequirePackage{xpatch}
 \newcommand*{\@ptsize}{}
 \newcommand*{\@memptsize}{}
 \newlength{\onelineskip}
@@ -57,8 +68,6 @@
 \newcommand*{\@memerror}{\ClassError{memoir}}
 \newcommand*{\@memwarn}{\ClassWarning{memoir}}
 
-\providecommand\IfFormatAtLeastTF{\@ifl at t@r\fmtversion}
-
 \newif\ifsamename
 \newcommand{\nametest}[2]{%
   \samenamefalse%
@@ -108,6 +117,26 @@
 \newcommand\memsetlengthmin[3]{\ifdim#2<#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
 \newcommand\memsetlengthmax[3]{\ifdim#2>#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
 
+\ExplSyntaxOn
+\IfFormatAtLeastTF{ 2022-06-01 }
+{}
+{
+  \RequirePackage { xparse }
+  \providecommand \ExpandArgs [1]
+  { \cs_if_exist_use:c { exp_args:N #1 } }
+}
+\ExplSyntaxOff
+
+\providecommand\NewHookWithArguments[2]{}
+\ExplSyntaxOn
+\@ifundefined{UseHookWithArguments}{
+  \cs_new:Npn \UseHookWithArguments #1 #2 {
+    \cs:w use_none: \prg_replicate:nn {#2} { n } \cs_end:
+  }
+}{}
+\ExplSyntaxOff
+\NewHook{memoir/subcaption/aftercounter}
+
 \newcommand*{\@memfakeusepackage}[1]{%
   \@namelet{ver@#1.sty}\@empty}
 
@@ -217,7 +246,10 @@
     \@ifclassloaded{#1}{#2}%
     {\AtEndFile{#1.\@clsextension}{#2}}}
 
-} % end of els part of format check
+
+ % end of else part of format check
+}
+
 \newcommand{\phantomsection}{}
 
  \renewcommand*{\nofiles}{%
@@ -406,6 +438,16 @@
 \newcommand*{\memRTLmainraggedright}{\raggedright}
 \newcommand*{\memRTLmainraggedleft}{\raggedleft}
 
+ % secret extra option for testing stuff in the wild
+ % caution 1: patching inside \ifmem at devmode ... \fi requires that all
+ % if statements in the patch are blanced
+ % caution 2: pathing inside \mem at devmode@run{ ... }{} does not work
+ % if the search pattern contains #<num>
+ % thus added both variants
+\newif\ifmem at devmode
+\let\mem at devmode@run\@secondoftwo
+\DeclareOption{dev-mode}{\let\mem at devmode@run\@firstoftwo\mem at devmodetrue}
+
 \@ifundefined{stockwidth}{\newdimen{\stockheight}}{}
 \@ifundefined{stockwidth}{\newdimen{\stockwidth}}{}
 \newlength{\trimtop}
@@ -633,24 +675,17 @@
 \newcommand\mem at settopoint[1]{\@settopoint{#1}}
 \DeclareOption{fullptlayout}{\renewcommand\mem at settopoint{\@gobble}}
 
-\newif\ifmem at noetex
-  \mem at noetexfalse
-\DeclareOption{noetex}{\mem at noetextrue}
-
 \ExecuteOptions{final,letterpaper,10pt,onecolumn,openright,twoside,
                 portrait}
 \ProcessOptions*
-  \ifmemlandscape
-    \setlength\@tempdima  {\stockheight}
-    \setlength\stockheight{\stockwidth}
-    \setlength\stockwidth {\@tempdima}
-  \fi
 
-\ifmem at noetex\relax\else
-  \ifx\e at alloc\@undefined
-    \IfFileExists{etex.sty}{\RequirePackage{etex}}{}
-  \fi
+\ifmemlandscape
+  \setlength\@tempdima  {\stockheight}
+  \setlength\stockheight{\stockwidth}
+  \setlength\stockwidth {\@tempdima}
 \fi
+
+
 \providecommand*{\memoirpostopthook}{}
   \memoirpostopthook
 
@@ -2243,12 +2278,10 @@
   \makefootrule{companion}{\textwidth}{\footruleheight}{\footruleskip}
 }
 
-\renewcommand{\pagenumbering}{%
-  \@ifstar{\@smempnum}{\@mempnum}}
-\newcommand{\@smempnum}[1]{%
-  \gdef\thepage{\csname @#1\endcsname \c at page}}
-\newcommand{\@mempnum}[1]{%
-  \@smempnum{#1}\global\c at page \@ne}
+\RenewDocumentCommand\pagenumbering{sm}{%
+  \gdef\thepage{\csname @#2\endcsname \c at page}%
+  \IfBooleanF{#1}{\global\c at page \@ne}% reset counter unless starred
+}
 
 \newcounter{storedpagenumber}
   \setcounter{storedpagenumber}{1}
@@ -2328,18 +2361,18 @@
 }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check what this does!!!!!!!!
-\renewcommand*{\@setsize}[4]{%
-  \@nomath#1%
-  \let\@currsize#1%
-  \baselineskip #2%
-  \baselineskip \baselinestretch\baselineskip
-  \parskip \baselinestretch\parskip
-  \setbox\strutbox \hbox{%
-    \vrule height.7\baselineskip
-           depth .3\baselineskip
-           width \z@}%
-  \skip\footins \baselinestretch\skip\footins
-  \normalbaselineskip\baselineskip#3#4}
+ % \renewcommand*{\@setsize}[4]{%
+ %   \@nomath#1%
+ %   \let\@currsize#1%
+ %   \baselineskip #2%
+ %   \baselineskip \baselinestretch\baselineskip
+ %   \parskip \baselinestretch\parskip
+ %   \setbox\strutbox \hbox{%
+ %     \vrule height.7\baselineskip
+ %            depth .3\baselineskip
+ %            width \z@}%
+ %   \skip\footins \baselinestretch\skip\footins
+ %   \normalbaselineskip\baselineskip#3#4}
 
 \newenvironment{SingleSpace}{%
   \vskip\baselineskip
@@ -2394,14 +2427,23 @@
   \the\everydisplay
   \memdskips}
 
-\AtBeginDocument{
-  \let\m at m@xfloat\@xfloat
-  \def\@xfloat #1[#2]{%
-    \m at m@xfloat #1[#2]%
+\IfFormatAtLeastTF{2021/04/20}{%
+  \AddToHook{cmd/@xfloat/after}{%
     \def\baselinestretch{\m at m@float at spacing}%
     \normalsize%
-    \@nameuse{#1adjustment}%
-  }
+    \@nameuse{\@captype adjustment}% \@xfloat stores its #1 arg in \@captype
+  }%
+}{%
+  \AtBeginDocument{%
+    % \typeout{Old kernel, redefining \string\@xfloat\ instead of using a hook}
+    \let\m at m@xfloat\@xfloat%
+    \def\@xfloat #1[#2]{%
+      \m at m@xfloat #1[#2]%
+      \def\baselinestretch{\m at m@float at spacing}%
+      \normalsize%
+      \@nameuse{#1adjustment}%
+    }%
+  }%
 }
 
 \newdimen\memPD
@@ -2491,11 +2533,8 @@
 \newcommand{\makethanksmark}{%
   \leavevmode%
   \parindent 1em\noindent
-%%%  \leftskip\thanksmarksep\relax
   \memRTLleftskip\thanksmarksep\relax
-%%%  \advance\leftskip\thanksmarkwidth
   \advance\memRTLleftskip\thanksmarkwidth
-%%%  \null\nobreak\hskip-\leftskip\relax
   \null\nobreak\hskip-\memRTLleftskip\relax
   \makethanksmarkhook\relax
   \thanksfootmark}
@@ -2664,8 +2703,8 @@
 \newcommand*{\glossarymark}{}
 
 \setcounter{secnumdepth}{2}
-\newcounter{book} \setcounter{book}{0}
-\newcounter{part} \setcounter{part}{0}
+\newcounter{book}    \setcounter{book}{0}
+\newcounter{part}    \setcounter{part}{0}
 \newcounter{chapter} \setcounter{chapter}{0}
 \newcounter{section}[chapter]
 \newcounter{subsection}[section]
@@ -2745,7 +2784,7 @@
     \@memback at floats
   \fi}
 
-\def\theHbook{\arabic{book}}
+\def\theHbook{\the\value{book}}
 \def\toclevel at book{-2}
 
 \newcommand*{\book}{%
@@ -3035,7 +3074,7 @@
     \fi
   \fi
   \mempostaddchaptertotochook%
-  \ifheadnameref\M at gettitle{\f at rhdr}\else\M at gettitle{\f at rtoc}\fi%
+  \ifheadnameref\ExpandArgs{V}\M at gettitle\f at rhdr\else\ExpandArgs{V}\M at gettitle\f at rtoc\fi%
   \memendofchapterhook%
 }
 
@@ -3064,9 +3103,9 @@
   \addtocontents{lof}{\protect\addvspace{10pt}}%
   \addtocontents{lot}{\protect\addvspace{10pt}}}
 
-\newlength{\beforechapskip}\setlength{\beforechapskip}{50pt}
-\newlength{\midchapskip}\setlength{\midchapskip}{20pt}
-\newlength{\afterchapskip}\setlength{\afterchapskip}{40pt}
+\newlength{\beforechapskip} \setlength{\beforechapskip}{50pt}
+\newlength{\midchapskip}    \setlength{\midchapskip}{20pt}
+\newlength{\afterchapskip}  \setlength{\afterchapskip}{40pt}
 
 \newcommand{\@chs at def@ult}{%
   \def\chapterheadstart{\vspace*{\beforechapskip}}%
@@ -3099,7 +3138,7 @@
   \else
     \memchapstarinfo{\f at rhdr}{#2}%
   \fi
-  \ifheadnameref\M at gettitle{\f at rhdr}\else\M at gettitle{#2}\fi}
+  \ifheadnameref\ExpandArgs\M at gettitle\f at rhdr\else\M at gettitle{#2}\fi}
 
 \newcommand{\@schapter}[1]{%
   \m at mpn@new at schaptrue%
@@ -3694,6 +3733,8 @@
   \fi
   \@xsect{#5}}
 
+\def\@sect#1#2#3#4#5#6[#7]#8{\M at sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#7}]{#8}}
+
 \let\@mem at old@ssect\@ssect
 \def\@ssect#1#2#3#4#5{%
   \M at gettitle{#5}%
@@ -4291,7 +4332,7 @@
         \csname the##1\endcsname\quad}
   \fi
 }{%
-  \def\theHsection{\theHchapter.\arabic{section}}
+  \def\theHsection{\theHchapter.\the\value{section}}
 }
 
 \newcommand*{\leadpagetoclevel}{chapter}
@@ -4384,9 +4425,7 @@
   \vadjust{}{\parfillskip\z@\memorigpar}}
 
 \newcommand*{\centerlastline}{%
-%%%  \leftskip\@flushglue
   \memRTLleftskip\@flushglue
-%%%  \rightskip=\z@ plus -1fil
   \memRTLrightskip=\z@ plus -1fil
   \parfillskip=\z@ plus 2fil}
 
@@ -4408,16 +4447,12 @@
   \setlength{\ragrparindent}{\parindent}
 \newcommand{\raggedyright}[1][2em]{%
   \let\\\@centercr\@rightskip \z@ \@plus #1\relax
-%%%  \rightskip\@rightskip
   \memRTLrightskip\@rightskip
-%%%  \leftskip\z at skip
   \memRTLleftskip\z at skip
   \parindent\ragrparindent}
 
 \newcommand*{\justlastraggedleft}{%
-%%%  \leftskip\@flushglue
   \memRTLleftskip\@flushglue
-%%%  \rightskip-\leftskip
   \memRTLrightskip-\memRTLleftskip
   \parfillskip\leftskip
   \parindent \z@}
@@ -5198,8 +5233,8 @@
 \NumberPoemTitle
 
 \newcounter{poem}\setcounter{poem}{0}
-  \renewcommand*{\thepoem}{\@arabic\c at poem}
-\newcommand*{\theHpoem}{\arabic{poem}}
+\renewcommand*{\thepoem}{\@arabic\c at poem}
+\providecommand*{\theHpoem}{\the\value{poem}}
 
 \newcommand*{\poemtitlestarmark}[1]{}
 \newcommand*{\poemtitlepstyle}{}
@@ -5252,7 +5287,7 @@
     \addcontentsline{toc}{\poemtoc}{\poemf at rtoc}%
     \memPoemTitleinfo{}{\poemf at rtoc}{\poemf at rhdr}{#2}%
   \fi
-  \ifheadnameref\M at gettitle{\poemf at rhdr}\else\M at gettitle{\poemf at rtoc}\fi}
+  \ifheadnameref\ExpandArgs{V}\M at gettitle\poemf at rhdr\else\ExpandArgs{V}\M at gettitle\poemf at rtoc\fi}
 
 \def\@makePoemTitlehead#1{{%
   \PoemTitleheadstart
@@ -5330,336 +5365,6 @@
   \ifnum \c at chapter>\z@ \thechapter.\fi \@arabic\c at equation}
 
 \RequirePackage{array}[2018/04/30]
- %
- % %%%%%%%%%% Array package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% Frank Mittelbach & David Carlisle %%%%%%%%%%%%%%%%%%%%%
- %
- % %%%%%%%%%% Copy corresponds to array.sty 2016/10/06 v2.4d %%%%%%%%%
- % % \newcount \@chclass
- % % \newcount \@chnum
- % % \newcount \@lastchclass
- % \def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}}
- % \def\@testpach{\@chclass
- %  \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
- %   \ifnum \@lastchclass=7 5 \else
- %    \ifnum \@lastchclass=8 \tw@ \else
- %     \ifnum \@lastchclass=9 \thr@@
- %    \else \z@
- %    \ifnum \@lastchclass = 10 \else
- %    \edef\@nextchar{\expandafter\string\@nextchar}%
- %    \@chnum
- %    \if \@nextchar c\z@ \else
- %     \if \@nextchar l\@ne \else
- %      \if \@nextchar r\tw@ \else
- %    \z@ \@chclass
- %    \if\@nextchar |\@ne \else
- %     \if \@nextchar !6 \else
- %      \if \@nextchar @7 \else
- %       \if \@nextchar <8 \else
- %        \if \@nextchar >9 \else
- %   10
- %   \@chnum
- %   \if \@nextchar m\thr@@\else
- %    \if \@nextchar p4 \else
- %     \if \@nextchar b5 \else
- %    \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi
- %    \fi \fi  \fi  \fi  \fi  \fi  \fi \fi \fi \fi \fi \fi}
- % \def\@xexpast#1*#2#3#4\@@{%
- %    \@tempcnta #2
- %    \toks@={#1}\@temptokena={#3}%
- %    \let\the at toksz\relax \let\the at toks\relax
- %    \def\@tempa{\the at toksz}%
- %    \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do
- %      {\edef\@tempa{\@tempa\the at toks}\advance \@tempcnta \m at ne}%
- %        \let \@tempb \@xexpast \else
- %        \let \@tempb \@xexnoop \fi
- %    \def\the at toksz{\the\toks@}\def\the at toks{\the\@temptokena}%
- %    \edef\@tempa{\@tempa}%
- %    \expandafter \@tempb \@tempa #4\@@}
- % %  \def\@xexnoop#1\@@{}
- % \def\prepnext at tok{\advance \count@ \@ne
- %    \toks\count@{}}
- % \def\save at decl{\toks\count@ \expandafter{\@nextchar}}
- % \def\insert at column{%
- %    \the at toks \the \@tempcnta
- %    \ignorespaces \@sharp \unskip
- %    \the at toks \the \count@ \relax}
- % %    \newif \@iffirstamp
- % %    \def\@addamp{\if at firstamp \@firstampfalse
- % %                 \else \@addtopreamble &\fi}
- % \newdimen\col at sep
- % \def\@acol{\@addtopreamble{\hskip\col at sep}}
- % %    \def\@acolampacol{\@acol\@addamp\@acol}
- % \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
- %    \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
- %    \@xexpast #1*0x\@@
- %    \count@\m at ne
- %    \let\the at toks\relax
- %    \prepnext at tok
- %    \expandafter \@tfor \expandafter \@nextchar
- %     \expandafter :\expandafter =\@tempa \do
- %    {\@testpach
- %    \ifcase \@chclass \@classz \or \@classi \or \@classii
- %      \or \save at decl \or \or \@classv \or \@classvi
- %      \or \@classvii \or \@classviii  \or \@classix
- %      \or \@classx \fi
- %    \@lastchclass\@chclass}%
- %    \ifcase\@lastchclass
- %    \@acol \or
- %    \or
- %    \@acol \or
- %    \@preamerr \thr@@ \or
- %    \@preamerr \tw@ \@addtopreamble\@sharp \or
- %    \or
- %    \else  \@preamerr \@ne \fi
- %    \def\the at toks{\the\toks}}
- % \def\@classx{%
- %   \ifcase \@lastchclass
- %   \@acolampacol \or
- %   \@addamp \@acol \or
- %   \@acolampacol \or
- %   \or
- %   \@acol \@firstampfalse \or
- %   \@addamp
- %   \fi}
- % \def\@classz{\@classx
- %    \@tempcnta \count@
- %    \prepnext at tok
- %    \@addtopreamble{\ifcase \@chnum
- %       \hfil
- %       \d at llarbegin
- %       \insert at column
- %       \d at llarend \hfil \or
- %       \hskip1sp\d at llarbegin \insert at column \d at llarend \hfil \or
- %       \hfil\hskip1sp\d at llarbegin \insert at column \d at llarend \or
- %    $\vcenter%$ emacs
- %    \@startpbox{\@nextchar}\insert at column \@endpbox $\or%$ emacs
- %    \vtop \@startpbox{\@nextchar}\insert at column \@endpbox \or
- %    \vbox \@startpbox{\@nextchar}\insert at column \@endpbox
- %   \fi}\prepnext at tok}
- % \def\@classix{\ifnum \@lastchclass = \thr@@
- %        \@preamerr \thr@@ \fi
- %        \@classx}
- % \def\@classviii{\ifnum \@lastchclass >\z@
- %       \@preamerr 4\@chclass 6 \@classvi \fi}
- % \def\@arrayrule{\@addtopreamble \vline}
- % \def\@classvii{\ifnum \@lastchclass = \thr@@
- %    \@preamerr \thr@@ \fi}
- % \def\@classvi{\ifcase \@lastchclass
- %       \@acol \or
- %       \@addtopreamble{\hskip \doublerulesep}\or
- %       \@acol \or
- %       \@classvii
- %       \fi}
- % \def\@classii{\advance \count@ \m at ne
- %    \save at decl\prepnext at tok}
- % \def\@classv{\save at decl
- %    \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
- %    \prepnext at tok}
- % \def\@classi{\@classvi
- %    \ifcase \@chnum \@arrayrule \or
- %       \@classv \fi}
- % \def\@startpbox#1{\bgroup
- %   \setlength\hsize{#1}\@arrayparboxrestore
- %    \everypar{%
- %       \vrule \@height \ht\@arstrutbox \@width \z@
- %       \everypar{}}%
- %    }
- % \def\@endpbox{\@finalstrut\@arstrutbox \egroup\hfil}
- % \def\@array[#1]#2{%
- %   \@tempdima \ht \strutbox
- %   \advance \@tempdima by\extrarowheight
- %   \setbox \@arstrutbox \hbox{\vrule
- %              \@height \arraystretch \@tempdima
- %              \@depth \arraystretch \dp \strutbox
- %              \@width \z@}%
- %   \begingroup
- %   \@mkpream{#2}%
- %   \xdef\@preamble{\noexpand \ialign \@halignto
- %                   \bgroup \@arstrut \@preamble
- %                           \tabskip \z@ \cr}%
- %   \endgroup
- %   \@arrayleft
- %   \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
- %   \bgroup
- %   \let \@sharp ##\let \protect \relax
- %   \lineskip \z@
- %   \baselineskip \z@
- %   \m at th
- %   \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble}
- % \def\arraybackslash{\let\\\tabularnewline}
- % \newdimen \extrarowheight
- % \extrarowheight=0pt
- % \def\@arstrut{\unhcopy\@arstrutbox}
- % \def\@arraycr{\relax\iffalse{\fi\ifnum 0=`}\fi
- %   \@ifstar \@xarraycr \@xarraycr}
- % \def\@xarraycr{\@ifnextchar [%
- %   \@argarraycr {\ifnum 0=`{}\fi\cr}}
- % \def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@
- %   \expandafter\@xargarraycr\else
- %   \expandafter\@yargarraycr\fi{#1}}
- % \def\@xargarraycr#1{\unskip
- %   \@tempdima #1\advance\@tempdima \dp\@arstrutbox
- %   \vrule \@depth\@tempdima \@width\z@ \cr}
- % \def\@yargarraycr#1{\cr\noalign{\vskip #1}}
- % \long\def\multicolumn#1#2#3{%
- %    \multispan{#1}\begingroup
- %    \def\@addamp{\if at firstamp \@firstampfalse \else
- %                 \@preamerr 5\fi}%
- %    \@mkpream{#2}\@addtopreamble\@empty
- %    \endgroup
- %    \def\@sharp{#3}%
- %    \@arstrut \@preamble
- %    \null
- %    \ignorespaces}
- % \let\d at llarbegin\begingroup
- % \let\d at llarend\endgroup
- % \def\array{\col at sep\arraycolsep
- %   \def\d at llarbegin{$}\let\d at llarend\d at llarbegin\def\@halignto{}%$ emacs
- %   \@tabarray}
- % \def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
- % \def\tabular{\def\@halignto{}\@tabular}
- % \expandafter\def\csname tabular*\endcsname#1{%
- %        \setlength\dimen@{#1}%
- %        \edef\@halignto{to\the\dimen@}\@tabular}
- % \def\@tabular{%
- %   \leavevmode
- %   \hbox \bgroup $\col at sep\tabcolsep \let\d at llarbegin\begingroup% $ emacs
- %                                     \let\d at llarend\endgroup
- %   \@tabarray}
- % \def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
- % \def\endtabular{\endarray $\egroup}%$ emacs
- % \expandafter\let\csname endtabular*\endcsname=\endtabular
- % \let\@ampacol=\relax        \let\@expast=\relax
- % \let\@arrayclassiv=\relax   \let\@arrayclassz=\relax
- % \let\@tabclassiv=\relax     \let\@tabclassz=\relax
- % \let\@arrayacol=\relax      \let\@tabacol=\relax
- % \let\@tabularcr=\relax      \let\@@endpbox=\relax
- % \let\@argtabularcr=\relax   \let\@xtabularcr=\relax
- % \def\@preamerr#1{\def\@tempd{{..} at wrong position: }%
- %    %\PackageError{array}{%
- %    \ClassError{memoir}{% changed in menoir
- %    \ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0
- %     Missing arg: token ignored\or                           %1
- %     Empty preamble: `l' used\or                             %2
- %     >\@tempd token ignored\or                               %3
- %     <\@tempd changed to !{..}\or                            %4
- %     Only one column-spec. allowed.\fi}\@ehc}                %5
- % \def\newcolumntype#1{%
- %   \edef\NC at char{\string#1}%
- %   \@ifundefined{NC at find@\NC at char}%
- %     {\@tfor\next:=<>clrmbp@!|\do{\if\noexpand\next\NC at char
- %         %\PackageWarning{array}%
- %           \@memwarn{Redefining primitive column \NC at char}\fi}% memoir change
- %      \NC at list\expandafter{\the\NC at list\NC at do#1}}%
- %    {%\PackageWarning{array}
- %       \@memwarn{Column \NC at char\space is already defined}}% memoir change
- %   \@namedef{NC at find@\NC at char}##1#1{\NC@{##1}}%
- %   \@ifnextchar[{\newcol@{\NC at char}}{\newcol@{\NC at char}[0]}}
- % \def\newcol@#1[#2]#3{\expandafter\@reargdef
- %      \csname NC at rewrite@#1\endcsname[#2]{\NC at find#3}}
- % \def\NC@#1{%
- %   \@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC at ifend}
- % \def\NC at ifend{%
- %   \ifx\next\relax
- %     \else\@tempswatrue\expandafter\NC at rewrite\fi}
- % \def\NC at do#1{%
- %   \expandafter\let\expandafter\NC at rewrite
- %     \csname NC at rewrite@\string#1\endcsname
- %   \expandafter\let\expandafter\NC at find
- %     \csname NC at find@\string#1\endcsname
- %   \expandafter\@temptokena\expandafter{\expandafter}%
- %         \expandafter\NC at find\the\@temptokena#1\relax}
- % \def\showcols{{\def\NC at do##1{\let\NC at do\NC at show}\the\NC at list}}
- % \def\NC at show#1{%
- %   \typeout{Column #1\expandafter\expandafter\expandafter\NC at strip
- %   \expandafter\meaning\csname NC at rewrite@#1\endcsname\@@}}
- % \def\NC at strip#1:#2->#3 #4\@@{#2 -> #4}
- % \newtoks\NC at list
- % \newcolumntype{*}[2]{}
- % \long\@namedef{NC at rewrite@*}#1#2{%
- %   \count@#1\relax
- %   \loop
- %   \ifnum\count@>\z@
- %   \advance\count@\m at ne
- %   \@temptokena\expandafter{\the\@temptokena#2}%
- %   \repeat
- %   \NC at find}
- % \let\@xexpast\relax
- % \let\@xexnoop\relax
- % \def\save at decl{\toks \count@ = \expandafter\expandafter\expandafter
- %                   {\expandafter\@nextchar\the\toks\count@}}
- % \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
- %    \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
- %    \@temptokena{#1}\@tempswatrue
- %    \@whilesw\if at tempswa\fi{\@tempswafalse\the\NC at list}%
- %    \count@\m at ne
- %    \let\the at toks\relax
- %    \prepnext at tok
- %    \expandafter \@tfor \expandafter \@nextchar
- %     \expandafter :\expandafter =\the\@temptokena \do
- %    {\@testpach
- %    \ifcase \@chclass \@classz \or \@classi \or \@classii
- %      \or \save at decl \or \or \@classv \or \@classvi
- %      \or \@classvii \or \@classviii
- %      \or \@classx
- %      \or \@classx \fi
- %    \@lastchclass\@chclass}%
- %    \ifcase\@lastchclass
- %    \@acol \or
- %    \or
- %    \@acol \or
- %    \@preamerr \thr@@ \or
- %    \@preamerr \tw@ \@addtopreamble\@sharp \or
- %    \or
- %    \else  \@preamerr \@ne \fi
- %    \def\the at toks{\the\toks}}
- % \let\@classix\relax
- % \def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else
- %       \@preamerr 4\@chclass 6 \@classvi \fi\fi}
- % \def\@classv{\save at decl
- %    \expandafter\NC at ecs\@nextchar\extracolsep{}\extracolsep\@@@
- %    \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
- %    \prepnext at tok}
- % \def\NC at ecs#1\extracolsep#2#3\extracolsep#4\@@@{\def\@tempa{#2}%
- %   \ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi}
- % \def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}}
- % \let\@@array\@array
- % \def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}}
- % \let\@arrayleft\@empty
- % \let\@arrayright\@empty
- % \newlength{\extratabsurround}
- % \setlength{\extratabsurround}{2pt}
- % \newlength{\backup at length}
- % \newcommand{\firsthline}{%}} emacs
- %   \multicolumn1c{%
- %     \global\backup at length\ht\@arstrutbox
- %     \global\advance\backup at length\dp\@arstrutbox
- %     \global\advance\backup at length\arrayrulewidth
- %      \raise\extratabsurround\copy\@arstrutbox
- %     }\\[-\backup at length]\hline
- % }
- % \newcommand{\lasthline}{\hline\multicolumn1c{%}} emacs
- %     \global\backup at length2\ht\@arstrutbox
- %     \global\advance\backup at length2\dp\@arstrutbox
- %     \global\advance\backup at length\arrayrulewidth
- %     }\\[-\backup at length]%
- %     \multicolumn1c{%
- %        \lower\extratabsurround\copy\@arstrutbox
- %        }%
- % }
- % \CheckCommand*\@xhline{\ifx\reserved at a\hline
- %                \vskip\doublerulesep
- %                \vskip-\arrayrulewidth
- %              \fi
- %       \ifnum0=`{\fi}}
- % \renewcommand*\@xhline{\ifx\reserved at a\hline
- %                \vskip\doublerulesep
- %              \fi
- %       \ifnum0=`{\fi}}
- % %%%%%%%%%% end array.sty 2016/10/06 v2.4d %%%%%%%%%
- %
 \newif \@iffirstamp
 \let\m at mold@addamp\@addamp
 \newcommand*{\m at m@addamp}{%
@@ -5674,450 +5379,12 @@
 
 
 \RequirePackage{dcolumn}[2014/10/28]
- % %%%%%%%%%% Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- %
- % \def\DC@#1#2#3{%
- %   \uccode`\~=`#1\relax
- %   \m at th
- %   \afterassignment\DC at x\count@#3\relax{#1}{#2}}
- % \def\DC at x#1\relax#2#3{%
- %   \ifnum\z@>\count@
- %     \expandafter\DC at centre
- %   \else
- %     \expandafter\DC at right
- %   \fi
- %   {#2}{#3}{#1}}
- % \def\DC at centre#1#2#3{%
- %   \let\DC at end\DC at endcentre
- %   \uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}%$
- %   \setbox\tw@=\hbox{${\phantom{{#2}}}$}%
- %   \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 }%$
- % \def\DC at endcentre{$\egroup%$
- %     \ifdim \wd\z@>\wd\tw@
- %       \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}%
- %     \else
- %       \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi
- %     \box\z@\box\tw@}
- % \def\DC at right#1#2#3{%
- %   \ifx\relax#3\relax
- %     \hfill
- %     \let\DC at rl\bgroup
- %   \else
- %     \edef\DC at rl{to\the\count@\dimen at ii\bgroup\hss\hfill}%
- %     \count@\@gobble#3\relax
- %   \fi
- %   \let\DC at end\DC at endright
- %   \uppercase{\def~}{$\egroup\setbox\tw@\hbox to\dimen@\bgroup${#2}}%
- %    \setbox\z@\hbox{$1$}\dimen at ii\wd\z@
- %    \dimen@\count@\dimen at ii
- %    \setbox\z@\hbox{${#2}$}\advance\dimen@\wd\z@
- %    \setbox\tw@\hbox to\dimen@{}%
- %    \setbox\z@\hbox\DC at rl$\mathcode`#1="8000 }%$
- % \def\DC at endright{$\hfil\egroup\box\z@\box\tw@}%$
- % \newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC at end}}
- %
- % %%%%%%%%%% end Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
- %
 \RequirePackage{delarray}[2014/10/28]
- % %%%%%%%%%% Delarray package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- %
- % \def\@@array[#1]{\@ifnextchar\bgroup
- %   {\let\@arrayleft\relax\let\@arrayright\relax\@array[#1]}%
- %   {\@del at array[#1]}}
- % \def\@del at array[#1]#2#3#4{%
- %   \setbox\z@\hbox{$\left#2\right#4$}%
- %   \if#1c\def\@arrayleft{\left#2}\def\@arrayright{\right#4}%
- %   \else\def\@arrayleft{\setbox\z@}%
- %   \def\@arrayright{%
- %      \dimen@=\dp\z@
- %      \advance\dimen at -\ht\z@
- %      \divide \dimen@ by \tw@
- %      \advance\dimen@ by\fontdimen22 \textfont\tw@
- %      \lower\dimen@\hbox{$\left#2\vcenter{\unvbox\z@}\right#4$}}%
- %   \fi
- %   \@array[#1]{#3}}
- % %%%%%%%%%% end Delarray package code %%%%%%%%%%%%%%%%%%%%%
- %
 \RequirePackage{tabularx}[2016/02/03]
-
- % %%%%%%%%%% Tabularx package code %%%%%%%%%%%%%%%%%%%%%
- % %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
- %
- % %%% This is a carbon copy of the tabularx dtx sources for v2.11,
- % %%% 2016/02/03 with two changes: error messages mention the class
- % %%% instead of tabularx.
- %
- % %%%%%%%%%% Tabularx package code v2.11 2016/02/03 %%%%%%%%%%%%%%%%%%%%%
- %
- % \newdimen\TX at col@width
- % \newdimen\TX at old@table
- % \newdimen\TX at old@col
- % \newdimen\TX at target
- % \newdimen\TX at delta
- % \newcount\TX at cols
- % \newif\ifTX@
- % \def\tabularx#1{%
- % \edef\TX@{\@currenvir}%
- %   {\ifnum0=`}\fi
- %   \setlength\TX at target{#1}%
- %   \TX at typeout{Target width: #1 = \the\TX at target.}%
- %   \toks@{}\TX at get@body}
- % \let\endtabularx\relax
- % \long\def\TX at get@body#1\end
- %   {\toks@\expandafter{\the\toks@#1}\TX at find@end}
- % \def\TX at find@end#1{%
- %   \def\@tempa{#1}%
- %   \ifx\@tempa\TX@\expandafter\TX at endtabularx
- %   \else\toks@\expandafter
- %     {\the\toks@\end{#1}}\expandafter\TX at get@body\fi}
- % \long\def\TX at find@endtabularxa
- %        #1\endtabularx#2\endtabularx#3\TX at find@endtabularxa{%
- %   \ifx\TX@#2\relax\else
- %   \toks@\expandafter{\the\toks@#1}%
- %   \fi}
- % \long\def\TX at find@endtabularxb
- %        #1\endtabularx#2\endtabularx#3\TX at find@endtabularxb{%
- %   \ifx\TX@#2%
- %     \expandafter\@firstoftwo
- %   \else
- %      \expandafter\@secondoftwo
- %   \fi
- %   {#1}{#2}}
- % \def\TX at find@endtabularxbb{%
- %   \expandafter\expandafter\expandafter
- %   \TX at find@endtabularxb
- % }
- % \def\TX@{tabularx}
- % \def\TX at endtabularx{%
- %    \expandafter\expandafter\expandafter
- %      \TX at find@endtabularxa\csname end\TX@\endcsname
- %      \endtabularx\TX@\endtabularx\TX at find@endtabularxa
- %   \expandafter\TX at newcol\expandafter{\tabularxcolumn{\TX at col@width}}%
- %   \let\verb\TX at verb
- %   \def\@elt##1{\global\value{##1}\the\value{##1}\relax}%
- %   \edef\TX at ckpt{\cl@@ckpt}%
- %   \let\@elt\relax
- %   \TX at old@table\maxdimen
- %   \TX at col@width\TX at target
- %   \global\TX at cols\@ne
- %   \TX at typeout@
- %     {\@spaces Table Width\@spaces Column Width\@spaces X Columns}%
- %   \TX at trial{\def\NC at rewrite@X{%
- %           \global\advance\TX at cols\@ne\NC at find p{\TX at col@width}}}%
- %   \loop
- %     \TX at arith
- %     \ifTX@
- %     \TX at trial{}%
- %   \repeat
- %   {\let\@footnotetext\TX at ftntext\let\@xfootnotenext\TX at xftntext
- %     \csname tabular*\expandafter\endcsname\expandafter\TX at target
- %       \the\toks@
- %     \csname endtabular*\endcsname}%
- %   \global\TX at ftn\expandafter{\expandafter}\the\TX at ftn
- %   \ifnum0=`{\fi}%
- %    \expandafter\expandafter\expandafter
- %    \TX at find@endtabularxbb
- %     \expandafter\end\expandafter{\TX@}%
- %     \endtabularx\TX@\endtabularx\TX at find@endtabularxb
- % }
- % \def\TX at arith{%
- %   \TX at false
- %   \@tempdimb\maxdimen
- %   \divide\@tempdimb\TX at cols
- %   \ifdim\TX at col@width>\@tempdimb
- %     \TX at typeout@{Don't exceed \maxdimen}%
- %     \wd\@tempboxa\maxdimen
- %   \fi
- %   \ifdim\TX at old@table=\wd\@tempboxa
- %     \TX at col@width\TX at old@col
- %     \TX at typeout@{Reached minimum width, backing up.}%
- %   \else
- %     \dimen@\wd\@tempboxa
- %     \advance\dimen@ -\TX at target
- %     \ifdim\dimen@<\TX at delta
- %       \TX at typeout@{Reached target.}%
- %     \else
- %       \ifnum\TX at cols>\@ne
- %         \advance\TX at cols\m at ne
- %       \fi
- %       \divide\dimen@\TX at cols
- %       \advance\dimen@ -\TX at col@width
- %       \ifdim \dimen@ >\z@
- %         %\PackageWarning{tabularx}%
- %          \@memwarn{X Columns too narrow (table too wide)\MessageBreak}% <-- change here
- %         \TX at col@width\TX at error@width\relax
- %       \else
- %         \TX at old@col\TX at col@width
- %         \TX at old@table\wd\@tempboxa
- %         \TX at col@width-\dimen@
- %         \TX at true
- %       \fi
- %     \fi
- %   \fi}
- % \def\TX at error@width{1em}
- % \TX at delta\hfuzz
- % \newcolumntype{X}{}
- % \def\tabularxcolumn#1{p{#1}}
- % \def\TX at newcol{\newcol@{X}[0]}
- % \def\TX at trial#1{%
- %   \setbox\@tempboxa\hbox{%
- %     #1\relax
- %   \let\@footnotetext\TX at trial@ftn
- %   \let\TX at vwarn\@empty
- %    \expandafter\let\expandafter\tabularx\csname tabular*\endcsname
- %    \expandafter\let\expandafter\endtabularx\csname endtabular*\endcsname
- %    \def\write{\begingroup
- %      \def\let{\afterassignment\endgroup\toks@}%
- %         \afterassignment\let\count@}%
- %     \hbadness\@M
- %     \hfuzz\maxdimen
- %     \let\hbadness\@tempcnta
- %     \let\hfuzz\@tempdima
- %     \expandafter\tabular\the\toks@
- %     \endtabular}%
- %   \TX at ckpt
- %   \TX at typeout@{\@spaces
- %      \expandafter\TX at align
- %         \the\wd\@tempboxa\space\space\space\space\space\@@
- %      \expandafter\TX at align
- %         \the\TX at col@width\space\space\space\space\space\@@
- %      \@spaces\the\TX at cols}}
- % \def\TX at align#1.#2#3#4#5#6#7#8#9\@@{%
- %   \ifnum#1<10 \space\fi
- %   \ifnum#1<100 \space\fi
- %   \ifnum#1<\@m\space\fi
- %   \ifnum#1<\@M\space\fi
- %   #1.#2#3#4#5#6#7#8\space\space}
- % \ifx\arraybackslash\@undefined
- % \def\arraybackslash{\let\\\tabularnewline}
- % \fi
- % \def\tracingtabularx{%
- %   %\def\TX at typeout{\PackageWarningNoLine{tabularx}}%
- %   \def\TX at typeout{\ClassWarningNoLine{memoir}}% <--- changed
- %   \def\TX at typeout@##1{\typeout{(tabularx) ##1}}}
- % \let\TX at typeout\@gobble
- % \let\TX at typeout@\@gobble
- % \newtoks\TX at ftn
- % \long\def\TX at ftntext#1{%
- %   \edef\@tempa{\the\TX at ftn\noexpand\footnotetext
- %                     [\the\csname c@\@mpfn\endcsname]}%
- %   \global\TX at ftn\expandafter{\@tempa{#1}}}%
- % \long\def\TX at xftntext[#1]#2{%
- %   \global\TX at ftn\expandafter{\the\TX at ftn\footnotetext[#1]{#2}}}
- % \long\def\TX at trial@ftn#1{}
- % {\uccode`\*=`\ %
- % \uppercase{\gdef\TX at verb{%
- %   \leavevmode\null\TX at vwarn
- %   {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
- %   \@ifstar{\let~*\TX at vb}{\TX at vb}}}}
- % \def\TX at vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
- %     \expandafter\TX at v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
- % \def\TX at v#1!{\afterassignment\TX at vfirst\let\@tempa= }
- % \begingroup
- % \catcode`\*=\catcode`\#
- % \catcode`\#=12
- % \gdef\TX at vfirst{%
- %   \if\@tempa#%
- %     \def\@tempb{\TX at v@#}%
- %   \else
- %     \let\@tempb\TX at v@
- %     \if\@tempa\space~\else\@tempa\fi
- %   \fi
- %   \@tempb}
- % \gdef\TX at v@*1 *2{%
- %   \TX at v@hash*1##\relax\if*2\\\else~\expandafter\TX at v@\fi*2}
- % \gdef\TX at v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX at v@hash\fi*2}
- % \endgroup
- % \def\TX at vwarn{%
- %   \@warning{\noexpand\verb may be unreliable inside tabularx}%
- %   \global\let\TX at vwarn\@empty}
- %
- % %%%%%%%%%% end Tabularx package code v2.11 %%%%%%%%%%%%%%%%%%%%%
- %
- %
- %
- %
- % %%\@memfakeusepackage{array}
- % %%\@memfakeusepackage{dcolumn}
- % %%\@memfakeusepackage{delarray}
- % %%\@memfakeusepackage{tabularx}
- %
 \newcommand*{\bktabrule}[1]{%
   \hrule \@height#1}
 
-%%%%%%%%%% Booktabs package code       %%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% slightly modified by PRW    %%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% by permission of Simon Fear %%%%%%%%%%%%%%%%%%%%%
-
-\AtBeginDocument{%
-  \providecommand*{\CT at arc@}{}}
-
-\newdimen\heavyrulewidth
-\newdimen\lightrulewidth
-\newdimen\cmidrulewidth
-\newdimen\belowrulesep
-\newdimen\belowbottomsep
-\newdimen\aboverulesep
-\newdimen\abovetopsep
-\newdimen\cmidrulesep
-\newdimen\cmidrulekern
-\newdimen\defaultaddspace
-\heavyrulewidth=.08em
-\lightrulewidth=.05em
-\cmidrulewidth=.03em
-\belowrulesep=.65ex
-\belowbottomsep=\z@
-\aboverulesep=.4ex
-\abovetopsep=\z@
-\cmidrulesep=\doublerulesep
-\cmidrulekern=.5em
-\defaultaddspace=.5em
-
-\newcount\@cmidla
-\newcount\@cmidlb
-\newdimen\@aboverulesep
-\newdimen\@belowrulesep
-\newcount\@thisruleclass
-\newcount\@lastruleclass
-\@lastruleclass=0
-\newdimen\@thisrulewidth
-
-\def\futurenonspacelet#1{\def\@BTcs{#1}%
- \afterassignment\@BTfnslone\let\nexttoken= }
-\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
-\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
- \else\let\next=\nexttoken\fi \next}
-\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }
-
-
-
-
-\def\toprule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\abovetopsep
-  \global\@belowrulesep=\belowrulesep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
-
-\def\midrule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\aboverulesep
-  \global\@belowrulesep=\belowrulesep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\lightrulewidth]}}
-
-\def\bottomrule{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=\aboverulesep
-  \global\@belowrulesep=\belowbottomsep
-  \global\@thisruleclass=\@ne
-  \@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
-
-\def\specialrule#1#2#3{\noalign{\ifnum0=`}\fi
-  \@aboverulesep=#2\global\@belowrulesep=#3\global\@thisruleclass=\tw@
-  \@BTrule[#1]}
-
-\def\addlinespace{\noalign{\ifnum0=`}\fi
-  \@ifnextchar[{\@addspace}{\@addspace[\defaultaddspace]}}
-\def\@addspace[#1]{\global\@belowrulesep=#1\global\@thisruleclass=\tw@
-  \futurelet\@tempa\@BTendrule}
-
-\def\@BTrule[#1]{%
-  \ifx\longtable\undefined
-    \let\@BTswitch\@BTnormal
-  \else\ifx\hline\LT at hline
-    \nobreak
-    \let\@BTswitch\@BLTrule
-  \else
-    \let\@BTswitch\@BTnormal
-  \fi\fi
-  \global\@thisrulewidth=#1\relax
-  \ifnum\@thisruleclass=\tw@\vskip\@aboverulesep\else
-  \ifnum\@lastruleclass=\z@\vskip\@aboverulesep\else
-  \ifnum\@lastruleclass=\@ne\vskip\doublerulesep\fi\fi\fi
-  \@BTswitch}
-
-\def\@BTnormal{%
-%%  \bktabrule{\@thisrulewidth}
-  {\CT at arc@\bktabrule{\@thisrulewidth}}%
-  \futurenonspacelet\@tempa\@BTendrule}
-\def\@BLTrule{\@ifnextchar({\@@BLTrule}{\@@BLTrule()}}
-\def\@@BLTrule(#1){\@setrulekerning{#1}%
-\global\@cmidlb\LT at cols
-\ifnum0=`{\fi}%
-\@cmidruleb
-\noalign{\ifnum0=`}\fi
-\futurenonspacelet\@tempa\@BTendrule}
-
-\def\@BTendrule{%
-  \ifx\@tempa\toprule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\midrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\bottomrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\cmidrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\specialrule\global\@lastruleclass=\@thisruleclass
-  \else\ifx\@tempa\addlinespace\global\@lastruleclass=\@thisruleclass
-  \else\global\@lastruleclass=\z@\fi\fi\fi\fi\fi\fi
-  \ifnum\@lastruleclass=\@ne\relax\else\vskip\@belowrulesep\fi
-  \ifnum0=`{\fi}}
-\def\@setrulekerning#1{%
-  \global\let\cmrkern at l\z@
-  \global\let\cmrkern at r\z@
-  \@tfor\@tempa :=#1\do
-  {\def\@tempb{r}%
-   \ifx\@tempa\@tempb
-     \global\let\cmrkern at r\cmidrulekern
-      \def\cmrsideswitch{\cmrkern at r}%
-   \else
-     \def\@tempb{l}%
-     \ifx\@tempa\@tempb
-       \global\let\cmrkern at l\cmidrulekern
-       \def\cmrsideswitch{\cmrkern at l}%
-     \else
-       \global\expandafter\let\cmrsideswitch\@tempa
-     \fi
-   \fi}}
-
-\def\cmidrule{\noalign{\ifnum0=`}\fi
-    \@ifnextchar[{\@cmidrule}{\@cmidrule[\cmidrulewidth]}}
-\def\@cmidrule[#1]{\@ifnextchar({\@@cmidrule[#1]}{\@@cmidrule[#1]()}}
-\def\@@cmidrule[#1](#2)#3{\@@@cmidrule[#3]{#1}{#2}}
-
-\def\@@@cmidrule[#1-#2]#3#4{\global\@cmidla#1\relax
-    \global\advance\@cmidla\m at ne
-    \ifnum\@cmidla>0\global\let\@gtempa\@cmidrulea\else
-    \global\let\@gtempa\@cmidruleb\fi
-    \global\@cmidlb#2\relax
-    \global\advance\@cmidlb-\@cmidla
-    \global\@thisrulewidth=#3
-    \@setrulekerning{#4}
-    \ifnum\@lastruleclass=\z@\vskip \aboverulesep\fi
-    \ifnum0=`{\fi}\@gtempa
-    \noalign{\ifnum0=`}\fi\futurenonspacelet\@tempa\@xcmidrule}
-\def\@xcmidrule{\ifx\@tempa\cmidrule\vskip-\@thisrulewidth
-    \global\@lastruleclass=\@ne\else
-    \ifx\@tempa\morecmidrules\vskip \cmidrulesep
-    \global\@lastruleclass=\@ne\else
-    \vskip \belowrulesep\global\@lastruleclass=\z@\fi\fi
-    \ifnum0=`{\fi}}
-
-\def\@cmidrulea{%
-  \multispan\@cmidla&\multispan\@cmidlb
-%%    \unskip\hskip \cmrkern at l\leaders\bktabrule{\@thisrulewidth}\hfill
-    \unskip\hskip \cmrkern at l{%
-    \CT at arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
-    \hskip \cmrkern at r\cr}
-\def\@cmidruleb{%
-  \multispan\@cmidlb
-%%    \unskip\hskip \cmrkern at l\leaders\bktabrule{\@thisrulewidth}\hfill
-  \unskip\hskip \cmrkern at l{%
-    \CT at arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
-    \hskip \cmrkern at r\cr}
-
-\def\morecmidrules{\noalign{\relax}}
-
-%%%%%%%%%% end of Booktabs package code %%%%%%%%%%%%%%%%%%%%%
-
-%%\@memfakeusepackage{booktabs}
-
+\RequirePackage{booktabs}[2020/01/12]
 \newskip\ctableftskip \ctableftskip=\fill
 \newskip\ctabrightskip \ctabrightskip=\fill
 
@@ -6442,8 +5709,6 @@
   \newenvironment{#2*}{\@dblfloat{#2}}{\end at dblfloat}
 } % end \newfloat
 
-  %\let\mem at old@xfloat\@xfloat
-  %\def\@xfloat#1[#2]{\mem at old@xfloat{#1}[#2]\@nameuse{#1adjustment}}
 \newcommand*{\setfloatlocations}[2]{\@namedef{fps@#1}{#2}}
 
 \newcommand*\setfloatadjustment[2]{\@namedef{#1adjustment}{#2}}
@@ -6880,7 +6145,7 @@
     \ifdonemaincaption\else
       \advance\csname c@\@captype\endcsname\@ne
     \fi
-    \refstepcounter{sub\@captype}\@contkeep
+    \mem at step@subcounter%
     \@ifnextchar [%
       {\@memsubcap{sub\@captype}}%
       {\@memsubcap{sub\@captype}[\@empty]}}
@@ -6908,10 +6173,10 @@
   \@makesubfloatcaption{\@nameuse{@the#1}}{#3}}
 
 \newcommand{\contsubcaption}{%
-  \bgroup
+  \bgroup%
     \let\label=\memsub at label
-    \@contset
-    \refstepcounter{sub\@captype}\@contkeep
+    \@contset%
+    \mem at step@subcounter%
     \@ifnextchar [%
       {\@memsubcap{sub\@captype}}%
       {\@memsubcap{sub\@captype}[\@empty]}}
@@ -6919,6 +6184,7 @@
 
 \newcommand\mem at step@subcounter{%
   \refstepcounter{sub\@captype}\@contkeep%
+  \UseHook{memoir/subcaption/aftercounter}%
 }
 \newcommand{\subbottom}{%
   \@contbotsubtrue
@@ -7072,68 +6338,25 @@
                      \@nameuse{p at sub\@captype}%
                      \@nameuse{thesub\@captype})}}
 \def\sf at memsub@label(#1)#2{%
-  \protected at edef\mem at currentlabelname{#1}%
+  \protected at edef\@currentlabelname{#1}%
+  % if available we can also use %  \ExpandArgs{x}\mem at set@cln{#1}
   \sf@@memsub at label{#2}}
 
-\newcommand\sf@@memsub at label@hook[1]{}
+\AtBeginDocument{
+  \let\mem at kernel@label\label
+}
 
-\AtBeginDocument{%
-  \@ifpackageloaded{nameref}{%
-    \newcommand*{\sf@@memsub at label}[1]{%
-      \@bsphack
-      \sf@@memsub at label@hook{#1}%
-      \protected at write\@auxout{}{%
-        \string\newlabel{#1}%
-          {{\@nameuse{p at sub\@captype}\@nameuse{@@thesub\@captype}}%
-          {\thepage}%
-          {\mem at currentlabelname\relax}%
-          {\@currentHref}{}}}%
-      \protected at write\@auxout{}{%
-        \string\newlabel{sub@#1}%
-          {{\@nameuse{@@thesub\@captype}}%
-          {\thepage}%
-          {\mem at currentlabelname\relax}%
-          {\@currentHref}{}}}%
-  \@esphack}
-  }{% no nameref
-    \@ifpackageloaded{hyperref}{%
-      \newcommand*{\sf@@memsub at label}[1]{%
-        \@bsphack
-        \sf@@memsub at label@hook{#1}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{#1}%
-            {{\@nameuse{p at sub\@captype}\@nameuse{@@thesub\@captype}}%
-            {\thepage}%
-            {\mem at currentlabelname\relax}%
-            {\@currentHref}{}}}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{sub@#1}%
-            {{\@nameuse{@@thesub\@captype}}%
-            {\thepage}%
-            {\mem at currentlabelname\relax}%
-            {\@currentHref}{}}}%
-    \@esphack}
-    }{% no hyperref
-      \let\@memoldlabel\label
-      \newcommand*{\sf@@memsub at label}[1]{%
-        \@bsphack
-        \sf@@memsub at label@hook{#1}%
-        \@memoldlabel{#1}%
-        \protected at write\@auxout{}{%
-          \string\newlabel{sub@#1}%
-            {{\@nameuse{@@thesub\@captype}}%
-            {\thepage}}}%
-    \@esphack}
-    }{}%
-  }% end no nameref
-   \@ifpackageloaded{showkeys}{%
-     \ifdefined\SK@\relax
-       \renewcommand\sf@@memsub at label@hook[1]{%
-        \SK@\SK@@label{#1}%
-      }
-     \fi
-  }{}
-} % end AtBeginDocument
+\newcommand\sf@@memsub at label[1]{%
+  \@bsphack%
+  \mem at kernel@label{#1}% normal label
+  \begingroup%
+  % \ExpandArgs{x}\mem at set@cln{\@nameuse{@@thesub\@captype}}
+  \protected at edef\@currentlabel{\@nameuse{@@thesub\@captype}}% sub at label
+  \def\showkeyslabelformat##1{}% disable showkeys for this extra label
+  \mem at kernel@label{sub@#1}% internally generated sub at label
+  \endgroup%
+  \@esphack%
+}
 
 \DeclareRobustCommand{\subcaptionref}{%
   \@ifstar{\ssc at ref}{\sc at ref}}
@@ -7671,54 +6894,34 @@
 \newcommand*{\Cref}[1]{\chapterrefname\ref{#1}}
 \newcommand*{\Sref}[1]{\sectionrefname\ref{#1}}
 
+\def\NR at nopatch@sectioning{set}
+\def\NR at nopatch@caption{set}
+\RequirePackage{nameref}
+\newcommand\titleref{\nameref}
+
+\def\mem at set@cln{\NR at gettitle}
+\newcommand\M at gettitle[1]{\mem at set@cln{#1}}
 \newif\ifheadnameref
 \newcommand*{\headnameref}{\headnamereftrue}
 \newcommand*{\tocnameref}{\headnamereffalse}
   \tocnameref
-\newcommand{\theTitleReference}[2]{#2}
-
-\let\@mem at old@label\label
-\def\label#1{\@bsphack\begingroup
-  \protected at edef\@currentlabel{\protect\M at TitleReference
-      {\@currentlabel}{\M at currentTitle}}%
-  \@mem at old@label{#1}%
-  \endgroup \@esphack}%
-
-\def\@mem@@gettitle#1{\begingroup \let\protect\@unexpandable at protect
-    \let\label\@mem at nestwarn
-    \let\index\@gobble \let\glossary\@gobble
-    \let\markboth\@gobbletwo \let\@mkboth\@gobbletwo
-    \let\markright\@gobble
-    \edef\@tempa{\noexpand\def\noexpand\M at currentTitle{#1}}%
-  \expandafter\endgroup\@tempa}
-
-\let\@mem at nestwarn\@gobble
-\let\M at TitleReference\@firstoftwo
-
-\newcommand*\@mem at titleref[1]{\begingroup
-  \let\numberline\@gobble
-  \let\M at TitleReference\@mem at theTR % interrupt recursion of \ref
-  \ref{#1}\endgroup}
-\let\@mem at titlerefnolink\@mem at titleref
-
-\DeclareRobustCommand\titleref{\@ifstar{\@mem at titlerefnolink}{\@mem at titleref}}
-
-\DeclareRobustCommand{\currenttitle}{\begingroup
-  \let\numberline\@gobble
-  \theTitleReference\@currentlabel\M at currentTitle\endgroup}
-
-\let\M at currentTitle\@empty
-
-\def\@mem at theTR{\let\M at TitleReference\@firstoftwo \theTitleReference}
-
-\newcommand*{\namerefon}{\let\M at gettitle\@mem@@gettitle}
-\newcommand*{\namerefoff}{\let\M at gettitle\@gobble}
-  \namerefon
+\providecommand\namerefon{\@memwarn{\protect\namerefon\space no longer does anything}}
+\providecommand\namerefoff{\@memwarn{\protect\namerefoff\space no longer does anything}}
+\providecommand\currenttitle{%
+  \@memerror{The \protect\currenttitle\space command is no longer\MessageBreak
+    available}{%
+    Place a label and use \protect\titleref{label} instead
+  }
+}
+\providecommand\theTitleReference[2]{%
+  \@memwarn{\protect\theTitleReference\space is no longer available}
+}
+\let\M at TitleReference\@gobbletwo
 \newcommand{\@pnumwidth}{1.55em}
 \newcommand{\@tocrmarg} {2.55em}
 \newcommand{\@dotsep}{4.5}
 \newlength{\tocentryskip} \setlength{\tocentryskip}{1em}
-\newlength{\tocbaseline} \setlength{\tocbaseline}{20pt}
+\newlength{\tocbaseline}  \setlength{\tocbaseline}{20pt}
 \newcommand{\tocskip}[1]{%
     \addtocontents{toc}{\protect\vspace{#1}}}
 \newcommand*{\onecoltocetc}{%
@@ -8008,7 +7211,7 @@
     \endgroup
   \fi}
 
-\newcommand*{\toclevel at part}{-1}
+\def\toclevel at part{-1}
 
 \newcommand*\partnumberlinehook[1]{}
 \newcommand{\partnumberline}[1]{%
@@ -8675,11 +7878,11 @@
   }%
   \vss}}
 
-\renewcommand{\raggedbottom}{%
+\DeclareRobustCommand{\raggedbottom}{%
   \def\mem at flshbot{01}%
   \def\@textbottom{\vskip\z@ plus.0001fil}%
   \let\@texttop\@mkidx}
-\renewcommand{\flushbottom}{%
+\DeclareRobustCommand{\flushbottom}{%
   \def\mem at flshbot{00}%
   \let\@textbottom\relax
   \let\@texttop\@mkidx}
@@ -9285,11 +8488,12 @@
 
 \long\def\@verbfootnotetext{%
   \insert\footins\bgroup
-    \footnotesize
+    \foottextfont%
     \interlinepenalty\interfootnotelinepenalty
     \splittopskip\footnotesep
     \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{footnote}%
     \edef\@currentlabel{\csname p at footnote\endcsname\@thefnmark}%
 %%%%    \color at begingroup
     \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
@@ -9310,11 +8514,12 @@
 
 \long\def\@verbmpfootnotetext{%
   \global\setbox\@mpfootins\vbox{%
-    \reset at font\footnotesize
+    \reset at font\foottextfont
     \unvbox\@mpfootins
     \bgroup
     \hsize\columnwidth
     \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \edef\@currentlabel{\csname p at mpfootnote\endcsname\@thefnmark}%
     \color at begingroup
     \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
@@ -9360,12 +8565,13 @@
     \unvbox\@mpfootins
     \def\baselinestretch{\m at m@footnote at spacing}%
     \foottextfont \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
   \reset at font%
     \@makefntext{%
-      \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+      \rule\z@\footnotesep\ignorespaces\foottextfont #1%
       \@finalstrut\strutbox}%
   \color at endgroup}}
 
@@ -9482,11 +8688,12 @@
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
   \hsize\columnwidth
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname\@nameuse{@thefnmark#1}}%
   \color at begingroup
     \@nameuse{@makefntext#1}{%
-      \rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
+      \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1 ##1}%
       \@finalstrut\strutbox}%
   \color at endgroup}%
   \m at mmf@prepare}}
@@ -9498,11 +8705,12 @@
       \def\baselinestretch{\m at m@footnote at spacing}%
       \reset at font\@nameuse{foottextfont#1}%
       \hsize\columnwidth \@parboxrestore
+      \def\@currentcounter{mpfootnote}%
       \protected at edef\@currentlabel{%
         \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
     \color at begingroup
       \@nameuse{@makefntext#1}{%
-        \rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
+        \rule\z@\footnotesep\ignorespaces\@nameuse{foottextfont#1}##1%
         \@finalstrut\strutbox}%
     \color at endgroup}%
     \m at mmf@prepare}}
@@ -9659,6 +8867,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -9675,7 +8884,7 @@
 
 \newcommand{\@twocolfootfmt}[1]{%
   \@preamtwofmt
-  {\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
+  {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
 
 \newcommand{\@mptwocolfootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -9683,6 +8892,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\foottextfont
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -9712,6 +8922,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\@nameuse{foottextfont#1}%
     \@preamfntext
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
     \color at begingroup
@@ -9726,6 +8937,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -9736,7 +8948,7 @@
   \@namedef{@twocolfootfmt#1}##1{%
     \@preamtwofmt
     {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
+      \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
 
 \newcommand{\m at make@twocol at footgroup}[1]{%
   \@namedef{@twocol at footgroup#1}{{%
@@ -9763,6 +8975,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -9778,7 +8991,7 @@
 
 \newcommand{\@threecolfootfmt}[1]{%
   \@preamthreefmt
-  {\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
+  {\footfootmark\strut \foottextfont #1\strut\par}\allowbreak}
 
 \newcommand{\@mpthreecolfootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -9786,6 +8999,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\foottextfont
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
   \color at begingroup
@@ -9814,6 +9028,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -9827,6 +9042,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
   \color at begingroup
@@ -9837,7 +9053,7 @@
 \@namelongdef{@threecolfootfmt#1}##1{%
   \@preamthreefmt
   {\@nameuse{footfootmark#1}\strut
-   {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
+    \@nameuse{foottextfont#1}##1\strut\par}\allowbreak}}
 
 \newcommand{\m at make@threecol at footgroup}[1]{%
 \@namedef{@threecol at footgroup#1}{{%
@@ -9906,6 +9122,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%
   \reset at font\foottextfont
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote\endcsname\@thefnmark}%
   \setbox0=\vbox{\hsize=\maxdimen
@@ -9917,7 +9134,7 @@
 \newcommand{\@parafootfmt}[1]{%
   \parindent=\z@
   \parfillskip=0pt \@plus 1fil
-  {\footfootmark\strut {\foottextfont #1}\penalty-10}}
+  {\footfootmark\strut \foottextfont #1\penalty-10}}
 
 \newcommand{\@mpparafootnotetext}[1]{%
   \global\setbox\@mpfootinsv at r\vbox{%
@@ -9925,6 +9142,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\foottextfont
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote\endcsname\@thefnmark}%
     \setbox0=\vbox{\hsize=\maxdimen
@@ -9964,6 +9182,7 @@
   \def\baselinestretch{\m at m@footnote at spacing}%
   \reset at font\@nameuse{foottextfont#1}%
   \@preamfntext
+  \def\@currentcounter{footnote}%
   \protected at edef\@currentlabel{%
     \csname p at footnote#1\endcsname \@nameuse{@thefnmark#1}}%
   \setbox0=\vbox{\hsize=\maxdimen
@@ -9979,6 +9198,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font\@nameuse{foottextfont#1}%
     \hsize\columnwidth \@parboxrestore
+    \def\@currentcounter{mpfootnote}%
     \protected at edef\@currentlabel{%
       \csname p at mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
     \setbox0=\vbox{\hsize=\maxdimen
@@ -9992,7 +9212,7 @@
   \parindent=\z@
   \parfillskip=0pt \@plus 1fil
   {\@nameuse{footfootmark#1}\strut
-   {\@nameuse{foottextfont#1}##1}\penalty-10}}}
+   \@nameuse{foottextfont#1}##1\penalty-10}}}
 
 \newcommand{\m at make@para at footgroup}[1]{%
 \@namedef{@para at footgroup#1}{%
@@ -10220,6 +9440,7 @@
     \def\baselinestretch{\m at m@footnote at spacing}%
     \reset at font
     \foottextfont
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote\endcsname\@thefnmark}%
     \color at begingroup
@@ -10232,11 +9453,12 @@
     \foottextfont
     \@preamfntext
     \hsize\columnwidth
+    \def\@currentcounter{footnote}%
     \protected at edef\@currentlabel{%
       \csname p at footnote\endcsname\@thefnmark}%
     \color at begingroup
       \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+        \rule\z@\footnotesep\ignorespaces\foottextfont #1%
         \@finalstrut\strutbox}%
     \color at endgroup}%
   \fi%
@@ -10426,6 +9648,7 @@
   \allowbreak
   \prevdepth=\dp\strutbox
   \vskip-\parskip
+  \def\@currentcounter{sidefootnote}%
   \protected at edef\@currentlabel{%
     \csname p at sidefootnote\endcsname\@thesidefnmark}%
 \color at begingroup
@@ -10692,10 +9915,12 @@
 \newcommand*{\mempnofilewarn}{%
   \ClassWarning{memoir}{There is no .ent file}}
 
-\newcommand\startnoteentrystart[4]{%
+\newcommand\startnoteentrystart[4]{% number; manual id; auto label; href anchor
   \prenoteinnotes%
   \noteidinnotes{#1}{#2}%
-  \@ifmtarg{#2}{\phantomsection\def\@currentlabel{#1}}{}%
+  \phantomsection%
+  \@ifmtarg{#2}{\def\@currentlabel{#1}}{\def\@currentlabel{#2}}%
+  \def\@currentcounter{pagenote}%
   \pagenoteanchor{#4}%
   \pageinnotes{#3}%
   \prenotetext%
@@ -13136,7 +12361,7 @@
 \EmulatedPackage{abstract}[2008/07/23]
 \EmulatedPackage{appendix}[2008/07/23]
  % \EmulatedPackage{array}[2016/10/06]
-\EmulatedPackage{booktabs}[2016/05/16]
+ % \EmulatedPackage{booktabs}[2016/05/16]
 \EmulatedPackage{ccaption}[2008/07/23]
 \EmulatedPackage{changepage}[2008/07/23]
 \EmulatedPackage{chngcntr}[2008/07/23]



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