tcolorbox: “enlarge bottom finally by” doesn't work in all cases

I want to make sure that a short text (a signature) after a tcolorbox doesn't end on a page of its own. I'm using a \raisebox and tried to enlarge the bounding box of the tcolorbox with enlarge bottom finally by:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\begin{document}
\begin{tcolorbox}[
enlarge bottom finally by=1cm,
enhanced,
show bounding box,
breakable,
title={my title},title after break={my title}]
%\lipsum[1] %for a box with a break.
\lipsum[1-4]b\\c\\d\\e%
\raisebox{-1cm}[0pt][0pt]{some text}
\end{tcolorbox}
\end{document}


The bounding box is in most cases as expected.

But there is a problem if the box in itself can be placed on the page but is to large when the additional bottom is taken into account. In this case the additional bottom is squeezed and my text is in the footer:

How could I tell tcolorbox to break the box earlier without resorting to some manual fine tuning of the parameters (the box is in an automatically created document)?

The output may be unexpected, but the algorithm is working correctly.

The problem here is:

• if the box is broken, the height of first or middle part is as visually framed,
• the final part or unbroken part of the box is prolonged by 1cm (invisibly).

The critical case occurs, when the box content completely fits into the container of a first or middle part, but does not fit into the container of a last or unbroken part (this container is smaller since 1cm was reserved).

To handle this case, I see the following possibilites:

• break the box and put an empty box-ending on the next page,
• implement some loop to find an earlier break point (if there is any); the broken box would be considerably shorter and one or two lines would go to the next page,
• close the box on the page where all content fits in (for a first and middle part) and steal space from the bottom of the page if needed. That is the current implementation.

None of the three possibilities is ideal. The last one is the best for many use cases, especially since an optional lower box part also has to be considered by the algorithm.

Now, for the application here, you could add a shrink break goal to ease or at least change the effect. This parameter virtually shrinks the available space on the page as the algorithm sees it. Broken boxes will become smaller, but any extension to the bottom of the page also. For example:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\begin{document}
\begin{tcolorbox}[
enlarge bottom finally by=1cm,
shrink break goal=5mm,%<-----------------------
enhanced,
show bounding box,
breakable,
title={my title},title after break={my title}]
%\lipsum[1] %for a box with a break.
\lipsum[1-4]b\\c\\d\\e%
\raisebox{-1cm}[0pt][0pt]{some text}
\end{tcolorbox}
\end{document}

• An empty ending box is naturally not an option ;-) (Actually I got one and I was quite relieved that this problem seems to be gone after the last update). shrink break goal has the problem that is affects also first and middle parts and as the signature can take two or three lines that looks rather unpleasant. What I need is something like \parfillskip which ensures that there is a certain amount of free space on the page only after the last box. Would it be possible to implement a shorten last page? – Ulrike Fischer Feb 10 '15 at 9:09
• @UlrikeFischer I fear that such an option (which would be nice to have) leads to the same splitting problem as enlarge bottom finally by. Currently, I have no bright idea for that. – Thomas F. Sturm Feb 10 '15 at 9:54
• I had another idea: I moved my signature inside the box with a real height: \lipsum[1-4]\par\nobreak\raisebox{0cm}[1cm][0pt]{some text} and then "shortened" the skin, which is no problem in my case as there is only a simple rule at the bottom that I can easily shift up by 1cm. – Ulrike Fischer Feb 10 '15 at 10:47