[Tex/LaTex] “Go to Source” for Latex on VS Code does not seem to work

visual-studio-code

I am currently trying to migrate to VS Code (on Mac) for creating and editing tex files. Everything has been working just fine except that, when I build and preview, I do not seem to be able to use the "Go to source" feature. In other words, I have a side by side split window, tex file on the left and PDF on the right, and what I wish do is to be able to click on the PDF preview and be taken to the source code on the left. Likewise, I would like to click on the code and be taken to the PDF on the right.

I have the LaTeX Preview extension installed which is supposed to do that, but the 'Show in Preview' button is absolutely inert, as well as double-clicking (or ctrl+click) the PDF. I have even considered the hypothesis that the name of the files might have had special characters, so I ran a test with a file named 'test.tex', and it still doesn't work.

I am digging around, trying to learn something about synctex in this link but I'm really out of my element here. Would appreciate some help.

Thanks in advance.

Best Answer

I recommend installing LaTeX Workshop instead of LaTeX Preview.

Then use the following shortcuts for synctex (aka 'jumping' between code and pdf):

  • from code to pdf:
    • mac: cmd+option+j
    • windows/linux: ctrl+alt+j
  • from pdf to code: ctrl+click

Make sure to enable synctex in the settings.json.

"latex-workshop.synctex.synctexjs.enabled": true,
"latex-workshop.synctex.afterBuild.enabled": true,
"latex-workshop.view.pdf.viewer": "tab",
Related Question