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.

I think I may have stumbled upon a bug in the mdframed package. I have an mdframed environment with just one align environment inside it. Consider this minimum working example:

\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{mdframed}
\usepackage{blindtext}

\begin{document}
\blindtext \\ \blindtext \\ \blindtext 

\begin{mdframed}
\begin{align*}
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2
\end{align*}
\end{mdframed}

\end{document}

This gives the following output:

As you can see, the \begin{mdframed} command is issued around the bottom of the page. Because align is not splittable, the whole frame plus contents gets placed on the next page, which is absolute what expect to happen. However, extra vertical white space appears on the bottom inside the mdframed environment, so that the mdframed environment is much higher than it should be.

From experimenting a bit, I think that the amount of extra white space is about the same amount of remaining vertical space on the previous page, which implies that the mdframed could be up to twice as high as it should be.

Is there a workaround for this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

The environment align isn't a splittable material by default. So you run into an loop which produce such unwanted space. However at the moment I am working on a fix. I think I will upload the new version at the weekend (inspired by Nicolas Markey).

To fix this with the current version use the following example which uses the command \allowdisplaybreaks to make align splitable.

\documentclass[11pt]{article}

\usepackage{amsmath}

\usepackage{mdframed}
\usepackage{blindtext}

\begin{document}
\blindtext \\ \blindtext \\ \blindtext 

\allowdisplaybreaks
\begin{mdframed}
\rule{\linewidth}{0pt}
\begin{align*}
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2 \\
x^2 + y^2 = z^2
\end{align*}
\end{mdframed}

\end{document}

enter image description here

share|improve this answer
    
Thanks for your reply, and thanks also for this great package! I will patiently wait for your new version then. In the mean time, adding the \allowdisplaybreaks is actually not such a bad idea. –  Yori Apr 25 '12 at 19:47

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.