我正在尝试获得一个(或多或少)像这样的盒子样式:
但是有了rounded edges
和shadow
(该图像是我用 Gimp 做出的最佳成果......)
我一直在尝试改编文档的示例tcolorbox
。这是我的 MWE:
\documentclass{standalone}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[enhanced,title=Example 123,drop fuzzy shadow= lightgray,%
colframe=gray,colback=white,colbacktitle=white,fonttitle=\small\sffamily,boxrule=0.2mm,%
coltitle=black,attach boxed title to top right=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},%
boxed title style={boxrule=0.2mm,drop fuzzy shadow= lightgray,%
frame code={ \path[tcb fill frame] ([xshift=-0mm]frame.west)
-- (frame.north west) -- (frame.north east) -- ([xshift=-2mm]frame.east)
-- (frame.south east) -- (frame.south west) -- cycle; },
interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west)
-- (interior.north west) -- (interior.north east)
-- ([xshift=0mm]interior.east) -- (interior.south east) -- (interior.south west)
-- cycle;} }]
\lipsum[2]
\end{tcolorbox}
\end{document}
它看起来有点像(但又很远)我要找的东西。我如何获得这个盒子?
答案1
用 绘制所有内容可能是最简单的frame code
。
\documentclass[border=2mm]{standalone}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[enhanced,title=Example 123,drop fuzzy shadow= lightgray,%
colframe=gray,colback=white,colbacktitle=white,fonttitle=\small\sffamily,
boxrule=0mm,%
coltitle=black,
attach boxed title to top right=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},%
boxed title style={empty,arc=0pt,outer arc=0pt,boxrule=0pt},
frame code={
\draw[rounded corners=2pt,line width=0.4pt] let \p1=($(title.north)-(frame.north)$) in
(title.north) -- (title.north west) -- ++ (-\y1+0.2pt,-\y1+0.2pt) -|
([xshift=-0.2pt,yshift=-0.2pt]frame.south west) -| ([xshift=0.2pt]frame.east) |- ([xshift=1em]title.north) [rounded corners=0pt] -- cycle ;}]
\lipsum[2]
\end{tcolorbox}
\end{document}