[Tex/LaTex] “Goto Source” opens pgflibraryfadings.code.tex


Edit: Seems to be a problem with SyncTeX, as TeXworks reacts the same.
Edit2: same problem with texlive in Win7.

I have a similiar problem as described in TeXstudio Bugreport 1225
but with menukeys-package.

consider the following MWE for reconstructing the problem:


\keys{CTRL + X} in \directory{File/Save As}

It compiles fine, but when I click on "Goto Source" in the embedded viewer, pgflibraryfadings.code.tex is opened instead. This only happens on the first page of any document. Any clues on a fix?

I use MiKTeX 2.9 (64bit), TeXstudio 2.10.8 on a Win7 machine.

Secondary setup:
TeX Live 2015, TeXworks, Win7

Best Answer

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.
Related Question