将 tcolorbox 中的锯齿形装饰替换为波浪装饰

将 tcolorbox 中的锯齿形装饰替换为波浪装饰

首先,我要感谢 CarLateX 在这个问题上的回答邮政

我的要求是在此代码中用波浪装饰代替锯齿形装饰

\tcolorboxenvironment{defin}{
blanker,
breakable,
before skip=\topsep,
after skip=\topsep,
borderline west={1pt}{20pt}{decoration={**zigzag**,amplitude=2pt,pre=moveto,pre 
length=12pt},decorate}
}

其中 wave 如下图所示 在此处输入图片描述

提前感谢您的帮助!

答案1

除了CarLaTeX 的精彩回答,我也从中复制了 MWE,此代码使用杰克的完整正弦这个答案,其中可以找到更多详细信息和解释。

\documentclass{article}
\usepackage{lipsum}% just to generate text for the example
\usepackage{ntheorem}

\theoremstyle{plain}
\theoremindent40pt 
\theoremheaderfont{\normalfont\bfseries\hspace{-\theoremindent}}
\newtheorem{theo}{Theorem}[section]
\newtheorem{defin}{Definition}[section]

\usepackage[most]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations}

\pgfdeclaredecoration{complete sines}{initial}
{
    \state{initial}[
        width=+0pt,
        next state=sine,
        persistent precomputation={\pgfmathsetmacro\matchinglength{
            \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
            \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
        }] {}
    \state{sine}[width=\pgfdecorationsegmentlength]{
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
}
    \state{final}{}
}

\tcbuselibrary{skins}
\tcolorboxenvironment{defin}{
    blanker,
    breakable,
    before skip=\topsep,
    after skip=\topsep,
     overlay={%
     \draw[fill,decoration={complete sines,segment length=9.5pt,path has corners}]
      decorate{ ([xshift=20pt,yshift=1.5pt]frame.south west) 
        -- ([xshift=20pt,yshift=-12pt]frame.north west)} -- 
         ([xshift=21.5pt,yshift=-13.5pt]frame.north west)
      decorate{([xshift=21.5pt,yshift=-13.5pt]frame.north west) --
      ([xshift=21.5pt,yshift=0pt]frame.south west)}  -- ([xshift=20pt,yshift=1pt]frame.south west)  
        ;
    },
    }

\begin{document}


\section{My section}
\lipsum[4]
\begin{defin}
\lipsum[4]
\end{defin}
\lipsum[4]
\end{document}

在此处输入图片描述

相关内容