Debian Codegraph @

texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.breakable.tex

raw
1 % !TeX root = tcolorbox.tex
2 % include file of tcolorbox.tex (manual of the LaTeX package tcolorbox)
3 \clearpage
4 \section{Library \mylib{breakable}}\label{sec:breakable}%
5 \tcbset{external/prefix=external/breakable_}%
6 The library is loaded by a package option or inside the preamble by:
7 \begin{dispListing}
8 \tcbuselibrary{breakable}
9 \end{dispListing}
10 This also loads the package \refPkg{pdfcol}.
11
12 \subsection{Technical Overview}
13 The library \mylib{breakable} supports the automatic breaking of a |tcolorbox|.
14 This feature is enabled by \refKey{/tcb/breakable}
15 and disabled by \refKey{/tcb/unbreakable}.
16
17 {
18 \tcbset{colframe=Navy,colback=AliceBlue,fonttitle=\bfseries,
19 watermark color=AliceBlue!85!Navy,enhanced}
20 If a |tcolorbox| is set to be \refKey{/tcb/breakable}, then the following
21 algorithm is executed:
22 \begin{enumerate}
23 \item The box content is read to a box register similar but not identical
24 to the unbreakable case.
25 \item If the total box fits into the current page, it is shipped out visibly
26 unbroken and the algorithm stops.
27 \begin{tcolorbox}[title=Unbroken Box,watermark text=unbroken]
28 The box.
29 \end{tcolorbox}
30 \item Otherwise, it is checked if at least \refKey{/tcb/lines before break}
31 of the upper box can be placed on the current page.
32 If not, a page break is inserted and the algorithm goes back to Step 2.
33 \item Now, the \emph{break sequence} starts.
34 The upper box part or the lower box part is split such that it fits
35 into the current page. The fitting part is named \emph{first part} of
36 the \emph{break sequence} and shipped out.
37 \begin{tcolorbox}[title=Broken Box,watermark text=first,skin=enhancedfirst]
38 The box.
39 \end{tcolorbox}
40 \item
41 If the remaining content of the total box
42 fits into the current page, the algorithm continues with Step 7, else
43 with Step 6.
44 \item
45 The upper box part or the lower box part is split such that it fits
46 into the current page. The fitting part is named \emph{middle part} of
47 the \emph{break sequence} and shipped out.
48 Then, the algorithm goes back to Step 5.
49 \begin{tcolorbox}[watermark text=middle,skin=enhancedmiddle]
50 The box.
51 \end{tcolorbox}
52 \item
53 The remaining part is named \emph{last part} of
54 the \emph{break sequence} and shipped out. The algorithm stops.
55 \begin{tcolorbox}[watermark text=last,skin=enhancedlast]
56 The box.
57 \end{tcolorbox}
58 \end{enumerate}
59 }
60
61 The algorithm takes care that the optional segmentation line never appears at
62 the end of a box. The optional lower box part is also checked to
63 have at least \refKey{/tcb/lines before break}.
64
65 \clearpage
66 In principle, all boxes of the \emph{break sequence} share the same geometric
67 parameters. The differences are:
68 \begin{itemize}
69 \item The given \refKey{/tcb/before} and \refKey{/tcb/after} values are
70 used only before the \emph{first} and after the \emph{last} part
71 of the \emph{break sequence}.
72 \item A special behavior between the parts of the \emph{break sequence} can
73 be given by \refKey{/tcb/toprule at break},
74 \refKey{/tcb/bottomrule at break},
75 \refKey{/tcb/enlarge top at break by}, and
76 \refKey{/tcb/enlarge bottom at break by}.
77 \item The \refKey{/tcb/skin} decides \emph{how} the \emph{first}, \emph{middle},
78 and \emph{last} part look like. Actually, every part type has its own
79 skin given by the options \refKey{/tcb/skin first}, \refKey{/tcb/skin middle}, and
80 \refKey{/tcb/skin last}. Typically, these options are set automatically by
81 the main skin, see Subsection \ref{subsec:breaksequence} from
82 page \pageref{subsec:breaksequence}.
83 \end{itemize}
84
85
86 \subsection{Limitations and Known Bugs}
87 \begin{itemize}
88 \item The maximal total height of the upper and of the lower part
89 of normal breakable |tcolorbox|es is about 65536pt (ca.\,2300cm)
90 apiece. If such a part gets longer, the output will get buggy
91 without warning.
92 For very oversized boxes which are longer than 65536pt, use
93 the \docValue{unlimited} value for \refKey{/tcb/breakable}.
94 With the \docValue{unlimited} setting,
95 the applied algorithm has (virtually) no height limit for boxes, but
96 very likely the compiler memory will have to be increased for boxes longer
97 than 300 pages (depending on compiler settings and box content).
98 But it is recommended to use \docValue{unlimited} for critical large boxes only.
99 %,since there \emph{may} be a single interline space deviation (lost glue) around
100 %every 2300cm, e.\,g.\ a \refCom{tcbline*} \emph{may} get lost.
101 \item You can nest an unbreakable |tcolorbox| inside another |tcolorbox|,
102 even inside a breakable one.
103 But you cannot not nest a breakable box inside a breakable box.
104 The \refKey{/tcb/breakable} key for a nested box is ignored
105 automatically\footnote{Until |tcolorbox| 3.04, the \refKey{/tcb/breakable} key
106 was not ignored for nested boxes.}, i.\,e., inner
107 boxes are always unbreakable.\par
108 After all, in the unlikely case you really want to have the nested box to be breakable,
109 use \refKey{/tcb/enforce breakable} for the nested
110 box\footnote{\refKey{/tcb/enforce breakable} acts like \refKey{/tcb/breakable} until |tcolorbox| 3.04.}.
111 \textbf{But, a breakable box inside a breakable box will usually give a mess.}
112 \item\tcbdocmarginnote{\tcbdocnew{2020-09-17}}
113 Depending on the \LaTeX\ engine, if your text content contains some text
114 color changing commands, your color may not survive the break to the next box.
115 See the documentation for \refKey{/tcb/use color stack} for more information.
116 \item\tcbdocmarginnote{\tcbdocnew{2014-10-30}}
117 The |perpage| option of the \refPkg{footmisc} package is deliberately deactivated
118 inside a breakable box since all footnotes are placed at the end
119 of the box (possibly far away from the reference point).
120 \item\tcbdocmarginnote{\tcbdocnew{2016-02-15}}
121 Making a box \refKey{/tcb/breakable} which actually is not broken creates
122 a box which acts \emph{almost} like an unbreakable box. Visual differences
123 are kept as indiscernible as possible, but can appear with certain
124 \refKey{/tcb/before} and \refKey{/tcb/after} settings, especially, if there
125 is an automatic page break before the box.
126 \item\tcbdocmarginnote{\tcbdocnew{2016-05-25}}
127 Lua\TeX\ version 0.95 changes the behavior of the basic |\vsplit| (a bug?!)
128 resulting in badly broken boxes. Thanks to Jeremy Engel,
129 the \mylib{breakable} library contains a patch for this which
130 also loads the the \refPkg{ifluatex} package.
131 \end{itemize}
132
133
134 \clearpage
135 \subsection{Main Option Keys}
136 \begin{docTcbKey}[][doc updated=2017-02-01]{breakable}{\colOpt{=true\textbar false\textbar unlimited}}{default |true|, initially |false|}
137 Allows the |tcolorbox| to be breakable. If the box is larger than the
138 available space at the current page, the box is automatically broken
139 and continued to the next page. All sorts of |tcolorbox| can be made
140 breakable. It depends on the skin how the breaking looks like.
141 If you do not know better, use \refKey{/tcb/enhanced} for breaking a box.
142 The parts of the \emph{break sequence} are numbered
143 by the counter \docCounter{tcbbreakpart}.
144 \begin{itemize}
145 \item\docValue{false}: Sets the |tcolorbox| to be unbreakable.
146 \item\docValue{true}: Breaks the |tcolorbox| from one page to another.
147 The maximal total height of the upper and of the lower part is
148 about 65536pt (ca.\,2300cm or ca.\,90 pages) apiece.
149 \item\docValue{unlimited}: Experimental code for unlimited total height of
150 breakable boxes.
151 For boxes longer than 300 pages (or even shorter ones) the
152 compiler memory will have to be increased.
153 \end{itemize}
154
155 \begin{dispListing}
156 % \usepackage{lipsum} % preamble
157 \tcbset{enhanced jigsaw,colback=red!5!white,colframe=red!75!black,
158 watermark color=yellow!25!white,watermark text=\arabic{tcbbreakpart},
159 fonttitle=\bfseries}
160
161 \begin{tcolorbox}[breakable,title=My breakable box]
162 \lipsum[1-6]
163 \end{tcolorbox}
164 \end{dispListing}
165 \end{docTcbKey}
166 {\tcbusetemp}
167
168
169 \begin{docTcbKey}{unbreakable}{}{no value, initially set}
170 Sets the |tcolorbox| to be unbreakable.
171 \end{docTcbKey}
172
173
174 \begin{docTcbKey}{enforce breakable}{}{no value}
175 A |tcolorbox| inside a |tcolorbox| is automatically set to be unbreakable.
176 Using \refKey{/tcb/breakable} on such an inner box has no effect.
177 If one \emph{really} wants the inner box to be breakable, use \refKey{/tcb/enforce breakable}.
178 \textbf{This will usually give a mess of shattered boxes. You are advised to not use this option.}\\
179 Note that \refKey{/tcb/enforce breakable} has the functionality
180 that \refKey{/tcb/breakable} had until package version 3.04
181 and exists for backward compatibility.
182 \end{docTcbKey}
183
184
185 \begin{docTcbKey}[][doc updated=2018-07-26]{title after break}{=\meta{text}}{no default, initially empty}
186 The \refKey{/tcb/title} is used only for the \emph{first} part of a
187 \emph{break sequence}. Use |title after break| to create a heading line
188 with \meta{text} as content for all following parts.
189 Also see \refKey{/tcb/extras title after break} for formatting the title text.
190 \end{docTcbKey}
191
192
193 \begin{docTcbKey}{notitle after break}{}{no value, initially set}
194 Removes the title line or following parts in a \emph{break sequence} if set before.
195 \end{docTcbKey}
196
197
198 \begin{docTcbKey}{adjusted title after break}{=\meta{text}}{style, no default, initially unset}
199 Works like \refKey{/tcb/adjusted title} but applied to \refKey{/tcb/title after break}.
200 \end{docTcbKey}
201
202
203 \begin{docTcbKey}{lines before break}{=\meta{number}}{no default, initially |2|}
204 Assures that the given \meta{number} of lines of the upper box part or
205 the lower box part are placed before a break happens.
206 \end{docTcbKey}
207
208 \clearpage
209 \begin{docTcbKey}[][doc updated=2017-07-05]{break at}{=\meta{length}\colOpt{/\meta{length}/\ldots/\meta{length}}}{no default, initially |0pt|}
210 Defines break points at the given \meta{length} values.
211 The first \meta{length} defines the (maximal) height of the first partial box,
212 the second \meta{length} defines the (maximal) height of the second partial box,
213 and so on. The last \meta{length} value is applied to all following partial boxes if any.
214 \begin{itemize}
215 \item Setting a \meta{length} to |0pt| means that the naturally available
216 space is used for breaking.
217 \item Setting a \meta{length} to a negative value means that
218 the sum of this negative value and the naturally available space is used
219 for breaking (boxes will shrink in height).
220 Note that before version 4.10 negative values were treated like |0pt|.
221 \end{itemize}
222 \begin{dispExample}
223 % \usepackage{multicol,lipsum}
224 \begin{multicols}{3}\footnotesize
225 Breakable boxes inside a |multicols| environment need special attendance.
226 They are broken by default at |\textheight|.
227 The |break at| option can be used to insert better break points by hand.
228 \begin{tcolorbox}[enhanced jigsaw,size=small,vfill before first,
229 colframe=red,colback=yellow!10!white,before title=\raggedright,
230 title={Broken box inside a |multicols| environment},fonttitle=\bfseries,
231 enforce breakable,% use only breakable in the real world!
232 pad at break=1mm,break at=3cm/6.3cm ]
233 \lipsum[1]
234 \end{tcolorbox}
235 \refKey{/tcb/height fixed for} may also be considered for |multicols| environments.
236 \end{multicols}
237 \end{dispExample}
238 \end{docTcbKey}
239
240 \enlargethispage*{1cm}
241
242 \begin{docTcbKey}{enlargepage}{=\meta{length}\colOpt{/\meta{length}/\ldots/\meta{length}}}{no default, initially |0pt|}
243 Inserts a |\enlargethispage|\marg{length} to the pages of the break sequence,
244 i.\,e., allows one to enlarge (or shrink) partial boxes. The first \meta{length} is applied
245 to the first partial box, the second \meta{length} is applied
246 to the second partial box, and so on. The last \meta{length} value is applied
247 to all following partial boxes if any. Note that floating boxes will not be enlarged.
248 \begin{dispListing}
249 \begin{tcolorbox}[breakable,enlargepage=0mm/\baselineskip/2\baselineskip/0mm,...
250 \end{dispListing}
251 The example code enlarged the second partial box by one line, the third
252 partial box by two lines, and all following parts are not enlarged.
253 \begin{marker}
254 If an automated page break occurs before the first partial box, the
255 page enlargement is applied to the page before the first partial box \emph{and}
256 again to the page of the first partial box. Insert a manual break to prevent this.\\
257 In general, |enlargepage| should be used at the final stage of a document
258 for fine-tuning only.
259 \end{marker}
260 \end{docTcbKey}
261
262 \clearpage
263 \begin{docTcbKey}{enlargepage flexible}{=\meta{length}}{no default, initially |0pt|}
264 This allows an automated page enlargement for up to \meta{length}.
265 The algorithm can use this to avoid breaking a box, if there is enough room
266 after enlargement. Also, the \emph{last} partial box of a break sequence
267 may be enlarged to avoid further breaking.\\
268 Note that this potential enlargement is \emph{additive} to settings of
269 \refKey{/tcb/enlargepage}.
270 But \refKey{/tcb/enlargepage flexible} overwrites settings of
271 \refKey{/tcb/pad before break*} or \refKey{/tcb/pad at break*}.
272 \begin{dispListing}
273 % The following setting hinders orphan lines for the last partial box
274 \tcbset{enlargepage flexible=\baselineskip}
275 \end{dispListing}
276 \end{docTcbKey}
277
278
279 \begin{docTcbKey}[][doc new=2014-12-15]{compress page}{\colOpt{=\meta{option}}}{default |all|, initially |baselineskip|}
280 This option controls the space management on the page which contains the
281 unbroken box or the first part of a \emph{break sequence}.
282 Feasible \meta{option} values are:
283 \begin{itemize}
284 \item\docValue{all} (default value):
285 All shrinkable glue on the page is potentially used for the
286 unbroken box or the first part of a \emph{break sequence}. Thus, all
287 vertical spaces on the page will potentially be reduced to their
288 minimal values.
289 \item\docValue{baselineskip} (initial value):
290 Shrinkable glue up to one |\baselineskip| on the page is potentially used for the
291 unbroken box or the first part of a \emph{break sequence}.
292 \item\docValue{none}:
293 The break algorithm respects the target size of the given glue values
294 on the page. This was the initial value before version |3.34|.
295 \end{itemize}
296 \begin{marker}
297 Note that the box \emph{content} is not influenced by this option.
298 \end{marker}
299 \end{docTcbKey}
300
301
302 \begin{docTcbKey}{shrink break goal}{=\meta{length}}{no default, initially |0pt|}
303 This is an emergency parameter if the break algorithm produces unpleasant
304 breaks.
305 It shrinks the goal height of the current box part by \meta{length}
306 which may result in smaller boxes. Never use negative values.
307 \emph{Usually, this option will never be needed at all.}
308 \end{docTcbKey}
309
310
311
312 \begin{docTcbKey}[][doc new=2020-10-09]{use color stack}{\colOpt{=true\textbar false}}{default |true|, initially |false|}
313 Depending on the \LaTeX\ engine and loaded packages, if your text contains some
314 color changing commands, your color may not survive the break to the next box.
315 For some engines, there is support for additional color stacks which
316 allow colors to survive breaks. Such a color stack can be activated
317 by \refKey{/tcb/use color stack} with help of the \refPkg{pdfcol} package.
318 This can be done globally or per box.
319 \begin{marker}
320 Note that activating \refKey{/tcb/use color stack} inserts a color command with a \emph{whatsit}
321 at the begin of the upper part and of the lower part of a \refEnv{tcolorbox}.
322 This \emph{may} add additional vertical space, e.\,g.\ if your box text starts
323 with a list like \emph{enumerate}!
324 \end{marker}
325 \begin{itemize}
326 \item pdf\TeX: color stacks supported.
327 \item Lua\TeX: color stacks supported, but you should consider loading the
328 \refPkg{luacolor} package \emph{instead} which avoids the spacing problem.
329 \item Xe\TeX: color stacks not supported (yet?). From hearsay,
330 with the \refPkg{fontspec} package, you may use |\addfontfeatures{Color=mycolor}|
331 to add a font color which survives the break.
332 \end{itemize}
333 If |pdfcol| cannot initialize an additional color stack for the used engine,
334 \refKey{/tcb/use color stack} is silently ignored.
335
336 \clearpage
337 The result of the following example depends on the used \LaTeX\ engine and
338 loaded packages. The right-hand side is blue, if compiled using
339 pdf\TeX, Lua\TeX{} without |luacolor|, and Xe\TeX.
340 Lua\TeX{} with |luacolor| gives the next but one result.
341
342 \begin{dispExample}
343 % \usepackage{multicol,lipsum}
344 \begin{multicols}{2}\footnotesize
345 Breakable box without color stack.
346 \begin{tcolorbox}[enhanced jigsaw,
347 size=small, colframe=gray, colback=yellow!10!white, colupper=blue,
348 enforce breakable,% use only breakable in the real world!
349 vfill before first, pad at break=1mm, break at=33mm ]
350 Some blue text.\par\smallskip
351 {\color{red}\itshape\lipsum[2]}\par\smallskip
352 More blue text.
353 \end{tcolorbox}
354 Text after box.
355 \end{multicols}
356 \end{dispExample}
357
358 We do again with \refKey{/tcb/use color stack}. Again, the result depends on
359 the used \LaTeX\ engine. The right-hand side stays blue for Xe\TeX{} and
360 and is red and blue for pdf\TeX{} and Lua\TeX{}.
361
362 \begin{dispExample}
363 % \usepackage{multicol,lipsum}
364 \begin{multicols}{2}\footnotesize
365 Breakable box with color stack.
366 \begin{tcolorbox}[enhanced jigsaw, use color stack,
367 size=small, colframe=gray, colback=yellow!10!white, colupper=blue,
368 enforce breakable,% use only breakable in the real world!
369 vfill before first, pad at break=1mm, break at=33mm ]
370 Some blue text.\par\smallskip
371 {\color{red}\itshape\lipsum[2]}\par\smallskip
372 More blue text.
373 \end{tcolorbox}
374 Text after box.
375 \end{multicols}
376 \end{dispExample}
377
378 \end{docTcbKey}
379
380
381
382
383 \clearpage
384 \subsection{Option Keys for the Break Appearance}
385
386 \begin{docTcbKey}{toprule at break}{=\meta{length}}{no default, initially \texttt{0.5mm}}
387 Sets the line width of the top rule to \meta{length} \emph{if} the box is \refKey{/tcb/breakable}.
388 In this case, it is applied to \emph{middle} and \emph{last} parts in a
389 break sequence. Note that \refKey{/tcb/toprule} overwrites this value
390 if used afterwards.
391 \end{docTcbKey}
392
393
394 \begin{docTcbKey}{bottomrule at break}{=\meta{length}}{no default, initially \texttt{0.5mm}}
395 Sets the line width of the bottom rule to \meta{length} \emph{if} the box is \refKey{/tcb/breakable}.
396 In this case, it is applied to \emph{first} and \emph{middle} parts in a
397 break sequence. Note that \refKey{/tcb/bottomrule} overwrites this value
398 if used afterwards.
399 \end{docTcbKey}
400
401
402 \begin{docTcbKey}{topsep at break}{=\meta{length}}{no default, initially \texttt{0mm}}
403 Additional vertical space of \meta{length} which is added at the top of
404 \emph{middle} and \emph{last} parts in a break sequence. In general,
405 it is not advisable to change this value if these parts start with a rule or a title.
406 \end{docTcbKey}
407
408 \begin{docTcbKey}{bottomsep at break}{=\meta{length}}{no default, initially \texttt{0mm}}
409 Additional vertical space of \meta{length} which is added at the bottom of
410 \emph{first} and \emph{middle} parts in a break sequence.
411 In general, it is not advisable to change this value if these parts end with a rule.
412 \end{docTcbKey}
413
414 \begin{docTcbKey}{pad before break}{=\meta{length}}{style, no default, initially \texttt{3.5mm}}
415 Sets the total amount of vertical space after the text content and before the
416 break point to \meta{length}. This style sets \refKey{/tcb/toprule at break} to |0pt|
417 and changes \refKey{/tcb/topsep at break} as required.
418 In general, it is not advisable to change this value if the
419 \emph{middle} and \emph{last} parts in a break sequence start with a rule or a title.
420 \end{docTcbKey}
421
422 \begin{docTcbKey}{pad before break*}{=\meta{length}}{style, no default}
423 Sets \refKey{/tcb/pad before break} to \meta{length} and
424 \refKey{/tcb/enlargepage flexible} to an appropriate value such that
425 empty closing frames are avoided.
426 \end{docTcbKey}
427
428 \begin{docTcbKey}{pad after break}{=\meta{length}}{style, no default, initially \texttt{3.5mm}}
429 Sets the total amount of vertical space after the break point and before the
430 text content to \meta{length}. This style sets \refKey{/tcb/bottomrule at break} to |0pt|
431 and changes \refKey{/tcb/bottomsep at break} as required.
432 In general, it is not advisable to change this value if the
433 \emph{first} and \emph{middle} parts in a break sequence end with a rule.
434 \end{docTcbKey}
435
436 \begin{docTcbKey}{pad at break}{=\meta{length}}{style, no default, initially \texttt{3.5mm}}
437 Abbreviation for setting \meta{length} to \refKey{/tcb/pad before break}
438 and \refKey{/tcb/pad after break}.
439 \end{docTcbKey}
440
441 \enlargethispage*{10mm}
442
443 \begin{docTcbKey}{pad at break*}{=\meta{length}}{style, no default}
444 Sets \refKey{/tcb/pad at break} to \meta{length} and
445 \refKey{/tcb/enlargepage flexible} to an appropriate value such that
446 empty closing frames are avoided.
447 \end{docTcbKey}
448
449 \begin{dispListing}
450 % \usepackage{lipsum} % preamble
451 \tcbset{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries}
452
453 \begin{tcolorbox}[enhanced jigsaw,breakable,pad at break*=0mm,
454 title={For this box, the pad space at the break point is set to 0mm}]
455 \lipsum[1-2]
456 \end{tcolorbox}
457 \end{dispListing}
458 {\tcbusetemp}
459
460
461 \begin{marker}
462 \refKey{/tcb/pad at break} or \refKey{/tcb/pad at break*}
463 should be used as very last option in an option list, because
464 they adapt other settings.
465 \end{marker}
466
467
468 \begin{marker}
469 Also see \refKey{/tcb/enlarge top at break by}
470 and \refKey{/tcb/enlarge bottom at break by}.
471 \end{marker}
472
473
474 \begin{docTcbKey}{height fixed for}{=\meta{part}}{no default, initially |none|}
475 When certain amount of space is available for a partial box of a
476 break sequence, the partial box typically is smaller than this space
477 (depending on the box content). For given \meta{part}(s), the height can be
478 set to all available space.
479 \begin{itemize}
480 \item\docValue{none}: Every partial |tcolorbox| is set with its natural height.
481 \item\docValue{first}: The \emph{first} partial box is set to a height which matches the available space.
482 \item\docValue{middle}: All \emph{middle} partial boxes are set to a height which matches the available space.
483 \item\docValue{last}: The \emph{last} partial box is set to a height which matches
484 the available space.
485 \item\docValue{first and middle}: The \emph{first} and
486 all \emph{middle} partial boxes are set to a height which matches the available space.
487 \item\docValue{middle and last}: All \emph{middle} partial boxes and the \emph{last} partial box
488 are set to a height which matches the available space.
489 \item\docValue{all}: All partial boxes are set to a height which matches the available space.
490 \end{itemize}
491 \begin{marker}
492 If the box keeps unbroken, this option is not applied.
493 See \refKey{/tcb/height} for setting a fixed height for unbroken boxes.
494 See \refKey{/tcb/height fill} for giving unbroken boxes maximum height.
495 \end{marker}
496 \end{docTcbKey}
497
498
499 \begin{docTcbKey}{vfill before first}{\colOpt{=true\textbar false}}{default |true|, initially |false|}
500 Inserts a |\vfill| at the begin of the \emph{first} partial box to move this
501 partial box to the end of the current page. This may be used as an alternative
502 to \refKey{/tcb/height fixed for}|=|\docValue{first} to get justified
503 columns or pages. The |\vfill| is not inserted, if the box gets not
504 actually broken.
505 \end{docTcbKey}
506
507
508 \begin{docTcbKey}[][doc new=2017-03-20]{segmentation at break}{\colOpt{=true\textbar false}}{default |true|, initially |true|}
509 If a breakable box contains an \emph{upper part} and a \emph{lower part} and
510 the break happens at the \emph{segmentation} between both parts, then
511 \begin{itemize}
512 \item the segmentation line (or similar) is drawn as first element of the
513 partial box containing the \emph{lower part}, if \refKey{/tcb/segmentation at break}
514 is set to be |true|.
515 \item the segmentation line (or similar) is not drawn at all, if
516 \refKey{/tcb/segmentation at break} is set to be |false|.
517 This may be preferable for skins like \refSkin{bicolor}, \refSkin{tile},
518 or \refSkin{beamer}.
519 \end{itemize}
520 \end{docTcbKey}
521
522
523 \clearpage
524 \subsection{Extra Options for Partial Boxes}\label{subsec:extras}
525
526
527 \begin{docTcbKey}[][doc new=2015-07-16]{extras}{=\marg{options}}{no default, initially unset}
528 Adds |tcolorbox| \meta{options} to every box of a \emph{break sequence}
529 (also including unbroken boxes) after skin settings are done. This is quite late in box processing.
530 Geometry and break settings should \emph{not be used} here, because they
531 will either be ignored or have unexpected negative results. But it is possible
532 to change most colors, skin effects, shadows, borders, frame code, etc.\par
533 While \refKey{/tcb/extras} affects every box (including unbroken boxes),
534 \refKey{/tcb/extras first}, \refKey{/tcb/extras middle}, \refKey{/tcb/extras last},
535 \refKey{/tcb/extras unbroken}, etc., apply extra options to specific partial
536 boxes.\par
537 \refKey{/tcb/extras} and also \refKey{/tcb/extras first}, etc., are stackable,
538 i.\,e., the given \meta{options} are appended to any previous extra options.
539 Use \refKey{/tcb/no extras} to remove all extra options.\par
540 If needed, \refKey{/tcb/extras pre} prepends options to previous extra options.
541 \end{docTcbKey}
542
543
544 \begin{docTcbKey}[][doc new=2015-07-16]{no extras}{}{style, no default, initially set}
545 Removes all extras if set before.
546 \end{docTcbKey}
547
548
549 \begin{docTcbKey}[][doc new=2015-07-16]{extras broken}{=\marg{options}}{no default, initially unset}
550 If the box is set to be \refKey{/tcb/breakable} and \emph{is} broken actually,
551 then the \meta{options} are added to every box of the \emph{break sequence}.
552 \refKey{/tcb/extras} overwrites this key.
553 This is a shortcut for setting
554 \refKey{/tcb/extras first}, \refKey{/tcb/extras middle}, and \refKey{/tcb/extras last}.
555 \end{docTcbKey}
556
557 \begin{docTcbKey}[][doc new=2015-07-16]{extras unbroken}{=\marg{options}}{no default, initially unset}
558 If the box is set to be \refKey{/tcb/breakable} but \emph{is not} broken actually
559 or if the box is set to be \refKey{/tcb/unbreakable},
560 then the \meta{options} are added to the box.
561 \refKey{/tcb/extras} overwrites this key.
562 \end{docTcbKey}
563
564 \begin{docTcbKey}[][doc new=2015-07-16]{no extras unbroken}{}{style, no default, initially set}
565 Removes the unbroken extras if set before.
566 \end{docTcbKey}
567
568 \begin{docTcbKey}[][doc new=2015-07-16]{extras first}{=\marg{options}}{no default, initially unset}
569 If the box is set to be \refKey{/tcb/breakable} and \emph{is} broken actually,
570 then the \meta{options} are added to the \emph{first} box of the break sequence.
571 \refKey{/tcb/extras} overwrites this key.
572 \end{docTcbKey}
573
574 \begin{docTcbKey}[][doc new=2015-07-16]{no extras first}{}{style, no default, initially set}
575 Removes the first extras if set before.
576 \end{docTcbKey}
577
578 \begin{docTcbKey}[][doc new=2015-07-16]{extras middle}{=\marg{options}}{no default, initially unset}
579 If the box is set to be \refKey{/tcb/breakable} and \emph{is} broken actually,
580 then the \meta{options} are added to every \emph{middle} box (if any) of the break sequence.
581 \refKey{/tcb/extras} overwrites this key.
582 \end{docTcbKey}
583
584 \begin{docTcbKey}[][doc new=2015-07-16]{no extras middle}{}{style, no default, initially set}
585 Removes the middle extras if set before.
586 \end{docTcbKey}
587
588 \begin{docTcbKey}[][doc new=2015-07-16]{extras last}{=\marg{options}}{no default, initially unset}
589 If the box is set to be \refKey{/tcb/breakable} and \emph{is} broken actually,
590 then the \meta{options} are added to the \emph{last} box of the break sequence.
591 \refKey{/tcb/extras} overwrites this key.
592 \end{docTcbKey}
593
594 \begin{docTcbKey}[][doc new=2015-07-16]{no extras last}{}{style, no default, initially set}
595 Removes the last extras if set before.
596 \end{docTcbKey}
597
598 \clearpage
599
600 \begin{docTcbKey}[][doc new=2015-07-16]{extras unbroken and first}{=\marg{options}}{no default, initially unset}
601 This is an abbreviation for setting
602 \refKey{/tcb/extras unbroken} and
603 \refKey{/tcb/extras first} together.
604 \refKey{/tcb/extras} overwrites this key.
605 \end{docTcbKey}
606
607 \begin{docTcbKey}[][doc new=2015-07-16]{extras middle and last}{=\marg{options}}{no default, initially unset}
608 This is an abbreviation for setting
609 \refKey{/tcb/extras middle} and
610 \refKey{/tcb/extras last} together.
611 \refKey{/tcb/extras} overwrites this key.
612 \end{docTcbKey}
613
614 \begin{docTcbKey}[][doc new=2015-07-16]{extras unbroken and last}{=\marg{options}}{no default, initially unset}
615 This is an abbreviation for setting
616 \refKey{/tcb/extras unbroken} and
617 \refKey{/tcb/extras last} together.
618 \refKey{/tcb/extras} overwrites this key.
619 \end{docTcbKey}
620
621 \begin{docTcbKey}[][doc new=2015-07-16]{extras first and middle}{=\marg{options}}{no default, initially unset}
622 This is an abbreviation for setting
623 \refKey{/tcb/extras first} and
624 \refKey{/tcb/extras middle} together.
625 \refKey{/tcb/extras} overwrites this key.
626 \end{docTcbKey}
627
628
629 \begin{docTcbKey}[][doc new=2018-07-26]{extras title after break}{=\marg{options}}{no default, initially unset}
630 If the box has a \refKey{/tcb/title after break}, then the \meta{options}
631 are added for all titles after the first break, i.\,e., all middle and last.
632 The color, font, and alignment of titles after break can be adapted choosing
633 \meta{options}, e.\,g.\ by \refKey{/tcb/coltitle}, \refKey{/tcb/fonttitle},
634 \refKey{/tcb/halign title}.
635 Note that \refKey{/tcb/colbacktitle} has to be placed into
636 \refKey{/tcb/extras middle and last}.
637 \end{docTcbKey}
638
639 \begin{docTcbKey}[][doc new=2018-07-26]{no extras title after break}{}{style, no default, initially set}
640 Removes the title after break extras if set before.
641 \end{docTcbKey}
642
643 \bigskip
644
645 \begin{exdispExample}{extras}
646 % \usepackage{lipsum,multicol}
647 % \usetikzlibrary{decorations.pathmorphing}
648 % \tcbuselibrary{skins}
649 \newtcolorbox{mybox}[1][]{
650 tile,
651 colback=green!7,coltitle=blue!50!black,colbacktitle=blue!5,
652 center title,
653 toprule=1.25mm,bottomrule=1.25mm,
654 extras unbroken and first={
655 borderline north={0.25mm}{0.5mm}{blue,decoration={zigzag,amplitude=0.5mm},decorate}},
656 extras unbroken and last={
657 borderline south={0.25mm}{0.5mm}{blue,decoration={zigzag,amplitude=0.5mm},decorate}},
658 #1
659 }
660
661 \begin{mybox}[title=My unbroken box]
662 \lipsum[1]
663 \end{mybox}
664
665 \begin{multicols}{3}
666 \begin{mybox}[title=My broken box,
667 enforce breakable,% use only breakable in the real world!
668 break at=4.2cm,pad at break=2mm,
669 height fixed for=first and middle, ]
670 \lipsum[2]
671 \end{mybox}
672 \end{multicols}
673 \end{exdispExample}
674
675
676
677
678 \clearpage
679 \subsection{Breakable boxes and the \texttt{multicol} package}\label{subsec:multicol}
680 \begin{marker}
681 With version 4.10, the algorithm for detecting the available height
682 for a |tcolorbox| inside a |multicols| environment was improved with help
683 of Frank Mittelbach. This change \emph{may} impact existing user
684 code which \emph{may} have to be adapted.
685 \end{marker}
686
687 \begin{multicols}{2}
688 \begin{tcolorbox}[enhanced jigsaw,size=small,breakable,colback=yellow!10!white,
689 colframe=red!50!white,break at=3cm,height fixed for=all]
690 Unbreakable |tcolorbox|es can be used without special care inside a
691 |multicols| environment from the \refPkg{multicol} package \cite{mittelbach:multicol}.
692
693 Since version 3.10, a breakable |tcolorbox| detects, if it is used inside
694 a |multicols| environment. But choosing break points for a breakable box
695 cannot be done by the balancing routine of |multicols|. By default, boxes
696 will break at maximum column height. To get pleasant results, use the
697 \refKey{/tcb/break at} and \refKey{/tcb/height fixed for} options.
698 \end{tcolorbox}
699 \end{multicols}
700
701 \enlargethispage{\baselineskip}
702 \begin{dispListing}
703 % \usepackage{lipsum,multicol} % preamble
704 \footnotesize
705 \begin{multicols}{2}
706 \lipsum[1]
707 \begin{tcolorbox}[enhanced jigsaw,breakable,size=title,
708 colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
709 title=My breakable box,pad at break=1mm, break at=-\baselineskip/0pt ]
710 \lipsum[2-4]
711 \end{tcolorbox}
712 \lipsum[4]
713 \end{multicols}
714 \end{dispListing}
715 {\tcbusetemp}
716
717 \clearpage
718
719 \begin{multicols}{2}
720 \small
721 This example is already set inside a |multicols| environment.
722 This time, a \emph{middle} part has full column height (here |\textheight|).
723 \refKey{/tcb/height fixed for} is used to spread this box part over the full
724 height to align with neighboring columns.
725 \begin{dispListing}
726 % \usepackage{lipsum,multicol}
727 \lipsum[1]
728 \begin{tcolorbox}[enhanced jigsaw,
729 breakable,
730 size=title,
731 colback=red!5!white,
732 colframe=red!75!black,
733 fonttitle=\bfseries,
734 title=My breakable box,
735 pad at break=2mm,
736 break at=-\baselineskip/0pt,
737 height fixed for=middle ]
738 \lipsum[2-7]
739 \end{tcolorbox}
740 \lipsum[8]
741 \end{dispListing}
742 {\tcbusetemp}
743 \end{multicols}
744
745
746 The following example has a |\tcolorbox| which fills the |\multicols|
747 environment completely. Here, \refKey{/tcb/height fixed for} is used
748 to give all three columns the full height.
749 Note that the appropriate \refKey{/tcb/break at} value is not computed
750 automatically but set manually.
751
752 \begin{dispListing}
753 % \usepackage{lipsum,multicol} % preamble
754 \small
755 \begin{multicols}{3}
756 \begin{tcolorbox}[enhanced jigsaw,breakable,size=small,
757 colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
758 title=My breakable box,pad at break=2mm,drop fuzzy shadow,
759 height fixed for=all, break at=11.4cm ]
760 \lipsum[1-3]
761 \end{tcolorbox}
762 \end{multicols}
763 \end{dispListing}
764 {\tcbusetemp}
765
766 \clearpage
767 \subsection{Break Point Insertion}\label{subsec:breakpoints}
768
769 \begin{docCommand}[doc new=2017-07-05]{tcbbreak}{}
770 A \emph{breakable} box is not broken, if there is enough
771 space on the current page or column.
772 Therefore, typical penalty insertion with
773 |\break|, |\pagebreak|, |\columnbreak|, \ldots \emph{may} only work as
774 expected, if the box is broken at least into two parts
775 \emph{without} inserting the penalties.\par\smallskip
776 To \emph{force} a page or column break, \refCom{tcbbreak}
777 starts a new paragraph and inserts an insane tall rule which causes a
778 break and which is immediately discarded. You may ignore this technical
779 information and just use it as you would use |\pagebreak|.\par\smallskip
780 For an \emph{unbreakable box}, \refCom{tcbbreak} is identical to insert |\par|,
781 i.\,e., it just starts a new paragraph.\par\smallskip
782 Also see \refKey{/tcb/break at} for defining height dependent breaks.
783
784 \begin{dispListing}
785 % \usepackage{lipsum,multicol} % preamble
786 \begin{multicols}{3}
787 \begin{tcolorbox}[breakable,enhanced jigsaw,size=small,
788 colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
789 title=Break into parts
790 ]
791 First part\tcbbreak
792 Second part\tcbbreak
793 Third part
794 \end{tcolorbox}
795 \end{multicols}
796
797 \begin{multicols}{3}
798 \begin{tcolorbox}[enhanced jigsaw,size=small,
799 colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
800 title=You shall not break
801 ]
802 First part\tcbbreak
803 Second part\tcbbreak
804 Third part
805 \end{tcolorbox}
806 \end{multicols}
807
808 \end{dispListing}
809 {\tcbusetemp}
810
811 \end{docCommand}
812
813
814
815 \clearpage
816 \subsection{Break Sequence for the Skins}\label{subsec:breaksequence}
817 The following diagrams document the \emph{break sequence} for different
818 skins. Depending on the main skin of a |tcolorbox|, the actual skins of
819 the \emph{break sequence} parts are displayed.
820
821 \def\tcbbreakskininto#1#2#3#4#5{%
822 \begin{center}\begin{tikzpicture}
823 \tcbset{width=7cm,colframe=Navy,colback=AliceBlue,fonttitle=\bfseries,
824 watermark color=AliceBlue!85!Navy,#5
825 }
826 \node[above] (unbroken) at (0,0) {\begin{tcolorbox}[title=Unbroken Box,skin=#1,watermark text=unbroken,height=3.8cm]
827 \texttt{skin=#1}
828 \end{tcolorbox}};
829 \node[above] (first) at (8.7,2.4) {\begin{tcolorbox}[title=Broken Boxes,skin=#2,watermark text=first,height=1.4cm]
830 \texttt{skin=#2}
831 \end{tcolorbox}};
832 \node[above] (middle) at (8.7,1.2) {\begin{tcolorbox}[skin=#3,watermark text=middle,height=1cm]
833 \texttt{skin=#3}
834 \end{tcolorbox}};
835 \node[above] (last) at (8.7,0) {\begin{tcolorbox}[skin=#4,watermark text=last,height=1cm]
836 \texttt{skin=#4}
837 \end{tcolorbox}};
838 \path[draw=FireBrick,line width=2pt,->] (unbroken) edge (first.west) edge (middle.west) edge (last.west);
839 \end{tikzpicture}\end{center}}
840
841 \tcbbreakskininto{standard}{standard}{standard}{standard}{watermark text/.style={}}
842 \tcbbreakskininto{standard jigsaw}{standard jigsaw}{standard jigsaw}{standard jigsaw}{watermark text/.style={}}
843 \tcbbreakskininto{spartan}{spartan}{spartan}{spartan}{}
844 \clearpage
845 \tcbbreakskininto{enhanced}{enhancedfirst}{enhancedmiddle}{enhancedlast}{}
846 \tcbbreakskininto{enhancedfirst}{enhancedfirst}{enhancedmiddle}{enhancedmiddle}{}
847 \tcbbreakskininto{enhancedmiddle}{enhancedmiddle}{enhancedmiddle}{enhancedmiddle}{}
848 \tcbbreakskininto{enhancedlast}{enhancedmiddle}{enhancedmiddle}{enhancedlast}{}
849 \clearpage
850 \tcbbreakskininto{enhanced jigsaw}{enhancedfirst jigsaw}{enhancedmiddle jigsaw}{enhancedlast jigsaw}{}
851 \tcbbreakskininto{enhancedfirst jigsaw}{enhancedfirst jigsaw}{enhancedmiddle jigsaw}{enhancedmiddle jigsaw}{}
852 \tcbbreakskininto{enhancedmiddle jigsaw}{enhancedmiddle jigsaw}{enhancedmiddle jigsaw}{enhancedmiddle jigsaw}{}
853 \tcbbreakskininto{enhancedlast jigsaw}{enhancedmiddle jigsaw}{enhancedmiddle jigsaw}{enhancedlast jigsaw}{}
854 \clearpage
855 {\tcbset{borderline={2pt}{0pt}{black!10!white}}%
856 \tcbbreakskininto{empty}{emptyfirst}{emptymiddle}{emptylast}{}
857 \tcbbreakskininto{emptyfirst}{emptyfirst}{emptymiddle}{emptymiddle}{}
858 \tcbbreakskininto{emptymiddle}{emptymiddle}{emptymiddle}{emptymiddle}{}
859 \tcbbreakskininto{emptylast}{emptymiddle}{emptymiddle}{emptylast}{}
860 }
861 \clearpage
862 \tcbbreakskininto{bicolor}{bicolorfirst}{bicolormiddle}{bicolorlast}{bicolor}
863 \tcbbreakskininto{bicolorfirst}{bicolorfirst}{bicolormiddle}{bicolormiddle}{bicolor}
864 \tcbbreakskininto{bicolormiddle}{bicolormiddle}{bicolormiddle}{bicolormiddle}{bicolor}
865 \tcbbreakskininto{bicolorlast}{bicolormiddle}{bicolormiddle}{bicolorlast}{bicolor}
866 \clearpage
867 \tcbbreakskininto{bicolor jigsaw}{bicolorfirst jigsaw}{bicolormiddle jigsaw}{bicolorlast jigsaw}{bicolor jigsaw}
868 \tcbbreakskininto{bicolorfirst jigsaw}{bicolorfirst jigsaw}{bicolormiddle jigsaw}{bicolormiddle jigsaw}{bicolor jigsaw}
869 \tcbbreakskininto{bicolormiddle jigsaw}{bicolormiddle jigsaw}{bicolormiddle jigsaw}{bicolormiddle jigsaw}{bicolor jigsaw}
870 \tcbbreakskininto{bicolorlast jigsaw}{bicolormiddle jigsaw}{bicolormiddle jigsaw}{bicolorlast jigsaw}{bicolor jigsaw}
871 \clearpage
872 \tcbbreakskininto{tile}{tilefirst}{tilemiddle}{tilelast}{tile,colbacktitle=Navy}
873 \tcbbreakskininto{tilefirst}{tilefirst}{tilemiddle}{tilemiddle}{tile,colbacktitle=Navy}
874 \tcbbreakskininto{tilemiddle}{tilemiddle}{tilemiddle}{tilemiddle}{tile,colbacktitle=Navy}
875 \tcbbreakskininto{tilelast}{tilemiddle}{tilemiddle}{tilelast}{tile,colbacktitle=Navy}
876 \clearpage
877 \tcbbreakskininto{beamer}{beamerfirst}{beamermiddle}{beamerlast}{beamer}
878 \tcbbreakskininto{beamerfirst}{beamerfirst}{beamermiddle}{beamermiddle}{beamer}
879 \tcbbreakskininto{beamermiddle}{beamermiddle}{beamermiddle}{beamermiddle}{beamer}
880 \tcbbreakskininto{beamerlast}{beamermiddle}{beamermiddle}{beamerlast}{beamer}
881 \clearpage
882 \tcbbreakskininto{widget}{widgetfirst}{widgetmiddle}{widgetlast}{widget}
883 \tcbbreakskininto{widgetfirst}{widgetfirst}{widgetmiddle}{widgetmiddle}{widget}
884 \tcbbreakskininto{widgetmiddle}{widgetmiddle}{widgetmiddle}{widgetmiddle}{widget}
885 \tcbbreakskininto{widgetlast}{widgetmiddle}{widgetmiddle}{widgetlast}{widget}
886 \tcbbreakskininto{draft}{draft}{draft}{draft}{draft}
887 \clearpage
888 \tcbbreakskininto{freelance}{freelancefirst}{freelancemiddle}{freelancelast}{}
889 \tcbbreakskininto{freelancefirst}{freelancefirst}{freelancemiddle}{freelancemiddle}{}
890 \tcbbreakskininto{freelancemiddle}{freelancemiddle}{freelancemiddle}{freelancemiddle}{}
891 \tcbbreakskininto{freelancelast}{freelancemiddle}{freelancemiddle}{freelancelast}{}
892
893
894
895
896 \clearpage
897 \subsection{Break by Hand (Faked Break)}
898
899 \begin{marker}
900 See \zvref{subsec:multicol} for \emph{real} column breaks.
901 \end{marker}
902
903 Since the appearance of broken boxes is done by skins, it is quite easy
904 to 'fake a break'. For this, you actually don't need the
905 \mylib{breakable} library at
906 all.
907
908 \begin{dispExample}
909 \tcbset{enhanced,equal height group=fakedbreak,
910 colback=LightGreen,colframe=DarkGreen,
911 width=(\linewidth-6mm)/3,nobeforeafter,
912 left=1mm,right=1mm,top=1mm,bottom=1mm,middle=1mm}
913 %
914 \begin{tcolorbox}[title=My broken box,skin=enhancedfirst]
915 This is a box which breaks from one column to another
916 \end{tcolorbox}\hfill
917 \begin{tcolorbox}[skin=enhancedmiddle]
918 column. I am sorry to say that this is a trick.
919 Nevertheless, you may use this trick for your
920 \end{tcolorbox}\hfill
921 \begin{tcolorbox}[skin=enhancedlast]
922 own purposes.
923 \end{tcolorbox}
924 \end{dispExample}
925
926