在VS Code中配置LaTeX的最新方法(2021年6月)

目前已经习惯了VS Code写代码,虽然有很多奇葩的地方,但是至少界面看起来比较舒服。LaTeX除了Overleaf,之前使用的是TeX Maker,感觉界面太原始了,就想换成VS Code,参考了下面几个教程:

https://zhuanlan.zhihu.com/p/38178015

https://blog.csdn.net/edward_zcl/article/details/114155507

http://wap.sciencenet.cn/home.php?mod=space&do=blog&id=1251549

很多内容我就不详细介绍了,大家看看这些教程就明白。强调几点:

安装好LaTeX Workshop之后,在VS Code的界面中按F1打开Settings.json,然后这个json文件中增加以下内容:

"latex-workshop.latex.recipes": [

        {

          "name": "pdflatex -> bibtex -> pdflatex*2",

          "tools": [

              "pdflatex",

              "bibtex",

              "pdflatex",

              "pdflatex"

          ]

        }

        ],

        "latex-workshop.latex.tools": [{

        "name": "latexmk",

        "command": "latexmk",

        "args": [

          "-synctex=1",

          "-interaction=nonstopmode",

          "-file-line-error",

          "-pdf",

          "%DOC%"

        ]

        }, {

        "name": "xelatex",

        "command": "xelatex",

        "args": [

          "-synctex=1",

          "-interaction=nonstopmode",

          "-file-line-error",

          "%DOC%"

        ]

        }, {

        "name": "pdflatex",

        "command": "pdflatex",

        "args": [

          "-synctex=1",

          "-interaction=nonstopmode",

          "-file-line-error",

          "%DOC%"

        ]

        }, {

        "name": "bibtex",

        "command": "bibtex",

        "args": [

          "%DOCFILE%"

        ]

        }],

        // "latex-workshop.view.pdf.viewer": "tab",

        "latex-workshop.latex.clean.fileTypes": [

        "*.aux",

        "*.bbl",

        "*.blg",

        "*.idx",

        "*.ind",

        "*.lof",

        "*.lot",

        "*.out",

        "*.toc",

        "*.acn",

        "*.acr",

        "*.alg",

        "*.glg",

        "*.glo",

        "*.gls",

        "*.ist",

        "*.fls",

        "*.log",

        "*.fdb_latexmk"

        ],

        "latex-workshop.view.pdf.viewer": "external",

        "latex-workshop.view.pdf.ref.viewer":"external",

 

        // "latex-workshop.view.pdf.external.viewer.command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",

        "latex-workshop.view.pdf.external.viewer.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe",

 

        "latex-workshop.view.pdf.external.viewer.args": [

        "%PDF%"

        ],

 

        "latex-workshop.view.pdf.external.synctex.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe",

        // "latex-workshop.view.pdf.external.synctex.command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",

 

        "latex-workshop.view.pdf.external.synctex.args":[

        "-forward-search",

        "%TEX%",

        "%LINE%",

        "-reuse-instance",

        "-inverse-search",

        // "\"D:/Program Files/Microsoft VS Code/Code.exe\" -r -g \"%f\":%l",

        "\"D:/Program Files/Microsoft VS Code/Code.exe\" \"D:/Program Files/Microsoft VS Code/resources/app/out/cli.js\" -r -g \"%f:%l\"",

        "%PDF%"

        ],

(CSDN感觉不能用了,代码段点不出来)。需要注意的是,大家可以看到预览PDF的工具我尝试了好几个,只有目前用SumatraPDF以及目前这种配置可以实现正向搜索和反向搜索。另外,如果这个json中本来就有内容,可以把上面的这些填到后面,但有可能向我一样,前面的一个设置选项后面没有逗号:"python.languageServer": "Pylance"  导致会报Expected Comma,这时候只需要给前面加上逗号即可。另外,VS Code的路径大家要改成自己机子上的。

另外,如果不能正常换行的话,把View——Toggle Word Wrap前的对号选上即可。

2021年6月10日更新:发现这样默认安装的话,LaTeX没有拼写检查的功能,解决方法也很简单,在VS Code Extension里搜索“LTeX”即可,具体可以参考这里:https://zhuanlan.zhihu.com/p/92670838

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值