[latex3-commits] [latex3/latex2e] latexlab/rcb: adding RCBs WIP (57ed064f)
github at latex-project.org
github at latex-project.org
Thu Jun 15 23:30:27 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : latexlab/rcb
Link : https://github.com/latex3/latex2e/commit/57ed064f73c0d59db9d19fb803e9885544ec05fc
>---------------------------------------------------------------
commit 57ed064f73c0d59db9d19fb803e9885544ec05fc
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Thu Jun 15 23:30:27 2023 +0200
adding RCBs WIP
>---------------------------------------------------------------
57ed064f73c0d59db9d19fb803e9885544ec05fc
required/latex-lab/latex-lab-footnotes.dtx | 60 +++-------
required/latex-lab/latex-lab-new-or-2.dtx | 112 ++++++++++++++----
required/latex-lab/latex-lab-rcb.dtx | 177 +++++++++++++++++++++++++++++
required/latex-lab/latex-lab-testphase.dtx | 11 +-
required/latex-lab/latex-lab.ins | 1 +
5 files changed, 288 insertions(+), 73 deletions(-)
diff --git a/required/latex-lab/latex-lab-footnotes.dtx b/required/latex-lab/latex-lab-footnotes.dtx
index 4c8c9b73..1c32423d 100644
--- a/required/latex-lab/latex-lab-footnotes.dtx
+++ b/required/latex-lab/latex-lab-footnotes.dtx
@@ -2008,9 +2008,10 @@
% \texttt{dblfnote} package if we integrate that).
% \begin{macrocode}
\ifFN at para
- \def\@makecol at cfgpointii {%
+ \DeclareRCBCode{@makecol/footnotes}{para}{%
\global\setbox\footins\vbox{\FN at makefootnoteparagraph}%
}
+ \AssignRCBCode{@makecol/footnotes}{para}
\fi
% \end{macrocode}
%
@@ -2038,64 +2039,29 @@
% \end{macrocode}
%
%
-%
% \begin{macrocode}
\ifcase \FN at bottomcases\relax
-\ERROR
-\or
+ \ERROR
+\or %1
\ifFN at abovefloats
- \def\@makecol at cfgpoint {%
- \@if at footnotes@TF
- {\@outputbox at append{\vfill}}%
- {\@if at bfloats@TF{\@outputbox at append{\vfill}}%
- {\@outputbox at reinsertbskip}}%
- \@outputbox at appendfootnotes
- \@outputbox at attachfloats
- }
+ \AssignRCBCode{@makecol/outputbox}{space-footnotes-floats}
\else
- \def\@makecol at cfgpoint {%
- \@outputbox at attachfloats
- \@if at footnotes@TF
- {\@outputbox at append{\vfill}}%
- {\@outputbox at reinsertbskip}%
- \@outputbox at appendfootnotes
- }
+ \AssignRCBCode{@makecol/outputbox}{floats-footnotes-space}
\fi
-\or
+\or %2
\ifFN at abovefloats
- \def\@makecol at cfgpoint {%
- \@outputbox at appendfootnotes
- \@if at bfloats@TF
- {\@outputbox at append{\vfill}}%
- {\@outputbox at reinsertbskip}%
- \@outputbox at attachfloats
- }
+ \AssignRCBCode{@makecol/outputbox}{footnotes-space-floats}
\else
- \def\@makecol at cfgpoint {%
- \@if at footnotes@TF
- {\@outputbox at append{\vfill}}%
- {\@if at bfloats@TF{\@outputbox at append{\vfill}}%
- {\@outputbox at reinsertbskip}}%
- \@outputbox at attachfloats
- \@outputbox at appendfootnotes
- }
+ \AssignRCBCode{@makecol/outputbox}{space-floats-footnotes}
\fi
-\or
+\or %3
\ifFN at abovefloats
- \def\@makecol at cfgpoint {%
- \@outputbox at appendfootnotes
- \@outputbox at attachfloats
- \@outputbox at reinsertbskip
- }
+ \AssignRCBCode{@makecol/outputbox}{footnotes-floats}
\else
- \def\@makecol at cfgpoint {%
- \@outputbox at attachfloats
- \@outputbox at appendfootnotes
- \@outputbox at reinsertbskip
-}
+ \AssignRCBCode{@makecol/outputbox}{floats-footnotes}
\fi
\else
-\ERROR
+ \ERROR
\fi
% next can be dropped when cleaned up
diff --git a/required/latex-lab/latex-lab-new-or-2.dtx b/required/latex-lab/latex-lab-new-or-2.dtx
index 74d56d68..26886cb9 100644
--- a/required/latex-lab/latex-lab-new-or-2.dtx
+++ b/required/latex-lab/latex-lab-new-or-2.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
%% File: latex-lab-new-or-2.dtx
-% Copyright (C) 2022 The LaTeX Project
+% Copyright (C) 2022-2023 The 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
@@ -131,6 +131,7 @@
\ProvidesPackage{latex-lab-testphase-new-or-2}
[2022-11-04 v0.1c changes to the output routine]
% \end{macrocode}
+%
% \subsection{\cs{@makecol} reimplementation}
%
% In order for other packages to prepend or append code to
@@ -160,10 +161,10 @@
\xdef\@freelist{\@freelist\@midlist}%
\global \let \@midlist \@empty
% \end{macrocode}
-% Here we have the configurable part.
-% \fmi{Interface to configuration points will change in the future}
+% Here we have the configurable part. It appends floats and
+% footnotes as appropriate to the \cs{@outputbox}.
% \begin{macrocode}
- \@makecol at cfgpoint
+ \UseRCB{@makecol/outputbox}%
% \end{macrocode}
% The we deal with any \cs{enlargethispage} or run the normal code
% to build a column.
@@ -354,10 +355,10 @@
% First come two configuration points: what to do if we are in a split
% footnote situation and a second one that does some manipulation
% of the \cs{footins} box before it gets appended.
-% \fmi{this code will get revised as part of CP handling in the future}
+% \fmi{this code will get revised as part of RCB handling in the future}
% \begin{macrocode}
\@makecol at handlesplitfootnotes
- \@makecol at cfgpointii
+ \UseRCB{@makecol/footnotes}%
% \end{macrocode}
% Then the footnotes are appended:
% \begin{macrocode}
@@ -437,12 +438,14 @@
%
% \begin{macro}{\@makecol at cfgpointii}
%
-% Configuration point to support manipulation of footins box
-% (result needs to be moved back in there). Used by the
-% \texttt{para} option.
-% \fmi{Interface will change in the future}
+% RCB to support manipulation of \cs{footins} box
+% (result needs to be moved back in there). Used when footnotes are
+% reformatted into a single paragraph by the
+% \texttt{para} option of \pkg{footmisc}.
% \begin{macrocode}
-\let \@makecol at cfgpointii \@empty
+\NewRCB{@makecol/footnotes}{0}
+\DeclareRCBCode{@makecol/footnotes}{default}{}
+\AssignRCBCode{@makecol/footnotes}{default}
% \end{macrocode}
%
% \end{macro}
@@ -497,27 +500,94 @@
% \subsection{The \cs{@makecol} configuration}
%
%
-% \begin{macro}{\@makecol at cfgpoint}
+% \begin{macro}{@makecol/outputbox}
+% We have one RCB that is supposed to augment the \cs{@outputbox}
+% by attching floats and footnotes with appropriate spacing
+%
+% \begin{macrocode}
+\NewRCB{@makecol/outputbox}{0}
+% \end{macrocode}
+% \end{macro}
%
-% Here is only the configuration for the default case for now,
-% others are provided by \pkg{footmisc}.
+% The following named code alternatives are available:
%
% \begin{macrocode}
- \def\@makecol at cfgpoint {%
- \@outputbox at appendfootnotes
- \@outputbox at attachfloats
+\DeclareRCBCode{@makecol/outputbox}{space-footnotes-floats} {%
+ \@if at footnotes@TF
+ {\@outputbox at append{\vfill}}%
+ {\@if at bfloats@TF
+ {\@outputbox at append{\vfill}}%
+ {\@outputbox at reinsertbskip}%
+ }%
+ \@outputbox at appendfootnotes
+ \@outputbox at attachfloats
+}
% \end{macrocode}
-% We do, however, reinsert the bottom skip from \cs{newpage} if it
+%
+% \begin{macrocode}
+\DeclareRCBCode{@makecol/outputbox}{floats-footnotes-space} {%
+ \@outputbox at attachfloats
+ \@if at footnotes@TF
+ {\@outputbox at append{\vfill}}%
+ {\@outputbox at reinsertbskip}%
+ \@outputbox at appendfootnotes
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRCBCode{@makecol/outputbox}{footnotes-space-floats} {%
+ \@outputbox at appendfootnotes
+ \@if at bfloats@TF
+ {\@outputbox at append{\vfill}}%
+ {\@outputbox at reinsertbskip}%
+ \@outputbox at attachfloats
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRCBCode{@makecol/outputbox}{space-floats-footnotes} {%
+ \@if at footnotes@TF
+ {\@outputbox at append{\vfill}}%
+ {\@if at bfloats@TF
+ {\@outputbox at append{\vfill}}%
+ {\@outputbox at reinsertbskip}}%
+ \@outputbox at attachfloats
+ \@outputbox at appendfootnotes
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRCBCode{@makecol/outputbox}{floats-footnotes} {%
+ \@outputbox at attachfloats
+ \@outputbox at appendfootnotes
+ \@outputbox at reinsertbskip
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRCBCode{@makecol/outputbox}{footnotes-floats} {%
+ \@outputbox at appendfootnotes
+ \@outputbox at attachfloats
+% \end{macrocode}
+% We do reinsert the bottom skip from \cs{newpage} if it
% was taken out earlier. This is, strictly speaking, not necessary
% in most cases, but it is a \cs{vfil} while \cs{raggedbottom} is
% only generating \verb=\vspace{0pt plus .0001fil}=, so if you have
% several \cs{vfil} on the page before the \cs{newpage} you would
% alter the space distribution if one is taken out.
% \begin{macrocode}
- \@outputbox at reinsertbskip
- }
+ \@outputbox at reinsertbskip
+}
% \end{macrocode}
-% \end{macro}
+% The \texttt{footnote-floats} one is is the default used by
+% \LaTeX{}, it can be overwritten either through \pkg{footmisc} or
+% by assigning any of the other named RCB code chunks.
+% \begin{macrocode}
+\AssignRCBCode{@makecol/outputbox}{footnotes-floats}
+% \end{macrocode}
+%
+%
+%
%
%
% \section {Replacement for the \pkg{footmisc} package}
diff --git a/required/latex-lab/latex-lab-rcb.dtx b/required/latex-lab/latex-lab-rcb.dtx
new file mode 100644
index 00000000..76df28d2
--- /dev/null
+++ b/required/latex-lab/latex-lab-rcb.dtx
@@ -0,0 +1,177 @@
+% \iffalse meta-comment
+%
+%% File: latex-lab-rcb.dtx
+% Copyright (C) 2023 The 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
+% license or (at your option) any later version. The latest version
+% of this license is in the file
+%
+% https://www.latex-project.org/lppl.txt
+%
+%
+% The development version of the bundle can be found below
+%
+% https://github.com/latex3/latex2e/required/latex-lab
+%
+% for those people who are interested or want to report an issue.
+%
+%<*driver>
+\documentclass{l3doc}
+\EnableCrossrefs
+\CodelineIndex
+\begin{document}
+ \DocInput{latex-lab-rcb.dtx}
+\end{document}
+%</driver>
+%
+% \fi
+%
+%
+% \title{The \texttt{latex-lab-testphase-rcb} code\thanks{}}
+% \author{Frank Mittelbach, \LaTeX{} Project}
+%
+% \maketitle
+%
+% \newcommand\fmi[1]{\begin{quote} TODO: \itshape #1\end{quote}}
+% \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}}
+% \providecommand\pkg[1]{\texttt{#1}}
+%
+% \begin{abstract}
+% \end{abstract}
+%
+% \section{Introduction}
+%
+% This code implements the \enquote{replaceable code blocks}.
+%
+%
+%
+%
+% \StopEventually{\setlength\IndexMin{200pt} \PrintIndex }
+%
+%
+% \section{The Implementation}
+%
+% The implementation of the RCB mechanism should be redone and we
+% should probably stored the different code chunks in a property
+% list so that we can have a decent \cs{ShowRCB} command the shows
+% the available alternatives.
+%
+% \begin{macrocode}
+%<*code>
+%<@@=rcb>
+% \end{macrocode}
+%
+% \subsection{File declaration}
+%
+% \begin{macrocode}
+\ProvidesExplPackage {latex-lab-testphase-rcb} {2023-06-15} {0.1a}
+ {replaceable code blocks}
+% \end{macrocode}
+%
+% \subsection{The L3 layer commands}
+%
+% \begin{macro}{\rcb_new:nn}
+%
+% Declaring a RCB creates a str to hold the name (a pointer) to the
+% code that should be used when the RCB is used, and an integer to
+% hold the number of arguments of that RCB. Initially, an
+% "unassigned" code chunk is created and assigned so the RCB cannot
+% be used without a proper code block being assigned.
+% \begin{macrocode}
+\cs_new_protected:Npn \rcb_new:nn #1 #2 {
+ \str_if_exist:cTF { g_@@_#1_code_str }
+ {
+ \errmessage { RCB~ '#1'~ already~ declared! }
+ }
+ {
+ \str_new:c { g_@@_#1_code_str }
+ \int_const:cn { c_@@_#1_args_int } {#2}
+ \rcb_new_code:nnn {#1} { _@@_unassigned }
+ { \errmessage { No~RCB~code~for~'#1'~assigned! } }
+ \rcb_assign_code:nn {#1} { _@@_unassigned }
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\rcb_new_code:nnn}
+%
+% Declaring a code for an RCB is just doing a definition, taking
+% the number of arguments from the saved int.
+% \begin{macrocode}
+\cs_new_protected:Npn \rcb_new_code:nnn #1 #2 #3 {
+ \str_if_exist:cTF { g_@@_#1_code_str }
+ {
+ \cs_generate_from_arg_count:cNnn
+ { _@@_#1_code_#2:w }
+ \cs_new_protected:Npn
+ { \int_use:c { c_@@_#1_args_int } }
+ {#3}
+ }
+ {
+ \errmessage { RCB~ '#1'~ not~ declared! }
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\rcb_assign_code:nn}
+%
+% Assigning a RCB just changes the name in the RCB string.
+% \begin{macrocode}
+\cs_new_protected:Npn \rcb_assign_code:nn #1 #2 {
+ \str_if_exist:cTF { g_@@_#1_code_str }
+ {
+ \cs_if_exist:cTF { _@@_#1_code_#2:w }
+ {
+ \str_gset:cn { g_@@_#1_code_str } {#2}
+ }
+ {
+ \errmessage { RCB~ instance~ '#2'~ for~ RCB~ '#1'~ not~ declared! }
+ }
+ }
+ {
+ \errmessage { RCB~ '#1'~ not~ declared! }
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\rcb_use:n}
+%
+% And using it is more or less a \cs{use:c} so very lightweight. We do not add a
+% runtime check for speed reasons!
+% \begin{macrocode}
+\cs_new_protected:Npn \rcb_use:n #1 {
+ \use:c { _@@_#1_code_ \str_use:c { g_@@_#1_code_str } :w }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{The \LaTeXe{} interface commands}
+%
+% \begin{macro}{\NewRCB,\DeclareRCBCode,\AssignRCBCode,\UseRCB}
+%
+% \begin{macrocode}
+\cs_new_eq:NN \NewRCB \rcb_new:nn
+\cs_new_eq:NN \DeclareRCBCode \rcb_new_code:nnn
+\cs_new_eq:NN \AssignRCBCode \rcb_assign_code:nn
+\cs_new_eq:NN \UseRCB \rcb_use:n
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macrocode}
+%<@@=>
+%</code>
+% \end{macrocode}
+%
+% \Finale
+%
diff --git a/required/latex-lab/latex-lab-testphase.dtx b/required/latex-lab/latex-lab-testphase.dtx
index ce882030..f93ce5e3 100644
--- a/required/latex-lab/latex-lab-testphase.dtx
+++ b/required/latex-lab/latex-lab-testphase.dtx
@@ -43,8 +43,8 @@
% This code implements small files which can be loaded with the |testphase|
% key of \cs{DocumentMetadata}. This will be extended to allow user to load
% well defined parts of the tagged PDF project.
-% Currently the values |phase-I|, |phase-II| and |new-or| are provided.
-% |tagpdf| is an undocumented alias for |phase-II| which is kept for compability.
+% Currently the values |phase-I|, |phase-II|, |phase-III|, and |new-or| are provided.
+% |tagpdf| is an undocumented alias for |phase-II| which is kept for compatibility.
%
%
% \StopEventually{\setlength\IndexMin{200pt} \PrintIndex }
@@ -63,7 +63,7 @@
% \begin{macrocode}
%<*new-or>
\ProvidesFile{new-or-latex-lab-testphase.ltx}
- [2022-11-04 v0.1a latex-lab wrapper new-or]
+ [2023-06-15 v0.1b latex-lab wrapper new-or]
%</new-or>
% \end{macrocode}
% \begin{macrocode}
@@ -75,7 +75,7 @@
% \begin{macrocode}
%<*phase-II>
\ProvidesFile{phase-II-latex-lab-testphase.ltx}
- [2022-11-04 v0.1a latex-lab wrapper phase-II]
+ [2023-06-15 v0.1b latex-lab wrapper phase-II]
%</phase-II>
% \end{macrocode}
% \begin{macrocode}
@@ -110,9 +110,10 @@
\RequirePackage{latex-lab-testphase-new-or-1}
%</tagpdf|phase-I|phase-II|new-or|new-or-1>
% \end{macrocode}
-% New output routine code is loaded in phase-II and new-or:
+% Replaceable code blocks and the new output routine code are loaded in phase-II and new-or:
% \begin{macrocode}
%<*tagpdf|phase-II|new-or>
+\RequirePackage{latex-lab-testphase-rcb}
\RequirePackage{latex-lab-testphase-new-or-2}
%</tagpdf|phase-II|new-or>
% \end{macrocode}
diff --git a/required/latex-lab/latex-lab.ins b/required/latex-lab/latex-lab.ins
index 1989ddcf..a1ba67d6 100644
--- a/required/latex-lab/latex-lab.ins
+++ b/required/latex-lab/latex-lab.ins
@@ -80,6 +80,7 @@ where one can also log issues in case there are any.
% support files (the new-or code is a private package to make life easier)
+\generate{\file{latex-lab-testphase-rcb.sty}{\from{latex-lab-rcb.dtx}{code}}}
\generate{\file{latex-lab-testphase-new-or-2.sty}{\from{latex-lab-new-or-2.dtx}{code}}}
\generate{\file{latex-lab-testphase-new-or-1.sty}{\from{latex-lab-new-or-1.dtx}{code}}}
\generate{\file{latex-lab-footmisc.ltx}{\from{latex-lab-footnotes.dtx}{footmisc}}}
More information about the latex3-commits
mailing list.