Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there something equivalent to "lines before break" for the end part in tcolorbox? If there is I can't find it ;-)

The following box should have at least 3 lines on the second page. As the code is created automatically any solution that involves manual break points (like break at) is not suitable.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tcolorbox,lipsum}
\tcbuselibrary{skins,breakable}
\begin{document}
\begin{tcolorbox}[enhanced,colback=lightgray!20!white,frame hidden,breakable]
a\\b\\c\\d\\e\\f\\g
\lipsum[1-4]
\end{tcolorbox}

\end{document}
share|improve this question
    
Do you mean a bottom line for the first part of the box and a top line for the second part of the box? If yes, I also looked unsuccessfully for that. I planned to write a feature request to Thomas Sturm for that. –  Christian Hupfer Aug 6 at 15:03
    
No I don't mean rules but text lines. I don't want a lonely last line on a page. –  Ulrike Fischer Aug 6 at 15:06
    
Ok, a slight misunderstanding ;-) –  Christian Hupfer Aug 6 at 16:44

1 Answer 1

There is a (very limited) support for that by using the enlargepage flexible option from version 3.12 (2014/07/29). This allows to enlarge the pre-last (becoming last) page to avoid such lonely lines. For example:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tcolorbox,lipsum}
\tcbuselibrary{skins,breakable}
\begin{document}
\begin{tcolorbox}[enhanced,colback=lightgray!20!white,frame hidden,breakable,
  enlargepage flexible=\baselineskip
  ]
a\\b\\c\\d\\e\\f\\g
\lipsum[1-4]
\end{tcolorbox}

\end{document}

Here, you avoid a single lonely line. If you insert some more lines, 2 lines will flip to the next page.

To avoid 2 lonely lines, you could use enlargepage flexible=2\baselineskip. Naturally, the enlarged page will become too large if you continue with that to higher values.

Note that this will not protect from getting a lonely line from one paragraph which is in the mid of other paragraphs. But at least, the worst case (a framed single line at the end) can be avoided...

share|improve this answer
1  
Sounds like a Echternacher Springprozession: Two step forward, one step back ;-). enlargepage flexible=\baselineskip is ok in this case but a minimum height of split= option would be imho useful too. –  Ulrike Fischer Aug 6 at 16:18
    
@UlrikeFischer I'm a little bit reluctant in changing the sensible breaking algorithm, but I will put your suggestion on my TODO list and I will see if it can be implemented without harm to other things. –  Thomas F. Sturm Aug 7 at 5:55
1  
I found the solution: before upper={\widowpenalties=3 10000 10000 150}. This naturally won't work if the last line is a paragraph on its own but then I can use \par\nobreak. –  Ulrike Fischer Aug 7 at 7:02
    
@UlrikeFischer Ah... eTeX goodies :-) Yes, that's much better than manually influencing the split points. –  Thomas F. Sturm Aug 7 at 11:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.