下面的 MWE 不应再简化,以免破坏我的真实场景。设置紧密耦合。
\documentclass{article}
\usepackage[a6paper,vmargin=15mm,hmargin=5mm]{geometry}
\usepackage{times}
\usepackage{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\allowdisplaybreaks
\usepackage{amssymb}% for \mathbb
\usepackage{tcolorbox}
\usepackage{cancel}
\usepackage{microtype}
\tcbuselibrary{breakable}
\newcounter{exercise}[subsection]
\makeatletter
\@addtoreset{exercise}{section}
\renewcommand{\theexercise}{%
\ifnum\value{subsection}>0\relax
\thesubsection
\else
\thesection
\fi
.\arabic{exercise}%
}
\newenvironment{exercise}
{\par\smallskip\refstepcounter{exercise}
\begin{tcolorbox}[breakable,title=Exercise \theexercise,left=0mm,lefttitle=2mm,shrink break goal=18pt]\ignorespaces}
{\end{tcolorbox}\par\smallskip\ignorespacesafterend}
\makeatother
\def\IncludeGraphics{\rule{4cm}{1.5cm}}
\begin{document}
\begin{exercise}
xxxxxxxx xxxxxxxxx xxxxxxx.
\begin{enumerate}
\item $-2x>4$
\item $7x-1<13$
\item $\tfrac{x-1}{2}\leq\tfrac{x+1}{3}$
\item $x^2 -5x +6 \geq 0$
\item $x^2 < 16$
\item $(x-1)^2(x+2)^3 > 0$
\item $\frac{(x-1)^2}{(x+2)^3} \geq 0$
\end{enumerate}
\tcblower
\begin{enumerate}
\item
$\!
\begin{aligned}[t]
-2x &>4\\
x &< \frac{4}{-2} &&\text{\parbox{5cm}{\color{red}\scriptsize xxxx xxxxx xxxx xxxxxx $-2$. xxxxx xxxxxxxxxxxxxx xxxxx xxxxxxx xxxx xxxxxxx xxxx xxxxxxx xxxxxx xxxxxxxx xxxxxxx}}\\
x &< -2
\end{aligned}
$
\item
$\!
\begin{aligned}[t]
7x -1 &< 13\\
7x &< 13 +1\\
7x &< 14\\
x &< \frac{14}{7}\\
x &< 2
\end{aligned}
$
\item
$\!
\begin{aligned}[t]
\frac{x-1}{2} &\leq \frac{x+1}{3}\\
\frac{x-1}{2} \times 2 \times 3 &\leq \frac{x+1}{3} \times 2 \times 3\\
\frac{x-1}{\bcancel{2}} \times \bcancel{2} \times 3 &\leq \frac{x+1}{\bcancel{3}} \times 2 \times \bcancel{3}\\
3(x-1) &\leq 2(x+1) \\
3x-3 &\leq 2x +2\\
3x-2x &\leq 2 +3\\
x &\leq 5
\end{aligned}
$
\item
xxxxxxxx xxxx xxxxx xxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxxx xx xxxx xxxx.
\begin{align*}
x^2 -5x +6 &\geq 0\\
x^2 -3x -2x +6 &\geq 0\\
x(x-3) -2(x-3) &\geq 0\\
(x-3)(x-2) &\geq 0
\end{align*}
{\color{red}xxxxxx xxxxxxx xxxxxxx xxx!
\begin{align*}
x-3&\geq 0 &&\text{or} & x-2&\geq 0\\
x&\geq 3 && \text{or} & x&\geq 2
\end{align*}\par}
xxxxxxxxxxx xxxxx xxxxxxxx~\ref{enum:xxxxxxx-xxxxxxxxxxxxxx}. xxxxxxx xxx xxxxxx xxxxxxxxxx.
\begin{center}
\IncludeGraphics
\end{center}
xxxxxxx xxxxxxxx xxxxxx $\{\, x\in \mathbb{R} \mid x\leq 2\vee x\geq 3\,\}$ xxxxxx xxxxxx $\vee$ xxxxxx ``xxxx''.
\item
xxxxxxxx xxxx xxxxx xxxx xxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxxx.
\begin{align*}
x^2 &< 16\\
x^2 -16 &< 0\\
x^2 -4x +4x -16 &< 0\\
x(x-4) +4(x-4) &< 0\\
(x-4)(x+4) &< 0
\end{align*}
{\color{red}xxxxxx xxxxxxxxx xxxxxxx xxxxxxxxxxx
\begin{align*}
x-4 &<0 &&\text{or} & x+4 &< 0\\
x &<4 &&\text{or} & x &<-4
\end{align*}\par}
xxxxxxxxxxxxx xxxxxxxxx xxxxxxxx~\ref{enum:xxxxxxx-xxxxxxxxxxx}. xxxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxx.
\begin{center}
\IncludeGraphics
\end{center}
xxxxxxx xxxxxx xxxxxxx $\{\, x\in \mathbb{R} \mid x > -4 \wedge x < 4\,\}$ xxxxxxx xxxxxxxx $\wedge$ xxxx ``xxx''. xxxxxxxxx $\{\, x\in \mathbb{R} \mid x > -4 \wedge x < 4\,\}$ xxxxxx xxxxxxxxxx xxxxxxxxxx $\{\, x\in \mathbb{R} \mid -4 < x < 4\,\}$.
\item
xxxxxxxx xxxxx xxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxxx xxxxx xxxxxxx xxxxxxx xxxxxxx xxxxx xxxxx xxxx xxxxxxxxxx xx xxxxxxxx.
\begin{align*}
(x-1)^2(x+2)^3 > 0
\end{align*}
xxxxxxxxxxxxx xxxxxxxxx xxxxxxxx~\ref{enum:xxxxxxx-xxxxxxxxxxx}. xxxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxx.
\begin{center}
\IncludeGraphics
\end{center}
xxxxxxxxx xxxxxxx xxxxxxxx $\{\, x\in \mathbb{R} \mid x > -2 \wedge x \ne 1\,\}$ xxxxx xxx $\wedge$ xxxxxxx ``xxxx''.
%
\item
xxxxxxxxx xxxx xxxxx xxxxx xxxxxx xxx xxx xxxxxxx xxxx xxxxx. xxxxx xx xxxx xxxxx xxxxxxx xxxxx xxx xxxxx xxxxx xxx.
\begin{align*}
\frac{(x-1)^2}{(x+2)^3} \geq 0\\
(x-1)^2(x+2)^3 \geq 0 && \text{xxxx $x\ne -2$}
\end{align*}
xxxxxxxxxxxxx xxxxxxxxx xxxxxxxx~\ref{enum:xxxxxxx-xxxxxxxxxxx}. xxxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxx.
\begin{center}
\IncludeGraphics
\end{center}
xxxxxxx xxxxxx xxxxxx $\{\, x\in \mathbb{R} \mid x > -2 \,\}$.
\end{enumerate}
\end{exercise}
\end{document}
问题:
- 有不需要的空白页。
- 出现色彩范围不一致的情况,不同破损页面的连续部分丢失了前一页的色彩范围。
- 存在不受欢迎的孤儿/寡妇效应。
- 最后一个
\item
不能被删除,否则会影响色彩范围。
如何解决这些问题?
编辑:
问题已解决!我正在尝试寻找另一个错误。:-)
答案1
对于 2.02 版本,您需要进行以下修改。我可以考虑一个新的实施步骤来减少重叠。
\makeatletter
\def\tcb@split@lower@box{%
\vfuzz=\maxdimen\vbadness=10000%
\setbox\tcb@lowerbox=\vsplit\tcb@totallowerbox to\tcb@split@dim%
\setbox\tcb@lowerbox=\vbox{\unvbox\tcb@lowerbox}%
\vbadness=\tcb@thevbadness\vfuzz=\tcb@thevfuzz%
\tcbdimto\tcb@h@lower{\ht\tcb@lowerbox+\dp\tcb@lowerbox}%
\ifdim\tcb@h@lower>\tcb@split@dim\relax%
\setbox\tcb@lowerbox=\vbox to\tcb@split@dim{\unvbox\tcb@lowerbox}%
\fi%
}
\def\tcb@split@L{%
\stepcounter{tcbbreakpart}%
\tcb@following@title%
\tcb@comp@h@page%
\let\tcb@h@upper=\tcb@zpt%
\tcbdimto\tcb@h@lower{\ht\tcb@totallowerbox+\dp\tcb@totallowerbox}%
\tcbdimto\tcb@h@total{\tcb@h@after+\tcb@h@padding@last+\tcb@h@padtitle+\tcb@h@lower}%
%
\ifdim\tcb@h@total<\tcb@h@page\relax% no break
\tcb@split@setstate@last%
\setbox\tcb@lowerbox=\vbox{\begingroup\color{\kvtcb@collower}\unvbox\tcb@totallowerbox\endgroup}%
\tcb@sdraw@L%
\let\tcb@split@next=\relax%
\else
\tcb@split@setstate@middle%
\tcbdimto\tcb@split@dim{\tcb@h@page-\tcb@h@padding@middle-\tcb@h@padtitle}%
\tcb@split@lower@box%
\tcb@sdraw@L%
\setbox\tcb@totallowerbox=\vbox{\unvbox\tcb@totallowerbox}
\ifdim\wd\tcb@totallowerbox=0pt
\let\tcb@split@next=\relax%
\else%
\let\tcb@split@next=\tcb@split@L%
\fi%
\fi%
\tcb@split@next%
}
\makeatother
旧答案
的拆分算法tcolorbox
有一些不足。例如,没有测试是否有任何框是空的,vbox
如果不删除不必要的空间,就不会结束。我没有分析完整的算法。
一个快速的解决方法是:
\documentclass{article}
\usepackage[a6paper,vmargin=15mm,hmargin=5mm]{geometry}
\usepackage{times}
\usepackage{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\allowdisplaybreaks
\usepackage{tcolorbox}
\usepackage{microtype}
\tcbuselibrary{breakable}
\newcounter{exercise}[subsection]
\@addtoreset{exercise}{section}
\renewcommand{\theexercise}{%
\ifnum\value{subsection}>0\relax
\thesubsection
\else
\thesection
\fi
.\arabic{exercise}%
}
\newenvironment{exercise}
{\par\smallskip\refstepcounter{exercise}
\begin{tcolorbox}[breakable,title=Exercise \theexercise,left=0mm,lefttitle=2mm]\ignorespaces}
{\end{tcolorbox}\par\smallskip\ignorespacesafterend}
\makeatletter
\def\endtcb@vbox{%
\unskip
\par\unskip%
\vskip\lastskip%
\par\strut\par\unskip\unskip
\setbox0=\lastbox
\vskip-.3\baselineskip
\endgroup}
\def\tcb@split@first{%
\setcounter{tcbbreakpart}{1}%
\ifx\kvtcb@float\@empty%
\def\tcb@before@first{\nointerlineskip\kvtcb@beforebox}%
\def\tcb@before@middle{\nointerlineskip\noindent}%
\let\tcb@before@last=\tcb@before@middle%
\long\def\tcb@after@first{\parskip\z@\par\pagebreak\nointerlineskip{\topskip\z@\null}}%
\let\tcb@after@middle=\tcb@after@first%
\let\tcb@after@last=\kvtcb@afterbox%
\else%
\edef\float@start{\noexpand\@float{tcbfloat}[\kvtcb@float]}%
\let\tcb@before@first=\float@start%
\let\tcb@before@middle=\float@start%
\let\tcb@before@last=\float@start%
\let\tcb@after@first=\end@float%
\let\tcb@after@middle=\end@float%
\let\tcb@after@last=\end@float%
\fi%
%
\edef\kvtcb@skin@@first{\kvtcb@skin@first}%
\edef\kvtcb@skin@@middle{\kvtcb@skin@middle}%
\edef\kvtcb@skin@@last{\kvtcb@skin@last}%
%
\let\tcb@h@breaksep@first=\kvtcb@bottomsep%
\tcbdimto\tcb@h@breaksep@middle{\kvtcb@bottomsep+\kvtcb@topsep}%
\let\tcb@h@breaksep@last=\kvtcb@topsep%
\tcbdimto\tcb@h@padding@first{\kvtcb@bbtop@stand+\kvtcb@bbbottom@break+\kvtcb@top@rule@stand+\kvtcb@bottom@rule@break+\tcb@h@breaksep@first+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\tcbdimto\tcb@h@padding@middle{\kvtcb@bbtop@break+\kvtcb@bbbottom@break+\kvtcb@top@rule@break+\kvtcb@bottom@rule@break+\tcb@h@breaksep@middle+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\tcbdimto\tcb@h@padding@last{\kvtcb@bbtop@break+\kvtcb@bbbottom@stand+\kvtcb@top@rule@break+\kvtcb@bottom@rule@stand+\tcb@h@breaksep@last+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
%
\tcb@split@setstate@first%
%
\splittopskip=0pt%
\splitmaxdepth=0pt%
\edef\tcb@thevfuzz{\the\vfuzz}%
\edef\tcb@thevbadness{\the\vbadness}%
%
\setbox\tcb@totalupperbox=\vbox{\unvbox\tcb@upperbox}%
\setbox\tcb@totallowerbox=\vbox{\unvbox\tcb@lowerbox}%
%
\tcbdimto\tcb@split@dim{\tcb@h@page-\tcb@h@before-\tcb@h@padding@first-\tcb@h@padtitle}%
\ifdim\tcb@split@dim<\tcb@h@upper\relax%
\tcb@split@upper@box%
\tcb@sdraw@U%
\let\tcb@split@next=\tcb@split@USL%
\else%
\setbox\tcb@upperbox=\vbox{\unvbox\tcb@totalupperbox}%
\tcbdimto\tcb@split@dim{\tcb@split@dim-\tcb@h@upper-\tcb@h@segment}
\ifdim\tcb@split@dim<\kvtcb@breakminlines\baselineskip\relax%
\tcb@sdraw@U%
\let\tcb@split@next=\tcb@split@SL%
\else
\tcb@split@lower@box%
\tcb@sdraw@USL%
\ifvoid\tcb@totallowerbox
\let\tcb@split@next=\relax%
\else
\let\tcb@split@next=\tcb@split@L%
\fi%
\fi%
\fi%
\tcb@split@next%
}
\makeatother
\begin{document}
\section{Function}
The notation $f(x)$ can be interpreted as
\begin{itemize}
\item an algebraic expression in a variable\footnote{variable is \ldots} $x$ or
\item the value of function $f$ when its variable equals to $x$.
\end{itemize}
\begin{exercise}
Explain what each of the following means
\begin{enumerate}
\item $h(x)$
\item $h(x+h)$
\item $g(a)$
\item $g(a+b-c)$
\end{enumerate}
\tcblower
\begin{enumerate}
\item $h(x)$ \ldots
\item $h(x+h)$ \ldots
\item $g(a)$ \ldots
\item $g(a+b-c)$ \ldots
\end{enumerate}
\end{exercise}
Note that $f(x)$ does not mean $f$ multiplied by $x$.
\end{document}
答案2
我是 2.22 版的作者tcolorbox
,我刚刚将版本 2.22 上传到 CTAN。这个新版本消除了(部分/大部分)已解决的问题。
“有不需要的空白页”
我找到了问题的原因并(希望)解决了它。由于的上部/下部特征的破坏
tcolorbox
有时有点棘手,我可能忽略了一些东西。如果尽管进行了更正,但仍出现空白页,请告诉我。“出现不一致的颜色范围”
我发现并(希望)纠正了一个颜色问题,该问题导致颜色范围效果不一致(\item 问题)。尽管如此,文本内容中的颜色变化在拆分后不会消失。这是 的一个已知缺点
tcolorbox
。很抱歉,我没有真正的解决方案。但据我所知,这是拆分 时的一个常见问题\vboxes
。“存在不受欢迎的孤儿/寡妇效应”
Marco Daniel 提供了一个快速解决方案(谢谢!),它隐藏了一个空白框。版本 2.22 试图规避在中断序列末尾出现空白框的所有情况。我对新版本进行了大量测试,一切运行良好。所以,希望这种效果不会再发生 - 如果发生,请告诉我...