LaTeX通过VS Code,macOS,解决'Recipe terminated with fatal error: spawn latexmk ENOENT.'错误


  • 我正在运行macOS
  • VS Code已安装并运行
  • 我已经安装了LaTeX Workshop
  • 已安装MacTeX
  • 我得到一个'配方终止致命错误:spawn latexmk enent .在VS Code
  • 中编译LaTeX文档时出现错误

根据文档,我知道我需要设置PATH环境变量。然而,我不明白(1)这意味着什么,(2)如何做。我按照文档中的链接,但我没能解决我的问题。

有谁能帮忙简单解释一下设置PATH所需的步骤吗?

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

我在macOS (Ventura 13.3.1)和macex -2023上解决问题的步骤是:

  1. Within VSCode:
    cmd+shift+P,选择Preferences: Open User Settings (JSON)
  2. 然后在json中,粘贴以下内容到{}中:
"latex-workshop.latex.path": "/Library/TeX/texbin",
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
}
],
"latex-workshop.latex.recipes": [
{
"name": "pdfLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "latexmk 🔃",
"tools": [
"latexmk"
]
},
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
"name": "xelatex ➞ bibtex ➞ xelatex`×2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
]        
  1. 确保"latex-workshop.latex.path": "/Library/TeX/texbin"反映您的MacTeX安装。如果您在安装MacTeX的.pkg时遵循默认提示,那么我指定的路径应该与相同。

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

  3. 尝试以下测试文件,在一个新的.tex文件(File > New File > test.tex):
    (我把这个从背面的兆瓦)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to Overleaf --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you open the
% 'Share' menu, you can invite other users to edit at the same
% time. See www.overleaf.com/learn for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[acronym]{glossaries}
makeglossaries
newglossaryentry{latex}
{
name=latex,
description={Is a mark up language specially suited for 
scientific documents}
}
newglossaryentry{maths}
{
name=mathematics,
description={Mathematics is what mathematicians do}
}
newglossaryentry{formula}
{
name=formula,
description={A mathematical expression}
}
newacronym{gcd}{GCD}{Greatest Common Divisor}
newacronym{lcm}{LCM}{Least Common Multiple}
begin{document}
printglossary[type=acronymtype]
The Gls{latex} typesetting markup language is specially suitable 
for documents that include gls{maths}. Glspl{formula} are 
rendered properly an easily once one gets used to the commands.
Given a set of numbers, there are elementary methods to compute 
its acrlong{gcd}, which is abbreviated acrshort{gcd}. This 
process is similar to that used for the acrfull{lcm}.
clearpage

%printglossary
end{document}
  1. 最后,在VSCode中:
    1. 选择左边栏的TeX Workshop扩展
    2. 选择Build LaTeX project
    3. 左边的下拉箭头
    4. 点击配方:Recipe: pdfLaTeX

您应该这样做:

  1. 使用win + x快捷方式或进入Windows设置并选择System
  2. 从那里,选择高级系统设置
  3. 现在你应该选择环境变量
  4. 您将看到窗口的两个部分,顶部是基于用户的环境变量,底部是系统变量。你会找到PATH并执行以下操作:
  5. 路径
  6. 选择and clicModify
  7. 并将路径添加到您的LaTeX发行版中,例如:C:texlive2021

如果你这样做,它应该工作,在我的情况下它在安装时工作,因为我已经将这些条目添加到PATH.

编辑:我一定是累了,我刚发现你用的是Mac OS。我将让我的Windows为其他人回答问题,但步骤必须看起来相似。

相关内容

最新更新