jlaurens / synctex

Synchronization for TeX
MIT License
64 stars 19 forks source link

Setting page background will influence the synctex location #46

Closed mazhe1988 closed 2 years ago

mazhe1988 commented 2 years ago

I am not sure if I ask the question in the right place. I ask this in the Stackexchange but no answer. I am using TeXstudio editor. When I set a background picture using the \addtohooknext command. It influence the Synctex locations always pointing to the end of the page not the actual text which I typed in.

Here is a simple example, I create the document that first page with background and second page without background:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\AddToHookNext{shipout/background}{%
    \put (0in,-\paperheight){\includegraphics{background.pdf}}%
}
\section{part 1}
This is the part one.
\section{part 2}
This is the part two.
\section{part 3}
This is the part three.
\section{part 4}
This is the part four.
\section{part 5}
This is the part five.
\section{part 6}
This is the part six.
\newpage
\section{part 7}
This is the part seven.
\section{part 8}
This is the part eight.
\section{part 9}
This is the part nine.
\section{part 10}
This is the part ten.
\section{part 11}
This is the part eleven.
\section{part 12}
This is the part twelve.
\end{document}

In the output pdf viewing, if you Ctrl+click the word in first page, it always pointing to the \newpage line. But in the second page, it actually pointing to the word I typed in. I have been tested using the background package, eso-pic package as well. They all giving same results. I think a workaround could be using a \colorbox to setting the background color but it won't fit to the whole page. Also it only allowed to setting simple color background not a actual picture background. The background.pdf was just a simple drawing using inkscape. The left and bottom side with gray color strip in the picture. background.pdf Is there a way to add background to the page, and make synctex still working properly?