[latex3-commits] [git/LaTeX3-latex3-latex2e] gh682: Added \newcolumn and Implemented optional arg for \columnbreak (a2a0d0e0)

Frank Mittelbach frank.mittelbach at latex-project.org
Fri Oct 8 19:31:26 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh682
Link       : https://github.com/latex3/latex2e/commit/a2a0d0e059fb05eb17fb280bf57d87ede84bfa93

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

commit a2a0d0e059fb05eb17fb280bf57d87ede84bfa93
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Fri Oct 8 19:31:26 2021 +0200

    Added \newcolumn and Implemented optional arg for \columnbreak


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

a2a0d0e059fb05eb17fb280bf57d87ede84bfa93
 base/doc/ltnews34.tex                    |  11 ++-
 required/tools/multicol.dtx              |  70 ++++++++++----
 required/tools/testfiles/github-0682.lvt | 155 +++++++++++++++++++++++++++++++
 required/tools/testfiles/github-0682.tlg |  17 ++++
 4 files changed, 235 insertions(+), 18 deletions(-)

diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index 57e101e8..d2507f69 100644
--- a/base/doc/ltnews34.tex
+++ b/base/doc/ltnews34.tex
@@ -696,10 +696,17 @@ rather than appearing before it.
 %
 \githubissue[s]{131 and 173}
 
-\subsection{???}
+\subsection{\pkg{multicol}: Better column break control}
 
+From version 1.9 onwards \cs{columnbreak} accepts an optional
+argument (just like \cs{pagebreak}) in which you can specify the
+desirability to break the column after the current line: supported values are
+\texttt{1} to \texttt{4} with higher numbers increasing the likelihood.
+This version also adds \cs{newcolumn}
+which forces a column break but runs the column short (comparible to
+\cs{newpage} for pages). 
 %
-\githubissue{000}
+\githubissue{682}
 
 
 \section{Changes to packages in the \pkg{amsmath} category}
diff --git a/required/tools/multicol.dtx b/required/tools/multicol.dtx
index bc306073..2b74d85a 100644
--- a/required/tools/multicol.dtx
+++ b/required/tools/multicol.dtx
@@ -98,7 +98,7 @@
 %<driver> \ProvidesFile{multicol.drv}
 % \fi
 %         \ProvidesFile{multicol.dtx}
-          [2021/10/02 v1.8z  multicolumn formatting (FMi)]
+          [2021/10/08 v1.9a  multicolumn formatting (FMi)]
 %
 %
 %%
@@ -564,6 +564,13 @@
 % forced into the second column  (resulting in some white
 % space between paragraphs in the first column).
 %
+% From version 1.9 onwards \cs{columnbreak} accepts an optional
+% argument (just like \cs{pagebreak}) in which you can specify the
+% desirability to break the column at that point: supported values are
+% \texttt{1} to \texttt{4}. This version also adds \cs{newcolumn}
+% which forces a column break but runs the column short (comparible to
+% \cs{newpage}). 
+%
 % \subsection{Floats inside a \mc{} environment}
 %
 % Within the \mc{} environment the usual star float commands are
@@ -4089,34 +4096,65 @@
 %
 %  \begin{macro}{\columnbreak}
 % \changes{v1.5u}{1999/05/25}{Macro added}
+% \changes{v1.9a}{2021/10/08}{Added optional argument for conditional break}
 %    |\columnbreak| is modeled after |\pagebreak| except that we
 %    generate a penalty -10005.
 %    \begin{macrocode}
 \mathchardef\@Mv=10005
