3

I am using multicol.sty for balanced columns on a small part of the page. Generally I want these columns to be balanced, but not if the resulting twocol part ist less than 3 lines in height. How can I do this? (By automation?)

MWE:

\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} 

So in this example I want all the twocol text to appear only in the left column.

enter image description here

3

Full automation is right now only possible with a code change. As a one-off it is easy: Before the environment set the counter unbalance to 2. This will enlarge the starting vertical size by 2 \baselineskips.

The counter will be reset to zero after each environment.

A more general solution that does it automatically could look like this:

\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} 

If we apply this patch then we get the following output (note that I change the minimum number of lines for the various environments):

enter image description here

  • @LaTechneuse in that case checkmark the answer – Frank Mittelbach Apr 29 '15 at 10:06
  • Sure I will but let me try to check it in my scenario first. Sometimes things emerge when transplanting a perfect solution to an imperfect case ;) – LaTechneuse Apr 29 '15 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.