Multicol – Combining Same Page and Multicol

multicolpage-breaking

I use multicols at times for specific blocks in my thesis, which has a title, and a block of stuff similar to the following:

\documentclass{article}

\usepackage{lipsum}
\usepackage{multicol}

\newenvironment{mh}[1]{%
    \textbf{#1}%
    \begin{multicols}{2}%
}{%BODY
    \end{multicols}%
}

\begin{document}
    \begin{mh}{This is the title.}
        \lipsum[1]
    \end{mh}
\end{document}

Top

I am getting an occurrence which is creating a page break between the title and the body, so I need to be able to instruct them to be on the same page. However the problem is, that using begin{samepage} ... \end{samepage} destroys the multicols environment, putting all the text in one column as per below:

 %NEED TO FORCE HEADING AND BLOCK ON SAME PAGE
 \begin{samepage}
    \begin{mh}{This is the title.}
         \lipsum[1]
    \end{mh}
\end{samepage}

Bottom

Anyone know how to work this?

Best Answer

The simplest way: use the optional argument that the {multicols} environment has for exactly such purposes:

\documentclass{article}

\usepackage{lipsum}
\usepackage{multicol}

\newenvironment{mh}[1]{%
  \begin{multicols}{2}[\textbf{#1}]%
}{%BODY
 \end{multicols}%
}

\begin{document}

\vspace*{.89\textheight}% this page
% \vspace*{.90\textheight}% next page

\begin{mh}{This is the title.}
  \lipsum[1]
\end{mh}

\end{document}