I created a custom environment for theorems using mdframed package:


        outerlinewidth = 0, 
        leftmargin= 40,%
        rightmargin= 20, 

then I use it in following way:

If something... and somethong... then following takes place:
some equations....

But sometimes this environment is being splitted between two pages. If the theorem is long, it is fine. But sometimes LaTeX is leaving one or two lines of the theorem on previous/next page.

How can I discourage LaTeX in splitting this environment between pages? I would like it to be splitted only if it really have to.

closed as unclear what you're asking by Joseph Wright Aug 19 '13 at 7:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please add a complete minimal working example. You can avoid splitting for single frames by using the option nobreak. – Marco Daniel Jun 18 '13 at 13:55
  • for just a few lines on the "previous" page, the needspace package might be helpful. for a few lines on a "next" page, you'd probably need to consider \enlargethispage (to be done only when you're nearing the final run, with no more changes anticipated); some good information here: Squeeze some more lines on the current page. unfortunately, both of these operations are manual, although it may be possible to build \needspace into your environment definition. – barbara beeton Jun 27 '13 at 17:46
  • mdframed has a needspace option that will reserve space at the top of the environment. E.g. needspace=5\baselineskip will ensure that there are at least 4 lines together. I don't see a corresponding option for the end. – Andrew Swann Jun 28 '13 at 9:45
  • We need a full MWE here to answer – Joseph Wright Aug 19 '13 at 7:56