VScode+latex+Sumatra 环境设置

[复制链接]
发表于 2026-2-22 16:43:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
安装Tex Live 及Vscode

此处参考博客:VScode+latex+Sumatra PDF环境设置(步步到位)举行安装。
本文重要记载设置的json文件设置。
  1. {
  2.     "latex-workshop.latex.autoBuild.run": "never",
  3.     "latex-workshop.synctex.afterBuild.enabled":true,
  4.     "latex-workshop.showContextMenu": true,
  5.     "latex-workshop.intellisense.package.enabled": true,
  6.     "latex-workshop.message.error.show": false,
  7.     "latex-workshop.message.warning.show": false,
  8.     "latex-workshop.latex.tools": [
  9.         {
  10.             "name": "xelatex",
  11.             "command": "xelatex",
  12.             "args": [
  13.                 "-synctex=1",
  14.                 "-interaction=nonstopmode",
  15.                 "-file-line-error",
  16.                 "%DOC%"
  17.             ]
  18.         },
  19.         {
  20.             "name": "pdflatex",
  21.             "command": "pdflatex",
  22.             "args": [
  23.                 "-synctex=1",
  24.                 "-interaction=nonstopmode",
  25.                 "-file-line-error",
  26.                 "%DOC%"
  27.             ]
  28.         },
  29.         {
  30.             "name": "latexmk",
  31.             "command": "latexmk",
  32.             "args": [
  33.                 "-synctex=1",
  34.                 "-interaction=nonstopmode",
  35.                 "-file-line-error",
  36.                 "-pdf",
  37.                 "-outdir=%OUTDIR%",
  38.                 "%DOC%"
  39.             ]
  40.         },
  41.         {
  42.             "name": "bibtex",
  43.             "command": "bibtex",
  44.             "args": [
  45.                 "%DOCFILE%"
  46.             ]
  47.         }
  48.     ],
  49.     "latex-workshop.latex.recipes": [
  50.         {
  51.             "name": "XeLaTeX",
  52.             "tools": [
  53.                 "xelatex"
  54.             ]
  55.         },
  56.         {
  57.             "name": "PDFLaTeX",
  58.             "tools": [
  59.                 "pdflatex"
  60.             ]
  61.         },
  62.         {
  63.             "name": "BibTeX",
  64.             "tools": [
  65.                 "bibtex"
  66.             ]
  67.         },
  68.         {
  69.             "name": "LaTeXmk",
  70.             "tools": [
  71.                 "latexmk"
  72.             ]
  73.         },
  74.         {
  75.             "name": "xelatex -> bibtex -> xelatex*2",
  76.             "tools": [
  77.                 "xelatex",
  78.                 "bibtex",
  79.                 "xelatex",
  80.                 "xelatex"
  81.             ]
  82.         },
  83.         {
  84.             "name": "pdflatex -> bibtex -> pdflatex*2",
  85.             "tools": [
  86.                 "pdflatex",
  87.                 "bibtex",
  88.                 "pdflatex",
  89.                 "pdflatex"
  90.             ]
  91.         },
  92.     ],
  93.     "latex-workshop.latex.clean.fileTypes": [
  94.         "*.aux",
  95.         "*.bbl",
  96.         "*.blg",
  97.         "*.idx",
  98.         "*.ind",
  99.         "*.lof",
  100.         "*.lot",
  101.         "*.out",
  102.         "*.toc",
  103.         "*.acn",
  104.         "*.acr",
  105.         "*.alg",
  106.         "*.glg",
  107.         "*.glo",
  108.         "*.gls",
  109.         "*.ist",
  110.         "*.fls",
  111.         "*.log",
  112.         "*.fdb_latexmk"
  113.     ],
  114.     "latex-workshop.latex.autoClean.run": "onFailed",
  115.     "latex-workshop.latex.recipe.default": "lastUsed",   
  116.     "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
  117.    
  118.     // 设置VScode内部查看生成的pdf文件
  119.     "latex-workshop.view.pdf.viewer": "external",
  120.     // PDF查看器用于在\ref上的[View on PDF]链接
  121.     "latex-workshop.view.pdf.ref.viewer":"auto",
  122.     // 使用外部查看器时要执行的命令。此功能不受官方支持。
  123.     "latex-workshop.view.pdf.external.viewer.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径
  124.     // 使用外部查看器时,latex-workshop.view.pdf.external.view .command的参数。此功能不受官方支持。%PDF%是用于生成PDF文件的绝对路径的占位符。
  125.     "latex-workshop.view.pdf.external.viewer.args": [
  126.         "%PDF%"
  127.     ],
  128.     // 将synctex转发到外部查看器时要执行的命令。此功能不受官方支持。
  129.     "latex-workshop.view.pdf.external.synctex.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径
  130.     // latex-workshop.view.pdf.external.synctex的参数。当同步到外部查看器时。%LINE%是行号,%PDF%是生成PDF文件的绝对路径的占位符,%TEX%是触发syncTeX的扩展名为.tex的LaTeX文件路径。
  131.     "latex-workshop.view.pdf.external.synctex.args": [
  132.         "-forward-search",
  133.         "%TEX%",
  134.         "%LINE%",
  135.         "-reuse-instance",
  136.         "-inverse-search",
  137.         ""D:\\Program Files\\Microsoft VS Code\\Code.exe" "D:\\Program Files\\Microsoft VS Code\\resources\\app\\out\\cli.js" --ms-enable-electron-run-as-node -r -g "%f:%l"",
  138.     ],
  139. }
复制代码
此中指令行表现编译完成后自动打开pdf。
   “latex-workshop.synctex.afterBuild.enabled”:true,
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表