# tikz-feynman: Searching for the perfect tadpole

I'm plotting automatically generated and laid-out (by tikz-feynman's default spring layout) QED feynman diagrams.

I'm looking to improve the look of the "tadpoles" i.e the vertices where both fermion arcs are attached to the same vertex.

This image shows the options I'm aware of/have considered (the last one a "work in progress"):

Self-contained code to produce those is below (works with Debian 11's texlive's lualatex).

The first row shows use of loop. Which I'm not sure is actually part of tikz-feynman as its not mentioned in the documentation and I've just seen it used in other people's examples. That can look good when oriented opposite the photon arc, but so far as I know it needs the angles to be set manually... is there any way of automatically getting the loop to be opposite the incoming photon, bearing in mind I'm not controlling the positioning of anything explicitly and leaving it up to tikz-feynman's layout?

The second row shows simply setting the tadpole vertex to an empty circle. That'd actually be pretty good if I could make the circle a bit bigger and put an arrowhead on it somewhere.

The third row is the start of an attempt to do just that, by defining a tadpole style for a vertex.

Here's the code to produce the above plot. What I'm ideally looking for is what I should be filling out the \tikzfeynmanset{tadpole/.style={... with to get a white-filled black circle with no text label, a specified size and an arrowhead somewhere on it. However at this point I'm completely out of my depth with tikz and how this stuff interacts with tikz-feynman. Thanks for any help or pointers.

Code for above plot:

\documentclass[a4paper]{minimal}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,decorations,backgrounds,calc,er,patterns}

\usepackage[compat=1.1.0]{tikz-feynman}

% First groping towards a custom "tadpole" style.
\tikzfeynmanset{
/tikz/shape=circle,
/tikz/minimum size=5mm,
/tikz/draw=black,
/tikz/fill=white,
/tikz/decoration={name=none}
}
}

% Tweak table appearance
\setlength{\tabcolsep}{1cm}
\renewcommand{\arraystretch}{2.0}

\begin{document}

\begin{center}
\begin{tabular}{ccc}

\parbox{3cm}{Using \texttt{loop}:\\Looks reasonable, but needs manual orientation.}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [dot],
b [dot] -- [out=315,in=45,loop] b [dot],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical'=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [dot],
b [dot] -- [out=315,in=45,loop] b [dot],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

\\ & & \\

\parbox{3cm}{Using \texttt{empty dot}:\\Would be better if bigger, and with an arrow.}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [empty dot],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical'=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [empty dot],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

\\ & & \\

\parbox{3cm}{Attempting to use a custom \texttt{tadpole} style:\\I've idea how to control the size and suppress label.}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [tadpole],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

&

\parbox{3cm}{
\resizebox{!}{3cm}{
\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical'=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [tadpole],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}
}
}

\end{tabular}
\end{center}

\end{document}


\documentclass[tikz, border=1cm]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\usetikzlibrary{arrows.meta}

\tikzset{
circle,
inner sep=0,
append after command={
\pgfextra
\endpgfextra
}}}

\begin{document}

\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [tadpole],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}

\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical'=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [tadpole],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}

\end{document}


Edit:

If the loop is a fermion, you should change the arrow tip to Triangle to mimic tikz-feynman arrows. But why not use the packages own notation like this:

\documentclass[tikz, border=1cm]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}

\begin{document}

\begin{tikzpicture}
\begin{feynman}
\diagram[small, vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b  -- [half left] bm -- [fermion, half left] b,
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}

\end{document}


Edit: For completeness, here is the tadpole style without label:

\documentclass[tikz, border=1cm]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\usetikzlibrary{arrows.meta, bending}

\tikzset{
particle={},
circle,
inner sep=0,
append after command={
\pgfextra
\endpgfextra
}}}

\begin{document}

\begin{tikzpicture}
\begin{feynman}
\diagram[small,vertical=out to in]{
in [desired at={(0,-1)}],
in -- [fermion] a [dot],
a [dot] -- [photon] b [tadpole],
a [dot] -- [fermion] out,
out [desired at={(0,1)}]
};
\end{feynman}
\end{tikzpicture}

\end{document}


• I do not know if the "b" should be there or not. If not, you can add particle={} to the tadpole style. Sep 17, 2022 at 8:28
• Thanks; just tried that second idea first... it simply hadn't occurred to me to just introduce an "extra" vertex to build the loop onto! It works quite well and the loops feel well integrated... they just seem a bit too big for what they are though - examples at i.imgur.com/IsixiLr.png and i.imgur.com/5UoY7QR.png . Unless there's some way of shrinking them relative to the other structure (that keeps them reasonably circular) my instinct is the other approach will work better; I'm more just looking for something which "caps" otherwise dangling photons. Will try that next... Sep 17, 2022 at 12:39
• Try \diagram[small, vertical=out to in]{ in [desired at={(0,-1)}], in -- [fermion] a [dot], a [dot] -- [photon] b -- [half left] bm[xshift=5mm] -- [fermion, half left] b, a [dot] -- [fermion] out, out [desired at={(0,1)}] };  Sep 17, 2022 at 13:15
• Interesting, but the effect of that depends on the orientation of the loop and I have loops with all sorts of orientations (see the linked .png in previous comment) laid out automatically. It seems to me that's what's really needed is a way of specifying that the natural distance b -- bm should be say half or a third of what it normally is for other links... but it's not clear to me if that can somehow be passed through to the underlying tikz graph or spring layout algorithm. Sep 17, 2022 at 16:01
• Ask a new question about that - I will be happy to look into it. Also remember to accept this answer. Sep 17, 2022 at 16:03

After hpekristiansen's answer persuaded me to work with tikz-feynman rather than try and subvert it, I ended up creating this, in which I'm quite pleased with how the "tadpoles" look:

https://pdfhost.io/v/TKiPIg~hO_Feynman_Diagrams_for_Quantum_Electrodynamics

Overview image:

The "recipe" is basically some python code to:

• Layout the diagram (but not the "extra" tadpole vertices) using graph-tool's graph_tool.draw.sfdp_layout algorithm. IMHO this gave more control over the appearance than is possible with tikz-feynman's use of tikz's graph layout tools (at least for a tex novice like me). That layout function is basically used with default parameters, except that:

• "In" and "out" pendant arcs and any tadpoles were placed into separate "groups". Since groups slightly repel, this usefully teased them out of the main body vertices (which were left in their own single group) and away from each other.

• The cooling_step parameter was increased to 0.99; the resulting slower annealing seemed to "shake out" a few cases of odd unnecessarily crossing lines.

• Add the extra vertices to build the tadpole loops onto at the required distance (ie what size loop I think looks good) in the required direction (opposite the connected photon arc).

• Emit include-able .tex file with commands for rendering via tikz-feynman.

The generated .tex code for that first-order diagram with the loop looks like

      \begin{tikzpicture}
\begin{feynman}
\node [dot] (a) at (2.580850cm,3.155348cm);
\node [dot] (b) at (5.450449cm,4.471133cm);
\vertex (in) at (2.351967cm,0.000000cm);
\vertex (out) at (0.000000cm,5.000000cm);
\vertex (tb) at (6.511165cm,4.957499cm);
\diagram*[large]{
(a) -- [photon] (b),
(a) --[fermion] (out),
(b) -- [half left] (tb) -- [fermion, half left] (b),
(in) -- [fermion] (a)
};
\end{feynman}
\end{tikzpicture}


with the "tb" vertex being the "extra" for building the loop off of from "b".

(The use of both \node and \vertex relates to this known issue in tikz-feynman 1.1.0: https://github.com/JP-Ellis/tikz-feynman/issues/24 )