Open dbitouze opened 5 months ago
To overcome some of the PDF viewer's "smart" behaviors, apart from usual tricks like detaching then reinserting title and emulating frame by /tcb/borderline
, it's also possible to fill the title and interior as a whole, by setting a customized /tcb/interior titled code
.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, magazine, skins}
\makeatletter
\tcbset{
, notitlerule unbroken/.style={
, title empty
, interior titled code={
% fill title with color /tcb/colback too
\fill[tcbcolback]
[rounded corners=\kvtcb@arc]
(title.north west) rectangle (interior.south east);
}
}
, notitlerule first/.style={
, title empty
, interior titled code={
\fill[tcbcolback]
[rounded corners=\kvtcb@arc]
([yshift=-\kvtcb@bottom@rule@break]interior.south west)
-- (title.north west) -- (title.north east)
[sharp corners]
-- ([yshift=-\kvtcb@bottom@rule@break]interior.south east)
-- cycle;
}
}
, notitlerule/.style={
, extras unbroken={notitlerule unbroken},
, extras first={notitlerule first}
}
}
\makeatother
\tcbset{titlerule=0pt, coltitle=black, fonttitle=\bfseries}
\begin{document}
\begin{tcolorbox}[
, enhanced
, notitlerule
, title=Unbreakable
]
No title.
\end{tcolorbox}
\begin{tcolorbox}[
, enhanced
, breakable
, notitlerule
, title={Breakable but unbroken}
]
Bar
\end{tcolorbox}
\begin{tcolorbox}[
, enhanced
, breakable
, break at=2cm
, notitlerule
, title={Breakable and broken}
, reset box array
, store to box array
]
Bar \par
Bar \par
Bar \par
Bar \par
Bar \par
Bar \par
\end{tcolorbox}
\noindent
\useboxarray{1}\\[.5\baselineskip]
\useboxarray{2}\\[.5\baselineskip]
\useboxarray{3}
\end{document}
Compatibilities with /tcb/title after break
and/or jigsaw skins are not handled (yet). Eventually, it seems a new set of skins are required.
@dbitouze The previewer glitch to show zero rule lines is known for a very long time. It is depended from the used skin which have different drawing philosophies.
standard
(you used) and enhanced
skin draw a solid rounded box in frame color first. Then, the title background and interior text back is drawn above. If their distance is zero, the background color may shimmer through (should not, but some previewer show the zero line). The first two boxes below show your example (just with yellow color) normally and frame-only.standard jigsaw
and enhanced jigsaw
draw the frame not solid, but with holes for the interior and (possibly) the title. The last box below shows just the frame. The third box does not show the zero line. In truth: depending on the previewer, it does, but a zero width white line between white (or very bright boxes) is not show in my previewer...\documentclass{article}
\usepackage[skins]{tcolorbox}
\begin{document}
Box with previewer glitch:
\begin{tcolorbox}[
, title={Foo}
, colbacktitle=yellow
, colback=yellow
, coltitle=black
, titlerule = 0mm
]
Bar
\end{tcolorbox}
Box with previewer glitch (frame only):
\begin{tcolorbox}[
, title={Foo}
, colbacktitle=yellow
, colback=yellow
, coltitle=black
, titlerule = 0mm
, interior titled engine=empty
, title engine=empty
]
Bar
\end{tcolorbox}
Box without (visible) previewer glitch:
\begin{tcolorbox}[
standard jigsaw,
, title={Foo}
, colbacktitle=yellow
, colback=yellow
, coltitle=black
, titlerule = 0mm
]
Bar
\end{tcolorbox}
Box without (visible) previewer glitch (frame only):
\begin{tcolorbox}[
standard jigsaw,
, title={Foo}
, colbacktitle=yellow
, colback=yellow
, coltitle=black
, titlerule = 0mm
, interior titled engine=empty
, title engine=empty
]
Bar
\end{tcolorbox}
\end{document}
@T-F-S Maybe it is worth to add a warning in the documentation where titlerule
is defined.
The last box below shows just the frame. The third box does not show the zero line. In truth: depending on the previewer, it does, but a zero width white line between white (or very bright boxes) is not show in my previewer...
Indeed, with Okular
on GNU/Linux, the zero width line is still visible.
As shown by the following MCE, a title rule of zero width may still be visible (depending on the PDF viewer and/or the zoom):