summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx')
-rw-r--r--macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx123
1 files changed, 120 insertions, 3 deletions
diff --git a/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx b/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx
index a50b367837..ba4addadd2 100644
--- a/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx
+++ b/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: latex-lab-firstaid.dtx (C) Copyright 2023 LaTeX Project
+%% File: latex-lab-firstaid.dtx (C) Copyright 2023-2024 LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -16,8 +16,8 @@
%
% for those people who are interested or want to report an issue.
%
-\def\ltlabfirstaiddate{2024-01-21}
-\def\ltlabfirstaidversion{0.85b}
+\def\ltlabfirstaiddate{2024-03-18}
+\def\ltlabfirstaidversion{0.85c}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
@@ -55,6 +55,7 @@
% patches once the packages have been updated.
% \section{Implementation}
+%
% \begin{macrocode}
%<*package>
%<@@=tag>
@@ -75,7 +76,116 @@
\AddToHook{class/amsbook/after}
{\def\@author{\authors}}
% \end{macrocode}
+%
+%
+%
+% \subsection{verse}
+%
+% The \pkg{verse} package has its own definition of the
+% \env{verse} environment, which would tag correctly, except that
+% it is overwritten by the block code in the hook
+% \texttt{begindocument/before}. So the simplest way to make
+% tagging work is to reinstall the package version afterwards,
+% which is what we are doing here.
+% \begin{macrocode}
+\AddToHook{package/verse/after}[latex-lab-firstaid]{%
+ \FirstAidNeededT{verse}{sty}{2014/05/10 v2.4b verse typesetting}%
+ {%
+ \AtBeginDocument{%
+ \renewenvironment{verse}[1][\linewidth]{%
+ \stepcounter{verse@envctr}%
+ \setcounter{poemline}{0}\refstepcounter{poemline}%
+ \setcounter{vslineno}{1}%
+ \let\\=\@vscentercr
+ \list{}{\itemsep \z@
+ \itemindent -\vindent
+ \listparindent\itemindent
+ \parsep \stanzaskip
+ \ifdim #1 < \linewidth
+ \rightmargin \z@
+ \setlength{\leftmargin}{\linewidth}%
+ \addtolength{\leftmargin}{-#1}%
+ \addtolength{\leftmargin}{-0.5\leftmargin}%
+ \else
+ \rightmargin \leftmargin
+ \fi
+ \addtolength{\leftmargin}{\vindent}}%
+ \item[]%
+ }%
+ {\endlist}%
+ }%
+ }%
+}
+% \end{macrocode}
+% Of course, this means that the
+% optional argument of the environment then only accepts a length
+% value and not any more a key value list for altering the
+% environment settings.
+%
+% A more elabroate version could be something like this that allows
+% key/val and legacy interface. Or one could extend the list
+% template to support a \texttt{list-width} key.
+%\begin{verbatim}
+% \ExplSyntaxOn
+% \cs_new_protected:Npn \ExtractAndDropKey #1#2#3#4#5 {
+% \tl_set_eq:NN #4 \c_novalue_tl % or empty?
+% \keys_define:nn { #1 } { #2 .code:n = \tl_set:Nn #4{##1} }
+% \keys_set_known:nnN { #1 } { #3 } #5
+% }
+% \ExplSyntaxOff
+%
+% % Change the env definition for verse matching verse.sty
+% % This keeps the verse.sty interface as it is and only adjusts the
+% % main environment to use the basic list env with the verse.sty
+% % specific settings.
+% \makeatletter
+%
+% \AddToHook{package/verse/after}{%
+% \AtBeginDocument{%
+% \RenewDocumentEnvironment{verse}{={verse-width}!O{\linewidth}}%
+% {%
+% \stepcounter{verse@envctr}%
+% \setcounter{poemline}{0}\refstepcounter{poemline}%
+% \setcounter{vslineno}{1}%
+% \let\\=\@vscentercr
+% %
+% \ExtractAndDropKey{verse}{verse-width}{#1}\@vswidth\@vsremainingkvlist
+% % If other keys have been specified but not verse-width we have no
+% % default for \@vswidth and need to set it again
+% \ExpandArgs{o}\IfNoValueT \@vswidth
+% {\def\@vswidth{\linewidth}}%
+% %
+% % This is a bit ugly but we can't stick \cs{@vsremainingkvlist} into
+% % the instance argument as keys are expected to be visible on
+% % top-level not hidden inside a macro. The alternative is to push
+% % in \verb=#1= but then the key/value \verb/verse-width=.../ is
+% % passed into the instance which is not known there (not harmful as
+% % it will get ignored but noticeably more and unnecessary
+% % processing).
+% %
+% \def\next##1{%
+% \UseInstance{blockenv}{list}%
+% {%
+% item-indent =-\vindent,%
+% parindent =-\vindent,%
+% par-skip =\stanzaskip,%
+% item-skip =0pt,%
+% leftmargin = (\linewidth-\@vswidth)/2+\vindent,%
+% rightmargin = \ifdim\@vswidth<\linewidth 0pt
+% \else (\linewidth-\@vswidth)/2\fi,%
+% ##1%
+% }}%
+% \ExpandArgs{o}\next\@vsremainingkvlist
+% \item\relax
+% }{\endblockenv}%
+% }%
+% }
+% \makeatother
+%\end{verbatim}
+%
+%
% \subsection{blindtext}
+%
% The blindtext package generates lists with nested \cs{loop} command.
% The inner loop introduces a group around the list which error when lists are tagged
% as \cs{@doendpe} is lost.
@@ -116,7 +226,10 @@
}%
}
% \end{macrocode}
+%
+%
% \subsection{cleveref}
+%
% The cleveref package redefines \cs{@makefntext} and this means that the patches in
% the new footnote code fails. We use a hook instead
% \begin{macrocode}
@@ -140,9 +253,13 @@
}%
}
% \end{macrocode}
+%
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
+%
+%
% \begin{macrocode}
%<*latex-lab>
\ProvidesFile{firstaid-latex-lab-testphase.ltx}