# mdframed : Bug with page break? [closed]

I'm trying to use the package mdframed to handle framed boxes, that allow page breaking when the content of the box is too large. Nevertheless, i encounter the following difficulty :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{mdframed}

\begin{document}
\blindtext\blindtext\blindtext\vspace{5cm}
\begin{mdframed}[userdefinedwidth=\textwidth]
\begin{tabular}{rl}
coucou &coucou \\
coucou &coucou \\
coucou &coucou \\
\end{tabular}

TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2
\end{mdframed}

\end{document}


With this choice of \vspace{5cm} before the mdframed environment, the tabular appears on the top of one page, and the rest on the next page, which is is this case absurd.

Is it a bug ? how can i bypass it ?

I guess the problem comes somehow from the fact, that the tabular is not splittable.

## EDIT: PeterGrill

As Marco requested, here is a MWE without \vspace that reproduces the problem:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{mdframed}

\begin{document}
\blindtext\blindtext\blindtext\blindtext%\vspace{5cm}
TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT22
\begin{mdframed}[userdefinedwidth=\textwidth]
\begin{tabular}{rl}
coucou &coucou \\
coucou &coucou \\
coucou &coucou \\
\end{tabular}

TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2 TEXT2
\end{mdframed}
\end{document}


## EDIT: NicolasRoy

I attached two screenshots.

Output with mdframed v1.0b:

Output with mdframed v1.3a:

## EDIT: NicolasRoy

I put Marco's proposed code for \def\mdf@put@frame@i in the preamble of my MWE, and get the following output :

## closed as off-topic by LaRiFaRi, user13907, egreg, Mico, JesseJul 17 '15 at 12:39

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Seems like a bug to me. The tabular not being able to cross page boundaries explains why it is on the top of the page, but not why the text following gets pushed to the next page (this does not occur if you comment out the mdframed environment). – Peter Grill Mar 5 '12 at 16:09
• @MarcoDaniel: Well, i put a vspace for the MWE, but in my actual code there is not vspace. could you by the way explain the fix ? – nicolas roy Mar 5 '12 at 18:44
• @MarcoDaniel: Have provided a version without \vspace that reproduces the problem. – Peter Grill Mar 5 '12 at 19:04
• I reproduced the bug without vspace in a similar way to PeterGrill. By the way, exactly the same code (the one of the MWE) produces two different outputs (both "buggy") on my computers at work (windows+texlive) and at home (llinux+texlive). At work, i have the symptom described by PeterGrill in his first comment. I will try to put a screenshot for the home-computer... if i find out how to do it :) On the Home-computer (the one of the screenshot) i have :Package: mdframed 2011/12/09 v1.0b: mdframed – nicolas roy Mar 5 '12 at 19:26
• I'm voting to close this question as off-topic because it is about a bug which has been fixed in the meantime. – LaRiFaRi Jul 17 '15 at 11:59

I know it's a comment but too long ;-)

Thanks @PeterGrill for the nice example. The problem is based on the internal algorithm. To explain this behaviour I describe the algorithm.

1. If the content of the environment has enough space for the current page mdframed prints the material.

2. If the content is to big for one page but the available vertical space is more than 2\baselineskip mdframed tries to split the contents.

And here is the problem. The environment tabular can't be split. mdframed tests only whether the space of the split box is less than the available vertical space. If this test fails, mdframed repeats the splitting with a lower dimension (90% of the available space) and print the first part.

And here is my mistake. I didn't notice your approach. ;-). The environment tabular can't be split and the reduction of the splitting dimension fails. So I have to implement an additional test.

I uploaded version 1.4a to github. With the example of @PeterGrill you get the following output:

• hum ... i put your \def\mdf@put@frame@i in the preamble of my MWE, after \usepackage{mdframed} and i get the same. – nicolas roy Mar 6 '12 at 11:31