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.

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}
share|improve this question

closed as too localized by Marco Daniel, Martin Scharrer Jun 24 '12 at 10:00

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Not a solution; just a comment that could be useful to detect the problem. Your code produces some Overfull \vbox messages 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 4:24
2  
i've just tried it out with amsbook, and there aren't any blank pages. while amsbook is generally based on book, it's by no means identical, so one of the differences is apparently significant. –  barbara beeton Jun 21 '12 at 13:19
1  
@barbarabeeton: Thanks. Nice hint. –  Marco Daniel Jun 21 '12 at 13:28
    
Comment the equation $\cos'\left(0\right) = 0$ and everything works well. I don't know why? –  Marco Daniel Jun 21 '12 at 18:42
1  
Please test the new version at github. –  Marco Daniel Jun 21 '12 at 19:04
show 2 more comments