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

  • 1
    Confirmed that this problem no longer occurs in the current version of TeXLive2012. – Peter Grill Oct 20 '12 at 6:25
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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.