I want to have two distinct styles for my tcolorbox titles as illustrated here:
These are coded in My Title Style Default
and My Title Style Special
, but use an entire tcolorbox
(not just the title). The special style has three distinct changes:
- The rule color around all four sides of the title changes. The rule around the other three sides (west, south and east) of the body text should not change.
- The left and right rules are thicker to draw attention that these are different.
- A few characters
xxx
are placed on the left hand rule.
So far I am only able to obtain part of requirement 2 and draw the bottom portion of the rule for the special box:
These are coded in My Style Default
and My Style Special
.
Questions:
Main: What changes should I make to the
My Style Special
to obtain the desired title style for thetcolorbox
. Of the three requirements, 2 and 3 are more important, so willing to accept and answer without 1.Bonus: Is there a better way for me to place the
xxx
text? I had to manually tweak the coordinates
Code:
\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{My Title Style Default/.style={
boxsep=0pt,
top=4pt,%
bottom=1pt,%
left=5pt,% left skip
right=5pt,% right skip
boxrule=0.5pt,
fontupper=\bfseries\color{black},
}}
\tcbset{My Title Style Special/.style={
My Title Style Default,
left=1pt,% adjusted to allow for larger leftrule
right=1pt,% adjusted to allow for larger rightrule
leftrule=4pt,
rightrule=4pt,
colframe=red,
%% ---------------------------------------------------------------
%% https://tex.stackexchange.com/questions/582034/
%% text-along-all-the-four-borders-of-a-tcolorbox
enhanced,
overlay={%
\node[draw=none, fill=none, rotate=90, anchor=north]
%% Must be a better way to position this.
at ([shift={(-2.50pt,0.0pt)}]frame.west)
{\scalebox{0.40}{\textcolor{white}{xxx}}};
},
%% ---------------------------------------------------------------
}}
\tcbset{My Style Default/.style={
boxsep=0pt,
top=4pt,% Space at top
bottom=1pt,% Space at bottom
left=5pt,% left skip
right=5pt,% right skip
boxrule=0.5pt,
colbacktitle=white,
fonttitle=\bfseries\color{black},
toptitle=1mm,
bottomtitle=1mm,
}}
\tcbset{My Style Special/.style={% What modifications are needed here?
My Style Default,
enhanced,
titlerule=0.5pt,
titlerule style=red,
}}
\begin{document}
\noindent
Would like two styles of title:
\begin{tcolorbox}[My Title Style Default]
1. Default Title Style
\end{tcolorbox}
\begin{tcolorbox}[My Title Style Special]
2. Special Title Style
\end{tcolorbox}
\medskip\par\noindent
Want the titles to look like above:
\begin{tcolorbox}[
My Style Default,
title={1. Default Title},
]
The title in this boxe matches the desired default title.
\end{tcolorbox}
\begin{tcolorbox}[
My Style Special,
title={2. Special Title},
]
Desire to match the "Special title" style for this box???
\end{tcolorbox}
\end{document}