4

I'm looking for a way to define a style (I do not want to manually draw the edges by hand for each node) that provides a node containing three "normal" edges, and one zigzag edge. Here is an example :

enter image description here

I tried to use decorate, but I didn't obtain good results... By the way, any "general" solution to deal with custom boarders are welcome.

Here is a MWE :

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[
  broken/.style = {
    draw,
    rectangle
  }
  ]
  \node[broken] {Hello};
\end{tikzpicture}

\end{document}

Thank you.

=== EDIT === I found a solution, but I cannot fill the shape, properly, so the question is still open.

3

Here a solution based on your code, filling and drawing of nodes must be done within brokenrect style.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\tikzset{ brokenrect/.style={
    append after command={
      \pgfextra{
      \path[draw,#1]
       decorate[decoration={zigzag,segment length=0.4em, amplitude=.3mm}]
       {(\tikzlastnode.north east)--(\tikzlastnode.south east)}      
        -- (\tikzlastnode.south west)|-cycle;
        }}}}

\begin{tikzpicture}
  \node [brokenrect={fill=orange,draw=blue},inner sep=10pt] {Coucou};
\end{tikzpicture}

\end{document}

enter image description here

1
  • Great thank you ! I just added a "outer sep=0" in the brokenrect style to fit well in matrix. Thank you !
    – tobiasBora
    Jan 4 '17 at 23:40
3

I found this solution, I don't know if it's the more straight forward, but it works pretty well, and is quite clear I think. The problem of it is that the filling is very ugly, so any better solution would be nice.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\begin{tikzpicture}[
  brokenrect/.style={
    append after command={
      \pgfextra{
        \draw[] (\tikzlastnode.south west) |- (\tikzlastnode.north east);
        \draw[] (\tikzlastnode.south west) -- (\tikzlastnode.south east);
        \draw[decorate,decoration={zigzag,segment length=0.4em,amplitude=0.1em}] (\tikzlastnode.north east) -- (\tikzlastnode.south east);
      }
    }
  }
  ]
  \node [brokenrect] {Coucou};
\end{tikzpicture}

\end{document}

Here is the result in picture :

result

and the ugly filling :

ugly filling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.