Setting forward search and inverse search in SumatraPDF for LaTeX-Workshop
29 Jan 2025To set up forward and inverse search in SumatraPDF using LaTeX Workshop extention in Visual Studio Code, follow these steps:
Configure SumatraPDF
One of the following two methods can be used:
-
Method 1
1.1. Open SumatraPDF.
1.2. Go to
Settings>Options....1.3. In the
Inverse Search Command Linefield, enter the following command:"C:\path\to\Visual Studio Code\Code.exe" -r -g "%f:%l" -
Input the following text into the
SumatraPDF-settings.txtfile located in the same directory as SumatraPDF:
InverseSearchCmdLine = "C:\\path\\to\\Visual Studio Code\\Code.exe" "%f" -line %l
Configure LaTeX Workshop
- Open your
settings.jsonfile in Visual Studio Code. -
Add or update the following settings:
{ "latex-workshop.latex.autoBuild.run": "onSave", "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click", "latex-workshop.view.pdf.viewer": "external", "latex-workshop.view.pdf.external.viewer.command": "D:\\Program Files\\SumatraPDF-3.5.2-64\\SumatraPDF-3.5.2-64.exe", "latex-workshop.view.pdf.external.viewer.args": [ "-forward-search", "%TEX%", "%LINE%", "-reuse-instance", "-inverse-search", "\"C:\\Users\\liand\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"C:\\Users\\liand\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"", "%PDF%" ], "latex-workshop.view.pdf.external.synctex.command": "D:\\Program Files\\SumatraPDF-3.5.2-64\\SumatraPDF-3.5.2-64.exe", "latex-workshop.view.pdf.external.synctex.args": [ "-forward-search", "%TEX%", "%LINE%", "-reuse-instance", "-inverse-search", "\"C:\\Users\\liand\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"C:\\Users\\liand\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"", "%PDF%" ] }