2

The package mdframed works well breaking framed plain texts. I am trying hard to make it work also when the text contais equation arrays, but I keep getting strange compilation errors!

My last try was the test code below, inspired by this, which compiles nicely. But when I comment out the first \begin{coderule}...\end{coderule} and leave only the second, I get the following compilation error:

100:Something's wrong--perhaps a missing \item.\end{coderule}

What might be happening?

\documentclass{article}
  \usepackage{lipsum}% http://ctan.org/pkg/lipsum
  \usepackage{amsmath}% http://ctan.org/pkg/amsmath
  \usepackage[framemethod=tikz]{mdframed}% http://ctan.org/pkg/mdframed
  \usepackage{xparse}% http://ctan.org/pkg/xparse

\NewDocumentEnvironment{coderule}{O{1em} O{1em} O{black}}%
  {% \begin{coderule}[<rule width>][<rule sep>][<rule colour>]
\allowdisplaybreaks[1]%
\begin{mdframed}%
  [topline=false,rightline=false,bottomline=false,%
  innertopmargin=0pt,innerrightmargin=0pt,innerbottommargin=0pt,%
  skipabove=\parskip,skipbelow=0.3\baselineskip,%
  innerleftmargin=#2,outerlinewidth=#1,linecolor=#3]
  }
  {\end{mdframed}}% \end{coderule}

\begin{document}

\begin{coderule}[2em][1em][orange]
  Here is a short introduction:
  \begin{align}
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c \\
f(x) &= ax^2+bx+c
  \end{align}
  \lipsum[5-6]
\end{coderule}

\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}
Pela Proposi\c{c}\~{a}o \ref{proptrigocont}, 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}
Bis!
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}
Bis!
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}
\end{coderule}
\end{document}
10
  • Welcome to TeX.SE. I am not able to reproduce the error. Do you really need all that code to reproduce the problem. Would be helpful if you tried to minimize the code to only what is necessary to show the problem. Commented Jun 20, 2012 at 6:30
  • Which version do you use? Commented Jun 20, 2012 at 7:46
  • I get "undefined color orange" with TeX Live 2010, and no error either with TeX Live 2011 or 2012/pretest. With TeX Live 2009 nothing works (framemethod undefined). But in no case I get a missing \item error.
    – egreg
    Commented Jun 20, 2012 at 9:00
  • 2
    I can confirm the error on MikTeX 2.9 with mdframed v1.6b and cvs-pgf. With both coderule compiles perfect, but after commenting the first one, it fails. .log shows messages like Package mdframed Info: Not enough space on this page on input line 100. or Package mdframed Info: You first box width is to small mdframed fixed it (mdframed) on input line 100.
    – Ignasi
    Commented Jun 20, 2012 at 10:08
  • @Ignasi: Which error? That are information. Commented Jun 20, 2012 at 16:05

1 Answer 1

2

I can't reproduce the error!


However I noticed a bad break with version 1.6b. There is an extra \break inside the loop. However it's very difficult do find a good break point with so much equations.

Please test the current version at GitHub: https://github.com/marcodaniel/mdframed

Tested with version 1.6b.

4
  • You've got it! I manually updated the mdframed package and now the above example compiles and generates the expected result in both cases. Thanks! Even better, the infinite loop I was geting in other documents also stopped and they are compiling properly. I imagine how hard it is to break equations since many times even plain LaTeX can't make it without help... I appreciate very much your effort.
    – Lucas Seco
    Commented Jun 20, 2012 at 23:00
  • This was actually a prototype for a larger multifile document that I am working with a friend: a free Calculus book :) So now I find out that mdframe is not working well with book and memoir document class if the mdframe spans more than 3 pages... Using the same MWE above, but repeating the last paragraph so that the mdframe spans 3 pages and putting in the begining \documentclass{book} or \documentclass{memoir} it compiles properly, but the frames 'jump' some pages, leaving them blank... I've searched here and didn't find a workaround. Should I file another question?
    – Lucas Seco
    Commented Jun 20, 2012 at 23:29
  • Posted another question regarding this with MWE in tex.stackexchange.com/questions/60642/… Thanks!
    – Lucas Seco
    Commented Jun 21, 2012 at 4:03
  • Had an infinite loop with latest CTAN package; the github version fixed it for me. Thanks!
    – Michaël
    Commented Sep 8, 2012 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .