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?

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

Secondary setup: TeX Live 2015, TeXworks, Win7


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.
| improve this answer | |
  • thanks for the effort, but please don't be upset when I don't mark this as "accepted". I'd like to have the problem solved on a more permanent level and of course without the hacking around. I've tested your method and it does work, but it's too much of a hassle to do this everytime. I'd appreciate if you could send your findings to the DEV team of the respective package. much obliged – naphaneal Feb 13 '17 at 18:53
  • 3
    I posted it here: sourceforge.net/p/pgf/bugs/333. However, I think its best to have both: a quick fix to continue working, and to have it fixed upstream. – Elmar Zander Feb 14 '17 at 12:42

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.

| improve this answer | |
  • There isn't much to add to my post. The problem is described above by naphaneal and the solution, as stated in the 2nd sentence of my post, is to remove the library if not used. Nevertheless, I made some modifications to my post. – SebastianRV Jul 26 '17 at 8:30
  • To be precise, the problem is with tikzlibrary "fadings", which "shadows" internally uses. You may also encounter the same issue with other things that use "fadings", such as the todonotes package. – Disenchanted Lurker Dec 5 '19 at 10:40

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.