add tag
CarLaTeX
`\pagetotal` is not increased within a `tcolorbox`.

Is there a way to get an analogous value, but taking into account also the text inside a (breakable) `tcolorbox`?

```
\documentclass{article}
\usepackage{mwe}

\usepackage[most]{tcolorbox}
\tcbset{
    breakable, 
    colframe=blue, 
    colback=white
    }
    
\begin{document}
\lipsum[1]

Page goal here: \the\pagegoal

Page total here: \the\pagetotal

\begin{tcolorbox}[title=My breakable box]
Page goal here: \the\pagegoal

Page total here: \the\pagetotal

\lipsum[1]

Page goal here: \the\pagegoal

Page total here: \the\pagetotal

\lipsum[1]

Page goal here: \the\pagegoal

Page total here: \the\pagetotal


\lipsum[1]

Page goal here: \the\pagegoal

Page total here: \the\pagetotal


\end{tcolorbox}

Page goal here: \the\pagegoal

Page total here: \the\pagetotal

\lipsum[1]

Page goal here: \the\pagegoal

Page total here: \the\pagetotal


\end{document}
```
![2020-03-28 (2).png](/image?hash=65c9cc827b084643c1977a99b87e4f128747c159db92404c7850a4f2a36100b3)
Top Answer
CarLaTeX
Googling around, I found out there is the package `needspace` which seems to do what I actually need (to go on the next page if there is not enough space).

Thank you all for your suggestions.


```
\documentclass{article}
\usepackage{mwe}

\usepackage[showframe]{geometry}

\usepackage{tikz} 

\usepackage[most]{tcolorbox} 
\tcbuselibrary{breakable}

\usepackage{needspace}

\newsavebox{\mybox}
\newlength{\mylen}

\newcommand{\mytitle}[1]{%
	\begin{tikzpicture}
			\node[ 
				fill=blue, draw=blue,
				minimum height=.6cm,
				text=white,
				inner xsep=5mm
				] (a) {#1};
		\end{tikzpicture}}
		
\newcommand{\pizza}[1]{\savebox{\mybox}{\mytitle{#1}}%
    \settoheight{\mylen}{\usebox{\mybox}}%
    \needspace{\mylen}%
    \begin{tcolorbox}[
        grow sidewards by=5mm,
        enhanced,
        empty, 
        left=0pt, 
        boxsep=0pt, 
        leftrule=0pt, 
        before skip=4pt,
        after skip=2pt,
        ]
        \usebox{\mybox}
    \end{tcolorbox}%
    }

\newtcolorbox{mytcolorbox}[1][]{%
    breakable, 
    colframe=blue, 
    colback=white,
    #1
}

\begin{document}
\lipsum[1]

\begin{mytcolorbox}[title=My breakable box]
\lipsum[1]

\pizza{A fake title}


\lipsum[1]

Some text.

Some text.

Some text.
\pizza{A second fake title}
Some text.

There is no spaces for another fake title here, it goes on the next page.

\pizza{A third fake title}

\lipsum[1]

\pizza{A fourth fake title}
\lipsum[1]

\end{mytcolorbox}

\lipsum[1]

\end{document}
```

It seems to work:

![2020-04-03 (3).png](/image?hash=27fa620704bf80363b3d9df7284492259f17fff5247816b1d27bdc1843d2eced)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.