8

When a mdframed frame begins with a display math, and the break occurs just at the end of the display math environment, the widths of the frame are different across the page break boundary:

enter image description here

Also note the inconsistent spacing on the first few lines of the second page.

Notes:

  • The page geometry changes were to allow for a better image to show the problem.
  • I encounter this problem with Version 2012/04/08 v1.5, but apparently the earlier version 2012/03/04 v1.4 works just fine.

References:

Code:

\documentclass{article}
\usepackage[bottom=0.2cm,top=0.2cm]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{mdframed}
\newmdenv[%
    leftmargin=0.5cm,
    rightmargin=0.5cm,
    backgroundcolor=yellow,%
    ]{Myframe}%

\begin{document} \vspace{24.75cm} \begin{Myframe} \begin{align} e &= mc^2\ F &= ma \end{align*} \lipsum[1] \end{Myframe} \end{document}

Peter Grill
  • 223,288

2 Answers2

5

Today I uploaded the new version at github which fixed the problem. The idea was inspired by David Carlisle here: Ignore first parskip inside a save box

Also based on the new splitting algorithm the example:

\documentclass{article}
\usepackage[bottom=0.2cm,top=0.2cm]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{mdframed}
\newmdenv[%
    leftmargin=0.5cm,
    rightmargin=0.5cm,
    backgroundcolor=yellow,%
    ]{Myframe}%

\begin{document}
\vspace*{25.7cm}
\begin{Myframe}
    \begin{align*}
        e &= mc^2\\
        F &= ma
    \end{align*}
    \lipsum[1]
\end{Myframe}
\end{document}

results to: enter image description here

David Carlisle
  • 757,742
Marco Daniel
  • 95,681
4

I've found that a well-placed \mbox{} can sometimes help fix these types of bad breaks in an mdframed environment. Perhaps Marco Daniel will have a better fix though :)

enter image description here

\begin{Myframe}
    \mbox{}
    \begin{align*}
        e &= mc^2\\
        F &= ma
    \end{align*}
    \lipsum[1]
\end{Myframe}
David Carlisle
  • 757,742
cmhughes
  • 100,947