19

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.

Gregory Cosac
  • 193
  • 1
  • 1
  • 4

3 Answers3

46

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:
    • mac: cmd+click
    • windows/linux: 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",
dexteritas
  • 9,161
Jojo
  • 1,048
  • 2
    Thank you so much! Indeed, the latex-workshop.synctex.afterBuild.enabled value was "false". Must have been that. Working fine now. Thanks again!! – Gregory Cosac Apr 15 '20 at 22:23
  • 3
    What are the commands on "normal" (not mac) keyboards? I found "windows"+click to go from pdf to code. What is the back? – user855443 Dec 01 '20 at 09:24
  • To add to the accepted answer. On a Mac to go from pdf to code you use "command" + click. – Foivos Jun 27 '23 at 08:25
5

Try Ctrl + click on windows. It works for me according to this issue filed on GitHub.

odunayo12
  • 161
  • I had LaTex workshop and everything updated and installed correctly. This worked like a charm, thanks. – Matteo Sep 11 '21 at 10:33
0

Another possible cause for the problem is the (automatic) deletion of the synctex files. Some people dislike the cluttering due to the number of auxiliary files that are generated, and might modify the tex build to remove them. If the synctex files are deleted, this functionality is no longer provided, and the fix is simply to keep these files. I feel like this is a particularly easy problem to unknowingly create for newbies (talking from personal experience here), but did not find this answer on StackExchange.

Diego
  • 113