Page LayoutPage breaks using mdframed

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Zetison
Posts: 17
Joined: Fri Dec 02, 2011 2:05 pm

Page breaks using mdframed

Post by Zetison »

I use mdframed to write mathematical proofs in a box. Sometimes these proofs spans over several pages. This is fine as long as the frame is not cut in such a way that only a small partion of the box is left on a page.

So in the following code, the first frame is accepted while the other one is not.

Code: Select all

\documentclass[10pt,a4paper, makeidx]{report}
\usepackage[utf8]{inputenc}	
\usepackage{amsmath, amsfonts, amssymb}	%Enable mathematical expressions
\usepackage{mdframed}	%Package for making environments for proofs and example (using minipage)
\usepackage[margin=1.2in]{geometry}	%Defining the margins
\usepackage{parskip}	%Making a new line instead of indentation (for paragraphs)
\usepackage{blindtext}

%Defining some colors
\definecolor{examplesBackground}{RGB}{220,226.5,237}	%Background color for example environment
\definecolor{examplesHeaderLine}{RGB}{122,150,191}		%Color of header line in examples environment

%Environment for examples
\newmdenv[topline=false, bottomline=false, leftline=false, rightline=false,backgroundcolor=examplesBackground, frametitle={\tiny\hspace{2cm}}, frametitlebackgroundcolor=examplesHeaderLine, frametitleaboveskip=-1pt]{examples}
\begin{document}
	\blindtext\blindtext\blindtext\blindtext\blindtext	
	\begin{examples}
		\blindtext\blindtext\blindtext
	\end{examples}
	\blindtext\blindtext
	\begin{examples}
		\blindtext
		\begin{align}
			F = ma\\
			F = ma\\
			F = ma
		\end{align}
		\blindtext		
	\end{examples}	
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Page breaks using mdframed

Post by cgnieder »

This code looks fine for me both on WriteLaTeX (the link is above the code) where the second frame isn't split at all and on my system (up to date TL 2013) where the second split looks as follows:
mdframed.png
mdframed.png (18.46 KiB) Viewed 10925 times
Regards
site moderator & package author
User avatar
Zetison
Posts: 17
Joined: Fri Dec 02, 2011 2:05 pm

Re: Page breaks using mdframed

Post by Zetison »

Right. The problem is that the second split is not preferable...
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Page breaks using mdframed

Post by cgnieder »

Zetison wrote:Right. The problem is that the second split is not preferable...
This is very vague... What exactly don't you like about it? Looks fine to me.

Regards
site moderator & package author
User avatar
Zetison
Posts: 17
Joined: Fri Dec 02, 2011 2:05 pm

Re: Page breaks using mdframed

Post by Zetison »

It is a "widows and orphans"-problem. Either more text must be splitted into the next page, or there can be no splits on that frame.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Page breaks using mdframed

Post by cgnieder »

Zetison wrote:It is a "widows and orphans"-problem. Either more text must be splitted into the next page, or there can be no splits on that frame.
I would agree if it were only one line (i.e a real widowed line) or even only a part of the coloured frame without text. Still:can't you be more concrete? How many lines would be acceptable?

Regards
site moderator & package author
User avatar
Zetison
Posts: 17
Joined: Fri Dec 02, 2011 2:05 pm

Re: Page breaks using mdframed

Post by Zetison »

Let's say I want no less than 5 lines on the new page, is this obtainable.
Post Reply