使用 pdfLatex 的 Sublime Text 构建失败

使用 pdfLatex 的 Sublime Text 构建失败

我正在尝试使用一些 ST 资源之一来构建 latex 文档,但它们都不起作用。最初的尝试是使用 ST 的 pandoc 进行 markdown/latex 编译。我使用的是这个构建脚本:

{
    "shell_cmd": "pandoc -o \"$file.pdf\" \"$file\" && open -a Preview \"$file.pdf\"",
    "selector": "text.html.markdown",
    "path": "/usr/texbin:$PATH"
}

它打开控制台框,显示正在构建,但不会在我的目录中创建 pdf。

解决方案:

{
    "cmd": ["pandoc -o \"$file.pdf\" \"$file\" && open -a Preview \"$file.pdf\""],
    "shell": "true",
    "selector": "text.html.markdown",
    "path": "/usr/texbin:/usr/local/bin:/usr/bin:/bin"
}

我应该提一下

> pandoc -o example.pdf example.md

从命令行工作。

接下来,我尝试仅使用 latexTools 和常用的 latex 构建系统。我在 ST 中创建了一个 latex 文件,并尝试构建。我得到了完全相同的行为,控制台框为空白,目录中没有输出。

所以我想也许我的 pdfLatex 是问题所在:

> which pdflatex
/usr/texbin/pdflatex

> pdflatex --version
pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014)
kpathsea version 6.2.0
Copyright 2014 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.10; using libpng 1.6.10
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.03

然后我尝试:

> pdflatex example.tex 

这也有效(按预期输出 pdf 文件)。

编辑:我在控制台中得到了一些输出:

    Writing file /Users/bbischof/Library/Application Support/Sublime Text 2/Packages/User/Markdown to PDF.sublime-build with encoding UTF-8
Writing file /Users/bbischof/Library/Application Support/Sublime Text 2/Packages/User/Markdown to PDF.sublime-build with encoding UTF-8
Running 
Traceback (most recent call last):
  File "./sublime_plugin.py", line 337, in run_
  File "./exec.py", line 154, in run
TypeError: __init__() got an unexpected keyword argument 'shell_cmd'

编辑 2:删除"shell_cmd"并制作它"cmd"。如果我像这样运行它,"cmd"我会得到:

    [Errno 2] No such file or directory
[cmd:  [u'pandoc -o "/Users/bbischof/Documents/LatexDocs/example.md.pdf" "/Users/bbischof/Documents/LatexDocs/example.md" && open -a Preview "/Users/bbischof/Documents/LatexDocs/example.md.pdf"']]
[dir:  /Users/bbischof/Documents/LatexDocs]
[path: /usr/texbin:/usr/texbin:/usr/texbin:/usr/texbin:/usr/texbin:/usr/texbin:/usr/texbin:/usr/texbin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

如果我使用 cmd 运行它并"shell": "true",得到:

/bin/sh: pandoc: command not found
[Finished in 0.1s with exit code 127]

答案1

因此,在聊天中布局内容时,pandoc 可执行文件的路径,即/usr/local/bin必须添加到path构建器的设置中/usr/texbin(以确保可以找到 pdflatex 和朋友)。

因此您的path设置应该是:

"path": "/usr/texbin:/usr/local/bin:$PATH"

相关内容