# Very large tcolorbox

I have a very large breakable tcolorbox

\documentclass{article}

\usepackage{blindtext}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\begin{document}

\begin{tcolorbox}[breakable]
\blindtext[150]
\end{tcolorbox}

\end{document}


that exceeds the maximal dimension and causes the following error.

! Dimension too large.
<argument> \ht \tcb@upperbox
+\dp \tcb@upperbox
l.11 \end{tcolorbox}


When I use the batchmode as suggested for a very large mdframed environment I get a document with a single page and a colorbox that does not surround the content. The tcolorbox documentation states the following

The box content is a TEX \vbox register which has a restricted capacity.
Therefore, you cannot place hundreds of pages inside a tcolorbox.


What is the appropriate way of dealing with very large color boxes?

Edit

To add some context as there might as well be a better solution for my problem, I have a large list of small paragraphs (probably one or two lines). I don't know statically how many there are or how long a single paragraph is. I would like to put these paragraphs one after the other on a page as long as they fit and make a page break otherwise. The content of each page should be surrounded by a box. In fact, I additionally would like to separate each pair of consecutive paragraphs by a separator as described here. I also looked for multi page tabular environments but did not find a fit either.

• We probably need some more context here: at first glance I don't see that this really wants to be in a box at all, given the size. What's the real use case? – Joseph Wright Jul 3 '14 at 7:11
• I think it's a good question because I would like to have a solution myself (for larger listings, e.g.). The answer of David Carlisle to tex.stackexchange.com/questions/131350/long-frames-in-mdframed seems to be promising. Currently, I don't have the time too persue it, but I will do later. The core of the question is, if it is possible to do a \vsplit from a \vbox which is itself higher than the maximal dimension. – Thomas F. Sturm Jul 3 '14 at 7:50
• You can \vsplit a \vbox which is longer than \maxdimen as long as you don't try to access its dimension as the result is unpredictable: if I try with \setbox0=\vbox{\blindtext[2000]}\showthe\ht0, TeX reports -22137.05556pt; but it's happy to \vsplit it. – egreg Jul 3 '14 at 8:16
• @egreg Do you know if there is any reliable test code that will give me: yes, the \vbox is longer than \maxdimen ? – Thomas F. Sturm Jul 3 '14 at 9:54
• @ThomasF.Sturm I'm afraid there isn't. :( – egreg Jul 3 '14 at 9:56

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.

• @JanChristiansen You're welcome :-) I guess your question was/is interesting for many people (including me). – Thomas F. Sturm Jul 17 '14 at 6:36