2

Starting from a my previous old question Fix some problems with a nice frame using tcolorbox and using the excellent answer of the user @Ignasi,

enter image description here

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{pifont}
\newtcolorbox{mybox}[1]{%
    colback=teal!10,
    coltitle=black,
    colframe=teal!30,
    fonttitle=\bfseries,
    title=#1, 
    sharp corners,
    boxrule=0pt,
    enhanced,
    overlay={\node[font=\Huge, text=cyan!70!black] at ([yshift=-4mm]interior.north west) {\ding{228}};}
    }

\usepackage{lipsum}
\begin{document}
\begin{mybox}{An example}
\lipsum[1]
\end{mybox}
\end{document}

is it possible to add a crease upwards and with a shadow as this image

enter image description here

taken from manual for tcolorbox package?

0
3

As it's shown in this answer, this kind of boxes are called marker and defined in tcolorbox.doc.s_main.sty file. After adding part of marker definition's code to OP's mybox the result is:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{pifont}
\newtcolorbox{mybox}[2][]{%
    colback=teal!10,
    coltitle=black,
    colframe=teal!30,
    fonttitle=\bfseries,
    title=#2, 
    sharp corners,
    rounded corners=southeast,
    arc is angular,
    arc=3mm,
    boxrule=0pt,
    enhanced,
    overlay={\node[font=\Huge, text=cyan!70!black] at ([yshift=-4mm]interior.north west) {\ding{228}};},
    underlay={
        \path[fill=tcbcolback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
        \path[draw=tcbcolframe,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
    },
    drop fuzzy shadow,
    #1
    }

\usepackage{lipsum}
\begin{document}
\begin{mybox}{An example}
\lipsum[1]
\end{mybox}
\end{document}

enter image description here

0
1

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}

enter image description here

2
  • A very hug work :-( for you....thank you very very much. +1 – Sebastiano Oct 17 '20 at 23:09
  • @Sebastiano The patching code is improved a little bit. Instead of adding three new options, now arc={<dimension or coordinate>} is supported. – muzimuzhi Z Oct 18 '20 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.