It took some time and help from others, namely egreg and Heiko Oberdiek, to find a suitable solution, but now I have one.
I made a new enhanced version of tcolorbox
which is at the time of writing 3.10pre1 (2014/07/16)
. It's a pre-version available at GitHub, but it will be compatible to an official CTAN version to appear later.
With this new version, the normal breakable tcolorbox
content length is extended from about 16384pt by factor 4 to about 65536pt. If needed, this maximum can be extended by an option key as far as compiler memory allows.
As a consequence, your example compiles without any problem. Without any further tweaks, also the following compiles:
\documentclass{article}
\usepackage{blindtext,pgffor}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\begin{document}
\begin{tcolorbox}[breakable]
\foreach \n in {1,...,455}
{\textbf{\color{red}(\n)} \blindtext[1]\par}
\end{tcolorbox}
\end{document}
This compiles to a document with 125 pages.
This number of pages is depending on actual the size of a single-page tcolorbox
. But it should be save for other cases with say up to 100 pages of boxed content.
This limit can be overcome using the new option breakable=unlimited
which uses another algorithm. This algorithm is not perfect but could influence a single interline space every 65536pt (I would say: that's not too bad...).
Since a breakable tcolorbox
is a \box
which is completely processed in memory, the compiler memory is the next limit. Using pdflatex
with MiKTeX, the following example compiles without tweaks on my system:
\documentclass{article}
\usepackage{blindtext,pgffor}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\begin{document}
\begin{tcolorbox}[breakable=unlimited]
\foreach \n in {1,...,1300}
{\textbf{\color{red}(\n)} \blindtext[1]\par}
\end{tcolorbox}
\end{document}
This compiles to a document with 355 pages.
Again, the number of pages depends on the geometry and also on the content of the boxes.
If that's not enough, the compiler memory could be increased. I took the heavy hammer (MiKTeX dependend) I use for monstrous documents, i.e.
pdflatex --pool-size=10000000 --max-strings=500000 --save-size=50000 --extra-mem-bot=4000000 --extra-mem-top=4000000 jobname.tex
With that hammer, the following code compiles on my system:
\documentclass{article}
\usepackage{blindtext,pgffor}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\begin{document}
\begin{tcolorbox}[breakable=unlimited]
\foreach \n in {1,...,5000}
{\textbf{\color{red}(\n)} \blindtext[1]\par}
\end{tcolorbox}
\end{document}
This compiles to a document with 1364 pages.
Instead of \usepackage[listings]{tcolorbox}, you'd better \usepackage[most]{tcolorbox} to avoid all errors.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[x11names]{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}
\usepackage[most]{tcolorbox}
\usepackage{empheq}
\tcbuselibrary{theorems}
\newtcbox{\Goldonebox}[1][]{nobeforeafter,math upper,tcbox raise base, enhanced,frame hidden,boxrule=0pt,interior style={top color=Gold1!10!white,
bottom color=Gold1!10!white,middle color=Gold1!50!yellow},
fuzzy halo=1pt with Gold1,#1}
\newtcbox{\greenbox}[1][]{nobeforeafter,math upper,tcbox raise base,
enhanced,frame hidden,boxrule=0pt,interior style={top color=green!10!white,
bottom color=green!10!white,middle color=green!50!yellow},
fuzzy halo=1pt with green,#1}
\title{XCOLOR}
\author{MATTIA ONOFRI}
\date{August 2021}
\begin{document}
\maketitle
\Huge
\section{Introduction}
\begin{empheq}[box=\Goldonebox]{align}
a&=b+c\\
E&=mc^2
\end{empheq}
\begin{empheq}[box=\greenbox]{align}
a&=b+c\\
E&=mc^2
\end{empheq}
\textcolor{Gold1}{GOLDEN}.
\end{document}
Best Answer
The cover of
tcolorbox
documentation shows an example and the code is just on second page: