Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
Maybe a double line with wave decoration? –  Martin Scharrer Jul 5 '11 at 12:32
1  
@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
add comment

2 Answers

up vote 10 down vote accepted

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}
share|improve this answer
    
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}}}? –  CommuSoft 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); –  CommuSoft May 28 '12 at 20:16
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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