1.正向索引
在VScode setting.json中添加如下代码,注意将路径替换为自己的SumatraPDF路径和VScode路径。
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "C:/Users/AppData/Local/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "C:/Users/AppData/Local/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"code\"C:/Users/AppData/Local/Programs/Microsoft VS Code/Code.exe\" \"C:/Users/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
"%PDF%",
],
2.反向索引
打开SumatraPDF,点击 选项>>设置>>高级选项,将配置改为如下。
InverseSearchCmdLine = code"C:/Users/Rorschach/AppData/Local/Programs/Microsoft VS Code/Code.exe" "C:/Users/Rorschach/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js" --ms-enable-electron-run-as-node -gr "%f":"%l"
EnableTeXEnhancements = true
注意:如果设置了自动清除的命令,需将.synctex.gz文件注释掉,.synctex.gz文件是Latex转发到外部查看器时的辅助分件,删除将无法正常反向索引。