[Tips] Mac 下vs code无法找到latex命令

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"
            ]
        }
    ],
posted @ 2022-02-08 15:50  虚无真仙  阅读(2358)  评论(0编辑  收藏  举报