- 我正在运行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上解决问题的步骤是:
- Within VSCode:
cmd+shift+P
,选择Preferences: Open User Settings (JSON)
- 然后在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"
]
}
]
确保
"latex-workshop.latex.path": "/Library/TeX/texbin"
反映您的MacTeX安装。如果您在安装MacTeX的.pkg时遵循默认提示,那么我指定的路径应该与相同。重新启动Visual Studio代码。
。我发现用Developer: Reload Window
命令重新加载窗口是不够的,我需要退出Visual Studio Code并重新打开。尝试以下测试文件,在一个新的.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}
- 最后,在VSCode中:
- 选择左边栏的TeX Workshop扩展
- 选择
Build LaTeX project
左边的下拉箭头 - 点击配方:
Recipe: pdfLaTeX
您应该这样做:
- 使用
win + x
快捷方式或进入Windows设置并选择System。 - 从那里,选择高级系统设置。 现在你应该选择环境变量。
- 您将看到窗口的两个部分,顶部是基于用户的环境变量,底部是系统变量。你会找到PATH并执行以下操作: 路径
- 选择and clicModify。 新
- 按并将路径添加到您的LaTeX发行版中,例如:
C:texlive2021
如果你这样做,它应该工作,在我的情况下它在安装时工作,因为我已经将这些条目添加到PATH.
编辑:我一定是累了,我刚发现你用的是Mac OS。我将让我的Windows为其他人回答问题,但步骤必须看起来相似。