# Positioning a vertex directly above another vertex in feynMF

I have been trying to replicate this Feynman diagram with feynMF. (Image from [1]).

The first part, the double line, is rather easy, as it is already present in feynMF as the heavy style. For the crossed inside a circle, I used \fmfcmd to define a new style that I call crossed (I still haven't figured out how to reuse that without putting the style definition in each \fmffile environment, hence the verbosity of the code below).

Now, doing the obvious, i.e.

\begin{fmfgraph*}(60,60)
\fmfleft{i1}
\fmfright{o1}
\fmf{fermion}{i1,v1,v2,o1}
\fmffreeze
\fmftop{t1,t2}
\fmf{crossed}{t1,v1}
\fmf{crossed}{t2,v2}
\end{fmfgraph*}


results in the photon propagators to have an unpleasant looking angle (see the third diagram).

I have also tried to place vertices at specific locations, and then drawing the paths manually with the immedidate mode of feynMF, with limited success. I have tried the following snippet.

\begin{fmfgraph*}(60,60)
\fmfleft{i1}
\fmfright{o1}
\fmf{fermion}{i1,v1,v2,o1}
\fmffreeze
\fmfipair{t1,t2}
\fmfiequ{t1}{vloc(__v1) shifted (0,5mm)}
\fmfiequ{t2}{vloc(__v2) shifted (0,5mm)}
\fmfiv{d.sh=circle}{t1}
\fmfiv{d.sh=circle}{t2}
\fmfi{crossed}{vpath(__v1,__t1)}
\fmfi{crossed}{vpath(__v2,t2)}
\end{fmfgraph*}


The reasoning is as follows. I draw the fermion line first, and define the vertices on this line using the automatic mode of feynMF, i.e. with \fmfleft and the other usual commands. Then, after calling \fmffreeze, I switch to using the immediate mode. Then I declare a METAFONT pair with \fmfipair and set to a value that is shifted from the vertices v1 and v2. I then try to draw vertices at these locations and draw paths between v1, v2 and the shifted vertices, t1 and t2. The code, however, leads to a

! Illegal suffix of declared variable will be flushed.
1
l.15 pair t1
,t2;
?


error. What's wrong with my use of the immediate mode? Or of METAFONT? Is there a more direct way of doing what I want?

For reference, I have included the complete code below.

P.-S. I have tried tikz-feynman and it can indeed be done easily with this package, but I do not like the way loops look and I have issues with the baseline when they are included in equations.

$$\begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmffile}{dressed-propagator} \begin{fmfgraph*}(60,20) \fmfleft{i1} \fmfright{o1} \fmf{heavy}{i1,o1} \end{fmfgraph*} \end{fmffile} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture} = \begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmffile}{classical-source} \fmfcmd{% vardef cross_bar (expr p, len, ang) = ((-len/2,0)--(len/2,0)) rotated (ang + angle direction length(p)/2 of p) shifted point 0 of p shifted (0,1.5mm) enddef; style_def crossed expr p = cdraw (wiggly p); ccutdraw cross_bar (p, 3mm, 45); ccutdraw cross_bar (p, 3mm, -45); cdraw fullcircle scaled 3mm shifted point 0 of p shifted (0,1.5mm); enddef;} \begin{fmfgraph*}(60,60) \fmfleft{i1} \fmfright{o1} \fmftop{t1} \fmf{fermion,tension=100}{i1,v1,o1} \fmf{crossed}{t1,v1} \end{fmfgraph*} \end{fmffile} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture} + \begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmffile}{classical-source-2} \fmfcmd{% vardef cross_bar (expr p, len, ang) = ((-len/2,0)--(len/2,0)) rotated (ang + angle direction length(p)/2 of p) shifted point 0 of p shifted (0,1.5mm) enddef; style_def crossed expr p = cdraw (wiggly p); ccutdraw cross_bar (p, 3mm, 45); ccutdraw cross_bar (p, 3mm, -45); cdraw fullcircle scaled 3mm shifted point 0 of p shifted (0,1.5mm); enddef;} \begin{fmfgraph*}(60,60) \fmfleft{i1} \fmfright{o1} \fmf{fermion}{i1,v1,v2,o1} \fmffreeze \fmftop{t1,t2} \fmf{crossed}{t1,v1} \fmf{crossed}{t2,v2} \end{fmfgraph*} \end{fmffile} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture}$$


[1]: S. Meuren, (2015). Nonlinear quantum electrodynamic and electroweak processes in strong laser fields. http://archiv.ub.uni-heidelberg.de/volltextserver/18971/

