2

I would like to have a zigzag decoration around a box created with mdframed.

Minimal example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage[framemethod=tikz]{mdframed}

\begin{document}
Some text.

\begin{mdframed}[tikzsetting={draw=black,decorate,decoration=zigzag}]
Some boxed text.
\end{mdframed}

Some other text.
\end{document}

This is the result: zigzag and mdframed

As you can see, the zigzag is not fully displayed.

I tried playing with the options of mdframed (skipabove, skipbelow, leftmargin and rightmargin) but I could not get what I wanted. As a workaround I also tried with the zigzag options (amplitude and segment length) but to no avail.

I am pretty sure the answer lies in setting a particular margin in mdframed but I cannot find which one.

darpich
  • 319

2 Answers2

3

Here is one way of doing it:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{mwe}
\begin{document}

\mdfsetup{splitbottomskip=0.8cm,
          splittopskip=0cm,
          innerrightmargin=2cm,innertopmargin=1cm,%
          innerlinewidth=2pt,outerlinewidth=2pt,
          middlelinewidth=10pt,linecolor=blue,middlelinecolor=gray,
          tikzsetting={draw=yellow,line width=3pt,
                       decorate,decoration={name=zigzag}},%
          }

\begin{mdframed} \lipsum[1] \end{mdframed}

\end{document}

This is a variation of "Example 4 – Gimmick" in mdframed-example-tikz.pdf.

This is what it produces:

enter image description here

Of course, the colours can be improved:)

3

Here is a tcolorbox version.

\documentclass{article}
\usepackage[many]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}

\newtcolorbox{mybox}[1][]{%
    enhanced jigsaw,
    frame code={\path[draw=black,decorate,decoration=zigzag]
                 (frame.south west) rectangle (frame.north east);},
    left=0pt,right=0pt,top=0mm,bottom=0mm,
    colback = white,
    before = \vskip0.55\baselineskip\noindent,
%    arc = 2mm,
%    outer arc = 2mm
}

\begin{document}
Some text.

\begin{mybox}
Some boxed text.
\end{mybox}

Some other text.
\end{document}

enter image description here