LabCanvas

Feynman diagram with a loop in TikZ-Feynman, explained

Quick answer

This figure is an equation whose right-hand side is a Feynman diagram: an external line ending at a dot, and a loop of two charged-boson propagators, each labelled q, running to a crossed-dot vertex and back. It is written with TikZ-Feynman’s one-line form, \feynmandiagram, which places the vertices by itself, and inline=(a.base) aligns the diagram with the equation. The loop is two edges with half left, from a to b and from b back to a, each bending through half a circle.

Contents

The figure and its code

An equation: partial t of partial V over partial chi equals a Feynman diagram in which a straight line runs from the left to a black dot, from which two wavy lines with arrows, each labelled q, form a circle to a crossed circle on the right.
Feynman diagram with a loop, typeset with TeX Live 2026 (pdfLaTeX) from the code below, exactly as it is in janosh/diagrams.
Copyright (c) 2021 Janosh Riebesell · MIT licence (full text). The licence asks that this notice stay with the code: keep the first lines when you reuse it.
% Feynman diagram with a loop
% Source: https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/feynman-diagram-loop/feynman-diagram-loop.tex
% Copyright (c) 2021 Janosh Riebesell. MIT licence: https://github.com/janosh/diagrams/blob/main/license
% The licence’s copyright and permission notice: https://www.labcanvas.com/tikz-library/credits.html
\documentclass{standalone}

\usepackage{tikz-feynman}

\begin{document}
$\displaystyle\partial_t \frac{\partial V}{\partial \chi}
  = \raisebox{0.5ex}{\feynmandiagram [inline=(a.base)] {
  i1 -- a [dot]
  -- [charged boson, half left, edge label=$q$] b [crossed dot]
  -- [charged boson, half left, edge label=$q$] a,
  };}$
\end{document}

One package for everything

Lines 5–9 of the code

The document is a standalone page that loads only \usepackage{tikz-feynman}, which loads TikZ and the libraries it needs. There is no compat option, so the package prints a warning suggesting \usepackage[compat=1.1.0]{tikz-feynman}; adding it, as the variations do, silences the warning and records the version the code was written for. Without the tikz class option, standalone still crops the page to its content, here a line of maths.

An equation with a diagram in it

Lines 10–11 of the code

The picture is ordinary inline maths: $\displaystyle\partial_t \frac{\partial V}{\partial \chi} sets the fraction at display size, then the = sign and the diagram. \feynmandiagram is TikZ-Feynman’s shorthand that opens a tikzpicture and a feynman environment and reads a whole diagram in one argument. The key inline=(a.base) aligns the diagram vertically on the vertex named a and, according to the manual, also applies styles that make the diagram fit an equation (it is smaller than a stand-alone diagram). The diagram is wrapped in \raisebox{0.5ex}{…}, LaTeX’s command to lift a box, which raises it a little more so that its straight line sits near the height of the = sign rather than on the baseline.

The diagram in the graph syntax

Lines 12–15 of the code

The diagram is a chain of vertices and edges. i1 -- a [dot] creates two vertices on the fly, the external point i1 and a, drawn as a filled dot, and joins them with a plain line. -- [charged boson, half left, edge label=$q$] b [crossed dot] continues from a to a new vertex b, drawn as a small circle with a cross. The edge options set the propagator style (charged boson: a wavy line with an arrow), the shape (half left: bend through half a circle, to the left of the direction of travel) and a label. The last edge goes from b back to a with the same options; because a name used again is the same vertex, the two half circles close into a loop. The comma ends the chain, and }; ends the diagram.

Who places the vertices?

Lines 12–15 of the code

No vertex has a coordinate: \feynmandiagram hands them to TikZ’s graph drawing algorithms, which are written in Lua and need LuaLaTeX. The library compiles this file with pdfLaTeX, where TikZ-Feynman falls back to a simpler placement and warns that LuaTeX is required for automatic placement. For this short chain, from i1 -- a [dot] to the loop, the fallback is good enough, as the picture shows; for diagrams with several external legs it tends to pile vertices on top of each other. Two fixes: compile with lualatex, or give every vertex a position with \vertex and draw the edges with \diagram*, which works with any engine, as in the first variation.

Techniques used

  • TikZ-Feynman \feynmandiagram, vertex styles (dot, crossed dot), propagators and half left loops.
  • Physics diagrams Feynman diagrams alongside other physics figures and their conventions.
  • Pictures inside text and maths aligning a picture with the surrounding line: inline, baseline and \raisebox.
  • Curved edges the graph syntax a -- [options] b that TikZ-Feynman builds on.

Variations

Our own code, written for this page and typeset with TeX Live 2026 like the figure above. Each one is a complete example: copy it, or open it in the TikZ editor and change it. This code is CC0 1.0, free to use without conditions.

The same loop with vertices placed by hand

For a result that does not depend on the engine, place the three vertices with \vertex … at (x,y) and list the edges in \diagram*, the starred form that uses the given positions instead of a layout algorithm. A vertex with a style such as dot needs empty braces, {}, to become a node that can be drawn. The edge options are the same as in the original.

