[latex3-commits] [latex3/latex2e] gh1130: fix for #1130 (cbab910f)
github at latex-project.org
github at latex-project.org
Fri Nov 10 15:49:30 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : gh1130
Link : https://github.com/latex3/latex2e/commit/cbab910f98688135f3dd1db41a46664695f154f8
>---------------------------------------------------------------
commit cbab910f98688135f3dd1db41a46664695f154f8
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Fri Nov 10 15:49:30 2023 +0100
fix for #1130
>---------------------------------------------------------------
cbab910f98688135f3dd1db41a46664695f154f8
base/doc/ltnews39.tex | 17 ++++++++++++
required/tools/changes.txt | 5 ++++
required/tools/multicol.dtx | 40 +++++++++++++++++++++++++--
required/tools/testfiles/tlb-multicol-007.lvt | 30 ++++++++++++++++++++
required/tools/testfiles/tlb-multicol-007.tlg | 30 ++++++++++++++++++++
5 files changed, 119 insertions(+), 3 deletions(-)
diff --git a/base/doc/ltnews39.tex b/base/doc/ltnews39.tex
index b3cc99ec..ab639712 100644
--- a/base/doc/ltnews39.tex
+++ b/base/doc/ltnews39.tex
@@ -212,6 +212,23 @@ in a hotfix for release 2023-11.
\githubissue{1160}
+\subsection{\pkg{multicol}: \cs{columnbreak} interfers with mark mechanism}
+
+The \pkg{multicol} package has to keep track of marks (from
+\cs{markright} or \cs{markboth}) as part of its output routine code
+and can't rely on \LaTeX{} handling that automatically. It does so by
+artifically splitting page data with \cs{vsplit} to extract the mark
+data. With the introduction of \cs{columnbreak} that code failed
+sometimes, because it was not seeing any mark that followed such a
+forced column break.
+
+This has now been corrected, but there is further work to do, because
+as of now \pkg{multicol} does not handle marks using the new mark
+mechanism at all.
+%
+\githubissue{1130}
+
+
\section{Changes to files in the \pkg{cyrillic} category}
\subsection{Correct definition of \cs{k}}
diff --git a/required/tools/changes.txt b/required/tools/changes.txt
index 0ced77d5..a9f46a35 100644
--- a/required/tools/changes.txt
+++ b/required/tools/changes.txt
@@ -5,6 +5,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
=======================================================================
+2023-11-10 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * multicol.dtx (subsection{Maintaining the mark registers}]):
+ Get rid of forced breaks for mark extraction (gh/1130)
+
================================================================================
All changes above are only part of the development branch for the next release.
================================================================================
diff --git a/required/tools/multicol.dtx b/required/tools/multicol.dtx
index 2676d03a..3c05301f 100644
--- a/required/tools/multicol.dtx
+++ b/required/tools/multicol.dtx
@@ -99,7 +99,7 @@
%<driver> \ProvidesFile{multicol.drv}
% \fi
% \ProvidesFile{multicol.dtx}
- [2023/03/30 v1.9f multicolumn formatting (FMi)]
+ [2023/11/10 v1.9g multicolumn formatting (FMi)]
%
%
%%
@@ -2925,7 +2925,11 @@
% We start by setting the kept marks by updating them with any
% marks from this box. This has to be done \emph{before} we add a
% penalty of $-10000$ to the top of the box, otherwise only an
-% empty box will be considered.
+% empty box will be considered. But even that is not enough: the box
+% may contain \cs{columnbreak}s in which case doing some artifical
+% splitting to get the marks out still fails to see all marks
+% unless we take some special precaution in \cs{get at keptmarks}
+% (which is now done).
% \changes{v1.5h}{1994/08/26}{Get kept marks first}
% \begin{macrocode}
\get at keptmarks\mult at box
@@ -3751,8 +3755,15 @@
% everything is split off. As a result |\splitfirstmark| and
% |\splitbotmark| will contain the first and last mark in the box
% respectively.
+%
+% Unfortunately, a simple \cs{vsplit} is not enough if the material
+% contains forced breaks in that case we first have to get rid of
+% those which is why we do this work in a separate macro that can
+% call itself recursively.
+% \changes{v1.9g}{2023/11/10}{Get rid of forced breaks for mark
+% extraction (gh/1130)}
% \begin{macrocode}
- \setbox#1\vsplit#1to\maxdimen
+ \mc at get@all at box@marks #1%
% \end{macrocode}
% Therefore we can now set the kept marks which is a global
% operation and afterwards close the group. This will restore the
@@ -3773,6 +3784,29 @@
% \end{macro}
%
%
+% \begin{macro}{\mc at get@all at box@marks}
+% This macro splits a box to \cs{maxdimen} in order to get at the
+% marks inside. If it turns out that we have a remainder after the
+% split (e.g., if there was a \cs{columnbreak} in the material) we
+% stitch the the two parts together again (which omits the forced
+% break) and recurse. Eventually, everything is split off and the
+% split marks will then have the appropriate values.
+% \changes{v1.9g}{2023/11/10}{Get rid of forced breaks for mark
+% extraction (gh/1130)}
+% \begin{macrocode}
+\def\mc at get@all at box@marks #1{%
+ \setbox\@tempboxa\vsplit#1to\maxdimen
+ \ifvoid#1\else
+ \setbox#1\vbox{\unvbox\@tempboxa \unvbox#1}%
+ \mc at get@all at box@marks #1%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
% \begin{macro}{\set at keptmarks}
% The macro |\set at keptmarks| is responsible for setting
% |\kept at firstmark| and |\kept at botmark|, by checking the current
diff --git a/required/tools/testfiles/tlb-multicol-007.lvt b/required/tools/testfiles/tlb-multicol-007.lvt
new file mode 100644
index 00000000..f1d9079a
--- /dev/null
+++ b/required/tools/testfiles/tlb-multicol-007.lvt
@@ -0,0 +1,30 @@
+
+\input{test2e}
+
+\documentclass{article}
+
+\usepackage[markshow]{multicol}
+
+
+\makeatletter
+\def\@oddhead{\firstmark\hfil\botmark}
+\let\@evenhead\@oddhead
+
+\begin{document}
+
+\START
+
+\begin{multicols}{2}
+A. \mark{{.}{A}}
+
+\columnbreak % remove this, head will be correct
+
+B. \mark{{.}{B}}
+\end{multicols}
+
+Text following.
+
+\newpage
+
+\OMIT
+\end{document}
diff --git a/required/tools/testfiles/tlb-multicol-007.tlg b/required/tools/testfiles/tlb-multicol-007.tlg
new file mode 100644
index 00000000..bc1ee876
--- /dev/null
+++ b/required/tools/testfiles/tlb-multicol-007.tlg
@@ -0,0 +1,30 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+Package multicol: Starting environment with 2 columns on input line ....
+Package multicol: Current page:
+(multicol) height=16383.99998pt: used 0.0pt -> free=16383.99998pt
+(multicol) needed 50.0pt (for \premulticols ) on input line ....
+Package multicol: Forced column break seen on input line ....
+Package multicol: End penalty of multicols seen on input line ....
+Package multicol: Re-adding forced break(s) in balancing on input line ....
+Package multicol: Set kept first mark:
+(multicol) macro:->{.}{A}
+Package multicol: Set kept bot mark:
+(multicol) macro:->{.}{B}
+Package multicol: Balance columns on input line ...:
+Column 1 badness: 0
+First column = 10.0pt (10.0pt) <> last column = 10.0pt
+Final badness: 0
+Package multicol: Returned first mark:
+(multicol) macro:->{.}{A} on input line ....
+Package multicol: Returned bot mark:
+(multicol) macro:->{.}{B} on input line ....
+Package multicol: Column spec: 345.0pt = indent + columns + sep =
+(multicol) 0.0pt + 2 x 167.5pt + 1 x 10.0pt on input line ....
+Package multicol: Make kept marks empty on input line ....
+Package multicol: Current page:
+(multicol) height=550.0pt: used 10.0pt -> free=540.0pt
+(multicol) needed 20.0pt (for \postmulticols ) on input line ....
+Package multicol: Ending environment on input line ....
+[1
+]
More information about the latex3-commits
mailing list.