vscode中关于lateX的setting.json配置文件后编译不生效的问题
·
修改过程:
大家在第一次使用vscode中的latex_workshop插件时肯定会对setting.json文件进行环境配置,但本人按照教程配置结束后发现还是编译不了.tex文件,搜索过后还是无果,查看log信息后发现报告了两处可疑信息:
第一处:
error: spawn xelatex ENOEN
第二处:
Does the executable exist? $PATH: undefined,
这两处报告信息都说明是路径问题,搜索过后网上的修改意见有两点:
第一点:检查环境变量是否添加了texlive的bin文件路径,在这里笔者将系统和用户变量路径都添加过了,依旧无效。
第二点:与anaconda环境变量冲突,IDE先搜索的是anaconda的bin路径,笔者将texlive的bin路径移动到anaconda前面还是无效。
最终结果:
笔者最后尝试修改setting.json文件中的信息:
教程部分代码如下:
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
]
这是用来链接texlive中latex工具的代码,笔者尝试将其中的路径修改为绝对路径,即修改成:
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "C:\\texlive\\2024\\bin\\windows\\xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "C:\\texlive\\2024\\bin\\windows\\pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "C:\\texlive\\2024\\bin\\windows\\latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "C:\\texlive\\2024\\bin\\windows\\bibtex",
"args": [
"%DOCFILE%"
]
}
],
测试之后发现可以成功编译测试文件,测试文件下载地址:Click here to download the LaTeX testfile for vscode
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)