如何始终显示内嵌图像?

Beg*_*moT 5 emacs image org-mode

我正在尝试使用内嵌图像(例如通过 gnuplot 绘制数据),但遇到了问题:默认情况下,图像始终作为链接插入。我需要做一些按键来“强制”emacs 显示实际图像内联,而不仅仅是文件链接。

例如,我从 gnuplot 代码开始:

#+BEGIN_SRC gnuplot :file plot.png
plot sin(x)
#+END_SRC
Run Code Online (Sandbox Code Playgroud)

当我按下C-c C-c此代码块时,它会运行,并将结果显示为图像文件的链接:

#+RESULTS:
[[file:plot.png]]
Run Code Online (Sandbox Code Playgroud)
  • 如果我按C-c C-x C-v(org-toggle-inline-images) 两次 - 链接确实替换为内联图像
  • 如果我M-x org-redisplay-inline-images再次运行- 链接确实替换为图像
  • 如果我(org-display-inline-images t t)再次运行- 会显示图像

等等(这些选项取自Emacs org-display-inline-imagesInline images in org-mode questions)

但我不想按任何特别的东西:我希望图像默认内联显示。我发现并尝试了以下变量:

  • (setq org-startup-with-inline-images t).emacs配置中
  • #+STARTUP: inlineimages 标题
  • (setq org-display-inline-images t)

但两者都没有让我得到我想要的行为。我很困惑——我想要这么不自然的东西吗?

PS Im' 在 MacOS X 上使用 GNU Emacs v26.1,组织模式 v9.1.9-65,如果重要的话

PPS 虽然它看起来像是我的 emacs/orgmode 版本中的一个错误,我还没有报告它,但同时我发现了以下技巧:((add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)感谢ob-ipython作者)——它现在为我解决了问题。也许对其他人有用

Tob*_*ias 4

我可以通过以下方式重现该问题:

Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ /home/xyz/.emacs.d/elpa/org-plus-contrib-20190415/)
Run Code Online (Sandbox Code Playgroud)

再生产:

  1. emacs -Q使用.启动 Emacs 26.3
  2. M-x load-library RET org RET
  3. 添加Gnuplotorg-babel-load-languages通过M-x customize-option.
  4. 加载gnuplot.el
  5. 打开包含以下内容的 Org 文件,然后按C-c C-c源块。
#+STARTUP: inlineimages
Some text.

#+BEGIN_SRC gnuplot :file plot.png :results graphics
plot sin(x)
#+END_SRC
Run Code Online (Sandbox Code Playgroud)

我有一个与您在问题中建议的类似的解决方案,但有一点不同。

重新显示大型 Org 文档中的图像可能需要一些时间。因此,仅当源块具有 results-parameter 时我才执行此操作graphics

Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ /home/xyz/.emacs.d/elpa/org-plus-contrib-20190415/)
Run Code Online (Sandbox Code Playgroud)