• You mention that you've had issues with TikZ-Feynman because of the loops and baselines. The baselines can be adjusted with the inline option or even baseline option from TikZ, so I'm curious what your issue is. Regarding the loops, I'm sorry you don't like how they look :/ You can probably customize that with some extra TikZ code though. If you post these questions on TeX.SX, email me, or raise an issue on Github I'll take a look (PS: I created TikZ-Feynman). Curiously, would you like me to still post a TikZ-Feynman answer? – JP-Ellis Feb 29 '16 at 23:32
• @JP-Ellis The baseline issue is indeed a non-issue, just some fiddling required. I need to embed the diagrams in equations, and the direct result is this. I could of course align everything, it's not hard. The look of the loops is not your fault. I tried fiddling with the looseness parameter, but the way I see it, becasue of the path construction, it is hard to have a perfect circle in a loop diagram. Contrast what feynMF gives for the vacuum polarization diagram (i.imgur.com/f4vCMS3.png) to what TikZ-Feynman gives (i.imgur.com/FJC2MTo.png). – Joey Dumont Feb 29 '16 at 23:40
• @JP-Ellis You can still the post the TikZ-Feynman for posterity, but you are right, it is trivially easy to do this with TikZ-Feynman: I just used the manual placement mode, with the feynman environment you provide. In fact, the loops are my only issue with TikZ-Feynman, other than the fact that I have to figure out how to add arbitrary decorations to vertices (although I think you provide the crossed dot decoration already! Great work! ;) – Joey Dumont Feb 29 '16 at 23:42

There is a simpler solution to this problem. To position the vertices on the two lines the same, position them using rows with the same pattern of tensions. Once they have positions use \fmffreeze to fix positions and add the vertical lines.

The horizontal line that is used to position the top vertices would want to be drawn as phantom so it's invisible but would position them using the same algorithms as in the drawn line at the bottom. Using phantom lines is a very powerful tool that can produce many complex diagrams in much easier methods.

It's also possible to have multiple diagrams in one fmffile and then you only need to declare the formats once.

  \begin{fmfgraph*}(60,60)
% Needed so that the different vertices down the side are directly above each other.
\fmfstraight
\fmfleft{i0,i1,i2}
\fmfright{o0,o1,o2}
\fmf{fermion}{i1,v1,v2,o1}
\fmf{phantom}{i2,t1,t2,o2}
\fmffreeze
\fmf{crossed}{t1,v1}
\fmf{crossed}{t2,v2}
\end{fmfgraph*}


The full example is below

\begin{fmffile}{diagram}
\fmfcmd{%
vardef cross_bar (expr p, len, ang) =
((-len/2,0)--(len/2,0))
rotated (ang + angle direction length(p)/2 of p)
shifted point 0 of p shifted (0,1.5mm)
enddef;
style_def crossed expr p =
cdraw (wiggly p);
ccutdraw cross_bar (p, 3mm, 45);
ccutdraw cross_bar (p, 3mm, -45);
cdraw fullcircle scaled 3mm shifted point 0 of p shifted (0,1.5mm);
enddef;}
$$\begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmfgraph*}(60,20) \fmfleft{i1} \fmfright{o1} \fmf{heavy}{i1,o1} \end{fmfgraph*} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture} = \begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmfgraph*}(60,60) \fmfleft{i1} \fmfright{o1} \fmftop{t1} \fmf{fermion}{i1,v1,o1} \fmffreeze \fmf{crossed}{t1,v1} \end{fmfgraph*} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture} + \begin{tikzpicture}[baseline=(current bounding box.center)] \node{ \begin{fmfgraph*}(60,60) \fmfstraight \fmfleft{i0,i1,i2} \fmfright{o0,o1,o2} \fmf{fermion}{i1,v1,v2,o1} \fmf{phantom}{i2,t1,t2,o2} \fmffreeze \fmf{crossed}{t1,v1} \fmf{crossed}{t2,v2} \end{fmfgraph*} }; \path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west); \end{tikzpicture}$$
\end{fmffile}


Output is here

Although this answer doesn't user feynmf, this can be easily achieved in TikZ-Feynman. The only trick is that you have to manually adjust the baseline of diagrams so that the horizontal lines line up with minus and equal signs. Note that lualatex is required in order to exploit automatic positioning of vertices.

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

\begin{document}
$$\begin{split} \feynmandiagram [layered layout, horizontal=a to b, inline=-2.5pt] { a -- [double] b, }; &= \feynmandiagram [layered layout, horizontal=a to b, inline=-2.5pt] { a -- b, }; + \feynmandiagram [layered layout, horizontal=a to b, inline=-2.5pt] { a -- b -- c, {[same layer] b -- [photon] bi [crossed dot]}, }; + \feynmandiagram [layered layout, horizontal=a to b, inline=-2.5pt] { a -- b -- c -- d, {[same layer] b -- [photon] bi [crossed dot]}, {[same layer] c -- [photon] ci [crossed dot]}, }; \\ &\quad + \feynmandiagram [layered layout, horizontal=a to b, inline=-2.5pt] { a -- b -- c -- d -- e, {[same layer] b -- [photon] bi [crossed dot]}, {[same layer] c -- [photon] ci [crossed dot]}, {[same layer] d -- [photon] di [crossed dot]}, }; \end{split}$$
\end{document}


