# Loops & insertions in Tikz-Feynman

I'd like to produce these diagrams using Tikz-Feynman.

What I have so far is

\RequirePackage{luatex85}
\documentclass{standalone}

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

\begin{document}

$\feynmandiagram [horizontal=a to b, layered layout, baseline=(i1.base)] { i1 -- a [dot] -- [photon,half left,momentum'=$$q$$] b [dot] -- [photon,half left,momentum'=$$q$$] a, b -- f1 }; + \feynmandiagram [horizontal=a to b, layered layout, baseline=(a.base)] { {i1,i2} -- a [dot] -- [photon,half left,momentum'=$$q$$] b [crossed dot] -- [photon,half left,momentum'=$$q$$] a, };$

\end{document}


There are a few open questions:

1. How can I move the momentum arrows outside the loops?
2. How can I shorten the in and outgoing lines?
3. How can I precisely vertically align the center of both diagrams with the plus sign?
4. How can I add the crossed dot on the first diagram?

## Update

With the help of JP-Ellis I was able to get

\RequirePackage{luatex85}
\documentclass{standalone}

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

\begin{document}
$\feynmandiagram [horizontal=a to c,inline=(a.base)] { a [dot] -- [charged boson,quarter left,edge label=$$q$$] b -- [photon,quarter left] c [dot] -- [charged boson,quarter left,edge label=$$q$$] d [crossed dot] -- [charged boson,quarter left,edge label=$$q$$] a, f1 -- c, i1 -- a, }; \quad\raisebox{-0.5ex}{+}\quad \feynmandiagram [horizontal=a to b, layered layout, inline=(a.base)] { {i1,i2} -- a [dot] -- [charged boson,half left,edge label=$$q$$] b [crossed dot] -- [charged boson,half left,edge label=$$q$$] a [desired at={(0, 0)}], };$
\end{document}


One question remains: is there a way to move the arrow on charged boson and its edge label to the end of a line? My intent is to to have them at the top of the upper arch in the first diagram (rather than in the middle of the first quarter).

Great work on the diagrams already!

So let me address the questions:

How can I move the momentum arrows outside the loops?

The momentum key comes in two forms: momentum and momentum'. These differ only in terms of the side on which they arrows are placed; so using momentum solves the issue in your case.

How can I shorten the in and outgoing lines?

I recently answered another question on this site that explored the use of nudge. If you specifically just want to adjust the external lines, this could be used. Alternatively, perhaps you'll want to adjust the whole diagram to be smaller (as it looks like you'll be having them within an equation). This can be achieved with small.

How can I precisely vertically align the center of both diagrams with the plus sign?

You are correct in using baseline; however as you have noticed, the '+' symbol is not actually on the baseline and is in fact slightly above. The 'magic distance' from the baseline to the horizontal bar in the '+' is -\the\dimexpr\fontdimen22\textfont2\relax; though I don't remember where on this site I got this from originally.

The baseline key can then either take a node (as you have done), or an actual offset distance. In the case when a distance is specified, this is relative to the (0, 0) coordinate which, if no other coordinates are specified, will be the location of the first vertex. For the first diagram this is all good, but in the second case I tell the algorithm that (a) should be at (0, 0) using the desired at key.

How can I add the crossed dot on the first diagram?

You can add extra vertices at fixed locations, though unfortunately you can't do this within the \feynmandiagram command. The solution below uses the \diagram command within a {feynman} environment, and then manually places the crossed dot. The mid-way point is calculated with (a)!0.5!(b), and then it is just moved down until it looks good.

Here's the solution that implements everything. Note that I've made use of both nudge and small. This means that the second diagram has everything slightly smaller (hence the filled and crossed dots look different). Ideally, I would only use one of the two methods, but both are illustrated here.

\documentclass{article}

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

\def\plusheight{-\the\dimexpr\fontdimen22\textfont2\relax}

