VS Code+Sumatra PDF正反向搜索
重新裝機后,在配置VS Code和LaTeX的環(huán)境后,問題卡在了正反向搜索這邊,簡單記錄下。
綜合參考以下鏈接:
[VS Code + Tex Live + SumatraPDF配置LaTeX反向搜索(持續(xù)更新)](https://blog.csdn.net/yihuajack/article/details/123877375)
[解決SumatraPDF 在VS Code上反向搜索失效](https://www.jianshu.com/p/2b21384e0638)
[Sumatra PDF反向搜索的問題記錄 (texlive+vscode)](https://zhuanlan.zhihu.com/p/447892378)
正向
在安裝LaTeX Workshop后,打開VS Code的settings.json

首先是配置基本的命令參數(shù),常用的就是這三種
? ?"latex-workshop.latex.tools": [
? ? ? ?{
? ? ? ? ? ?"name": "xelatex",
? ? ? ? ? ?"command": "xelatex",
? ? ? ? ? ?"args": [
? ? ? ? ? ? ? ?"-synctex=1",
? ? ? ? ? ? ? ?"-interaction=nonstopmode",
? ? ? ? ? ? ? ?"-file-line-error",
? ? ? ? ? ? ? ?"-pdf",
? ? ? ? ? ? ? ?"%DOCFILE%"
? ? ? ? ? ?]
? ? ? ?},
? ? ? ?{
? ? ? ? ? ?"name": "pdflatex",
? ? ? ? ? ?"command": "pdflatex",
? ? ? ? ? ?"args": [
? ? ? ? ? ? ? ?"-synctex=1",
? ? ? ? ? ? ? ?"-interaction=nonstopmode",
? ? ? ? ? ? ? ?"-file-line-error",
? ? ? ? ? ? ? ?"%DOCFILE%"
? ? ? ? ? ?]
? ? ? ?},
? ? ? ?{
? ? ? ? ? ?"name": "bibtex",
? ? ? ? ? ?"command": "bibtex",
? ? ? ? ? ?"args": [
? ? ? ? ? ? ? ?"%DOCFILE%"
? ? ? ? ? ?]
? ? ? ?}
? ?],
然后是由上述基本命令引出的編譯鏈
? ?"latex-workshop.latex.recipes": [
? ? ? ?{
? ? ? ? ? ?"name": "xelatex",
? ? ? ? ? ?"tools": [
? ? ? ? ? ? ? ?"xelatex"
? ? ? ? ? ?]
? ? ? ?},
? ? ? ?{
? ? ? ? ? ?"name": "pdflatex",
? ? ? ? ? ?"tools": [
? ? ? ? ? ? ? ?"pdflatex"
? ? ? ? ? ?]
? ? ? ?},
? ? ? ?{
? ? ? ? ? ?"name": "xe->bib->xe->xe",
? ? ? ? ? ?"tools": [
? ? ? ? ? ? ? ?"xelatex",
? ? ? ? ? ? ? ?"bibtex",
? ? ? ? ? ? ? ?"xelatex",
? ? ? ? ? ? ? ?"xelatex"
? ? ? ? ? ?]
? ? ? ?},
? ? ? ?{
? ? ? ? ? ?"name": "pdf->bib->pdf->pdf",
? ? ? ? ? ?"tools": [
? ? ? ? ? ? ? ?"pdflatex",
? ? ? ? ? ? ? ?"bibtex",
? ? ? ? ? ? ? ?"pdflatex",
? ? ? ? ? ? ? ?"pdflatex"
? ? ? ? ? ?]
? ? ? ?}
? ?],
接著配置外部PDF閱讀器
? ?"latex-workshop.view.pdf.viewer": "external",
? ?"latex-workshop.view.pdf.ref.viewer": "external",
? ?"latex-workshop.view.pdf.external.viewer.command": "C:/Users/AppData/Local/SumatraPDF/SumatraPDF.exe",
接下來才是正向搜索:
首先保證
.gz
不會被刪除同樣地,在
settings.json
寫入配置
"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",
? ? ? ?"%PDF%"
? ?],
有人在latex-workshop.view.pdf.external.synctex.args
加入反向搜索的命令,但其實不會起作用,反向搜索只要在Sumatra PDF中設(shè)置就可以了
設(shè)置正向搜索等快捷鍵,打開
keybindings.json
{
? ? ? ?"key": "alt+s",
? ? ? ?"command": "latex-workshop.synctex",
? ? ? ?"when": "editorTextFocus && !isMac"
? ?},
? ?{
? ? ? ?"key": "alt+b",
? ? ? ?"command": "latex-workshop.build",
? ? ? ?"when": "editorTextFocus && !isMac"
? ?},
? ?{
? ? ? ?"key": "alt+t",
? ? ? ?"command": "latex-workshop.kill",
? ? ? ?"when": "editorTextFocus && !isMac"
? ?},
? ?{
? ? ? ?"key": "alt+e",
? ? ? ?"command": "latex-workshop.recipes"
? ?},
這樣就可以通過alt+s
來正向搜索
反向
在Sumatra PDF的設(shè)置->選項中,設(shè)置反向搜索命令:
"C:\Users\AppData\Local\Programs\Microsoft VS Code\Code.exe" "C:\Users\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js" --ms-enable-electron-run-as-node -r -g "%f":"%l"
第一個參數(shù)是VS Code的所在位置
第二個參數(shù)的
cli.js
和第三個參數(shù)的--ms-enable-electron-run-as-node
VS Code+Sumatra PDF正反向搜索的評論 (共 條)