• I added a note about the use of lualatex, it's far from being clear and answers should be self-sufficient ;-). In addition, for lining up the diagrams you don't need to do it manually, but there is the -\the\dimexpr\fontdimen22\textfont2\relax trick by egreg that evaluates automatically to -2.5pt (see tex.stackexchange.com/q/59658#comment126261_59660). – giordano Mar 1 '16 at 12:24
• Thanks for that :) Also, thanks for letting me know of this trick! I was looking for a way to do that more automatically. – JP-Ellis Mar 1 '16 at 14:33
• Quick question, how would modify this code to have the photon above the electron line? – Joey Dumont Mar 8 '16 at 2:28
• @JoeyDumont Replace horizontal= with horizontal'=. The primed version causes an the whole graph to flipped. – JP-Ellis Mar 8 '16 at 2:37

I haven't figured out why the snippet above fails, but I have found a solution to my problem. The relevant snippet is

  \begin{fmfgraph*}(60,60)
% -- Declares the vertices to be used.
\fmfleft{i1}
\fmfright{o1}
\fmftop{t1,t2}

% -- Since we want the diagram to be a straight line,
% -- we use \fmffreeze after drawing only the fermion line.
\fmf{fermion}{i1,v1,v2,o1}
\fmffreeze

% -- We force the position of the top vertices to be directly
% -- above the interaction vertices.
\fmfforce{vloc(__v1) shifted (0,10mm)}{t1}
\fmfforce{vloc(__v2) shifted (0,10mm)}{t2}

% -- We finally draw the paths.
\fmf{crossed}{t1,v1}
\fmf{crossed}{t2,v2}
\end{fmfgraph*}


This results in the following image, which is the desired image.

The use of \fmfforce and \fmfshift are described as last resort in the feynmf documentation, but I think this qualifies, as the use of a skeleton results in the diagrams shown in the original question.

The complete code is, for completeness:

\begin{equation*}
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node{
\begin{fmffile}{dressed-propagator}
\begin{fmfgraph*}(60,20)
\fmfleft{i1}
\fmfright{o1}
\fmf{heavy}{i1,o1}
\end{fmfgraph*}
\end{fmffile}
};
\path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west);
\end{tikzpicture}
=
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node{
\begin{fmffile}{classical-source}
\fmfcmd{%
vardef cross_bar (expr p, len, ang) =
((-len/2,0)--(len/2,0))
rotated (ang + angle direction length(p)/2 of p)
shifted point 0 of p shifted (0,1.5mm)
enddef;
style_def crossed expr p =
cdraw (wiggly p);
ccutdraw cross_bar (p, 3mm, 45);
ccutdraw cross_bar (p, 3mm, -45);
cdraw fullcircle scaled 3mm shifted point 0 of p shifted (0,1.5mm);
enddef;
}
\begin{fmfgraph*}(60,60)
\fmfleft{i1}
\fmfright{o1}
\fmftop{t1}
\fmf{fermion,tension=100}{i1,v1,o1}
\fmf{crossed}{t1,v1}
\end{fmfgraph*}
\end{fmffile}
};
\path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west);
\end{tikzpicture}
+
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node{
\begin{fmffile}{classical-source-2}
\fmfcmd{%
vardef cross_bar (expr p, len, ang) =
((-len/2,0)--(len/2,0))
rotated (ang + angle direction length(p)/2 of p)
shifted point 0 of p shifted (0,1.5mm)
enddef;
style_def crossed expr p =
cdraw (wiggly p);
ccutdraw cross_bar (p, 3mm, 45);
ccutdraw cross_bar (p, 3mm, -45);
cdraw fullcircle scaled 3mm shifted point 0 of p shifted (0,1.5mm);
enddef;
}
\begin{fmfgraph*}(60,60)
\fmfleft{i1}
\fmfright{o1}
\fmftop{t1,t2}
\fmf{fermion}{i1,v1,v2,o1}
\fmffreeze
\fmfforce{vloc(__v1) shifted (0,10mm)}{t1}
\fmfforce{vloc(__v2) shifted (0,10mm)}{t2}
\fmf{crossed}{t1,v1}
\fmf{crossed}{t2,v2}
\end{fmfgraph*}
\end{fmffile}
};
\path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west);
\end{tikzpicture}
\end{equation*}