在右下角添加带有阴影的折痕

在右下角添加带有阴影的折痕

从我以前的一个老问题开始修复使用 tcolorbox 的漂亮框架的一些问题并使用用户@Ignasi 的优秀答案,

在此处输入图片描述

\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}

是否可以添加向上的折痕并带有阴影,就像这张图片一样

在此处输入图片描述

取自包装手册tcolorbox

答案1

正如它所显示的这个答案,此类框marker在文件中被调用和定义tcolorbox.doc.s_main.sty。将部分marker定义的代码添加到OP中后mybox,结果为:

\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}

在此处输入图片描述

答案2

在这里我修补了tcolorbox扩展选项arc以接受 tikz 坐标,例如arc={(8mm,6mm)},它允许为水平和垂直弧设置不同的长度。(请注意,此补丁是实验性的,不保证其完整性和/或稳健性。)

然后underlay={<tikz code>}添加一个与圆弧三角形全等的翻转三角形。因此,您可以使用 轻松更改“弯曲”的大小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}

在此处输入图片描述

相关内容