Here I patched tcolorbox
to extend option arc
to accept a tikz coordinate, e.g., arc={(8mm,6mm)}
, which allows to set different lengths for horizontal and vertical arc. (Note this patch is experimental, and makes no warranty it is complete and/or robust.)
Then underlay={<tikz code>}
adds a flipped triangle which is congruent with the arced triangle. Hence you can easily change the size of "bending" by using arc={<coordinate>}
.
\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{pifont}
\usepackage{lipsum}
\usepackage{xpatch}
% extend tcb option "arc" to accept a coordinate
\makeatletter
\tcbset{
% redefine "arc", it now need "tikz" picture
arc/.code={%
\tikz@handle@vec{\tcb@arc@point}{\tcb@arc@single}#1\relax
},
bean arc/.append code={%
\tcbdimto\kvtcb@h@arc{\kvtcb@arc}%
\tcbdimto\kvtcb@v@arc{\kvtcb@arc}%
}
}
% inner arc: replace \kvtcb@arc with \kvtcb@[hv]@arc
% outer arc: replace \tcb@outer@arc with \tcb@outer@[hv]@arc
% shadow arc: replace \tcb@shadow@arc with \tcb@shadow@[hv]@arc
\def\tcb@arc@point#1\relax{%
\pgf@process{#1}%
\edef\kvtcb@h@arc{\the\pgf@x}%
\edef\kvtcb@v@arc{\the\pgf@y}%
}
\def\tcb@arc@single#1{%
\edef\kvtcb@h@arc{\the\dimexpr#1\relax}%
\edef\kvtcb@v@arc{\the\dimexpr#1\relax}%
}
\xpatchcmd\tcb@set@@dimensions
{\tcbdimto\kvtcb@arc{\kvtcb@arc}}
{}
{}{\fail}
\def\tcb@comp@arc@auto{%
\tcb@comp@arc@auto@\tcb@outer@h@arc\kvtcb@h@arc
{left@rule}{right@rule}%
\tcb@comp@arc@auto@\tcb@outer@v@arc\kvtcb@v@arc
{top@rule@stand}{bottom@rule@stand}%
}
\def\tcb@comp@arc@auto@#1#2#3#4{%
\expandafter\let\expandafter#1\csname kvtcb@#3\endcsname
\@for\tcb@temp@a:=#4\do{%
\ifdim\csname kvtcb@\tcb@temp@a\endcsname<#1\relax
\expandafter\let\expandafter#1\csname kvtcb@\tcb@temp@a\endcsname
\fi
}
\tcbdimto#1{\tcb@arc@scale\dimexpr#1\relax+#2}%
}
\let\tcb@comp@arc=\tcb@comp@arc@auto
\def\tcb@arc@ins#1{%
\if#1t% "t" means transpose
\pgfsetcornersarced{\pgfqpoint{\kvtcb@v@arc}{\kvtcb@h@arc}}%
\else
\pgfsetcornersarced{\pgfqpoint{\kvtcb@h@arc}{\kvtcb@v@arc}}%
\fi
}
\def\tcb@arc@out#1{%
\if#1t%
\pgfsetcornersarced{\pgfqpoint{\tcb@outer@v@arc}{\tcb@outer@h@arc}}%
\else
\pgfsetcornersarced{\pgfqpoint{\tcb@outer@h@arc}{\tcb@outer@v@arc}}%
\fi
}
% patch tcb lib "skins"
\def\tcb@shadow@comp@arc{%
\tcb@shadow@comp@arc@{\tcb@outer@h@arc}{\tcb@shadow@h@arc}%
\tcb@shadow@comp@arc@{\tcb@outer@v@arc}{\tcb@shadow@v@arc}%
}
\def\tcb@shadow@comp@arc@#1#2{%
\ifdim\dimexpr#1>\tcb@arc@scale\dimexpr\tcb@shadow@ts\relax%
\tcbdimto#2{#1-\tcb@arc@scale\dimexpr\tcb@shadow@ts\relax}%
\else%
\let#2=\tcb@zpt%
\fi%
}
\def\tcb@arc@sha#1{%
\if#1t%
\pgfsetcornersarced{\pgfqpoint{\tcb@shadow@v@arc}{\tcb@shadow@h@arc}}%
\else
\pgfsetcornersarced{\pgfqpoint{\tcb@shadow@h@arc}{\tcb@shadow@v@arc}}%
\fi
}
% update \tcb@arc@(ins|out|sha)@(NW|NE|SW|SE)@rounded
\@for\@tempa:=NE,SW\do{
\csdef{tcb@arc@ins@\@tempa @rounded}{\tcb@arc@ins f}
\csdef{tcb@arc@out@\@tempa @rounded}{\tcb@arc@out f}
\csdef{tcb@arc@sha@\@tempa @rounded}{\tcb@arc@sha f}
}
\@for\@tempa:=NW,SE\do{%
\csdef{tcb@arc@ins@\@tempa @rounded}{\tcb@arc@ins t}
\csdef{tcb@arc@out@\@tempa @rounded}{\tcb@arc@out t}
\csdef{tcb@arc@sha@\@tempa @rounded}{\tcb@arc@sha t}
}
\newtcolorbox{mybox}[2][]{%
colback=teal!10,
coltitle=black,
colframe=teal!30,
fonttitle=\bfseries,
title=#2,
sharp corners,
rounded corners=southeast,
arc is angular,
arc={(8mm,6mm)},
boxrule=0pt,
enhanced,
overlay={
\node[font=\Huge, text=cyan!70!black] at ([yshift=-4mm]interior.north west) {\ding{228}};
},
underlay={
\path
coordinate (x) at (interior.south east)
coordinate (left) at ([xshift=-\kvtcb@h@arc]x)
coordinate (upper) at ([yshift=\kvtcb@v@arc]x)
coordinate (x') at ($ (left)!(x)!(upper) $)
coordinate (x'') at ($ (x)!2!(x') $);
\fill[tcbcolframe] (left) -- (upper) -- (x'') -- cycle;
},
drop fuzzy shadow,
#1
}
\makeatother
\begin{document}
\begin{mybox}{An example}
\lipsum[2]
\end{mybox}
\begin{mybox}[arc={(10pt,15pt)}]{An example}
\lipsum[2]
\end{mybox}
\end{document}
