# Tikz-Feynman plots messed up in Texstudio

I try to compile the following file -

\documentclass[]{article}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram[inline=(b),vertical=a to b, green!40!black] {
a -- b -- {c [particle=$$c$$], d [particle=$$d$$]}
};
\end{document}


But instead of getting the image in the left, I get the on on the right - How to fix this?

• I'm guessing you need to compile with lualatex. – Torbjørn T. Nov 30 '18 at 23:15
• @TorbjørnT. Then I get errors like "Package pgf Error: Graph drawing library 'trees' not found. " and "Package pgfkeys Error: I do not know the key '/tikz/graphs/spring layout' " – proton Nov 30 '18 at 23:19
• There are some problems with the graph drawing algorithms, which have been addressed here. However, AFAIK this issue has not yet been fixed. So, if I am not mistaken, you may want to try not to use the graph drawing algorithms, but this diagram is simple enough. – marmot Nov 30 '18 at 23:21

## 1 Answer

You must compile with LuaLaTeX in order to get the expected output. However, due to a bug in the Lua code, some fix is necessary, see https://sourceforge.net/p/pgf/bugs/493/ and https://tex.stackexchange.com/a/453157/4427

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usepackage{luacode}

\begin{luacode*}
function pgf_lookup_and_require(name)
local sep = package.config:sub(1,1)
local function lookup(name)
local sub = name:gsub('%.',sep)
if kpse.find_file(sub, 'lua') then
require(name)
elseif kpse.find_file(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
\end{luacode*}

\usepackage[compat=1.1.0]{tikz-feynman}

\begin{document}

\feynmandiagram[inline=(b),vertical=a to b, green!40!black] {
a -- b -- {c [particle=$$c$$], d [particle=$$d$$]}
};

\end{document}