A straight line from the left to a black dot, and two wavy lines with arrows labelled q forming a circle from the dot to a crossed circle on the right.
the external line and the charged-boson loop with manually placed vertices (pdfLaTeX or LuaLaTeX)
Preamble: \usepackage{tikz} \usepackage[compat=1.1.0]{tikz-feynman}
\begin{tikzpicture}
  \begin{feynman}
    % the vertices placed by hand: the same result with pdfLaTeX and LuaLaTeX
    \vertex (i1) at (0,0);
    \vertex [dot] (a) at (1.6,0) {};
    \vertex [crossed dot] (b) at (3.6,0) {};
    \diagram* {
      (i1) -- (a),
      (a) -- [charged boson, half left, edge label=\(q\)] (b),
      (b) -- [charged boson, half left, edge label=\(q\)] (a),
    };
  \end{feynman}
\end{tikzpicture}
Open in the TikZ editor
Full document
A complete file you can compile as it is.
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{tikzpicture}
  \begin{feynman}
    % the vertices placed by hand: the same result with pdfLaTeX and LuaLaTeX
    \vertex (i1) at (0,0);
    \vertex [dot] (a) at (1.6,0) {};
    \vertex [crossed dot] (b) at (3.6,0) {};
    \diagram* {
      (i1) -- (a),
      (a) -- [charged boson, half left, edge label=\(q\)] (b),
      (b) -- [charged boson, half left, edge label=\(q\)] (a),
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

A diagram in an equation with baseline

An electron self-energy written as an equation, the usual home of loop diagrams. Instead of inline and \raisebox, the picture gets baseline={([yshift=-0.5ex]a)}: the baseline of the tikzpicture is put 0.5ex below the vertex a, so the fermion line sits at the height of the = sign. The vertices are placed by hand, so this compiles with pdfLaTeX as well.

The equation minus i Sigma of p equals a diagram, followed by plus dots: a straight fermion line with arrows and the momentum p, with a wavy photon line labelled k arching over its middle from one vertex to the other.
the one-loop electron self-energy as an equation: the picture aligned with baseline=
Preamble: \usepackage{tikz} \usepackage[compat=1.1.0]{tikz-feynman}
$\displaystyle
-i\Sigma(p) \;=\;
\begin{tikzpicture}[baseline={([yshift=-0.5ex]a)}]
  \begin{feynman}
    \vertex (i) at (0,0);
    \vertex (a) at (1.1,0);
    \vertex (b) at (2.7,0);
    \vertex (o) at (3.8,0);
    \diagram* {
      (i) -- [fermion, momentum=\(p\)] (a) -- [fermion] (b) -- [fermion] (o),
      (a) -- [photon, half left, momentum=\(k\)] (b),
    };
  \end{feynman}
\end{tikzpicture}
\;+\;\dots$
Open in the TikZ editor
Full document
A complete file you can compile as it is.
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
$\displaystyle
-i\Sigma(p) \;=\;
\begin{tikzpicture}[baseline={([yshift=-0.5ex]a)}]
  \begin{feynman}
    \vertex (i) at (0,0);
    \vertex (a) at (1.1,0);
    \vertex (b) at (2.7,0);
    \vertex (o) at (3.8,0);
    \diagram* {
      (i) -- [fermion, momentum=\(p\)] (a) -- [fermion] (b) -- [fermion] (o),
      (a) -- [photon, half left, momentum=\(k\)] (b),
    };
  \end{feynman}
\end{tikzpicture}
\;+\;\dots$
\end{document}

Frequently asked questions

How do I draw a loop in TikZ-Feynman?

Connect two vertices twice with half left: a -- [fermion, half left] b -- [fermion, half left] a. Each edge bends through half a circle, so together they close into a loop. looseness changes how round it is.

Why do my TikZ-Feynman vertices overlap?

Automatic placement (\feynmandiagram, or \diagram without positions) needs LuaLaTeX; under pdfLaTeX TikZ-Feynman warns and falls back to a basic placement. Compile with LuaLaTeX, or place the vertices with \vertex and draw the edges with \diagram*, which works with pdfLaTeX.

How do I put a Feynman diagram inside an equation?

Use \feynmandiagram [inline=(a.base)] {…}; inside the maths, or a tikzpicture with baseline=… set to a vertex, as in the second variation. Both align the diagram with the line of the equation.

References

  1. janosh/diagrams at commit 7a79b31: assets/feynman-diagram-loop/feynman-diagram-loop.tex (MIT licence)github.com
  2. TikZ-Feynman manual (v1.1.0, PDF on CTAN): §3.1 commands, §3.2 keys (inline, dot, crossed dot, charged boson, half left)mirrors.ctan.org
  3. TikZ-Feynman package on CTAN (v1.1.0, 2016-02-05)ctan.org
  4. PGF/TikZ manual, §12.2.1 Creating a Picture Using an Environment (baseline)tikz.dev
  5. LaTeX2e unofficial reference manual, §20.4 \raiseboxlatexref.xyz

The walkthrough was checked against these sources and the pictures are the code typeset with TeX Live 2026. The original figure is © Janosh Riebesell and contributors, under the MIT licence; the variations on this page are ours, CC0 1.0.

TikZ guides for these techniques

More figures explained

Change this figure in your browserOpen the figure or any variation in the free TikZ editor: it is typeset with TeX Live as you type, with errors pointed at their line.

Open the figure in the TikZ editor