SolvedLaTeX Workshop Synctex inverse search doesn't work half the time (and How I got forward search to work for SumatraPDF)
✔️Accepted Answer
Yes browser works indeed. My apologies.
However, still this is a maybe good work-around, and not a solution. People perfer dedicated viewer to browser for a range of different reasons. Right now it really hurts that, with SumatraPDF for example, one simply can't have inverse-search.
Other Answers:
I can not start SumatraPDF by using cmd
and list the viewer as an arg.
However, I found another workaround for this problem that I can call C:\Program Files\Microsoft VS Code\bin\code.cmd
instead of C:\Program Files\Microsoft VS Code\Code.exe
from SumatraPDF. Everything works now, except a black window flash around when doing the inverse search.
@qcts33 Black window occurs if you use C:\Program Files\Microsoft VS Code\bin\code.cmd
for invoking reverse sync. It can be very slow and is annoying as the black window blocks the screen.
The code.cmd just makes a call to code.exe which can be directly used in SumatraPDF to circumvent the black box. Based on where your vscode is installed, your inverse search setting in SumatraPDF should look something like
"C:\Program Files\Microsoft VS Code\Code.exe" "C:\Program Files\Microsoft VS Code\resources\app\out\cli.js" -g "%f":"%l"
Description
In SumatraPDF, double clicking should initiate a inverse search, but it doesn't work, IF the SumatraPDF instance is fired up by VS Code. If the SumatraPDF is opened independently, backward search will work.
LaTeX Workshop Output
Developer Tools Console
How to reproduce
Get any .tex compiled to pdf with synctex enabled.
Put this in user settings. Use "external" as pdf viewer.
In VS Code, use 'Synctex from cursor', the forward search works. Inverse search doesn't. In the fired up SumatraPDF, with double clicking, nothing happens.
If you check the fired up SumatraPDF, in settings - Options - Set inverse search command-line you will see
"code.exe" -g "%f:%l"
.However, if you fire up SumatraPDF independently, and put this into settings - Options - Set inverse search command-line
The inverse search actually works. This just let SumatraPDF to execute the commandline with 'goto` command to code.
I don't understand why the SumatraPDF instance initiated by VS Code can't perform inverse search, but the independent ones can. I also notice that, the SumatraPDF instance fired up by VS Code will also exit, if you close VS Code. Are they connected somehow? How to get around this problem?
Thank you.
Expected behavior
Described above.
Actual behavior
Described above.
Additional Information
I have read previous external pdf viewer issues, and I do understand the frustration of dealing with them. Here I would like to contribute a little bit by getting SumatraPDF to work.
I am using win7, VS Code 1.23.1 zip. Updated LW.
Synctex forward search with SumatraPDF
The default setting in LW doesn't work for SumatraPDF. To enable SumatraPDF with forward synctex search, put this in the user-settings:
This is assuming SumatraPDF and VS Code are in the system PATH.