# Pagebreaks and parskip with lots of small sections

I'm having trouble with page breaks in a LaTeX document. LaTeX seems to occasionally (and inexplicably) move a few lines onto a new page, even when there is clearly enough room for those lines at the bottom of the previous page.

I've been able to work out that changing the parskip value will change the behaviour. In the MWE below, using the default value for \parskip pushes a whole section onto a new page. Changing the \parskip to exactly 0 causes everything to fit on one page (the default \parskip seems to be 0pt plus 1pt). Alternately, changing the parskip to something like 0pt plus 4pt minus 1pt causes four whole sections to appear on the second page. Note that the actual paragraph spacing in the produced document does not change at all.

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{pgffor}
\usepackage[showframe,
left=10pc,
right=5pc,
top=5.5pc,
bottom=5pc,
marginparwidth=6pc,

\setlength{\parskip}{0pt plus 4pt minus 1pt} % Many lines go to next page
% \setlength{\parskip}{0pt} % Everything fits on one page.

\usepackage{titlesec}
\titleformat{\subsection}
[leftmargin]{\footnotesize\vspace{0pt}\filleft}{}{.5em}{}
\titlespacing{\subsection}
{4pc}{0.2ex plus .1ex minus .1ex}{1pc}

\begin{document}
\raggedbottom
\setlength{\parindent}{0pc} % Remove paragraph indentation

\the\parskip

\foreach \n in {7:30,8:00,8:30,9:00,9:30,10:00,10:30,11:00,11:30,12:00,12:30,13:00,13:30,14:00,14:30,15:00,15:30,16:00,16:30,17:00,17:30,18:00,18:30,19:00,19:30,20:30,21:30}{
\subsection{\n}\textbf{Time now is \n}\par Let's get busy!\par}

\end{document}


Result of MWE:

That's imho a bug in the titlesec command used for the leftmargin option. It removes from \pagegoal the current \pagestretch value, and with a positiv stretch value in \parskip this piles up. If I remove this line your document compiles fine:

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{pgffor}
\usepackage[showframe,
left=10pc,
right=5pc,
top=5.5pc,
bottom=5pc,
marginparwidth=6pc,

\setlength{\parskip}{0pt plus 4pt minus 1pt} % Many lines go to next page
% \setlength{\parskip}{0pt} % Everything fits on one page.

\usepackage{titlesec}
\titleformat{\subsection}
[leftmargin]{\footnotesize}{}{.5em}{}
\titlespacing{\subsection}
{4pc}{0.2ex plus .1ex minus .1ex}{1pc}

\usepackage{etoolbox}
\makeatletter