vs code中安裝了latex language support和latex workshop,配置了setting json后, 運行編譯latex無反應,檢查log發現有如下報錯:
Does the executable exist? PATH: /usr/bin:/bin:/usr/sbin:/sbin
這是因為vscode的PATH讀取的不完整,找不到用戶后期(主要在/.bashrc或/.zshrc)添加的PATH信息。
可以如下修改setting json,將latex的命令路徑補充完整,從而避免這個問題:
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "/Library/TeX/texbin/xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "/Library/TeX/texbin/latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "/Library/TeX/texbin/pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "/Library/TeX/texbin/bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],