LaTeX 通过 VS Code、macOS,解决“食谱因致命错误而终止:spawn Latexmk ENOENT”。错误

613*_*654 1 macos latex path visual-studio-code vscode-extensions

  • 我正在运行 macOS
  • VS Code 已安装并运行
  • 我已经安装了 LaTeX Workshop
  • 我已经安装了 MacTeX
  • 我收到一条“配方因致命错误而终止:spawn Latexmk ENOENT”。' 尝试在 VS Code 中编译 LaTeX 文档时出错

根据文档,我了解我需要设置 PATH 环境变量。但是我不明白(1)这意味着什么,以及(2)如何做。我已按照文档中的链接进行操作,但无法解决我的问题。

任何人都可以协助简化解释设置路径所需的步骤吗?

Mat*_*yne 5

我有同样的错误:Recipe terminated with fatal error: spawn latexmk ENOENT.

\n

我在 macOS (Ventura 13.3.1) 上使用 MacTeX-2023 解决问题所采取的步骤是:

\n
    \n
  1. 在 VSCode 中:
    \na。cmd+shift+P, 选择Preferences: Open User Settings (JSON)
  2. \n
  3. 然后在 json 中,将以下内容粘贴到 {} 中:
  4. \n
\n
"latex-workshop.latex.path": "/Library/TeX/texbin",\n    "latex-workshop.latex.tools": [\n        {\n         "name": "latexmk",\n         "command": "latexmk",\n         "args": [\n          "-synctex=1",\n          "-interaction=nonstopmode",\n          "-file-line-error",\n          "-pdf",\n          "-outdir=%OUTDIR%",\n          "%DOC%"\n         ],\n         "env": {}\n        },\n        {\n         "name": "xelatex",\n         "command": "xelatex",\n         "args": [\n          "-synctex=1",\n          "-interaction=nonstopmode",\n          "-file-line-error",\n          "%DOC%"\n         ],\n         "env": {}\n        },\n        {\n         "name": "pdflatex",\n         "command": "pdflatex",\n         "args": [\n          "-synctex=1",\n          "-interaction=nonstopmode",\n          "-file-line-error",\n          "%DOC%"\n         ],\n         "env": {}\n        },\n        {\n         "name": "bibtex",\n         "command": "bibtex",\n         "args": [\n          "%DOCFILE%"\n         ],\n         "env": {}\n        }\n       ],\n       "latex-workshop.latex.recipes": [\n        {\n         "name": "pdfLaTeX",\n         "tools": [\n          "pdflatex"\n         ]\n        },\n        {\n         "name": "latexmk ",\n         "tools": [\n          "latexmk"\n         ]\n        },\n        {\n         "name": "xelatex",\n         "tools": [\n          "xelatex"\n         ]\n        },\n        {\n         "name": "pdflatex \xe2\x9e\x9e bibtex \xe2\x9e\x9e pdflatex`\xc3\x972",\n         "tools": [\n          "pdflatex",\n          "bibtex",\n          "pdflatex",\n          "pdflatex"\n         ]\n        },\n        {\n        "name": "xelatex \xe2\x9e\x9e bibtex \xe2\x9e\x9e xelatex`\xc3\x972",\n        "tools": [\n          "xelatex",\n          "bibtex",\n          "xelatex",\n          "xelatex"\n         ]\n        }\n       ]        \n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  1. 确保"latex-workshop.latex.path": "/Library/TeX/texbin"反映您的 MacTeX 安装。如果你按照默认提示安装MacTeX的.pkg,那么我指定的路径应该是相同的。

    \n
  2. \n
  3. 重新启动 Visual Studio 代码。
    \na。我发现使用命令重新加载窗口Developer: Reload Window是不够的,我需要退出 Visual Studio Code 并再次打开。

    \n
  4. \n
  5. 在新的 .tex 文件 ( ) 中的测试文件中尝试以下内容File > New File > test.tex
    \n(我从 Overleaf 获取此 MWE)

    \n
  6. \n
\n
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Welcome to Overleaf --- just edit your LaTeX on the left,\n% and we\'ll compile it for you on the right. If you open the\n% \'Share\' menu, you can invite other users to edit at the same\n% time. See www.overleaf.com/learn for more info. Enjoy!\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[acronym]{glossaries}\n\n\\makeglossaries\n\n\\newglossaryentry{latex}\n{\n        name=latex,\n        description={Is a mark up language specially suited for \nscientific documents}\n}\n\n\\newglossaryentry{maths}\n{\n        name=mathematics,\n        description={Mathematics is what mathematicians do}\n}\n\n\\newglossaryentry{formula}\n{\n        name=formula,\n        description={A mathematical expression}\n}\n\n\\newacronym{gcd}{GCD}{Greatest Common Divisor}\n\n\\newacronym{lcm}{LCM}{Least Common Multiple}\n\n\\begin{document}\n\\printglossary[type=\\acronymtype]\nThe \\Gls{latex} typesetting markup language is specially suitable \nfor documents that include \\gls{maths}. \\Glspl{formula} are \nrendered properly an easily once one gets used to the commands.\n\nGiven a set of numbers, there are elementary methods to compute \nits \\acrlong{gcd}, which is abbreviated \\acrshort{gcd}. This \nprocess is similar to that used for the \\acrfull{lcm}.\n\n\\clearpage\n\n\n\n%\\printglossary\n\n\\end{document}\n\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  1. 最后,在 VSCode 中:\n
      \n
    1. 在左侧边栏中选择 TeX Workshop Extension
    2. \n
    3. 选择左侧的下拉箭头Build LaTeX project
    4. \n
    5. 点击菜谱:Recipe: pdfLaTeX
    6. \n
    \n
  2. \n
\n