Tikz, decorations

Just for fun, with feynmp and egreg's feynmp-auto. If on MikTeX or TeX Live 2012 or earlier, compile with --shell-escape (or --enable-write18) as command-line options. All manual positioning (\fmfforce commands) is done to match your sample, but the positions can be computed automatically by leaving these out.

\documentclass{standalone}
\usepackage{feynmp-auto}

\begin{document}
\unitlength = 2mm
\begin{fmffile}{testing}
\begin{fmfgraph*}(30,20)
  \fmfleft{i} \fmfright{o}
  \fmflabel{$p$}{o}
  \fmf{plain}{i,v1} \fmf{plain}{v2,o}
  \fmf{fermion,label=$p+k$}{v1,v2}
  \fmf{photon,left,label=$k$}{v1,v2}
  \fmfdot{v1,v2}
  \fmfforce{(0.3w,0.5h)}{v1}
  \fmfforce{(0.6w,0.5h)}{v2}
  \fmfforce{(0.9w,0.5h)}{o}
\end{fmfgraph*}
\end{fmffile}
\end{document}

enter image description here


Another solution with tikz, as requested. The problem with the linked answer is that the arguments to the atan function in the pgf low-level layer have been reversed. Switching the arguments inside the wavy semicircle definition solves that issue.

Code for the styles borrowed from here.

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{positioning,arrows.meta}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}

% adapted from https://tex.stackexchange.com/a/160358/21344; changed photon style
\tikzset{
  fermion/.style={draw=black, postaction={decorate},decoration={markings,mark=at position .55 with {\arrow{Latex}}}},
  vertex/.style={draw,shape=circle,fill=black,minimum size=2pt,inner sep=0pt},
  photon/.style={wavy semicircle,wave amplitude=0.3mm,wave count=10}
}

% adapted from https://tex.stackexchange.com/a/89003/21344; swapped atan args
\newif\ifmirrorsemicircle
\tikzset{
    wave amplitude/.initial=0.2cm,
    wave count/.initial=8,
    mirror semicircle/.is if=mirrorsemicircle,
    mirror semicircle=false,
    wavy semicircle/.style={
        to path={
            let \p1 = (\tikztostart),
            \p2 = (\tikztotarget),
            \n1 = {veclen(\y2-\y1,\x2-\x1)},
            \n2 = {atan2(\x2-\x1,\y2-\y1))} in
            plot [
                smooth,
                samples=(\pgfkeysvalueof{/tikz/wave count}+0.5)*8+1, % Calculate the number of samples needed, so the samples are in sync with the wave and fall on the extrema
                domain=0:1,
                shift={($(\p1)!0.5!(\p2)$)}
            ] ({ % Polar coordinates: Angle...
                (\x*180-\n2 + 180 + \ifmirrorsemicircle 1 \else -1 \fi * 90%
            }:{ % ... and radius
                (%
                    \n1/2+\pgfkeysvalueof{/tikz/wave amplitude} * %
                    sin(
                        \x * 360 * (\pgfkeysvalueof{/tikz/wave count} + 0.5%
                    )%
                )%
            })
        } (\tikztotarget)
    }
}

\begin{document}
\begin{tikzpicture}
\coordinate (i);
\coordinate[vertex, right=of i] (v1);
\coordinate[vertex, right=of v1] (v2);
\coordinate[right=of v2] (o);
\draw (i) -- (v1);
\draw[fermion] (v1) -- (v2) node[midway,below] {$p+k$};
\draw[photon] (v1) to (v2);
\path (v1) to[in=90,out=90] node[above=2mm]{$k$} (v2); % ghost path for label
\draw (v2) -- (o) node[right] {$p$};
\end{tikzpicture}
\end{document}

enter image description here

Personally, I feel that feynmp is much better suited for these uses. Knowing how to use a hammer really well doesn't make it a good tool for sawing.


All the three Feynman diagrams shown in the question can be realized with a few lines of code using the new TikZ-Feynman package (see also the project page).

Here is the code to produce all of them. You must compile with lualatex in order to take advantage of the automatic positioning of the vertices.

\documentclass[tikz]{standalone}
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.0.0}
\begin{document}
% first diagram
\feynmandiagram [layered layout, horizontal=a to d] {
  a [particle=\(\mu\)] -- [photon] b [dot],
  b -- [anti fermion, half left, edge label=\(k\)] c [dot] --
  [half left, fermion, edge label=\(k + q\)] b,
  c -- [photon] d [particle=\(\nu\)],
};

% second diagram
\feynmandiagram [layered layout, horizontal=a to d] {
  a -- b [dot] -- [fermion,edge label'=\(p + k\)] c [dot] -- d [particle=\(p\)],
  b -- [photon, half left, edge label=\(k\)] c,
};

% third diagram
\begin{tikzpicture}
  \begin{feynman}
    \vertex (a) {\(\mu\)};
    \vertex [right=of a] (b);
    \vertex [above right=of b] (u1);
    \vertex [above right=of u1] (u2) {\(p'\)};
    \vertex [below right=of b] (d1);
    \vertex [below right=of d1] (d2) {\(p\)};

    \diagram*{
      (a) -- [photon, edge label'=\(q\)] (b),
      (b) -- [fermion, edge label=\(k+q\)] (u1) -- [fermion] (u2),
      (b) -- [anti fermion, edge label'=\(k\)] (d1) -- [anti fermion] (d2),
      (d1) -- [photon, half right, edge label'=\(p - k\)] (u1),
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

enter image description here

enter image description here

enter image description here