The package mdframed works very well enclosing plain texts with decorated frames: even when they span many pages the frame breaks accordingly! :-)
Unfortunately that is not yet the case when the large text enclosed contais equation arrays: I was getting strange compilation errors, which were solved here by updating the mdframed package with the latest github. Now I am getting strange page skiping behaviour when the text with equation arrays span many pages under
\documentclass{memoir} or \documentclass{book} :-(
There is no strange skipping under \documentclass{article}, which indicates this is an issue between mdframed and two-sided styles.
This is illustrated in the MWE below, in which the text with equation arrays span 4 pages and mdframe skips the second and fourth pages. If the mdframe starts in the second page, then the mdframe skips the third and fifth pages. It seems that mdframe starts and ends in the correct page without skipping, but skips the pages in between.
What might be happening?
PS - Sorry for the large dummy text with equation arrays in the code below, but the mdframed breaks fine with large Lorem Ipsum texts.
% Comment in/out these lines to see which work
\documentclass{memoir} % mdframed skips page with memoir :(
%\documentclass{book} % mdframed skips page with book :(
%\documentclass{article} % mdframed works fine with article :)
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage[framemethod=tikz]{mdframed}% http://ctan.org/pkg/mdframed
\newenvironment{coderule}
{
\allowdisplaybreaks[1]
\begin{mdframed}
[topline=false,rightline=false,bottomline=false,
innertopmargin=0pt,innerrightmargin=0pt,innerbottommargin=0pt,
skipabove=\parskip,skipbelow=0.3\baselineskip,
innerleftmargin=1em,outerlinewidth=1em,linecolor=black]
}
{
\end{mdframed}
}
\begin{document}
%Comment in/out the line below to start mdframe in second page
%\mbox{}\newpage
\newcommand{\TestText}
{
Temos ent\~{a}o que
\begin{align}
\cos'\left(0\right) & = & - \lim_{h \to 0} \frac{\sin^2\left(h\right)}{h^2}\frac{h}{\cos\left(h\right) + 1} \\
& = & - \left(\lim_{h \to 0} \frac{\sin\left(h\right)}{h}\right)^2 \lim_{h \to 0}\frac{h}{\cos\left(h\right) + 1} \\
& = & -\left(\sin'\left(0\right)\right)^2\frac{0}{\cos\left(0\right) + 1} = 0.
\end{align}
}
\begin{coderule}
Para mostrarmos que $\sin'\left(0\right) = 1$, primeiro notamos que
\begin{equation}\nonumber
\sin'\left(0\right) = \lim_{h \to 0} \frac{\sin\left(h\right) - \sin\left(0\right)}{h} = \lim_{h
\to 0} \frac{\sin\left(h\right)}{h}.
\end{equation}
Temos que
\[
0 < \sin\left(h\right) < h < \tan\left(h\right),
\]
para todo $0 < h < \pi/2$. Dividindo por $\sin\left(h\right) > 0$, obtemos que
\[
1 < \frac{h}{\sin\left(h\right)} < \frac{1}{\cos\left(h\right)}.
\]
Invertendo todos os membros das desigualdades acima, segue que
\begin{equation}\nonumber
1 > \frac{\sin\left(h\right)}{h} > \cos\left(h\right).
\end{equation}
Pela continuidade do cosseno e pelo Teorema do Sandu\'{\i}che, segue ent\~{a}o que
\begin{equation}\nonumber
\sin'\left(0 \downarrow\right) = \lim_{h \downarrow 0} \frac{\sin\left(h\right)}{h} = 1.
\end{equation}
Como $h \downarrow 0$ se e s\'{o} se $-h \uparrow 0$, segue que
\[
\sin'\left(0 \uparrow\right) = \lim_{h \downarrow 0} \frac{\sin\left(-h\right)}{-h} = \lim_{h \downarrow 0} \frac{\sin\left(h\right)}{h} = 1,
\]
onde utilizamos o fato de que seno \'{e} \'{\i}mpar. Isso mostra que $\sin'\left(0\right) = 1$.
%\end{coderule}
%\begin{coderule}
Para mostrarmos que $\cos'\left(0\right) = 0$, primeiro notamos que
\begin{equation}\nonumber
\cos'\left(0\right) = \lim_{h \to 0} \frac{\cos\left(h\right) - \cos\left(0\right)}{h} = \lim_{h
\to 0} \frac{\cos\left(h\right) - 1}{h}.
\end{equation}
Consideramos ent\~{a}o as seguintes igualdades
\begin{align}
\cos'\left(0\right)& = & \lim_{h \to 0} \frac{\cos\left(h\right) - 1}{h}\frac{\cos\left(h\right) + 1}{\cos\left(h\right) + 1} \\
& = & \lim_{h \to 0} \frac{\cos^2\left(h\right) - 1}{h}\frac{1}{\cos\left(h\right) + 1} \\
& = & \lim_{h \to 0} \frac{-\sin^2\left(h\right)}{h}\frac{1}{\cos\left(h\right) + 1}
\end{align}
onde utilizamos o fato que $\cos^2\left(h\right) - 1 = -\sin^2\left(h\right)$.
Temos ent\~{a}o que
\begin{align}
\cos'\left(0\right) & = & - \lim_{h \to 0} \frac{\sin^2\left(h\right)}{h^2}\frac{h}{\cos\left(h\right) + 1} \\
& = & - \left(\lim_{h \to 0} \frac{\sin\left(h\right)}{h}\right)^2 \lim_{h \to 0}\frac{h}{\cos\left(h\right) + 1} \\
& = & -\left(\sin'\left(0\right)\right)^2\frac{0}{\cos\left(0\right) + 1} = 0.
\end{align}
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\TestText
\end{coderule}
\end{document}
Overfull \vboxmessages just when the blank pages are produced (those might be responsible for the odd behaviour); changing the page layout using, for example,\usepackage[vmargin=2cm]{geometry}the problem disappears. – Gonzalo Medina Jun 21 '12 at 04:24amsbook, and there aren't any blank pages. whileamsbookis generally based onbook, it's by no means identical, so one of the differences is apparently significant. – barbara beeton Jun 21 '12 at 13:19$\cos'\left(0\right) = 0$and everything works well. I don't know why? – Marco Daniel Jun 21 '12 at 18:42bookandmemoir! :-)Unfortunately a new problem appeared in my multifile project: in
mdframeswithframetitlethat happen to begin at the top of a page, the frametitle stays alone at the top of the page, followed by white space until the next page, where the text below the frametitle begins...I will post below a modification of the above MWE which produces this error...
What might be happening?
– Lucas Seco Jun 22 '12 at 10:52