Verzeichnis macros/latex/contrib/tcbnestbreak
tcbnestbreak Package
LaTeX: Breakable tcolorboxes inside breakable tcolorboxes
tcolorbox typesets the content of a breakable box as one vbox and splits it with \vsplit. A box inside is one picture in this vbox and cannot be split, so tcolorbox ignores breakable for a box inside another box.
With the tcbnestbreak package, breakable works for a box at the top level of the content of a breakable box, and for such a box inside one that is already broken in this way, to any depth. No new key is needed:
\usepackage{tcbnestbreak} \begin{tcolorbox}[breakable, title=Outer] ... \begin{tcolorbox}[breakable, title=Inner] ... % broken across pages together with the outer box \end{tcolorbox} ... \end{tcolorbox}
The inner box can have a title and a lower part (\tcblower), and it can be defined with \newtcolorbox. Where the outer box is broken, the frame of the inner box is open and goes on into the padding of the outer box, so that it is seen to continue on the next page.
Footnotes. With the tcbpagefootnote package (v1.4 or later), the footnotes of a box with page footnote are put at the bottom of the page, also for each part of a breakable box. With tcbnestbreak, this holds for the boxes inside as well: if the outer box and a box inside have page footnote, each footnote of the inner box is put on the page of its mark.
Vertical writing. The package also works in tate, with the tate classes of pLaTeX and upLaTeX (with the pxpgftate package) and of LuaTeX-ja.
- Supported formats/engines: pdfLaTeX, XeLaTeX, LuaLaTeX (with or without LuaTeX-ja), pLaTeX, upLaTeX (+ dvipdfmx); yoko and tate; one run, no Lua code
How it works
- The inner box flows. Its content is typeset indented, as in a list (
\@totalleftmargin,\linewidth,\parshape), and put line by line into the list of the box around it, with the space of its frame above and below. A TeX mark (\marksof a class of its own) is put at its start, at its end and between its upper and its lower part. tcolorbox then splits the outer box between these lines as usual. - The positions are measured. Before a part of the outer box is drawn, a copy of the part is taken apart with
\vsplit ... to -1sp, piece by piece. The heights of the pieces and of what is discarded between them (\splitdiscards) add up to the position of each mark. - The frames are drawn. For each inner box in the part, tcolorbox draws the frame with the options of that box and without text: as an unbroken box, or as a first, middle or last part of the height that is needed, with the segmentation line if the part has it. The frames are put behind the text of the part.
The text color of an inner box (coltext, colupper, collower) is set again at the top of the next part.
Files
| File | Description |
|---|---|
tcbnestbreak.sty |
The package |
tcbnestbreak.tex / .pdf |
Documentation |
test-*.tex |
Test suite (see below) |
Requirements
tcolorbox(thebreakableandskinslibraries are loaded by the package)- Tested with TeX Live 2025 (frozen: LaTeX2ε 2025-11-01, tcolorbox 6.9.0) and TeX Live 2026 (LaTeX2ε 2026-11-01, tcolorbox 6.10.0). The package uses internal macros of tcolorbox; they are listed at the top of
tcbnestbreak.sty. - For tate with pLaTeX and upLaTeX:
pxpgftate(in TeX Live from 2026 on; with TeX Live 2025, install it from CTAN)
Installation
Copy tcbnestbreak.sty to your local TeX tree: $TEXMF/tex/latex/tcbnestbreak/
Limitations
- A box flows only at the top level of the content of a breakable box or of a box that flows: not in a
minipage, a\parboxor a cell of atabular, and not withfloat,sidebysideor\tcbox. Such a box is an ordinary unbreakable box, as without the package. - Where the outer box is broken, the frame of the inner box is always open: a part of a box of the
standardskin is drawn with the skinsenhancedfirst,enhancedmiddleandenhancedlast, andtoprule at break,bottomrule at break,topsep at breakandbottomsep at breakof the inner box are not used. - The frame is drawn when the part of the outer box is drawn, with the options of the inner box applied again. Colors or styles that are defined inside the content of the outer box are not known then.
heightand theenlarge ... bykeys of a box that flows are not used. - The content is indented like the content of a list. Material that does not follow
\parshape(e.g. an\hrulein vertical mode) is not indented. - The text color of the box (
coltext,colupper,collower) is continued after a break; a\colorinside the content is not.
Testing
make test compiles the tests with pdfLaTeX, XeLaTeX, LuaLaTeX, pLaTeX and upLaTeX (+ dvipdfmx). make test TEXBIN=<directory of the binaries> runs them with another TeX Live than the one in PATH; PXPGFTATE=<directory> (default: ../pxpgftate) is where pxpgftate is taken from if that TeX Live does not have it. The tests check:
- no error and no overfull page;
TNB-RESULT OK: every box that flows has its frames (oneunbrokenframe, or afirstframe,middleframes and alastframe) on pages that follow each other; a box with a lower part has the segmentation in exactly one frame, with frames of the upper part before it and of the lower part after it; and the frames together are as high as what has flowed (recorded through the hookstcbnestbreak/flowandtcbnestbreak/frame; seetest-common.tex);test-plain: the text of the PDF is the same with and without the package;test-footnote(if tcbpagefootnote v1.4 or later is in../tcbpagefootnote, or inTPF=<directory>): every page footnote is on the page of its mark (TNB-NOTE OK), no footnote is split, and all footnote texts are in the PDF;test-tate: the same checks as fortest-basicandtest-footnote, in tate.
| Test | Engines | What it covers |
|---|---|---|
test-basic.tex |
pdflatex (also twocolumn), xelatex, lualatex (article, ltjsarticle), platex (jarticle, jsarticle), uplatex | boxes inside a box, three levels deep, broken across several pages; a list, a display and an ordinary box inside; a title, the enhanced skin, a text color, \newtcolorbox; a box as the first thing in the outer box, in an item, in the lower part; boxes with a lower part, broken in the upper and in the lower part, also of the bicolor skin; boxes that do not flow (in a minipage, in an unbreakable box); an outer box that is not broken |
test-plain.tex |
pdflatex, lualatex, platex | documents without a box that flows: unchanged by the package |
test-footnote.tex |
pdflatex, xelatex, lualatex, platex, uplatex | with tcbpagefootnote: footnotes of the outer box and of the boxes inside, three levels deep, also in a title |
test-tate.tex |
platex (tarticle), uplatex (utarticle), lualatex (ltjtarticle) | test-basic.tex and test-footnote.tex in tate, with pxpgftate for pLaTeX and upLaTeX |
test-common.tex holds the helpers shared by the tests.
License
This package is licensed under the conditions of the LaTeX Project Public License, either version 1.3c of this license or any later version.
Copyright (c) 2026 Munehiro Yamamoto
Herunterladen des vollständigen Inhalts dieses Pakets in einem Zip-Archiv (164.9k).
Tcbnestbreak – Breakable tcolorboxes inside breakable tcolorboxes
tcolorbox typesets the content of a breakable box as one box and splits it
into the parts for the pages. A box inside cannot be split, so tcolorbox
ignores breakable for a box inside another box. With this
package, breakable works for a box inside a breakable box, to any
depth: the inner box is broken across pages together with the outer box, and
its frame is open where the outer box is broken.
The inner box can have a title and a lower part. No new key is needed, the boxes are broken in one run, and no Lua code is used. With the tcbpagefootnote package (v1.4 or later), the footnotes of the boxes inside are put on the pages of their marks.
Supported formats/engines: pdflatex, xelatex,
lualatex, platex, uplatex (with
dvipdfmx), in horizontal and vertical writing.
| Paket | Tcbnestbreak |
| Fehlermeldungen | |
| Repository | |
| Version | 0.2 2026-11-22 |
| Lizenzen | The LaTeX Project Public License 1.3c |
| Copyright | 2026 Munehiro Yamamoto |
| Betreuer | Munehiro Yamamoto |
| Themen | Box-Umbruch Boxing |