# Synctex fails for input files. Related to fancyhdr + graphicx?

I have run into a problem with the synctex option of pdflatex that seems to be related to the fancyhdr and graphicx package.

Problem: Forward and inverse search between editor and PDF viewer work only for the root.tex and don't work for the tex file included via \input{input.tex}.

Fwd/Inv search does work, as soon as I remove the JPG from the header.

Here's a stripped down, short example of the problem (root.tex):

\documentclass{report}

\usepackage{fancyhdr}
\usepackage{graphicx}

\pagestyle{fancy}

\fancypagestyle{plain}{
\rhead{\includegraphics[height = 1 cm, trim = 0cm 5cm 0cm 5cm, clip]{pic.jpg} }
}

\begin{document}

\tableofcontents
\pagebreak

\chapter{main document}

main main main

main main main

main main main

\input{input.tex}

\end{document}


input.tex looks as follows:

\chapter{input chapter}
input input input

input input input

input input input


pic.jpg is a 1700x800px 110KB file in the original, but the problem also occurs for smaller files.

The PDF output looks correct. Both tex files are in the synctex file. But forwards and inverse search don't work for input.tex in the example above. The problem occurs identically in both following configurations:

• Win7 x64
• Miktex
• Sublime Text 3 + LatexTools (using texify)
• SumatraPDF

and

• Linux Mint 17.2 x64
• TeXlive
• Sublime Text 3 + LatexTools (using latexmk)
• Evince

Any ideas how to fix that or where that problem might come from?

• I can reproduce the problem (with example-image), and I had it once in a larger document too: In one chapter sync didn't work. As far as I can see the clip option is the problem. But it is unclear how exactly (in my larger document there were no images in the header, I had them in floats.). It helps to put a \newpage before the \input. Aug 25, 2015 at 13:32
• The problem seems indeed related to the clip option. My problem is, however, the whole thing is part of a huge project and I'm only supposed to edit the input.tex. In this case \newpage doesn't help, unfortunately.
– dd23
Aug 25, 2015 at 13:36
• I don't know why clip confuses the synctex infos. It doesn't help to put the graphics in a box. Perhaps @HeikoOberdiek has an idea. But as a workaround you could move the content to input-a.tex, and write \newpage\input{input-a} in your current input file. Aug 25, 2015 at 14:05
• The problems is still there, even if I add a \newpage before the \input in the example above. Did that solve the problem for you?
– dd23
Aug 25, 2015 at 14:53
• Yes, but I didn't use exactly your example: During the tests I at first tried to store the graphic in a box and used \rhead{\usebox{\myheaderimagebox}}. This makes a difference. Aug 26, 2015 at 7:56

This (longstanding) bug seems to be resolved in TeXlive 2017. The maintainer has committed "a number of nontrivial changes to fix that \pdfxform issue".