TikZ - How to draw an interrupted line?

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).

-
Maybe a double line with wave decoration? – Martin Scharrer Jul 5 '11 at 12:32
@ziggystar, it is not exactly the same symbol, but perhaps you could use this one? tex.stackexchange.com/questions/18436/… – pmav99 Jul 5 '11 at 12:40
@pmav Maybe as a last resort. :) Thanks – ziggystar Jul 5 '11 at 12:46
BTW not wavy = capacitor symbol. Check pages 311 and 317 of TikZ&PGF Manual for Version 2.10. – przemoc Jul 5 '11 at 13:15

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:

\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{0pt}{0pt}}
\pgfpathcurveto
{\pgfpoint{0pt}{-\pgfdecorationsegmentamplitude}}
}
\state{second wave}[width=0pt, next state=do nothing]
{
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
\pgfpathcurveto
{\pgfpoint{0pt}{0pt}}
\pgfpathcurveto
{\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}

-
Nice usage of custom decorations! – Martin Scharrer Jul 5 '11 at 13:36
That's the real stuff. Thank you! – ziggystar Jul 5 '11 at 14:11
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}{\pgfkeys‌​valueof{/discontinuity/sometext}}}? – Willem Van Onsem May 26 '12 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 '12 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); – Willem Van Onsem May 28 '12 at 20:16

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

-