虚线边框但自定义形状

虚线边框但自定义形状

我知道tcolorbox可以有虚线边框。但是条纹是矩形。但是是否可以将矩形改为平行四边形(45 度角),同时还有内边框和外边框,例如

在此处输入图片描述

答案1

您可以尝试使用tcboxedraster仅包含一个的tcolorbox。展开的框包含图案,内框覆盖部分图案,模仿倾斜的破折号。

模式定义取自使用带有阴影的 tikz 形状内的图案

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\usetikzlibrary{patterns}

\makeatletter
\tikzset{% customization of pattern
         % based on <m.wibrow@gm...> - 2013-03-24 07:20: 
        hatch distance/.store in=\hatchdistance,
        hatch distance=5pt,
        hatch thickness/.store in=\hatchthickness,
        hatch thickness=5pt
        }
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north east hatch}% name
    {\pgfqpoint{-1pt}{-1pt}}% below left
    {\pgfqpoint{\hatchdistance}{\hatchdistance}}% above right
    {\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
    {
        \pgfsetcolor{\tikz@pattern@color}
        \pgfsetlinewidth{\hatchthickness}
        \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
        \pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
        \pgfusepath{stroke}
    }
\makeatother

\tikzset{
    Pattern/.style={
        pattern=north east hatch,
        pattern color=black,
        hatch distance=15pt, 
        hatch thickness=5pt
    }
}

\begin{document}
\begin{tcboxedraster}[%
    raster columns=1,
    colframe=black,
    colback=white,
    ]{
    enhanced,
    colframe=black, 
    colback=white,
    underlay={%
        \begin{tcbclipinterior}
            \fill[Pattern] (frame.north west) rectangle (frame.south east);
        \end{tcbclipinterior}
        }
    }
\begin{tcolorbox}
\lipsum[1]
\end{tcolorbox}
\end{tcboxedraster}
\end{document}

在此处输入图片描述

相关内容