TikZ-Feynman

TikZ-Feynman is a LaTeX package allowing Feynman diagrams to be easily generated within LaTeX with minimal user instructions and without the need of external programs. It builds upon the TikZ package and leverages the graph placement algorithms from TikZ in order to automate the placement of many vertices. TikZ-Feynman still allows fine-tuned placement of vertices so that even complex diagrams can still be generated with ease.

TikZ-Feynman is made available through the Comprehensive TeX Archive Network (CTAN) and comes with some thorough documentation containing a tutorial and many examples. I have also submitted the documentation for v1.0.0 on the arXiv. If you use TikZ-Feynman, please cite:

Joshua Ellis. ‘TikZ-Feynman: Feynman diagrams with TikZ’. arXiv: 1601.05437 [hep-ph]

TikZ-Feynman is open source and contribution are welcome. If you have any suggestions, feature requests, or have found any bugs, feel free to create a new issue or pull request on Github.

Below are a few example to demonstrate how easy diagram can be, and how extensible it can be. Many more are given in the documentation:

QED Example
1
2
3
4
5
\feynmandiagram [horizontal=a to b] {
  i1 -- [fermion] a -- [fermion] i2,
  a -- [photon] b,
  f1 -- [fermion] b -- [fermion] f2,
};
Penguin Example
1
2
3
4
5
6
\feynmandiagram [large, vertical=e to f] {
  a -- [fermion] b -- [photon, momentum=\(k\)] c -- [fermion] d,
  b -- [fermion, momentum'=\(p_{1}\)] e -- [fermion, momentum'=\(p_{2}\)] c,
  e -- [gluon]  f,
  h -- [fermion] f -- [fermion] i;
};
Mixing Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
\begin{tikzpicture}
  \begin{feynman}
    \vertex (a1) {\(\overline b\)};
    \vertex[right=1cm of a1] (a2);
    \vertex[right=1cm of a2] (a3);
    \vertex[right=1cm of a3] (a4) {\(b\)};
    \vertex[right=1cm of a4] (a5);
    \vertex[right=2cm of a5] (a6) {\(u\)};

    \vertex[below=2em of a1] (b1) {\(d\)};
    \vertex[right=1cm of b1] (b2);
    \vertex[right=1cm of b2] (b3);
    \vertex[right=1cm of b3] (b4) {\(\overline d\)};
    \vertex[below=2em of a6] (b5) {\(\overline d\)};

    \vertex[above=of a6] (c1) {\(\overline u\)};
    \vertex[above=2em of c1] (c3) {\(d\)};
    \vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2);

    \diagram* {
      {[edges=fermion]
        (b1) -- (b2) -- (a2) -- (a1),
        (b5) -- (b4) -- (b3) -- (a3) -- (a4) -- (a5) -- (a6),
      },
      (a2) -- [boson, edge label=\(W\)] (a3),
      (b2) -- [boson, edge label'=\(W\)] (b3),

      (c1) -- [fermion, out=180, in=-45] (c2) -- [fermion, out=45, in=180] (c3),
      (a5) -- [boson, bend left, edge label=\(W^{-}\)] (c2),
    };

    \draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west)
          node [pos=0.5, left] {\(B^{0}\)};
    \draw [decoration={brace}, decorate] (c3.north east) -- (c1.south east)
          node [pos=0.5, right] {\(\pi^{-}\)};
    \draw [decoration={brace}, decorate] (a6.north east) -- (b5.south east)
          node [pos=0.5, right] {\(\pi^{+}\)};
  \end{feynman}
\end{tikzpicture}

Submitting with TikZ-Feynman

One of TikZ-Feynman's strengths is its simple syntax which is only possible by having vertex positioned automatically by graph drawing algorithms which are implement in the Lua scripting language. As a result, LuaTeX is required to compile documents that use TikZ-Feynman. Although LuaTeX is intended to supplant pdfTeX, the latter remains the standard when it comes to submitting to journals and the arXiv. Fortunately, there is a way to both use TikZ-Feynman and still submit to journals as long as they use a version of TikZ released after 2013.

Changelog

In order to make it easier for people to keep up to date with new releases of TikZ-Feynman, TikZ-Feynman's versioning approximately follows semantic versioning, and it is recommended that users load the package with \usepackage[compat=x.y.z]{tikz-feynman}. A log of the important changes is kept here, and a complete log of every change is kept through the commit history on Github.