12

Please tell me of an (as simple as possible) solution to draw an interrupted line. I don't know how this is technically called; interrupted line, interleaved line, broken line, discontinuous line?

Here is an image of what I want. It doesn't have to be wavy (but it would be nice).

enter image description here

3

2 Answers 2

17

Here's a decoration that will place a wavy discontinuity symbol at the midpoint of the first segment of a path. You can control the distance between the two waves using the segment length key, the width of the waves using amplitude and the degree of waviness using meta-segment length:

discontinuity symbol

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

\begin{document}

\pgfdeclaredecoration{discontinuity}{start}{
  \state{start}[width=0.5\pgfdecoratedinputsegmentremainingdistance-0.5\pgfdecorationsegmentlength,next state=first wave]
  {}
  \state{first wave}[width=\pgfdecorationsegmentlength, next state=second wave]
  {
    \pgfpathlineto{\pgfpointorigin}
    \pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
    \pgfpathcurveto
        {\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.75\pgfdecorationsegmentamplitude}}
        {\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.25\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0pt}{0pt}}
    \pgfpathcurveto
        {\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.25\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.75\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0pt}{-\pgfdecorationsegmentamplitude}}
}
\state{second wave}[width=0pt, next state=do nothing]
  {
    \pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
    \pgfpathcurveto
        {\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.75\pgfdecorationsegmentamplitude}}
        {\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.25\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0pt}{0pt}}
    \pgfpathcurveto
        {\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.25\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.75\pgfdecorationsegmentamplitude}}
        {\pgfpoint{0pt}{-\pgfdecorationsegmentamplitude}}
    \pgfpathmoveto{\pgfpointorigin}
}
  \state{do nothing}[width=\pgfdecorationsegmentlength,next state=do nothing]{
    \pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
  }
  \state{final}
  {
    \pgfpathlineto{\pgfpointdecoratedpathlast}
  }
}

\begin{tikzpicture}
\draw [decoration={%
        discontinuity,
        amplitude=0.75cm},
    decorate](0,0) -- (3,2);
\draw [decoration={%
        discontinuity,
        amplitude=0.5cm,
        segment length=0.25cm,
        meta-segment length=0.5cm},
    decorate](1,-1) -- (3,-2);
\end{tikzpicture}
\end{document}
4
  • Nice usage of custom decorations! Jul 5, 2011 at 13:36
  • is there a way to include self defined pgf parameters. For instance I would like to draw some text with: \pgftext[left,rotate=-90,base,x=\pgfshapeinnerxsep]{\raisebox{-0.75ex}{\pgfkeysvalueof{/discontinuity/sometext}}}? May 26, 2012 at 17:12
  • @CommuSoft: I don't quite understand the question. Do you have an example of what the sometext parameter could be? Should it just store a text? Or do you want to use it to influence the appearance of the discontinuity symbol in some way?
    – Jake
    May 28, 2012 at 18:55
  • I would like to draw text near the interrupted line (between the two waves for instance). By calleing a parameter like \draw [decoration={% discontinuity, amplitude=0.5cm, segment length=0.25cm, meta-segment length=0.5cm}, decorate,sometext={bla}](1,-1) -- (3,-2); May 28, 2012 at 20:16
8

Here is a way to include an interruption. I used straight lines, but now that you see how it is done, you could arrange it to your liking.

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\tikzstyle{interrupt}=[
    postaction={
        decorate,
        decoration={markings,
                    mark= at position 0.5 
                          with
                          {
                            \fill[white] (-0.1,-0.3) rectangle (0.1,0.3);
                            \draw (-0.1,0.3) -- (-0.1,-0.3)
                                  (0.1,0.3) -- (0.1,-0.3);
                          }
                    }
                }
]

\begin{document}

\begin{tikzpicture}

\draw[interrupt] (0,0) -- (5,5);

\end{tikzpicture}

\end{document}

The result is

interrupt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .