[Tex/LaTex] Error when using TikZ-Feynman package

errorsfeynmantikz-feynmantikz-pgf

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!

Best Answer

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.