jlaurens / synctex

Synchronization for TeX
MIT License
57 stars 19 forks source link

Go to source does not work with TiKz axes #2

Closed okomarov closed 6 years ago

okomarov commented 7 years ago

The issue happens with TeXstudio. The following MWE reproduces the issue (all necessary files are attached).

\documentclass{article}
\usepackage{pgfplots,tikz}
    \pgfplotsset{compat=newest}

\begin{document}
text text text
\begin{figure}
    \include{avg_time}
    \caption{caption caption caption caption}
\end{figure}
\end{document}

All files, .tex .pdf .synctex and included tikz .tex, are available here./

I could look into it, but I might need a pointer where the issue might be.

jlaurens commented 7 years ago

Hi,

this is most certainly due to the inner synctex algorithm. It fails sometimes due to inappropriate heuristics. Unfortunately, there are so many different situations that no unique synctex policy may exist. I should take a look at this point when I have time. NB: Usually, I compare with Texworks behaviour to see how the frontend is involved. J. Laurens

jlaurens commented 7 years ago

More technical details for further insight. Next sources give almost the same .synctex file. We can see that the tikzpicture creates a new h box with 0 width, height and depth, with many glue nodes inside. This box "catches" synchronization too much.

\documentclass{article}
\usepackage{tikz}
\begin{document}
A
B
%\begin{tikzpicture}\end{tikzpicture}%
C
D
\end{document}

and

\documentclass{article}
\usepackage{tikz}
\begin{document}
A
B
\begin{tikzpicture}\end{tikzpicture}%
%
C
D
\end{document}

BTW, it seems that we have to insert a void line in order to have the same line numbers for corresponding nodes with/without tikzpicture. That would suggest that line numbering is not properly managed by the SyncTeX technology inside the TeX engine, a deeper look is needed. J. Laurens

jlaurens commented 6 years ago

Works better with synctex 1.20. Maybe we must wait some time before changes are available in clients.