2

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]
\begin{equation}
    c^2 = a^2 + b^2
\end{equation}
\lipsum[2]
\begin{equation}
    r^2 = x^2 + y^2
\end{equation}
\lipsum[3]

\end{mdframed}

\end{document}
2
  • 2
    Use tcolorbox instead of mdframed - it handles breaking much better. Mar 1, 2019 at 19:33
  • This is good advice.
    – woeterb
    Mar 1, 2019 at 22:21

1 Answer 1

0

With tcolorbox:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{colortbl}

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

\tcbset{
    breakable,
    sharp corners,
    colback=lightgrey,
    colframe=lightgrey,
    after skip=12pt,
    before skip=12pt,
    left=10pt,
    right=10pt,
    top=8pt,
    bottom=8pt,
    boxsep=0pt
    }

\begin{document}

\begin{tcolorbox}

\lipsum
\lipsum[1]
\begin{equation}
    c^2 = a^2 + b^2
\end{equation}
\lipsum[2]
\begin{equation}
    r^2 = x^2 + y^2
\end{equation}
\lipsum[3]

\end{tcolorbox}

\end{document}

enter image description here

However, with the displayed formula, a little difference still exists.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .