JP-Ellis / tikz-feynman

Feynman Diagrams with TikZ
http://www.jpellis.me/projects/tikz-feynman
Other
146 stars 20 forks source link

Compiler cannot find PGF files even though they exist #62

Closed ominusliticus closed 4 years ago

ominusliticus commented 5 years ago

I hope to communicate this problem as comprehensibly as possible: The file tikzlibraryfeynman.code.tex has these line of code in it

\ifluatex  
    \usetikzlibrary{  
        graphdrawing  
    }  
\usegdlibrary{  
    circular,  
    force,  
    layered,  
    trees  
  }
\fi

And the corresponding ~/MikTex/tex/generic/pgf/graphdrawing/lua/pgf/gd/ has these exact folders in it.

Even the corresponding pgf documents (pgflibrarygraphdrawing.<insert lib name>.code.tex) reference these libraries.

However, when I try to compile my LaTeX document using the LuaLaTeX compiler, it throws me the error "! Package pgf Error: Graph drawing library 'circular' not found." Commenting out that line from the tikzlibraryfeynman.code.tex just causes it to say the next library cannot be found.

More importantly, when I use the XeLaTeX compiler none such errors arise, even if I comment out the entire section above from tikzlibraryfeynman.code.tex.

I run Windows 10 and use the TeXworks IDE to all my typesetting.

Please advise.

Elliot2560 commented 5 years ago

I am experiencing the same issue. I am running texlive on Arch Linux and invoking lualatex via latexmk in Sublime Text.

What's strange is that this was totally working last Friday, and I don't recall making any updates to texlive that would break this. It was working on an old computer with an out-of-date installation of texlive.

I suspect this is a problem with the compiler, not the library, though. Even when tikz-feynman is not loaded, just trying to load graphdrawing and graph drawing libraries with cause the error.

Elliot2560 commented 5 years ago

After some searching, I think the root cause is with pgf. This issue here explains the cause and provides a workaround: https://github.com/u-fischer/luaotfload/issues/6 (Note that for the workaround to work with tikz-feynman, you need to load tikz and graphdrawing before the luacode block, then load tikz-feynman)

ominusliticus commented 5 years ago

So I tried including tikz before tikz-feynman, and that did not work. Are you saying my .STY file should look like this

\usepacakge{tikz}
\usepackage{graphdrawing}
\usepackage{tikz-feynman}

I, myself, am not using any lua code. Just trying to draw diagrams using tex commands.

Elliot2560 commented 5 years ago

No, I'm saying in the preamble you could include something like this:

\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usepackage{luacode}
\begin{luacode}
  function pgf_lookup_and_require(name)
    local sep = '/'
    if string.find(os.getenv('PATH'),';') then
      sep = '\string\\'
    end
    local function lookup(name)
      local sub = name:gsub('%.',sep)
      local find_func = function (name, suffix)
        if resolvers then
          local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
          return (not (n == '')) and n or nil
        else
          return kpse.find_file(name,suffix)
        end
      end
      if find_func(sub, 'lua') then
        require(name)
      elseif find_func(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{tikzfeynman}

The lua code is a workaround that comes from the issue that I linked to in the earlier comment.

ominusliticus commented 5 years ago

I see, I completely misunderstand what that meant. Thank you for clarifying.

JP-Ellis commented 4 years ago

Has this issue been fixed? I don't believe it was a TikZ-Feynman issue in the first place?

Elliot2560 commented 4 years ago

Right, I think this was caused by an error (all the way upstream!) in pgf. According to this comment, the upstream error has been fixed. I tested (using pgf 3.1.4b) with some old documents that experienced this issue before, and they seem to compile fine.

ominusliticus commented 4 years ago

Yes, I just tried running the file I was looking at, at the time; it compiled successfully.