-\def\columnbreak{%
+\newcommand\columnbreak[1][4]{%
 %    \end{macrocode}
 %    We have to ensure that it is only used within a \mc{}
 %    environment since if that penalty would be seen by the unmodified
 %    \LaTeX{} output routine strange things would happen.
 %    \begin{macrocode}
- \ifnum\col at number<\tw@
-  \PackageError{multicol}%
-   {\noexpand\columnbreak outside multicols}%
-   {This command can only be used within
-    a multicols or multicols* environment.}%
- \else
-  \ifvmode
-    \penalty -\@Mv\relax
-  \else
-    \@bsphack
-    \vadjust{\penalty -\@Mv\relax}%
-    \@esphack
-  \fi
- \fi}
+   \ifnum\col at number<\tw@
+   \PackageError{multicol}%
+    {\noexpand\newcolumn outside multicols}%
+    {This command can only be used within
+     a multicols or multicols* environment.}%
+    \else
+%    \end{macrocode}
+%    Increasingly lower penalty based on argument value. This is like
+%    \cs{pagebreak} but we use other penalty values are the \LaTeX{}
+%    defaults aree rather pointless for pagination.
+%    \begin{macrocode}
+    \edef\mc at break@pen
+	{-\ifcase#1\@m\or 3333\or 6666\or 9999\else\@Mv\fi\relax}%
+    \ifvmode
+     \penalty \mc at break@pen
+   \else
+     \@bsphack
+     \vadjust{\penalty \mc at break@pen}%
+     \@esphack
+   \fi
+  \fi}
 %    \end{macrocode}
 %  \end{macro}
 %
 %
+%
+%  \begin{macro}{\newcolumn}
+% \changes{v1.9a}{2021/10/08}{Macro added}
+%    This is modeled after \cs{newpage} but for column breaks.
+%    \begin{macrocode}
+\newcommand\newcolumn{%
+   \ifnum\col at number<\tw@
+   \PackageError{multicol}%
+    {\noexpand\newcolumn outside multicols}%
+    {This command can only be used within
+     a multicols or multicols* environment.}%
+  \else
+    \ifvmode
+     \nobreak\vfill\penalty -\@Mv\relax
+   \else
+     \@bsphack
+     \vadjust{\nobreak\vfill\kern\z@\penalty -\@Mv\relax}%
+     \@esphack
+   \fi
+  \fi}
+%    \end{macrocode}
+%  \end{macro}
+%
 %  \begin{macro}{\colbreak at box}
 % \changes{v1.5u}{1999/05/25}{Macro added}
 %    Need a box to collect the galley up to the column break.
diff --git a/required/tools/testfiles/github-0682.lvt b/required/tools/testfiles/github-0682.lvt
new file mode 100644
index 00000000..6bf4a4ef
--- /dev/null
+++ b/required/tools/testfiles/github-0682.lvt
@@ -0,0 +1,155 @@
+% https://github.com/latex3/latex2e/issues/682
+
+\documentclass[a4paper]{article}
+
+\usepackage{multicol,lipsum}
+
+\addtolength\textheight{-8\baselineskip}
+
+\input{test2e}
+
+
+\begin{document}
+
+\START
+
+%\raggedcolumns  % multicol has aligned columns by default; uncomment to get extra space as the bottom
+
+\begin{multicols}{2}
+
+  \lipsum[1][1]\par
+  \lipsum[1][2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] 333\columnbreak[3]
+  \lipsum[3]
+
+  \lipsum[4]
+
+\end{multicols}
+
+\typeout{1: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1]\par
+  \lipsum[1][2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] XXX\columnbreak
+  \lipsum[3]
+
+  \lipsum[4]
+
+\end{multicols}
+
+\typeout{2: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1-2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] 111\columnbreak[1]
+  \lipsum[3]
+
+  \lipsum[4-5]
+
+\end{multicols}
+
+\typeout{3: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1-2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] 222\columnbreak[2]
+  \lipsum[3]
+
+  \lipsum[4-5]
+
+\end{multicols}
+
+\typeout{4: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1-3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] XXX\columnbreak
+  \lipsum[3]
+
+  \lipsum[4-5]
+
+\end{multicols}
+
+\typeout{5: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1]\par
+  \lipsum[1][2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] NEW\newcolumn
+  \lipsum[3]
+
+  \lipsum[4]
+
+\end{multicols}
+
+\typeout{1: \the\pagetotal}
+
+\newpage
+
+\begin{multicols}{2}
+
+  \lipsum[1][1]\par
+  \lipsum[1][2]\par
+  \lipsum[1][3]\par
+  \lipsum[1][4]\par
+  \lipsum[1][5]\par
+  \lipsum[1][6]\par
+  \lipsum[1][7-20]\par
+  \lipsum[2] NEW\newcolumn
+  \lipsum[3]
+
+  \lipsum[4-5]
+
+\end{multicols}
+
+\typeout{2: \the\pagetotal}
+
+\newpage
+
+\end{document}
+
diff --git a/required/tools/testfiles/github-0682.tlg b/required/tools/testfiles/github-0682.tlg
new file mode 100644
index 00000000..1846822b
--- /dev/null
+++ b/required/tools/testfiles/github-0682.tlg
@@ -0,0 +1,17 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+1: 454.0pt
+[1
+] [2]
+2: 0.0pt
+[3]
+3: 70.0pt
+[4] [5]
+4: 82.0pt
+[6] [7]
+5: 82.0pt
+[8] [9]
+1: 0.0pt
+[10]
+2: 82.0pt
+[11] (github-0682.aux)





More information about the latex3-commits mailing list.