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

label lost in overfull box in breakable tcolorbox #34

Closed
proteusGIT opened this issue Jan 23, 2018 · 8 comments
Closed

label lost in overfull box in breakable tcolorbox #34

proteusGIT opened this issue Jan 23, 2018 · 8 comments

Comments

@proteusGIT
Copy link

Hi,

the label lab1 should not be lost due to the overfull box

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\begin{document}

\begin{tcolorbox}[breakable]
\label{lab1}%
\rule{2cm}{19cm}
\end{tcolorbox}
lab1 \pageref{lab1} foo

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

T-F-S commented Jan 25, 2018

I can confirm the problem, but currently I do not see a solution by changing the break algorithm. I did a lot of experiments, but my changes for the algorithm produced new and more severe problems for other examples.

Fortunately, this problem can be easily circumvented. As far as I have seen, it can only happen at the very begin of a tcolorbox. Therefore, the label is a label for the tcolorbox itself and should preferably be put inside the options for the tcolorbox (see lab2 in the code below).

Another way of circumvention is to add an \mbox{} before the label, see lab3 below.

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\begin{document}

\begin{tcolorbox}[breakable]
\label{lab1}
\rule{2cm}{19cm}
\end{tcolorbox}
Problem: lab1 \pageref{lab1} foo

\clearpage

\begin{tcolorbox}[breakable,label=lab2]
\rule{2cm}{19cm}
\end{tcolorbox}
No problem: lab2 \pageref{lab2} foo

\clearpage

\begin{tcolorbox}[breakable]
\mbox{}\label{lab3}
\rule{2cm}{19cm}
\end{tcolorbox}
No problem: lab3 \pageref{lab3} foo

\end{document}

So, currently, I hesitate to change the break algorithm, because changes typically produce a lot of new problems for existing documents and I was not able to find a bullet-proof solution. Also, I hope that the easy ways of circumvention moderate the weight of the problem.

@proteusGIT
Copy link
Author

This solves the problem of course.
Also, I think, people will not overlook missing references.
However, maybe tcolorbox could detect the problem an typeout some hint.

@T-F-S
Copy link
Owner

T-F-S commented Jan 26, 2018

For the next version, I added a new warning Discard zero height first box part due to break problems (possible loss of zero height content) for the situation.

@T-F-S
Copy link
Owner

T-F-S commented Mar 24, 2018

A warning Discard zero height first box part due to break problems (possible loss of zero height content) is implemented for tcolorbox 4.13 (2018/03/22).

@T-F-S T-F-S closed this as completed Mar 27, 2018
@T-F-S
Copy link
Owner

T-F-S commented May 17, 2018

In the same situation, an \index can get lost as just happened with an document of mine.

The new warning also helped here :-)

@TinchoteSK
Copy link

TinchoteSK commented Jun 7, 2020

Thanks a lot for the analysis and the workaround. I had lots of boxes giving me that problem!

@muzimuzhi
Copy link
Contributor

Another way of circumvention is to add an \mbox{} before the label, see lab3 below.

Or \leavevmode. (Sorry for my bothering.)

@TinchoteSK
Copy link

Thanks :) The mbox hack worked for me, so I'm not touching it again :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants