4

ORIGINAL QUESTION: I have major problems compiling Feynman diagrams produced with the tikz-feynman package with lualatex. To make it less likely that I am just sloppy, I copied the example from this nice answer.

\documentclass[tikz, border=10pt]{standalone}

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

\begin{document}
\begin{tikzpicture}
  \begin{feynman}
    \diagram [vertical'=a to b, edges={red}] {
      i1 -- [fermion] a -- [fermion] f1,
      a -- [photon] b,
      i2 -- [fermion] b -- [fermion] f2,
    };

    \vertex [above right=of f1] (k1);
    \vertex [below right=of f1] (p1);
    \vertex [below right=of f2] (k2);
    \vertex [above right=of f2] (p2);

    \diagram* {
      (f1) -- [fermion] (k1),
      (f1) -- [photon] (p1),
      (f2) -- [fermion] (k2),
      (f2) -- [photon] (p2),
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

Given that this the accepted answer, it is probably safe to assume that there was a time when this could be compiled. However, when I compile it on my updated TeXLive2018 distribution with lualatex, I get the error message

! Package pgf Error: Graph drawing library 'circular' not found.

EXTRA INFORMATION: This question was marked as a duplicate (by myself) of this question. Indeed, if one uses the accepted answer to fix it, one may arrive at

\documentclass[tikz, border=10pt]{standalone}
\usepackage{luacode}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}

\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}
\begin{tikzpicture}
  \begin{feynman}
    \diagram [vertical'=a to b, edges={red}] {
      i1 -- [fermion] a -- [fermion] f1,
      a -- [photon] b,
      i2 -- [fermion] b -- [fermion] f2,
    };

    \vertex [above right=of f1] (k1);
    \vertex [below right=of f1] (p1);
    \vertex [below right=of f2] (k2);
    \vertex [above right=of f2] (p2);

    \diagram* {
      (f1) -- [fermion] (k1),
      (f1) -- [photon] (p1),
      (f2) -- [fermion] (k2),
      (f2) -- [photon] (p2),
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

enter image description here

The good news is that the error is gone. However, the output looks really different from the output of the original answer

enter image description here

in that the photon vertex on the top right has move to the left. When I marked my answer as a duplicate, I did not carefully check that the output is OK. Now I did, and realized that the output produced using Henri's fix produces unexpected results. Therefore, I'd like to reopen the question.

  • Workaround only. Copy texmf-dist/tex/generic/pgf/graphdrawing/tex/pgflibrarygraphdrawing.code.tex into the current direcroty and try the following: change line 1093 if resolvers then to if false then – Akira Kakuto Oct 13 '18 at 5:57
  • 2
    There is already a question and also a pgf bug report about this.sourceforge.net/p/pgf/bugs/493 – Ulrike Fischer Oct 13 '18 at 6:56
  • 2
    The obvious solution is to use picture mode instead of tikz-pgf – David Carlisle Oct 13 '18 at 8:31
  • 1
    @marmot: I'm only suggesting that the problem is caused by differences of versions of used lua. I don't know a solution. – Akira Kakuto Oct 15 '18 at 21:12
  • 1
    @JP-Ellis It is not the seed that changed but the whole RNG. Lua 5.2 used the C standard library rand() function, whereas Lua 5.3 uses the POSIX random() function. Therefore you get entirely different random numbers even with the same seed. – Henri Menke Jan 2 at 4:10
2

With the latest master branch of my TikZ/PGF development repository it compiles fine, but thanks to new features in Lua 5.3 some graphs might appear mirrored. There are workarounds for this but no backwards compatibility will be provided by TikZ.

\documentclass[tikz, border=10pt]{standalone}
\usepackage{luacode}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}

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

\begin{document}
\begin{tikzpicture}
  \begin{feynman}
    \diagram [vertical'=a to b, edges={red}] {
      i1 -- [fermion] a -- [fermion] f1,
      a -- [photon] b,
      i2 -- [fermion] b -- [fermion] f2,
    };

    \vertex [above right=of f1] (k1);
    \vertex [below right=of f1] (p1);
    \vertex [below right=of f2] (k2);
    \vertex [above right=of f2] (p2);

    \diagram* {
      (f1) -- [fermion] (k1),
      (f1) -- [photon] (p1),
      (f2) -- [fermion] (k2),
      (f2) -- [photon] (p2),
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.