[Tex/LaTex] tikz-feynman: edge labels

tikz-feynman

I would like to understand how can I label edges of diagrams as at this picture:
enter image description here

I assume that it possible to label vertices and than move each label, but I do not know how. Can anyone gives some suggestions?

What I tried: label each vertex

\begin{feynman}
    \vertex (v1) {\(cl\)};
    \vertex[right=0.5cm of v1] (v2) {\(cl\)};
    \vertex[right=1cm of v2] (v3) {\(cl\)};
    \vertex[right=0.5cm of v3] (v4) {\(cl\)};;
    \diagram*{(v1)--(v2), (v2)--[half left](v3)--[half left](v2),(v3)--(v4)};
\end{feynman}

It is awful. Then, I have tried to label edges:

\begin{feynman}
        \vertex (v1);
        \vertex[right=0.5cm of v1] (v2);
        \vertex[right=1cm of v2] (v3);
        \vertex[right=0.5cm of v3] (v4);
        \diagram*{(v1)--[edge label={\(cl \quad\)}](v2), (v2)--[half left,edge label={\(cl \quad cl\)}](v3)--[half left,edge label={\(cl \quad cl\)}](v2),(v3)--[edge label={\(\quad cl\)}](v4)};
    \end{feynman}

It looks not so awful, but not perfect: labels are so far from edges.

Best Answer

Using hardcoded coordinates like \node(a) at (.6,-.5) {\small cl}; in tikz is a deadly sin, this will break as soon as you change the tiniest thing.

  • to move the labels on the horizontal lines to the start and end of the lines, use near start and near end

  • to move the labels around the circle closer to the line, reduce the inner sep

  • don't use inline math to make multi-letter things italic


% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{tikz-feynman}

\begin{document}

\begin{tikzpicture}
\begin{feynman}
        \vertex (v1);
        \vertex[right=0.5cm of v1] (v2);
        \vertex[right=1cm of v2] (v3);
        \vertex[right=0.5cm of v3] (v4);
        \diagram*{
            (v1)--[edge label={\textit{cl}},near start](v2), 
            (v2)--[half left,edge label={\textit{cl\quad cl}},inner sep=1pt](v3)--[half left,edge label={\textit{cl\quad cl}},inner sep=1pt](v2),
            (v3)--[edge label={\textit{cl}},near end](v4)
        };
    \end{feynman}
 \end{tikzpicture}
\end{document}

enter image description here


Alternatively without any manual intervention, one can let tikz-feynman do it's job:

% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{tikz-feynman}

\begin{document}

\begin{tikzpicture}[inner sep=2pt]
    \itshape
    \begin{feynman}
        \diagram[horizontal=a to f,small]{
            a--[edge label={cl},near start]b, 
            b -- [quarter right,edge label'={cl}] 
            c -- [quarter right,edge label'={cl}] 
            d -- [quarter right,edge label'={cl}] 
            e -- [quarter right,edge label'={cl}] 
            b,
            d--[edge label={cl},near end]f
        };
    \end{feynman}
\end{tikzpicture}

\end{document}

enter image description here

Related Question