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.

I am drawing a little sketch, where a line enters a circle, and three other lines come out. Above each line, there is to be a tittle sinusoidal curve (almost as if I used a construct like \node (a) edge node[auto] {Some caption} (b); which you can find on page 48, PGF manual 2.10); this illustrates what I have so far (code below):

enter image description here

My question is: How can I place a wiggly line such as there is on the left above the other 3 lines on the right? Especially the lines also going north and south east are troubling me. Furthermore: how can I get anchors around the middle node (potential) which are placed on a circle, so that my edges coming all have the same length?

So far: I achieved placing the line above the left edge by placing two empty nodes above it, and shifting one to the left on the x axis, and one to the right, and naming them:

\node[shape=coordinate] (arrow start) [left=of potential,xshift=-1cm] {}
    edge [post] node[auto,above,name=wavestart,yshift=0.3cm,xshift=-0.7cm] {}
                node[auto,above,name=waveend,yshift=0.3cm,xshift=0.7cm] {} (potential);

Afterwards I could connect those new nodes easily by just creating another edge between them and pathmorphing it:

\path (wavestart) edge[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (waveend);

All code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns,positioning,decorations.pathmorphing,arrows}

\begin{document}

\begin{tikzpicture}%
    [post/.style={->,shorten >=1pt,>=stealth',semithick}]

    \node[circle, draw=black, pattern color=gray,%
     pattern=north east lines,label=below:$V(x)$,%
     minimum size=1cm] (potential) {};
    \node[shape=coordinate] [above right=of potential] (outgoing up) {};
    \node[shape=coordinate] [right=of potential] (outgoing mid) {};
    \node[shape=coordinate] [below right=of potential] (outgoing down) {};

    \path (potential)
        edge[post] (outgoing up)
        edge[post] (outgoing mid)
        edge[post] (outgoing down);

    \node[shape=coordinate] (arrow start) [left=of potential,xshift=-1cm] {}
        edge [post] node[auto,above,name=wavestart,yshift=0.3cm,xshift=-0.7cm] {}
                                node[auto,above,name=waveend,yshift=0.3cm,xshift=0.7cm] {} (potential);

    \path (wavestart) edge[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (waveend);



\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

You could put the wiggly line in a node and then position that like you normally would. Example code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,positioning,decorations.pathmorphing,arrows}
\begin{document}
\def\sinline{\tikz\draw[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (0,0) -- (.8,0);}
\begin{tikzpicture}%
    [post/.style={->,shorten >=1pt,>=stealth',semithick}]

    \node[circle, draw=black, pattern color=gray,%
     pattern=north east lines,label=below:$V(x)$,%
     minimum size=1cm] (potential) {};
    \node[shape=coordinate] [above right=of potential] (outgoing up) {};
    \node[shape=coordinate] [right=of potential] (outgoing mid) {};
    \node[shape=coordinate] [below right=of potential] (outgoing down) {};

    \path (potential) ++(-2,0) edge[post] node[above,sloped]{\sinline} (potential);

    \path (potential)
        edge[post] node[above,sloped]{\sinline} (outgoing up)
        edge[post] node[above,sloped]{\sinline} (outgoing mid)
        edge[post] node[above,sloped]{\sinline} (outgoing down);

\end{tikzpicture}
\end{document}

The result:

wiggly lines

share|improve this answer
    
Oh wow, that's a lovely solution! In fact, I wanted to do exactly that yesterday, but I couldn't figure out how. Thank you so much! –  mSSM Jan 30 '12 at 16:15
    
Is there a way to have tikz not inherit the post style? Right now, the node containing \sinline apparently inherits the post style from the edge. –  mSSM Jan 30 '12 at 21:04
    
Also: that syntax you used \path (potential) ++(-2,0) edge (potential): how could I use it in reverse? I guess \path (potential) edge ++(+2,0) would work, but what about \path (a) edge ++ (b) (+2,0) (that one fails)? –  mSSM Jan 30 '12 at 21:17
    
@mSSM: As far as inheriting the post style goes, I don't think there is much you can do. The easiest way is to explicitly set the values you want for those given in the post style on the node (they will override). For the reverse of the path notation, I don't really get what you mean. Your syntax is wrong on your try. You need to tell me what you wish to accomplish in order for me to be able to correct you. –  Roelof Spijker Jan 31 '12 at 0:21
    
Ok, let me rephrase my second question: with \path (a) ++(-2,0) edge (b) you essentially say "start at (a), move to (-2,0) from (a) and make this the new reference point, and draw a line to (b)". What I want to do is: "start at (a), draw a line to [ (b) ++(+2,0) ]", i.e. I would like to have an edge from (a) to a point somewhere past (b), using a similar syntax you employed. –  mSSM Jan 31 '12 at 13:24

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.