【问题标题】:Emacs24 , org-mode, can't find `latex'(needed to convert LaTeX fragments fo images)Emacs24,组织模式,找不到“乳胶”(需要将 LaTeX 片段转换为图像)
【发布时间】:2017-05-04 01:34:52
【问题描述】:

我想使用命令C-c C-x C-l 在组织模式下预览latex 代码。由于 emacs-nox 无法做到这一点,我尝试了apt-get install emacs24。但是,在我安装了带有 GUI 的 emacs24 后,我收到了类似

的错误
can't find \`latex'(needed to convert LaTeX fragments to images)

我已经安装了texlive2016,可以在shell命令中latex *.tex

我将/paht/to/latex 添加到 .emacs,但效果不佳。

【问题讨论】:

  • 你是如何将 /path/to/latex 添加到 emacs 的?
  • emacs C-x C-f 打开~/.emacs,添加` (setenv "PATH" (concat ":/path/to/latex" (getenv "PATH") ) )`
  • 您可以将debug-on-error 设置为t,尝试预览并在某处发布回溯吗?同时发布您的 org-mode 版本(M-x org-version 会告诉您)。顺便说一句,这可能在 org-mode 邮件列表中做得更好。
  • Emacs 也有exec-path,它被初始化为$PATH,但是是不同的。 (add-to-list 'exec-path "/path/to/latex")

标签: emacs latex org-mode


【解决方案1】:

我的水晶球告诉我,问题在于您没有从终端启动 GUI Emacs,因此它无法继承您的 $PATH 设置。参见例如https://emacs.stackexchange.com/questions/10722/(该问题在 OSX 中,但同样的问题出现在其他系统中)。

显然,您可以在~/.pam_environment(适用于 GNU/Linux 系统)中全局设置 env-vars(以便它们影响所有应用程序,包括直接从 GUI 启动的应用程序)。请注意,这仅在您登录时才会咨询,因此您需要注销+登录才能使更改生效。

【讨论】:

  • 谢谢。我确实从超级键启动我的 GUI Emacs。但是 ~/.emacs 中的 $PATH 正在工作。事实上,我的问题是我将/path/to/latex添加到$PATH,但没有添加$exec-path,The difference between exec-path and PATH
  • 你不应该在你的~/.emacs 中干预$PATH(也不是exec-path),因为它应该与所有其他应用程序中使用的$PATH 相同:它应该是全局设置。
  • 但是当我这样做时,它很有用并解决了我的问题
【解决方案2】:

将以下内容添加到我的init.el 使其工作:

;; Making emacs find latex (so that C-c C-x C-l works on orgmode)
(setenv "PATH" (concat ":/Library/TeX/texbin/" (getenv "PATH")))
(add-to-list 'exec-path "/Library/TeX/texbin/")

这不是一个非常漂亮的解决方案,但它可以完成工作并且很容易修改和理解。

此解决方案适用于运行 macOS Sierra 和 Emacs v25.1 的 Mac。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    • 2017-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多