14

Today I downloaded and installed the new TikZ-Feynman package to draw Feynman diagrams. I included the packages

\usepackage{tikz} 
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.0.0}
\usetikzlibrary{shapes,arrows,positioning,automata,backgrounds,calc,er,patterns}

into my preamble (changed them already many times).

However, already a simple sample code like

\begin{tikzpicture}
\begin{feynman}
\vertex (a) {\(\mu^{-}\)};
\vertex [right=of a] (b);
\vertex [above right=of b] (f1) {\(\nu_{\mu}\)};
\vertex [below right=of b] (c);
\vertex [above right=of c] (f2) {\(\overline \nu_{e}\)};
\vertex [below right=of c] (f3) {\(e^{-}\)};
\diagram* {
(a) -- [fermion] (b) -- [fermion] (f1),
(b) -- [boson, edge label'=\(W^{-}\)] (c),
(c) -- [anti fermion] (f2),
(c) -- [fermion] (f3),
};
\end{feynman}
\end{tikzpicture}

directly gives the error:

Package pgfkeys Error: I do not know the key '/graph drawing/node distance'.

Can you please help me? Thanks in advance!

1 Answer 1

19

You need to compile with lualatex!

If compiled width pdflatex, there's a warning message

Package tikz-feynman Warning: LuaTeX is required if you wish to have vertices a
utomatically placed. You can disable this warning by setting /tikzfeynman/warn 
luatex=false on input line 8.

However, disabling the warning does not cure the problem.

Unfortunately the tikz-feynman manual does not reveal anything about the usage of lualatex. It seems to be a hidden feature or the package author relied that this is known.

\documentclass{article}

\usepackage{tikz} 
\usetikzlibrary{shapes,arrows,positioning,automata,backgrounds,calc,er,patterns}
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.0.0}

\begin{document}
\begin{tikzpicture}
\begin{feynman}
\vertex (a) {\(\mu^{-}\)};
\vertex [right=of a] (b);
\vertex [above right=of b] (f1) {\(\nu_{\mu}\)};
\vertex [below right=of b] (c);
\vertex [above right=of c] (f2) {\(\overline \nu_{e}\)};
\vertex [below right=of c] (f3) {\(e^{-}\)};
\diagram* {
(a) -- [fermion] (b) -- [fermion] (f1),
(b) -- [boson, edge label'=\(W^{-}\)] (c),
(c) -- [anti fermion] (f2),
(c) -- [fermion] (f3),
};
\end{feynman}
\end{tikzpicture}
\end{document}

Here's the image produced for that apparent muon-decay

enter image description here


EDIT

As mentioned in the comment below, this was a bug in TikZ-Feynman in v1.0.0. As of v1.1.0, TikZ-Feynman issues warnings whenever a feature requiring LuaLaTeX is used.

If you still try using the automatic graph placement algorithms and don't use LuaLaTeX, a very simple algorithm is used which generates something like:

enter image description here

If you see this output, you'll either need to change compiler to LuaLaTeX, or manually position the location of the vertices.

3
  • 4
    I'm the package author. Happy to see people using it! Indeed, it was an oversight on my part in the documentation... In the process of revising the documentation I ended up removing all mentions that it must be compiled with LuaLaTeX. Additionally, the error you mention has been reported and fixed. I'm intending to release an update very soon with all the fixes.
    – JP-Ellis
    Feb 4, 2016 at 11:12
  • @JP-Ellis: Thanks, that's very nice
    – user31729
    Feb 4, 2016 at 11:29
  • 1
    @JP-Ellis I get such warning message even when I explicitly and manually set the position of all points (I start by placing one point at (0, 0) and then specify others points relative to it with left, below...). So does it mean that LuaLaTeX is always required?
    – zyy
    May 27, 2021 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .