# Vertically justify frame before page break using mdframed

When mdframed breaks a page, it appears that there is no vertical justification on the page before the page break. Compiling the code sample below for example, it can be seen that there is more vertical space left between the frame and the page number on page 2 than on page 1.

Is there a setting that can vertically justify the content in the frame, such that the page before the break is filled?

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{colortbl}

\definecolor{lightgrey}{RGB}{229,229,229}

\mdfsetup{
backgroundcolor=lightgrey,
linewidth=0pt,
skipabove=12pt,
skipbelow=12pt,
leftmargin=0pt,
rightmargin=0pt,
innertopmargin=10pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
splittopskip=2\topsep
}

\begin{document}

\begin{mdframed}

\lipsum
\lipsum[1]
$$c^2 = a^2 + b^2$$
\lipsum[2]
$$r^2 = x^2 + y^2$$
\lipsum[3]

\end{mdframed}

\end{document}

• Use tcolorbox instead of mdframed - it handles breaking much better. – Ulrike Fischer Mar 1 at 19:33
• This is good advice. – woeterb Mar 1 at 22:21