# Feynman diagram with a loop in TikZ-Feynman, explained

> A one-loop Feynman diagram inside an equation with TikZ-Feynman, explained: \feynmandiagram, inline, half left loops, and two pdfLaTeX-safe variations.

URL: https://www.labcanvas.com/tikz/examples/physics/feynman-diagram-with-a-loop

Updated 2026-11-22. Original figure: Feynman diagram with a loop, © Janosh Riebesell and contributors, MIT licence (licence text: https://www.labcanvas.com/tikz-library/credits.html#janosh), from https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/feynman-diagram-loop/feynman-diagram-loop.tex. Walkthrough and variations by LabCanvas; the variation code is CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/). Pictures typeset with TeX Live 2026 and PGF 3.1.12. Category: [TikZ physics examples](https://www.labcanvas.com/tikz/examples/physics).

## 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.

## 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.](https://www.labcanvas.com/tikz-snippets/fig-feynman-diagram-with-a-loop/original.webp)

Copyright (c) 2021 Janosh Riebesell, MIT licence (https://www.labcanvas.com/tikz-library/credits.html#janosh). The code below is exactly the library's file (pdfLaTeX); its first lines name the source and the licence, and the MIT licence asks that they stay with the code. Open it in the TikZ editor from the page: https://www.labcanvas.com/tikz/examples/physics/feynman-diagram-with-a-loop

```latex
% 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](https://www.labcanvas.com/tikz/feynman): `\feynmandiagram`, vertex styles (`dot`, `crossed dot`), propagators and `half left` loops.
- [Physics diagrams](https://www.labcanvas.com/tikz/physics-diagrams): Feynman diagrams alongside other physics figures and their conventions.
- [Pictures inside text and maths](https://www.labcanvas.com/tikz/tikzpicture): aligning a picture with the surrounding line: `inline`, `baseline` and `\raisebox`.
- [Curved edges](https://www.labcanvas.com/tikz/graphs): the graph syntax `a -- [options] b` that TikZ-Feynman builds on.

## Variations

Our own code, CC0 1.0, each typeset with TeX Live 2026 in a standalone document with the preamble lines shown.

### 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.](https://www.labcanvas.com/tikz-snippets/fig-feynman-diagram-with-a-loop/manual-vertices.webp)

*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}`

```latex
\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}
```

### 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.](https://www.labcanvas.com/tikz-snippets/fig-feynman-diagram-with-a-loop/self-energy-equation.webp)

*the one-loop electron self-energy as an equation: the picture aligned with baseline=*

Preamble: `\usepackage{tikz}`, `\usepackage[compat=1.1.0]{tikz-feynman}`

```latex
$\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$
```

## 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

- [janosh/diagrams at commit 7a79b31: assets/feynman-diagram-loop/feynman-diagram-loop.tex (MIT licence)](https://github.com/janosh/diagrams/blob/7a79b3114e201fad9b6785e936eab859d1bc8c12/assets/feynman-diagram-loop/feynman-diagram-loop.tex)
- [TikZ-Feynman manual (v1.1.0, PDF on CTAN): §3.1 commands, §3.2 keys (inline, dot, crossed dot, charged boson, half left)](https://mirrors.ctan.org/graphics/pgf/contrib/tikz-feynman/tikz-feynman.pdf)
- [TikZ-Feynman package on CTAN (v1.1.0, 2016-02-05)](https://ctan.org/pkg/tikz-feynman)
- [PGF/TikZ manual, §12.2.1 Creating a Picture Using an Environment (baseline)](https://tikz.dev/tikz-scopes#sec-12.2.1)
- [LaTeX2e unofficial reference manual, §20.4 \raisebox](https://latexref.xyz/_005craisebox.html)

## TikZ guides for these techniques

- [TikZ-Feynman: Feynman diagrams in LaTeX](https://www.labcanvas.com/tikz/feynman): Draw Feynman diagrams with TikZ-Feynman 1.1.0: vertices, fermion, photon, gluon and scalar lines, momentum arrows, manual vs LuaLaTeX layout, loops.
- [TikZ physics diagrams: forces, springs, optics, waves and fields](https://www.labcanvas.com/tikz/physics-diagrams): Physics diagrams in TikZ with code: free-body diagram, inclined plane, spring and pendulum, a lens ray diagram, waves, energy levels and a dipole field.
- [The tikzpicture environment: options, scaling and centring](https://www.labcanvas.com/tikz/tikzpicture): The tikzpicture environment: its options, scale vs transform shape vs \resizebox, centring it in a figure with a caption, and inline TikZ with baseline.
- [TikZ graphs: drawing networks of vertices and edges](https://www.labcanvas.com/tikz/graphs): Graph theory drawings in TikZ: vertices and edges by hand, directed and weighted graphs, loops, the \graph syntax, K_n and C_n, and automatic layouts.
