TransWikia.com

Unwanted page break with nested tcolorbox

TeX - LaTeX Asked on April 30, 2021

I was thinking of switching from mdframed to tcolorbox since nested mdframed environments cannot be splitted. It occured to me that tcolorbox has almost the exact same issue: in nested boxes, sometimes the page break occurs too early, leaving a huge part of the paper blank. For example, see this screenshot: enter image description here which can be obtained by the following MWE:

documentclass{article}
usepackage{amsmath, amsfonts, amssymb}
usepackage{geometry}
usepackage{varwidth}
usepackage{lipsum}
usepackage[most]{tcolorbox}


geometry{left=2cm,right=2cm,bottom=3cm}

definecolor{remarkPurple}{HTML}{8346FF}
definecolor{defBlue}{HTML}{0673FF}

%THEOREM
newtcbtheorem[auto counter,number within=section]{theorem}{Theorem}%
{enhanced,breakable,frame empty,interior empty,colframe=cyan!50!white, top=8mm,
    coltitle=black,fonttitle=bfseries,colbacktitle=cyan!15!white,
    borderline={0.5mm}{0mm}{cyan!15!white},
    borderline={0.5mm}{0mm}{cyan!50!white,dashed},
    attach boxed title to top left={yshift=-4mm},
    boxed title style={sharp corners=east,boxrule=1pt},varwidth boxed title}{thm}

%PROOF
newtcbtheorem[no counter]{prf}{Proof}%
{enhanced,breakable,frame empty,interior empty,colframe=remarkPurple!75!white, top=8mm,
    coltitle=black,fonttitle=bfseries,colbacktitle=remarkPurple!20!white,
    borderline={0.5mm}{0mm}{remarkPurple!20!white},
    borderline={0.5mm}{0mm}{remarkPurple!50!white,dashed},
    attach boxed title to top left={yshift=-4mm},
    boxed title style={sharp corners=east,boxrule=1pt},varwidth boxed title}{prf}

linespread{1.4}

begin{document}

section{First section}
    begin{theorem}{}{}
        lipsum[1-2]
    end{theorem}

    begin{theorem}{}{}
        Every vector space $V$ has a Hamel basis.
        begin{prf}{}{}
            lipsum[1-4]
        end{prf}   
    end{theorem}
end{document}

Even with breakable, the box still breaks at a wrong place. It would be so much nicer if the proof on page 2 can start on page 1. Is there any solution to this issue, other than the answer here? This one does partially solve the problem [and it’s nice!], but the drawback is also obvious — I have to wait till I’m done with the entire file before I can address this pagebreak issue.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP