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

share|improve this 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 update to mdframed 2012/02/04 v1.3a, and now i have the bug described in Peter's first comment. –  nicolas roy Mar 5 '12 at 21:22

1 Answer 1

up vote 7 down vote accepted

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 ;-)

share|improve this answer
    
ok great. Is itthe "old" code or the new one with the news test ? –  nicolas roy Mar 6 '12 at 9:25
    
@nicolasroy: It's the new code ;-) At the evening I will updload the beta version to github –  Marco Daniel Mar 6 '12 at 10:38
    
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
    
Please, see my new screenshot. –  nicolas roy Mar 6 '12 at 12:59
    
oh you're right (beginner's mistake, sorry). But nevertheless, even with, i don't see any difference. I updated the screenshot –  nicolas roy Mar 6 '12 at 17:18

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.