multicol:仅在达到最少行数后才进行列平衡?

multicol:仅在达到最少行数后才进行列平衡?

我在页面的一小部分上使用multicol.sty平衡列。通常我希望这些列是平衡的,但如果生成的两列部分的高度小于 3 行,则不希望如此。我该怎么做?(通过自动化?)

梅威瑟:

\documentclass{scrartcl}
\usepackage{multicol}
\parindent 0pt

\begin{document}

Some onecolumn text goes here on top of the page \ldots 

\begin{multicols}{2}
    This text is balanced into two columns, although it is very
    short. How can I prevent balancing below 3 lines minimum
    height?
\end{multicols}%

Some more onecolumn text goes here below the twocol part \ldots 

\end{document} 

因此在这个例子中我希望所有的 twocol 文本只出现在左列。

在此处输入图片描述

答案1

目前,只有通过更改代码才能实现完全自动化。一次性操作很简单:在环境之前将计数器设置unbalance为 2。这会将起始垂直尺寸扩大 2\baselineskip秒。

每次环境结束后计数器都会重置为零。

一个更通用的自动执行的解决方案可能是这样的:

\documentclass{scrartcl}
\usepackage[balancingshow]{multicol}
\parindent 0pt

%-------------------------------------------------------------------------------
\usepackage{regexpatch}

\newcounter{multicolminlines}
\setcounter{multicolminlines}{1}

\makeatletter
\xpatchcmd\balance@columns
   {\ifnum\dimen@<\topskip
     \mult@info\@ne
       {Start value
          \the\dimen@  \space ->
          \the\topskip \space (corrected)}%
     \dimen@\topskip
   \fi}
   {\skip@\c@multicolminlines\baselineskip
   \advance\skip@-\baselineskip
   \advance\skip@\topskip
   \ifnum\dimen@<\skip@
     \mult@info\@ne
       {Start value
          \the\dimen@  \space ->
          \the\skip@ \space (corrected)}%
     \dimen@\skip@
   \fi
   }
   {\typeout{Success!}}{\patchFAILED}
\makeatother
%-------------------------------------------------------------------------------

\begin{document}

Some onecolumn text goes here on top of the page \ldots 

\setcounter{multicolminlines}{3}
\begin{multicols}{2}
    This text is balanced into two columns, although it is very
    short. How can I prevent balancing below 3 lines minimum
    height?
\end{multicols}

Some more onecolumn text goes here below the twocol part \ldots 


\setcounter{multicolminlines}{2}
\begin{multicols}{2}
    This text is balanced into two columns, although it is very
    short. How can I prevent balancing below 3 lines minimum
    height?
\end{multicols}


\begin{multicols}{2}
    This text is balanced into two columns, although it is very
    short. 
\end{multicols}

\setcounter{multicolminlines}{1}
\begin{multicols}{2}
    This text is balanced into two columns, although it is very
    short. 
\end{multicols}

\end{document} 

如果我们应用此补丁,那么我们会得到以下输出(请注意,我根据不同的环境更改了最少的行数):

在此处输入图片描述

相关内容