1

I'm formatting a document using the multicol package. As I in some parts have frequent short subsections I ideally would not want them to be "column broken" such that the subsection heading and all of its text always appears in the same column. This can of course be done by a minipage environment as in Unbreakable block.

However, when using that environment and therefore causing a, lets call it premature, columnbreak before a longer section, lots of white space is added in between all line breaks of the preceding section. I would like to avoid this and have the content of the preceding column all be stacked on the top, as usual.

Using a minipage environment with [t] specified did not help my problem unfortunately, neither did a samepage environment. I also was not able to find anything specific to this in the package manual of multicol, however I think that there should probably be a solution to this also when using just normal pages and page breaking before longer sections instead of column breaking (I was not sure whether this would then work in a multicol environment though, so I added that extra information in this question).

In case you're confused, here is a MWE that hopefully clears things up:

\documentclass[10pt]{article}

\usepackage{multicol}
\usepackage{lipsum}

\begin{document}

\newbox\one
\newbox\two
\long\def\loremlines#1{%
    \setbox\one=\vbox {%
      \lipsum%
     }
   \setbox\two=\vsplit\one to #1\baselineskip
   \unvbox\two}
  
\begin{multicols*}{2}
\section*{Section 1}
So this is a section that I would like to be on the left column. Let me add some text here.
Here is some text.
\smallskip
\loremlines{10}

\section*{Section 2}
This is also a section that still fits onto the left column so lets leave it here.
Here is some text.
And here some more.
\smallskip
\loremlines{10}

\section*{Section 3}
This is a section that starts on the left column and continues on the right. As the sections in my document are usually much smaller than this, I would not want this, and would rather have the section heading on the right column, along with all of its text.
Here is some text.
\smallskip
\loremlines{18}
On the next page I will show what I would not want to happen (using one minipage; and then on the following page one using three minipages).

\end{multicols*}


\clearpage
\begin{multicols*}{2}

\section*{Section 1}
So this is a section that I would like to be on the left column. Let me add some text here.
Here is some text.
And here some more.
\smallskip
\loremlines{10}

\section*{Section 2}
This is also a section that still fits onto the left column so lets leave it here.
Here is some text.
And here some more.
\smallskip
\loremlines{10}

\begin{minipage}[t]{0.48\textwidth}
\section*{Section 3}
This is a section that used to start on the left column and continued on the right. Now it is completely on the right (yay!) but look at the left side. What a mess! (is even worse when there are three or four really short sections on the left, and this section originally took quite a big part of the left column).
Here is some text.
\smallskip
\loremlines{18}
\end{minipage}

\end{multicols*}


\clearpage
\begin{multicols*}{2}

\begin{minipage}[t]{0.48\textwidth}
\section*{Section 1}
So this is a section that I would like to be on the left column. Let me add some text here.
Here is some text.
And here some more.
\smallskip
\loremlines{10}
\end{minipage}

%the space here should go poof! else this looks fine.

\begin{minipage}[t]{0.48\textwidth}
\section*{Section 2}
This is also a section that still fits onto the left column so lets leave it here.
Here is some text.
And here some more.
\smallskip
\loremlines{10}
\end{minipage}

\begin{minipage}[t]{0.48\textwidth}
\section*{Section 3}
So the left side looks better than before. But still not really appealing. The space between the two sections on the left side should ideally go 'poof'.
Here is some text.
\smallskip
\loremlines{18}
\end{minipage}

\end{multicols*}
\end{document}

(definition of loremlines taken from Is there an equivalent of lipsum for shorter sections of text? and minimally adapted)

Thanks a lot!

Update: As Ivan has pointed out in a comment, I could add \vfill\null to manually force space to disappear. I'm wondering whether there is a possibility of not needing to do anything manually (adding \vfill\null after each minipage does not do anything of course) after compiling.

2
  • 1
    Does \vfill\null before the last minipage on page 2 solve your problem?
    – Ivan
    Feb 24, 2021 at 10:21
  • @Ivan kind of yes! However it does not do anything when I add it after each minipage on page 3 which is mainly what I would like to have - something I can add in advance so that I dont have to manually add it every time I add another section somewhere in the document. I will add that to my post, unless there is a better option I guess I will run with your suggestion.
    – Tork
    Feb 24, 2021 at 10:28

1 Answer 1

1

The main switch you need to make when using minipages is to convert from multicols* to multicols. Of course putting a \section at the top of the minipage will also lose the spacing above the section title, which is likely not what you want, so we have to add it back.

In the solution below, I've defined a simple environment to encapsulate the minipage and the spacing, using the standard spacing for the \section command.

Note also that recent versions of lipsum allow you to select specific sentences to print, so I've simplified your MWE by taking advantage of that capability.

\documentclass[10pt]{article}

\usepackage{multicol}
\usepackage{lipsum}

\newenvironment{myblock}{%
  \vspace{3.5ex plus 1ex minus .2ex}
  \begin{minipage}{0.48\textwidth}}{\end{minipage}}

\begin{document}

\begin{multicols}{2}

\begin{myblock}
\section*{Section 1}
So this is a section that I would like to be on the left column. Let me add some text here.
Here is some text.
And here some more.

\lipsum[1][1-6]
\end{myblock}

\begin{myblock}
\section*{Section 2}
This is also a section that still fits onto the left column so lets leave it here.
Here is some text.
And here some more.

\lipsum[1][1-6]
\end{myblock}

\begin{myblock}
\section*{Section 3}
So the left side looks better than before. But still not really appealing. The space between the two sections on the left side should ideally go 'poof'.
Here is some text.

\lipsum[1][1-14]
\end{myblock}

\end{multicols}
\end{document}

enter image description here

2
  • Thank you, I didnt expect any answer anymore! It seems to work for you, but for me it for some reason did not change anything, even when switching to multicols. Probably some interference with other packages?
    – Tork
    Mar 17, 2021 at 16:31
  • Possibly. Try stripping stuff away until things change
    – Karl Hagen
    Mar 18, 2021 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .