"Goto Source" opens pgflibraryfadings.code.tex

I had a similar problem when using the tikzlibrary "shadows".

As proposed here, if the library is not being used, removing it "solves" the problem.

%\usetikzlibrary{shadows}

After debugging that problem for a while (It bothers me, too, currently), I've came up with a work-around. But please use with care: I found the source of the problem, but I don't really know what I'm doing here ;-)

After debugging for a while, I found out that libraries/pgflibraryfadings.code.tex (note, all paths are relative to /usr/share/texlive/texmf-dist/tex/generic/pgf/) is included from frontendlayer/tikz/libraries/tikzlibraryfadings.code.tex and uses the macro \pgfdeclarehorizontalshading, which is defined in basiclayer/pgfcoreshade.code.tex. This uses \pgfsys@horishading which is defined in systemlayer/pgfsys-pdftex.def and contains somewhere the line \immediate\pdfxform resources ... in the definition of \pgfsys@horishading, and this is the main culprit. The problem seems to be the \immediate which ships out something immediately to the PDF and seems to confuse pdflatex. If you remove the \immediate everything seems to work fine. So I would propose the following workflow:

  1. Copy /usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.def to your current tex working directory.
  2. Locate the lines containing \immediate\pdfxform after \def\pgfsys@horishading#1#2#3{%, \def\pgfsys@vertshading#1#2#3{%, and \def\pgfsys@radialshading#1#2#3{% and remove the \immediate.
  3. The shading stuff still works for me, but maybe before the final build, you want to remove the file pgfsys-pdftex.def from your working directory again, to be sure the original version is used.