Search code examples
latexmulticol

Dealing with widows in a multicol environment


I have problems with dealing with widows within a multicols environment, that is, I have not managed to instruct LaTeX to remove the them.

This PDF document shows an example of the problem. At the top of the second page, I get a widow from the last paragraph of the first page. I have tried a couple of approaches, without luck:

  • setting both \widowpenalty and \clubpenalty to high values
  • switching between \raggedcolumns and \flushcolumns
  • adjusting the collectmore and unbalance counters

I've also read through the documentation for multicol but have not found anything useful.

Is there anything else I could try?

(The complete LaTeX document for the above example)


Solution

  • {\obeyspaces\gdef\nomorebreak{\beginnomorebreak\let \nobreakspace}}
    \def\beginnomorebreak{\begingroup
       \def\par{\endgraf\endgroup\par\penalty 9999 }\obeyspaces
       \brokenpenalty 10000 \widowpenalty 10000 \clubpenalty 10000 }
    \def\nobreakspace{\vadjust{\nobreak} \removespaces}
    \def\removespaces{\futurelet\next\checkspace}
    \def\checkspace{\ifx\next\nobreakspace\expandafter\removesinglespace\fi}
    \def\removesinglespace#1{\removespaces}
    

    Insert \nomorebreak at any place of your paragraph. Page breaks will be prohibited after this macro until the end of the paragraph.