[Tex/LaTex] Multicols: unwanted vertical space in the right column

multicol

This problem occurs when small paragraphs of a multicol environment are placed at the end of the page. I've produced the following MWE but the problem is sometimes more visible on longer documents:

\documentclass[letterpaper]{article}
\usepackage{multicol}\usepackage{biblatex}\usepackage{lipsum}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@Thesis{biblioEntry,
Title                    = {Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo Sed interdum libero Sed interdum libero Sed interdum libero},
Author                   = {Sed interdum libero},
Location                 = {Sed interdum libero},
Year                     = {1999},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document} 
\section{Section}
\lipsum[1-3]
\fullcite{biblioEntry}
\section{Section}
\begin{multicols}{2}
Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis.  Mauris lacinia lorem sit amet ipsum.

Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis.  Mauris lacinia lorem sit amet ipsum.

\lipsum[1]

\end{multicols}
\end{document}  

screenshot showing unbalanced columns at the end of a page

The same problem occurs in the actual multicols documentation:

multicols documentation, end of p. 6

As a workaround, I'm using \setlength{\parskip}{0pt} in the multicol environment. It works, but I'd like to know if there is a better solution.

Best Answer

This problem arises (as others have already said) because the are only 75pts left on the page and so when multicol cuts the columns it will split off columns of that size. However, with a default \baselineskip of 12pt and 10 points of \topskip 6 lines of text are worth 70pt, so in columns that have no stretch there will be a 5pt gap at the bottom and in the column with just the \parskip there will be an ugly gap between the paragraphs as all of these 5 points end up there.

A general fix may need a little bit more finesse but try this and see how far it gets you in general:

\usepackage{multicol}
\usepackage{etoolbox}

\makeatletter
\patchcmd\multi@column@out
{\process@cols}
{%
  \typeout{Requested vsize = \the\dimen@ }%
   \advance\dimen@ -\topskip
   \divide\dimen@ \baselineskip
   \multiply\dimen@ \baselineskip
   \advance\dimen@ \topskip
   \typeout{Reducing vsize to integral number of lines = \the\dimen@ }%
   \process@cols}
{\typeout{Success!}}{\ERROR}
\makeatother  

This should solve the problem, although I wonder if there need to be a different action if the gap is close to a whole baseline. So need to think about it a bit more.

Anyway, with the above I get:

enter image description here

which I think is what you are looking for.

Note

As pointed out in a comment, this results in the whole page being short which is true (by 5pt) and thus doesn't align with a facing page. However, this is only because \raggedbottom is used (which is the default in the article class). Thus any alignment is only by chance anyway. So if one wants the above but with aligned pages (and not just aligned by chance sometimes) then the right thing to do is to use \flushbottom in the preamble.

I could have forced such pages to be always bottom aligned which may or may not be better even with \raggedbottom in force but that's not done in the above patch.