VScode使用latex-workshop配置latex

西门磊
2023-12-01

settings.json:(代码出处

{
    "latex-workshop.latex.tools": [
      {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
        ]
      },
      {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
        ]
      },
      {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
          "%DOCFILE%"
        ]
      }
    ],
  
  
    "latex-workshop.latex.recipes": [
      {
        "name": "pdflatex",
        "tools": [
          "pdflatex"
        ]
      },
      {
        "name": "xelatex",
        "tools": [
          "xelatex"
        ]
      },
      {
        "name": "xe->bib->xe->xe",
        "tools": [
          "xelatex",
          "bibtex",
          "xelatex",
          "xelatex"
        ]
      },
      {
        "name": "pdflatex -> bibtex -> pdflatex*2",
        "tools": [
          "pdflatex",
          "bibtex",
          "pdflatex",
          "pdflatex"
        ]
      }
    ],
  
    "latex-workshop.latex.autoBuild.run": "never",
    "latex-workshop.synctex.afterBuild.enabled": true,

    //配置外部pdf阅读器
    "latex-workshop.view.pdf.viewer": "external",
    "latex-workshop.view.pdf.external.viewer.command": "D:/Tools/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.viewer.args": [
      "%PDF%"
    ], 
    //配置正向搜索
    "latex-workshop.view.pdf.external.synctex.command": "D:/Tools/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.synctex.args": [
      "-forward-search",
      "%TEX%",
      "%LINE%",
      "%PDF%"
    ],
    "latex-workshop.showContextMenu":true,   //右键菜单
    "security.workspace.trust.untrustedFiles": "open",
  }

sumatrapdf 选项 ,双击执行的命令填写

"D:\VSCode\Microsoft VS Code\Code.exe" "D:\VSCode\Microsoft VS Code\resources\app\out\cli.js"  --ms-enable-electron-run-as-node -r -g "%f:%l"

高级设置 替换两个设置:

InverseSearchCmdLine = "D:\Tools\VSCode\install path\Microsoft VS Code\Code.exe" "D:\Tools\VSCode\install path\Microsoft VS Code\resources\app\out\cli.js"  --ms-enable-electron-run-as-node -r -g "%f:%l"
EnableTeXEnhancements = true

注意地址改成自己的安装地址,反斜杠方向。

 类似资料: