[Tex/LaTex] Avoid page break between paragraphs with \medskip in between

page-breaking

Consider this texample

\documentclass{report}
\begin{document}
Some text

\medskip
\textbf{Mini title}
\medskip

\nopagebreak
Some more text
\end{document}

How can I avoid a page break between "Mini title" and "Some more text". I am exploring \nopagebreak to this end but to no avail?

Best Answer

I copied the \medbreak command from LaTeX and made a \mednobreak. It does a \nopagebreak and a \medskip. It will attach the first line of the following paragraph to the \textbf{Mini title}. Comment the line marked to see the effect.

\documentclass{report}
\usepackage{lipsum}
\def\mednobreak{\par\ifdim\lastskip<\medskipamount
  \removelastskip\nopagebreak\medskip\fi}
\begin{document}
\lipsum[1-4]
\lipsum[2]

another line % comment to see difference

\medskip
\textbf{Mini title}
\mednobreak
\lipsum[1]
\end{document}