\begin{document}
$$\begin{tikzpicture}[baseline=\plusheight] \begin{feynman} \diagram [horizontal=a to b, layered layout] { i1 [nudge right=0.7cm] -- a [dot] -- [photon, half left, momentum=$$q$$] b [dot] -- [photon, half left, momentum=$$q$$] a , b -- f1 [nudge left=0.7cm] }; \vertex [crossed dot, fill=white] (i) at ((a)!0.5!(b) - (0, 0.75)) {}; \end{feynman} \end{tikzpicture} + \feynmandiagram [horizontal=a to b, layered layout, small, baseline=\plusheight] { {i1,i2} -- a [dot] -- [photon, half left, momentum=$$q$$] b [crossed dot] -- [photon, half left, momentum=$$q$$] a [desired at={(0, 0)}], };$$
\end{document}


To address the updated answer: the charged boson style is, internally, a combination of boson and with arrow=0.99. The with arrow style is undocumented at this stage as I did not envisage people to use it, but I probably should add it to the documentation. For some reason, with arrow=1 doesn't actually work, so 0.99 is good enough.

As a result, you can simply replace charged boson with boson, with arrow=1 to the desired result:

\RequirePackage{luatex85}
\documentclass{standalone}

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

\begin{document}
\feynmandiagram [horizontal=a to c, small] {
a [dot] -- [boson, with arrow=0.99, quarter left, edge label=$$q$$] b
-- [photon, quarter left] c [dot]
-- [charged boson, quarter left, edge label=$$q$$] d [crossed dot]
-- [charged boson, quarter left, edge label=$$q$$] a,
f1 -- c,
i1 -- a,
};
\end{document}


• +1 Nice solution with the charged dot! I would suggest passing small for the first diagram so the two diagrams have the same sized dots? – Troy Jun 30 '17 at 15:41
• As I mention in the answer, I think it is either/or. Personally, I would put small in both, but and leave somewhat longer external lines, but some people prefer short external lines and I'm really just illustrating both options. – JP-Ellis Jun 30 '17 at 15:42
• I see. Also, I don't quite understand why the q on the second diagram is not centered on the arrow? – Troy Jun 30 '17 at 15:44
• The discrepancy in the second diagram is because of the slight asymmetry in the lines. The dot and crossed dot aren't the same sizes, so the arcs are actually lopsided to begin with. The momentum arrows (and thus momentum labels) suffer of the same lopsidedness. – JP-Ellis Jun 30 '17 at 15:49
• @JP-Ellis Please see my updated question. – Casimir Jun 30 '17 at 16:23

For your second diagram:

% !TEX TS-program = lualatex
\RequirePackage{luatex85}
\documentclass{standalone}

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

\begin{document}

$\feynmandiagram [horizontal=a to b, layered layout, baseline=(a.base)] { {i1,i2} -- a [dot] -- [charged boson,half left,edge label=$$q$$] b [crossed dot] -- [charged boson,half left,edge label=$$q$$] a, };$

\end{document}


Or with custom arrow tips:

% !TEX TS-program = lualatex
\RequirePackage{luatex85}
\documentclass{standalone}

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

\tikzfeynmanset{ with arrow/.style = {
decoration={
markings,
mark=at position 0.5
with {\arrow[xshift=1mm]{Stealth[width=2mm,length=2mm]}}
},
postaction=decorate}
}

\begin{document}

$\feynmandiagram [horizontal=a to b, layered layout, baseline=(a.base)] { {i1,i2} -- a [dot] -- [charged boson,half left,edge label=$$q$$] b [crossed dot] -- [charged boson,half left,edge label=$$q$$] a, };$

\end{document}


Same with the first diagram:

% !TEX TS-program = lualatex
\RequirePackage{luatex85}
\documentclass{standalone}

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

\tikzfeynmanset{ with arrow/.style = {
decoration={
markings,
mark=at position 0.5
with {\arrow[xshift=1mm]{Stealth[width=1.8mm,length=1.8mm]}}
},
postaction=decorate}
}

\begin{document}
$\feynmandiagram [horizontal'=a to c,inline=(a.base)] { a [dot] -- [charged boson,half left,edge label=$$q$$] c [dot] -- [charged boson,quarter left,edge label=$$q$$] d [crossed dot, yshift=0.4cm] -- [charged boson,quarter left,edge label=$$q$$] a, f1[yshift=-0.465cm] -- c, i1[yshift=-0.465cm] -- a, };$
\end{document}


• I tried charged boson too but the arrows don't look very nice on those snake lines. – Casimir Jun 30 '17 at 15:34