# How to avoid that the \newenvironment text is placed on one single page

I am using the \newenvironment command for the first time and well it's causing troubles. I am using it for creating a new theorem environment


\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{amsthm , amsfonts, latexsym}
\usepackage{tikz}
\usepackage[mathscr]{euscript}
\usepackage{graphics,graphicx}
\usepackage{enumerate}
\usepackage{color}

\theoremstyle{definition}

\newenvironment{lem}[1][]{
\begin{lems}[#1]\hspace*{1mm}
}{\end{lems}}


Using this new theorem environment I am doing a proof of a lemma that needs some pages of space.


\begin{document}
\begin{lem}
Let $H$ be a connected S-thin hypergraph, and $A \boxtimes B$ and $C \boxtimes D$ be two
decompositions of $H$ with respect to the strong product. Then there exists a decomposition
$$A_C \boxtimes A_D \boxtimes B_C \boxtimes B_D$$
of $H$ such that $A = A_C \boxtimes A_D, B= B_C \boxtimes B_D , C= A_C \boxtimes B_C, D=A_D \boxtimes B_D$.
\begin{proof}
The idea of the proof is by using the PFD of the cartesian skeleton $H^{\Box}$ of $H$  to define four proper factors, such that
each factor has as vertex set the set of one of our desired factors, e.g. $A_C$. Then we define the desired factors of $H$ by defining projections on $H$ where the vertex set is given by the composed factors of the cartesian skeleton and such that the
edges obey the definition of the strong product. Finally via those projections it is shown that $A=A_C \boxtimes A_D$.\

Let $H_1 \Box H_2 \Box ... \Box H_n$ be the unique PFD of a cartesian skeleton $H^{\Box}$ of $H$ . Let $I_A$ be the subset of the index set ${1,2,...,n}$ with $V(A)=V(\Box_{i \in I_A} H_i)$
and $I_B, I_C$ and $I_D$ be defined analogously. Furthermore set
$$H_{A,C} = \Box_{i \in I_A \cap I_C} H_i$$
and define $H_{A,D}, H_{B,C}$ and $H_{B,D}$ similarly. Then
$$H^{\Box} = H_{A,C} \Box H_{A,D} \Box H_{B,C} \Box H_{B,D} .$$
It will be convenient to use only four coordinates $(x_1,x_2,x_3,x_4)$  for every vertex $x \in V(G)$ henceforth. Of course it is possible that not all of the intersections $I_A \cap I_C, I_A \cap I_D, I_D \cap I_C$
and $I_B \cap I_D$ are nonempty. Suppose that $I_B \cap I_C = \emptyset$ then $I_A \cap I_D \neq \emptyset$. If in addition $I_A \cap I_C$ were empty, then $I_A = I_D$ and thus $I_B=I_C$, but then
would be nothing to prove.   \
We can thus assume that all but possibly $I_B \cap I_D$ are nonempty and at least three of the four
coordinates are nontrivial, that is to say, there are at least two vertices that differ in the first, second
and third coordinates, but it is possible that all vertices have the same fourth coordinate. \
Clearly, for $y=(y_1,y_2,y_3,y_4),$
$$V(A^y) = { (x_1,x_2,y_3,y_4) | x_1 \in V(H_{A,C}), x_2 \in V(H_{A,D}) }$$
$$V(B^y) = { (y_1,y_2,x_3,x_4) | x_3 \in V(H_{B,C}), x_4 \in V(H_{B,D}) }$$
$$V(C^y) = { (x_1,y_2,x_3,y_4) | x_1 \in V(H_{A,C}), x_3 \in V(H_{B,C}) }$$
$$V(D^y) = { (y_1,x_2,y_3,x_4) | x_2 \in V(H_{A,D}), x_4 \in V(H_{B,D}) }$$
are the vertex sets of the $A-,B-,C-$ and $D-$ layers of $H$. \

We now define $A_C$ as $p_1(H)$, namely $V(A_C) = V(H_{A,C})$ and  $${x_1^1,...,x_k^1 } \in E(A_C)$$
if and only if there are vertices $\tilde x_1=(x_1^1,x_1^2,x_1^3,x_1^4),..., \tilde x_k =(x_k^1,x_k^2,x_k^3,x_k^4) \in H \text { such that}$
$$\exists e \in E(H) : \exists S \subseteq I={2,3,4} : p_1(e) = { x_1^1,...,x_k^1}$$
\begin{itemize}

\item[(i)] $p_s(e) \subseteq e_s \in E_s , \forall s \in S$
\item[(ii)]$|e| = |p_s(e)|, \forall s \in S$
\item[(iii)] $|p_i(e)|=1, \forall i \in I \setminus S$
\end{itemize}

It is clear what is meant by $A_D, B_C$ and $B_D$. For the proof of the lemma it suffices to show that
$A = A_C \boxtimes A_D$. Recall that $A$ is obtained by projection of $H$ onto the vertex set of $A$. We
call this projection $p_A$ and define $p_B,p_C,p_D$ analogously. With our present coordinatization we thus have
$$p_A(x_1,x_2,x_3,x_4) = (x_1,x_2,-,-),$$
$$p_B(x_1,x_2,x_3,x_4) = (-,-,x_3,x_4),$$
$$p_C(x_1,x_2,x_3,x_4) = (x_1,-,x_3,-),$$
$$p_D(x_1,x_2,x_3,x_4) = (-,x_2,-,x_4).$$
In order to show that $A=A_C \boxtimes A_D$, it suffices to prove that for $e={\tilde x_1,..., \tilde x_k } \in H$ holds
$$p_A(e) \in A$$ if and only if
$$p_1(e) \in A_C \text{ and either is } e \text{ an edge in }A_D \text{, hence } p_2(e) \subseteq e \in A_D, |e|=|p_2(e)|$$
$$\text{ or not and thus } |p_2(e)|=1$$
(wlog. we assume that the edge of $A_C$ is of minimal rank, otherwise we could easily add a case to the above definition
where the edge of $A_D$ was the minimal one. But for the sake of clarity we omit this case).

Suppose that ${p_A \tilde x_1,..., p_A \tilde x_k } \subseteq e \in A$. We can assume, wlog., that
$\tilde x_1, ... , \tilde x_k$ are chosen such that ${ \tilde x_1 ,... , \tilde x_k } \in E(H).$ But then
${p_1 \tilde x_1, ... , p_1 \tilde x_k } \in A_C$ and ${p_2 \tilde x_1, ... , p_2 \tilde x_k } \in A_D$
by the definition of $A_C$ and $A_D$. \
On the other hand, suppose that the edge
${ (x_1^1,-,-,-),(x_2^1,-,-,-),...,(x_k^1,-,-,-}$ is in $A_C$ and ${(_,x_1^2,-,-),...,(-,x_t^2,-,-)}$ is
in $A_D , t \leq t$. \
Then there are vertices $\tilde x_1, \tilde x_2, ... , \tilde x_k, ... , \tilde x_t$ of the form
$$\tilde x_i = ( x_i^1, x_i^2, x_i^3, x_i^4)$$
with ${ \tilde x_1 , ... , \tilde x_k } \in E(H)$ and ${ \tilde x_1 , ... ,\tilde x_t } \in E(H)$. \
From this we infer that there are edges
$${ (x_1^1,-,x_1^3,-),...,(x_s^1,-,x_s^3,-) } \in E(C) , k \leq s \leq t$$
$${(-,x_1^2,-,x_1^4),...,(-,x_r^2,-,x_r^4) } \in E(D), k \leq r \leq t$$
Since $H = C \boxtimes D$ this implies that
$${(x_1^1,x_1^2,x_1^3,x_1^4),...,(x_s^1,x_s^2,x_s^3,x_s^4) } \in E(H) \text{ where wlog. } s \leq r$$
and hence ${(x_1^1,x_1^2,-,-),...,(x_s^1,x_s^2,-,-) } \subseteq e \in E(A)$.
\end{proof}
\end{lem}
\end{document}


It isn't the proof that troubles me, hence no one has to check it for me ;). The problem is rather that the proof needs several pages but LaTeX puts it all on one page, which is obviously a bit disadvantageous.

Therefore I would be glad if someone could tell me how to adjust the environment in such a way that the content flows across pages.

-
Related: tex.stackexchange.com/q/67408/3954 In this answer the problem with shadethm is mentioned and the mdframed alternative is suggested. –  Gonzalo Medina Aug 17 '12 at 18:38

The behaviour you're seeing is because of the shadethm package, which admits that it can not handle page breaks

The shadethm package is quite old- the good news is that since then the extremely powerful and user-friendly mdframed package has been created by Marco Daniel.

You can create truly beautiful framed environments using it, and it handles page breaks. A complete MWE follows, which you can tweak as necessary- see the documentation for more details.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newmdtheoremenv[outerlinewidth=3,
innerlinewidth=2,linecolor=gray,
backgroundcolor=blue!20,%
innerlinecolor=blue!50,outerlinecolor=red!50,innertopmargin=0pt,%
splittopskip=\topskip,skipbelow=0pt,%
]{lem}{Lemma}[section]

\begin{document}
\begin{lem}
Let $H$ be a connected S-thin hypergraph, and $A \boxtimes B$ and $C \boxtimes D$ be two
decompositions of $H$ with respect to the strong product. Then there exists a decomposition
$$A_C \boxtimes A_D \boxtimes B_C \boxtimes B_D$$
of $H$ such that $A = A_C \boxtimes A_D, B= B_C \boxtimes B_D , C= A_C \boxtimes B_C, D=A_D \boxtimes B_D$.
\mbox{} % needed because you end your lemma with mathematical content
\begin{proof}
\lipsum
\end{proof}
\end{lem}
\end{document}


Some other notes:

• I noticed that you were using $$...$$ for your displayed-math content. This is out of date, and you should use $...$, see Why is $...$ preferable to ? for a good discussion.
• I also noticed that you had quite a few displayed-math environments back to back. This should also be avoided, and you should use one of the environments from the amsmath package, something like gather perhaps.
-
Thanks a lot for this very fast answer. I will check your advices out, will take me a while, i guess. Thx again so far. –  M. Noll Aug 17 '12 at 18:52
@M.Noll you're welcome :) don't forget to upvote my answer if it helped... if it resolved the issue, please consider accepting it by clicking on the green check mark –  cmhughes Aug 17 '12 at 18:57