[latex3-commits] [git/LaTeX3-latex3-latex2e] gh1002: Fix for #1002 (bcd87d6c)

Frank Mittelbach frank.mittelbach at latex-project.org
Sat Feb 25 10:08:01 CET 2023


Repository : https://github.com/latex3/latex2e
On branch  : gh1002
Link       : https://github.com/latex3/latex2e/commit/bcd87d6cadd9112b27c6c4aeb1a66c0f88ef4ec6

>---------------------------------------------------------------

commit bcd87d6cadd9112b27c6c4aeb1a66c0f88ef4ec6
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Sat Feb 25 10:08:01 2023 +0100

    Fix for #1002


>---------------------------------------------------------------

bcd87d6cadd9112b27c6c4aeb1a66c0f88ef4ec6
 base/doc/ltnews37.tex                    | 13 ++++++++++++
 required/tools/changes.txt               |  6 ++++++
 required/tools/multicol.dtx              | 35 ++++++++++++++++++++++++--------
 required/tools/testfiles/github-0822.tlg |  1 +
 required/tools/testfiles/github-1002.lvt |  2 ++
 5 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/base/doc/ltnews37.tex b/base/doc/ltnews37.tex
index 9aa9d940..e5e206a6 100644
--- a/base/doc/ltnews37.tex
+++ b/base/doc/ltnews37.tex
@@ -412,6 +412,19 @@ correct.
 \section{Changes to packages in the \pkg{tools} category}
 
 
+\subsection{Fix handling of nested \env{multicols}}
+
+If \env{multicols} environments have been nested into each other (the
+inner one boxed) it could fail if the boxed environment appeared near a
+page break. The problem was that the output routine was called while
+the \cs{hsize} was still altered to fit the column width of the inner
+\env{multicols} --- thereby messing up the placement of columns of the
+page. This has now been fixed.
+%
+\githubissue{1002}
+
+
+
 %\medskip
 
 \begin{thebibliography}{9}
diff --git a/required/tools/changes.txt b/required/tools/changes.txt
index 7b3e63dc..95a3d685 100644
--- a/required/tools/changes.txt
+++ b/required/tools/changes.txt
@@ -9,6 +9,12 @@ are not part of the distribution.
 All changes above are only part of the development branch for the next release.
 ================================================================================
 
+2023-02-25  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* multicol.dtx:
+	Delay returning boxed multicols so that all parameters get restored first
+	in case the boxed multicols is used into another multicols (gh/1002)
+
 #########################
 # 2022-11-01 Release
 #########################
diff --git a/required/tools/multicol.dtx b/required/tools/multicol.dtx
index aa21d75f..d49ad7c5 100644
--- a/required/tools/multicol.dtx
+++ b/required/tools/multicol.dtx
@@ -20,7 +20,7 @@
 % \iffalse    This is a METACOMMENT
 %
 %% Package `multicol' to use with LaTeX2e
-%% Copyright 1989-2019 Frank Mittelbach
+%% Copyright 1989-2023 Frank Mittelbach
 %%
 %%  In addition to the terms of LPPL any distributed version
 %%  (unchanged or modified) of multicol has to keep the statement
@@ -99,7 +99,7 @@
 %<driver> \ProvidesFile{multicol.drv}
 % \fi
 %         \ProvidesFile{multicol.dtx}
-          [2021/11/30 v1.9d  multicolumn formatting (FMi)]
+          [2023/02/25 v1.9e  multicolumn formatting (FMi)]
 %
 %
 %%
@@ -1760,14 +1760,27 @@
                  \kept at firstmark
     \return at nonemptymark{bot}%
                   \kept at botmark
-    \page at sofar
+%    \end{macrocode}
+%    When the boxed multicol is returned to the page it can happen
+%    that it doesn't fit onto it and \LaTeX{} therefore breaks
+%    earlier. The problem in that case is that during the generation
+%    \cs{hsize}, etc.\ got changed and this setting is still in effect
+%    right now, and if this boxed multicol is within, say,
+%    \env{multicols*} then its output routine gets very upset. We
+%    therefore delay returning the result by saving it in box for now
+%    until we have left the group below.
+% \changes{v1.9e}{2023/02/25}{Delay returning boxed multicols (gh/1002)}
+%    \begin{macrocode}
+    \global\setbox\mc at boxedresult\vbox{%    
+      \page at sofar
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-    \global\let\kept at firstmark
-               \l at kept@firstmark
-    \global\let\kept at botmark
-            \l at kept@botmark
+      \global\let\kept at firstmark
+                 \l at kept@firstmark
+      \global\let\kept at botmark
+                 \l at kept@botmark
+    }%
 %<*marktrace>
     \mult at info\tw@
       {Restore kept marks to\MessageBreak
@@ -1879,12 +1892,16 @@
 %    \end{macrocode}
 %    Now it's time to return any footnotes if we are in unrestricted
 %    mode. In boxed mode footnotes are kept inside, but in that case
-%    we have to write another column status into the \texttt{.aux}
+%    we have to first return the saved box to the page and then write
+%    another column status into the \texttt{.aux}
 %    file to support \cs{docolaction} in case we have nested
 %    environments.
 % \changes{v1.8s}{2018/04/20}{Support for \cs{docolaction} (issue/39)}
+% \changes{v1.9e}{2023/02/25}{Delay returning boxed multicols (gh/1002)}
 %    \begin{macrocode}
   \if at boxedmulticols
+%    \end{macrocode}
+    \unvbox\mc at boxedresult
     \mc at col@status at write
   \else
     \reinsert at footnotes
@@ -1949,6 +1966,7 @@
 % \SpecialMainIndex{\multicolsep}
 % \SpecialMainIndex{\multicolbaselineskip}
 % \SpecialMainIndex{\partial at page}
+% \SpecialMainIndex{\mc at boxedresult}
 %    Let us end this section by allocating all the registers used so
 %    far.
 %    \begin{macrocode}
@@ -1970,6 +1988,7 @@
 \newskip\multicolbaselineskip
 \newbox\partial at page
 \newbox\last at line
+\newbox\mc at boxedresult
 %    \end{macrocode}
 %    And here are their default values:
 %    \begin{macrocode}
diff --git a/required/tools/testfiles/github-0822.tlg b/required/tools/testfiles/github-0822.tlg
index 4fd42690..d074b088 100644
--- a/required/tools/testfiles/github-0822.tlg
+++ b/required/tools/testfiles/github-0822.tlg
@@ -53,6 +53,7 @@ Package: multicol ....-..-.. v... multicolumn formatting (FMi)
 \multicolbaselineskip=\skip...
 \partial at page=\box...
 \last at line=\box...
+\mc at boxedresult=\box...
 \maxbalancingoverflow=\dimen...
 \mult at rightbox=\box...
 \mult at grightbox=\box...
diff --git a/required/tools/testfiles/github-1002.lvt b/required/tools/testfiles/github-1002.lvt
index babaf622..6637e2a3 100644
--- a/required/tools/testfiles/github-1002.lvt
+++ b/required/tools/testfiles/github-1002.lvt
@@ -49,6 +49,8 @@ There should be an itemize environment here but the bug happens even without it.
 a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\
 a\\a\\a\\a\\a\\a\\a\\a\\a\\a
 
+\typeout{A and B should show the same x-position}
+
 a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\
 a\\a\\a\\a\\a\\a\\a\\a\\a\\a\hfill B\savepos\write20{TIMO^^JB: \the\lastxpos^^JOMIT}
 





More information about the latex3-commits mailing list.