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 \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}
如果我們應用這個補丁,那麼我們會得到以下輸出(請注意,我更改了各種環境的最小行數):