10

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: screenshot with mdframed v1.0b

Output with mdframed v1.3a: screenshot 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 : screenshot for the fix

Loic Rosnay
  • 8,167
  • 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 05 '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 ? – Loic Rosnay Mar 05 '12 at 18:44
  • @MarcoDaniel: Have provided a version without \vspace that reproduces the problem. – Peter Grill Mar 05 '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 – Loic Rosnay Mar 05 '12 at 19:26
  • I update to mdframed 2012/02/04 v1.3a, and now i have the bug described in Peter's first comment. – Loic Rosnay Mar 05 '12 at 21:22
  • 4
    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
  • @LaRiFaRi I just had this problem now. I think it is not something that is off-topic, even if the bug has been fixed. The meaningful thing to do is to put that information into an answer. (with reason being: "This question does not fall within the scope of TeX, LaTeX or related typesetting systems" is totally inaccurate.) – Jonathan Komar Sep 25 '15 at 08:04
  • @macmadness86 do you have this problem with version 1.9b? Is it really the same situation or is some other package interfering? You can always vote to reopen or ask new questions. The closure has been a democratic decision. The reason for me closing such topics is: If someone has a problem with TeX and knows that he has the most actual packages on the system, he should not need to open this post here. In any case, it is just closed and not deleted. The content is still browsable. – LaRiFaRi Sep 25 '15 at 10:15

1 Answers1

12

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:

enter image description here

PS: I am happy about every proof reader ;-)

pluton
  • 16,421
Marco Daniel
  • 95,681