# Different width of frame across page bounadries with mdframed

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:

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.

## 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}

-
Please test the new version at github: github.com/marcodaniel/mdframed –  Marco Daniel May 17 '12 at 19:20

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:

-
Confirmed that this problem no longer occurs in the current version of TeXLive2012. –  Peter Grill Oct 20 '12 at 6:25
@PeterGrill: Thanks –  Marco Daniel Oct 20 '12 at 6:31

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 :)

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

-