Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Please test the new version at github: github.com/marcodaniel/mdframed –  Marco Daniel May 17 '12 at 19:20
add comment

2 Answers

up vote 5 down vote accepted

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

share|improve this answer
    
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
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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