Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The setup: I need to use multicols for say 3 columns where I have many small sections. I noticed that some sections are broken in the middle and end up wrapping to the next column, which I do not want.

After some research (i.e googling) found that adding \interlinepenalty=10000 prevents this. And it does. Multicol - don't wrap

But instead of having the gaps at the bottom of the columns (ragged bottoms, or whatever the correct name for it), the columns end up with large empty space in between, which does not look good.

Mathematica graphics

generated using:

\documentclass[10pt,notitlepage]{article}%
\setlength{\columnseprule}{0pt} %column thicnkess 
\setlength{\columnsep}{5.0pt}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\begin{document}
\begin{multicols*}{3}     
\interlinepenalty=10000
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[3]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[4]
\section{some section}
\lipsum[75]
\end{multicols*}
\end{document}

removing \interlinepenalty=10000 gives

Mathematica graphics

which I do not want since section is flowing across columns.

Removing the star version does not help either. One must use \interlinepenalty=10000 to prevent page break inside a section. But then the problem are those large gaps in between sections.

Then I used samepage to wrap each section inside it in the hope it will help. But this result was more strange. I must have done something wrong here:

Mathematica graphics

Here is the code for the above

\documentclass[10pt,notitlepage]{article}%
\setlength{\columnseprule}{0pt} %column thicnkess 
\setlength{\columnsep}{5.0pt}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\begin{document}
\begin{multicols}{3}     
%\interlinepenalty=10000

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[3]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[4]
\end{samepage}

\begin{samepage}
\section{some section}
\lipsum[75]
\end{samepage}

\end{multicols}
\end{document}

What is the correct way to prevent page breaks in the middle of sections, but have the extra space be at the bottom and not in between?

Using Tex live 2013 on Linux. (ps. one day, I need to learn how to use Latex to make copies code fragment to I do not copy paste same code again and again).

share|improve this question
    
Try adding \raggedcolumns before or after \begin{multicols}{3} in your first MWE (works with both the starred and non starred version of multicol. –  dcmst Dec 26 '13 at 9:01
1  
@dcmst thanks that worked. If you like to add this as answer so I can accept and close this. –  Nasser Dec 26 '13 at 10:47

1 Answer 1

up vote 7 down vote accepted

The desired effect can be achieved using the \raggedcolumns macro:

\documentclass[10pt,notitlepage]{article}%
\setlength{\columnseprule}{0pt} %column thicnkess 
\setlength{\columnsep}{5.0pt}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\begin{document}
\begin{multicols}{3}
\raggedcolumns     %new code
\interlinepenalty=10000
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[3]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[75]
\section{some section}
\lipsum[4]
\section{some section}
\lipsum[75]
\end{multicols}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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