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 trying to draw some Feynman diagrams using TikZ but seem to run into trouble where the arrow of a parent is also applied to the child, giving me two arrows on one line. (I have been using the example here as a base for creating my own)

Here's what my output look like (I am aware this diagram is incorrect):

enter image description here

As you can see the position line has two arrows overlapping, it seems it is only the arrows that are inherited.

Code:

\documentclass[10pt]{revtex4-1}

\usepackage{tikz}

\begin{document}

\usetikzlibrary{decorations.pathmorphing,decorations.markings,trees,positioning,arrows}   

 \tikzset{
    photon/.style={,decorate, decoration={snake}, draw=red},
    particle/.style={,draw=blue, postaction={decorate},
        decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{>}}}},
    antiparticle/.style={,draw=blue, postaction={decorate},
        decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{<}}}},
    gluon/.style={,decorate, draw=black,
        decoration={snake,amplitude=4pt, segment length=5pt}}
     }

\begin{tikzpicture}[
        thick,
        level/.style={level distance=2cm},
        level 2/.style={sibling distance=2cm},
    ]
\begin{scope}
\node{}
        child[grow=right]{
            edge from parent [particle]
            child []{
                edge from parent [photon]
                node [above=2pt, anchor=south,shift={(0.2,0)}] {$\gamma$};
            }
            child[] {
                edge from parent [antiparticle]
                node [above=2pt, anchor=south] {$e^+$};
            }
            node [above=3pt](gam) {$e^-$}
         };
  \end{scope}
\end{tikzpicture}

\end{document}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Include each decoration option inside the corresponding postaction for each style:

\documentclass[10pt]{revtex4-1}
\usepackage{tikz}

\begin{document}

\usetikzlibrary{decorations.pathmorphing,decorations.markings,trees,positioning,arrows}   

 \tikzset{
    photon/.style={decorate, decoration={snake}, draw=red},
    particle/.style={draw=blue,postaction={decorate,
        decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{>}}}}},
    antiparticle/.style={draw=blue,postaction={decorate,
        decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{<}}}}},
    gluon/.style={decorate, draw=black,
        decoration={snake,amplitude=4pt, segment length=5pt}}
     }

\begin{tikzpicture}[
        thick,
        level/.style={level distance=2cm},
        level 2/.style={sibling distance=2cm},
    ]
\begin{scope}
\node{}
        child[grow=right]{
            edge from parent [particle]
            child []{
                edge from parent [photon]
                node [above=2pt, anchor=south,shift={(0.2,0)}] {$\gamma$};
            }
            child[] {
                edge from parent [antiparticle]
                node [above=2pt, anchor=south] {$e^+$};
            }
            node [above=3pt](gam) {$e^-$}
         };
  \end{scope}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Brilliant, works a treat. –  JJPP Sep 10 '12 at 19:08
    
@JJPP While the drawing seems to be what you wanted, please note that physically this is incorrect - the graph suggests two electrons annihilating into a photon, eliminating a charge of 2e despite charge conservation. A positron is drawn the same way as an electron but with the arrow pointing in the opposite time direction, but the arrow direction along a path is continuous (so you can imagine a positron ~ as an electron travelling back in time). Have a look at this diagram's left half for a physically correct example. –  Tobias Kienzler May 2 '13 at 6:45
add comment

just two additions/comments to solution given by Claudio Fiandrino:

  1. if the color of decoration arrow(s) is the same color as decorated line, it is not necessary to define color of arrow, i.e. instead \arrow[draw=blue] {>} it is enough to say \arrow{>}.

  2. for arrow in opposite direction of line (edge) you also can use \arrowreversed{>}. this is convenient, if you like to declare a tip of arrow (for example \arrowreversed{latex}, etc).

share|improve this answer
    
Thanks, though if you use the \arrow{latex} you need the option [blue] or the arrow will be black. Maybe that is what the original author was thinking of. –  JJPP Sep 10 '12 at 19:16
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.