[Tex/LaTex] Feynman Diagrams with tikz

feynmantikz-pgf

I am trying to find some example code for some very simple Feynman diagrams. Something similar to any or all of the pictures below

Simple Feynman diagrams

I was able to find some example code on texample.net, but being new to TikZ I am not really able to tweak it to produce something simple like the examples above. I would appreciate any help :).

EDIT: I managed to get the code down to a smaller example that is close to what I want:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,trees}
\begin{document}

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

\begin{tikzpicture}[
        thick,
        % Set the overall layout of the tree
        level/.style={level distance=1.5cm},
        level 2/.style={sibling distance=3.5cm},
    ]
    \coordinate
        child[grow=left]{
            edge from parent [gluon]
            child {
                edge from parent [particle]
                node [above] {$g$}
            }
            child {
                edge from parent [antiparticle]
                node [below] {$g$}
            }
            node [above=3pt] {$g$}
         }
        % I have to insert a dummy child to get the tree to grow
        % correctly to the right.
        child[grow=right, level distance=0pt] {
            child {
                edge from parent [antiparticle]
                node [above] {$g$}
            }
            child {
                edge from parent [particle]
                node [below] {$g$}
            }
        };
\end{tikzpicture}
\end{document}

However, if instead of the coil decoration for the gluon, I want a straight dashed line, I change the line

gluon/.style={decorate, draw=black,
        decoration={snake,amplitude=4pt, segment length=5pt}}

for

gluon/.style={draw=black,dashed}

However, this makes the two particles to the left of the gluon become dashed as well. Can someone suggest a way to fix this?

Best Answer

As far as I understand it, the "dashed" style option is a shorthand that sets /tikz/dash pattern to a dashed style (PGF manual v2.1, p157). That then stays in effect for the rest of the path, until you change the dash pattern again. Because the other styles don't specify the dash pattern, they'll keep using whatever was in effect. Try adding "solid" to the definitions of (anti-)particle and gluon, and it should work.

Related Question