mdframed 包可以很好地打破纯文本的框架。我努力让它在文本包含方程数组时也能工作,但我总是收到奇怪的编译错误!
我最后一次尝试的是下面的测试代码,灵感来自这,编译得很好。但是当我注释掉第一个 \begin{coderule}...\end{coderule} 并只留下第二个时,我收到以下编译错误:
100:有些不对劲——可能缺少 \item。\end{coderule}
可能发生什么事?
\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}
答案1
我无法重现该错误!
但是我注意到 1.6b 版本有一个不好的断点。循环内有一个多余的东西\break
。但是,在这么多方程式的情况下,很难找到一个好的断点。
请在 GitHub 上测试当前版本:https://github.com/marcodaniel/mdframed
使用 1.6b 版本测试。