# Wrapping a Feynman diagram in an ellipse or a circle?

I used a variation of the following code in order to create Feynman like diagram in latex using the answer in Drawing a scattering Feynman diagram with TikZ However, I want to wrap the diagram inside a circle or an ellipse? Does anybody can suggest how I can do this?

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}

\begin{document}

\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}

\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label=left:$e^{-}$] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label=right:$e^{-}$] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label=left:$e^{-}$] (e3);
\coordinate[below right=of aux2,label=right:$e^{-}$] (e4);

\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\end{tikzpicture}
\end{document}


One option would be to use the fit library; to use an ellipse you will also need the shapes library:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,fit}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}

\begin{document}

\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}

\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label={[xshift=-3pt]left:$e^{-}$}] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label={[xshift=6pt]right:$e^{-}$}] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label={[xshift=-6pt]left:$e^{-}$}] (e3);
\coordinate[below right=of aux2,label={[xshift=3pt]right:$e^{-}$}] (e4);

\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\node[draw,line width=3pt,circle,fit=(e1) (e4),inner sep=.5\pgflinewidth] {};
\end{tikzpicture}
\end{document}


Instead of ultra thick, you could use thick, or line width=<length> for finer control:

\node[draw,line width=3pt,circle,fit=(e1) (e4),inner sep=0pt] {};


A new request has been made in a comment:

... to "factorize" the internal gluon. In other words, I want to split the gluon line inside into two straight lines both touching the circle at the same point (could be in either left or right but something that looks nice).

In this case, the intersections library can be used to locate the point of intersection between the circle and a horizontal diameter and then use this new point to draw the additional lines:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,fit,intersections,decorations.pathmorphing,decorations.markings}

\begin{document}

\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}

\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label={[xshift=-3pt]left:$e^{-}$}] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label={[xshift=6pt]right:$e^{-}$}] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label={[xshift=-6pt]left:$e^{-}$}] (e3);
\coordinate[below right=of aux2,label={[xshift=3pt]right:$e^{-}$}] (e4);

\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\node[draw,name path=circle,line width=3pt,circle,fit=(e1) (e4),inner sep=.5\pgflinewidth] {};
\path[name path=diameter] let \p1=(aux1), \p2=(aux2)
in (aux1|-0,0.5*\y2+0.5*\y1) -- ++(-3cm,0);% horizontal line from the center to the left
\path[name intersections={of=circle and diameter, by={aux3}}];% find the intersection
\draw[particle] (aux2) -- (aux3);
\draw[particle] (aux3) -- (aux1);
\node[label={[xshift=3pt]left:$m$}] at (aux3) {};
\end{tikzpicture}
\end{document}


• Thank you for your answer. I want to make the circle touch the external lines so i replaced, \node[draw,circle,fit=(e1) (e4),inner sep=0.5pt] {}. Is there a way to make the circle bold and whether there is an efficient way to do it than what I just did? – Voltaire Mar 30 '13 at 20:11
• @anvSnMusater You're welcome; please see my updated answer. For the inner sep value, it's better to use .5\pgflinewidth so you don't have to guess the right value. Also, please remember to up-vote good answers and to accept the ones you consider best solved your problem (two different actions); in case of doubt, please see How do you accept an answer?. – Gonzalo Medina Mar 30 '13 at 20:36
• One thing, that is perhaps trivial but I cant quite do is try to "factorize" the internal gluon. In other words, I want to split the gluon line inside into two straight lines both touching the circle at the same point (could be in either left or right but something that looks nice). I tried something like $\coordinate[above left=of aux2,label={[xshift=-6pt]left:$m$}] (e5);$ and drew \draw[particle] (e5) -- (aux2); \draw[particle] (e5) -- (aux1); Will you be able to offer any suggestion? – Voltaire Mar 30 '13 at 22:06
• @anvSnMusater please see my updated answer. Is something like that what you had in mind? – Gonzalo Medina Mar 31 '13 at 0:01
• this is exactly how i wanted it. thank you very much. – Voltaire Mar 31 '13 at 21:39

This is easy to do with the new tikz-feynman package (see also the project page), based on this answer. The only requirement for using automatic positioning of the vertices is to compile the document with lualatex:

\documentclass[tikz]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\tikzfeynmanset{
every fermion={blue},
every anti fermion={blue},
}
\begin{document}
\begin{tikzpicture}
\begin{feynman}
\diagram [vertical=b to a]{
i1 [particle=$$\textup{e}^{-}$$] -- [fermion] a,
i2 [particle=$$\textup{e}^{-}$$] -- [anti fermion] a,
a  -- [photon,edge label'=$$\gamma$$] b,
b  -- [anti fermion] f1 [particle=$$\textup{e}^{-}$$],
b  -- [fermion] f2 [particle=$$\textup{e}^{-}$$],
};
\draw[red,thick] ($(a)!0.5!(b)$) circle (1.85);
\end{feynman}
\end{tikzpicture}
\end{document}


• I'm the author of TikZ-Feynman! It's amazing to see it being used. Thanks @giordano! – JP-Ellis Feb 4 '16 at 11:35