# How to prevent the initial page break when calling \chapter inside a tcolorbox

I am trying to put a whole \chapter inside of a breakable tcolorbox. This results in the box being broken even before the chapter heading and an almost empty page is added. The following MWE shows this:

\documentclass[a4paper]{book}

\usepackage{lipsum}
\usepackage[most]{tcolorbox}

\begin{document}

\begin{tcolorbox}[enhanced, breakable]
\chapter*{A chapter}
\lipsum[1-7]
\end{tcolorbox}

\end{document}


Is there a way how to prevent this initial page break?

The cause of the early breaking is \clearpage -- a chapter by default uses \cleardoublepage which calls \clearpage, so a new page is shipped, leading to premature breaking of the tcolorbox.

Preventing this:

Using before upper={\let\clearpage\relax} as option leaves the change of \clearpage internally to the tcolorbox and does not leak outside:

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}

\begin{document}
\tableofcontents

\begin{tcolorbox}[enhanced, breakable,before upper={\let\clearpage\relax}]
\chapter*{A chapter}
\lipsum[1-7]
\end{tcolorbox}
% Just for testing
\chapter{Another chapter}

\end{document}


You can locally redefine the \clearpage command, that \chapter seems to use, in order to prevent it from doing anything.

\documentclass[a4paper]{book}

\usepackage{lipsum}
\usepackage[most]{tcolorbox}

\begin{document}

\newcommand*{\mychap}[1]{%
\begingroup%
\let\clearpage\relax%
\chapter*{#1}
\endgroup%
}

\begin{tcolorbox}[enhanced, breakable]
\mychap{A chapter}
\lipsum[1-7]
\end{tcolorbox}

\end{document}


There might be side effects, though; I'm not sure. Alternatively, redefine \@makeschapterhead (it works for the report documentclass, so maybe for books too). This is a command that typesets the heading for \chapter*. This should be documented in some places.