Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breakable tcolorbox eats my minipage #200

Closed
guillaumesalagnac opened this issue Nov 16, 2022 · 4 comments
Closed

breakable tcolorbox eats my minipage #200

guillaumesalagnac opened this issue Nov 16, 2022 · 4 comments
Assignees
Labels

Comments

@guillaumesalagnac
Copy link

I noticed a weird interaction between minipage and breakable tcolorboxes. As illustrated by the MWE below, sometimes a minipage gets pushed beyond the bottom of the paper, even though there is plenty of space above. Obviously this is caused by the tcolorbox below, but in the output it ends up on the next page and looks very innocent.

I'm not sure if this is a bug (and even less sure of whose fault it is) but when I asked about my problem on tex.sx I was told to report the issue upstream, so here I am.

Any advice would be greatly appreciated. My actual complaint here is that when the output does break down (which is rare but does happen in practice) we get no error message or useful warning.

\documentclass[a4paper,12pt]{book}

\usepackage[margin=2cm,showframe]{geometry}

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

\usepackage{lipsum}

\begin{document}
\lipsum[1]

\lipsum[2]

\begin{minipage}{10cm}
\color{blue}\rule{2cm}{16cm}

O brother were art thou ?
\end{minipage}

\begin{tcolorbox}[breakable=true]
\lipsum[4]
\end{tcolorbox}

\lipsum[5]

\end{document}
@T-F-S
Copy link
Owner

T-F-S commented Nov 18, 2022

A breakable tcolorbox inserts the code given by the before option and then calculates the remaining height of the page. If the height is not large enough, as in your example, tcolorbox tries to undo inserted spacing during before and afterwards inserts a \pagebreak.

Apparently, the undoing in your case gives unexpected results. The reason is the large depth of your minipage, because \prevdepth is taken into account for the undoing process. Using \begin{minipage}[b] would circumvent the problem.

I have to investigate further, if the whole situation can be avoided. But, I'm quite sure that the \prevdepth value is used for a good reason for other situations and I am reluctant to change things which would influence or break many existing documents. Nevertheless, I will look for a solution.

@guillaumesalagnac
Copy link
Author

Thanks for your clear answer. Indeed, \begin{minipage}[b] fixes the layout, and is easy enough to add, once the problem has been noticed. But it was a schock for me to notice the missing contents visually rather than through some error message. When the blue rectangle goes beyond the page boundary, shouldn't we get at least an "overfull vbox" warning, or something like that ?

@T-F-S
Copy link
Owner

T-F-S commented Feb 10, 2023

After many tests my conclusion is that the space undoing code of tcolorbox for this special case (box does not fit partially on the current page but needs to go to the following page) is more harmful than helpful. Therefore, I remove it for the next version which also resolves your problem.

@T-F-S
Copy link
Owner

T-F-S commented Feb 10, 2023

Resolved with https://github.com/T-F-S/tcolorbox/releases/tag/v6.0.0

@T-F-S T-F-S closed this as completed Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants