Tcolorbox:防止边界框在断裂后缩小

Tcolorbox:防止边界框在断裂后缩小

我正在尝试用 创建一个漂亮而干净的内容框tcolorbox。大部分过程都很顺利,但我遇到了一个奇怪的小问题,我无法弄清楚。

的边界框tcolorbox似乎收缩分页之后!?

演示

当框位于同一页上时

演示1

当盒子破损时

演示2

平均能量损失

\documentclass{article}

\usepackage{lipsum}

\usepackage[many]{tcolorbox}
\usepackage{interfaces-base}
\LoadInterface{pgfkeys}
\usetikzlibrary{calc}

\tcbset{
    bmcbox/.style={
        enhanced,
        % text
        fonttitle=\large\bfseries,
        coltitle=black,
        colback=black!10!white,
        colbacktitle=black!10!white,
        % frame
        colframe=black!10!white,
        toprule=4pt,titlerule=0pt,bottomrule=0pt,rightrule=0pt,leftrule=0pt,
        segmentation hidden,
        sharpish corners,
        overlay={%
            \draw[line width=2.5pt,#1] (frame.north west)--(frame.south west);
        },
        % margins & padding
        before skip=\baselineskip,
        after skip=\baselineskip,
        boxsep=2pt,
        top=6pt,
        bottom=4pt,
        left=8pt,
        right=6pt,
        breakable=unlimited,
        show bounding box=red
    },
    bmcboxtitle/.style 2 args={
        extras middle and last={%
            top=20pt,
            overlay={%
                \draw[line width=2.5pt,#1] (frame.north west)--(frame.south west);
                \draw[] {([yshift=-12pt,xshift=4.5pt]frame.north west)} node[anchor=west] {#2};
            }
        },
    }
}

\DeclareTColorBox[auto counter]{boxed}{o O{\thetcbcounter} o}{
    bmcbox={blue},bmcboxtitle={blue}{%
        \color{blue}\small%
        \IfNoValueTF{#3}{Box \thetcbcounter}{#3}%
        \fontseries{tx}\selectfont%
        \IfNoValueTF{#1}{}{: #1}\itshape\enspace continued},
    title={%
        \IfNoValueTF{#3}{Box \thetcbcounter}{#3}%
        \IfNoValueTF{#1}{}{: \fontseries{tx}\selectfont#1}}
}

\begin{document}

\begin{boxed}
    \lipsum[1]
\end{boxed}

\section{A Section}

\begin{boxed}
    \lipsum[2-5]
\end{boxed}

\section{Another Section}

\end{document}

答案1

这似乎是breakable=unlimited选项的一个错误实验根据tcolorbox手册。

\documentclass{article}

\usepackage{lipsum}

\usepackage[many]{tcolorbox}
\usepackage{interfaces-base}
\LoadInterface{pgfkeys}
\usetikzlibrary{calc}

\tcbset{
    bmcbox/.style={
        enhanced,
        % text
        fonttitle=\large\bfseries,
        coltitle=black,
        colback=black!10!white,
        colbacktitle=black!10!white,
        % frame
        colframe=black!10!white,
        toprule=4pt,titlerule=0pt,bottomrule=0pt,rightrule=0pt,leftrule=0pt,
        segmentation hidden,
        sharpish corners,
        overlay={%
            \draw[line width=2.5pt,#1] (frame.north west)--(frame.south west);
        },
        % margins & padding
        before skip=\baselineskip,
        after skip=\baselineskip,
        boxsep=2pt,
        top=6pt,
        bottom=4pt,
        left=8pt,
        right=6pt,
        breakable, %=unlimited, <----------
        show bounding box=red
    },
    bmcboxtitle/.style 2 args={
        extras middle and last={%
            top=20pt,
            overlay={%
                \draw[line width=2.5pt,#1] (frame.north west)--(frame.south west);
                \draw[] {([yshift=-12pt,xshift=4.5pt]frame.north west)} node[anchor=west] {#2};
            }
        },
    }
}

\DeclareTColorBox[auto counter]{boxed}{o O{\thetcbcounter} o}{
    bmcbox={blue},bmcboxtitle={blue}{%
        \color{blue}\small%
        \IfNoValueTF{#3}{Box \thetcbcounter}{#3}%
        \fontseries{tx}\selectfont%
        \IfNoValueTF{#1}{}{: #1}\itshape\enspace continued},
    title={%
        \IfNoValueTF{#3}{Box \thetcbcounter}{#3}%
        \IfNoValueTF{#1}{}{: \fontseries{tx}\selectfont#1}}
}

\begin{document}

\begin{boxed}
    \lipsum[1]
\end{boxed}

\section{A Section}

\begin{boxed}
    \lipsum[2-5]
\end{boxed}

\section{Another Section}

\end{document}

在此处输入图片描述

相关内容