SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2k stars 362 forks source link

Okular opens .tex file instead of .pdf #1561

Open RJDan opened 2 years ago

RJDan commented 2 years ago

Building a tex file results in Okular trying to open the .tex file instead of the pdf.

I think this may be a snap issue but I can't be sure. I recently move both Okular and sublime from the ppa install to snaps. Both work fine but building the .tex file results in the following error:

Could not open file:///home/XXXX/.cache/sublime-text-3/Cache/LaTeXTools/dbf46e7462bf661bf33ff56bbe21196e/FILE_220529.pdf%23src:36/home/XXXX/FILE_220529.tex. 

When I sway to using Evince, it does not start up at all on build (also snap package).

Okular : Version 20.12.3 Sublime Text: Stable Channel, Build 4126 Ubuntu Jammy Asus Tuf A15

ig0774 commented 1 year ago

So, this isn’t going to solve things, but a bit of a comment on what’s happening here:

In order for forward and reverse sync to work, i.e., to open the PDF at the “same” spot as in the editor and vice versa, when opening the PDF file in Okular, we pass the file and line number in the TeX file in addition to the PDF name. This is done via a hash so we end up running something like:

okular file://<path_to_pdf>.pdf#src:<line>:<path_to_tex>.tex

This is a URL that should resolve to the PDF with a locator (the bit after the #) to tell it where it goes.

In the error message you show above, the # has been converted to %23, so when this gets to Okular, it isn’t being interpreted correctly.

I’m not exactly sure where that conversion from # -> %23 is happening, but it’s outside of LaTeXTools itself.