I'm struggling with the problem of proper wrapping of the environment which I am use in twocolumn page layout - with book class scrbook. I am using the tcolorbox package to define fancy boxes. As you can see in my code, I have two color-boxes. One for note called tcnote
and other one box for definition (as is usual in a math textbook).
Unfortunately, the compilation result depends on how much text is on the page. For example if I add more dummy text, then the result is terrible as you can see on the figure below. You can play with my code by commenting/uncomenting the line \lipsum[1][2] % dummy text ON/OF
- Outside the tcnote environment, the equation in green box will print as expected.
- Inside the tcnote environment the equation is printed outside the green box which is wrong.
- The tcnote environment is split over several pages, although one page should be enough.
MNWE:
\documentclass[fontsize=10pt,twocolumn]{scrbook}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{amsmath,mathtools}
\newcommand\abs[1]{\ensuremath{\lvert#1\rvert}}
\newtcolorbox{tcnote}[1][]{%
enhanced jigsaw, % better frame drawing
enforce breakable, % breakable,
borderline west={2pt}{0pt}{red}, % straight vertical line at the left edge
sharp corners, % No rounded corners
boxrule=0pt, % no real frame,
coltitle={red!25!black}, % Black colour for title
colback={yellow!30},
attach title to upper, % Move the title into the box
right=10pt,
compress page,
enhanced,
#1
}
\newtcbtheorem[auto counter,number within=chapter]{fyzdef}{DEF}{%
colback=green!5!white,
colframe=green!75!black,
fonttitle=\itshape, % \bfseries,
enforce breakable, % breakable,
compress page,
enhanced,
}{fyz}
\begin{document}
\section{Section}
\lipsum[5]
\lipsum[5]
\lipsum[1]
\lipsum[1][2]
% \lipsum[1][2] % dummy text ON/OF
\begin{fyzdef}{Kronecker}{def016}
\begin{equation}
\delta_{ij} =
\begin{cases}
1 & \text{for } i = j \\
0 & \text{for } i \neq j.
\end{cases}
\end{equation}
\end{fyzdef}
\lipsum[1]
\begin{tcnote}
\lipsum[1]
\begin{fyzdef}{Einstein sume rule}{def015}
\lipsum[1][3]
\begin{equation*}
a'_i = \sum^3_{j=1} = \alpha_{ij}a_j.
\end{equation*}
text
\begin{equation}
a_ia_i = a_1a_1 + a_2a_2 + a_3a_3 = \abs{a}^2 = a^2. % (2.1)
\end{equation}
\end{fyzdef}
\lipsum[1][2]
\begin{fyzdef}{Kronecker}{def016}
\begin{equation}
\delta_{ij} =
\begin{cases}
1 & \text{for } i = j \\
0 & \text{for } i \neq j.
\end{cases}
\end{equation}
\end{fyzdef}
\lipsum[1][2]
\begin{equation}
a'_i = α_{ij} a_j
\end{equation}
\lipsum[1][2]
\begin{equation}
α_{ik} α_{ij} = δ_{kj},
\end{equation}
\lipsum[1]
\end{tcnote}
\end{document}
enforce breakable
withbreakable
it's fine. The tcolorbox documentation saysenforce breakable
"... will usually give a mess of shattered boxes. You are advised to not use this option"