视网膜显示器上的Org LaTeX预览模糊

时间:2015-05-10 12:22:53

标签: emacs latex org-mode retina-display retina

我一直在使用Emacs 24.4获取所有数学/科学笔记。 org-latex-preview非常棒!但最近,我升级为带有视网膜显示的macbook pro,我现在看到我在org-mode中的所有方程都是......模糊的。我可以改变这些设置吗?

以下是截图:

enter image description here

谢谢!

4 个答案:

答案 0 :(得分:6)

几年前,我决定修复此问题并编写补丁,将dvisvgm添加为乳胶预览的渲染选项。虽然这很有效,但我从未提交过(没有时间或知识如何正式修补组织)。

今天,我很高兴发现org-mode v9.0.6,现在有了这个功能!

要激活,请先检查系统上是否有dvisvgm。然后更新组织模式并将以下行添加到init.el文件中:

(setq org-latex-create-formula-image-program 'dvisvgm)

并且presto!

enter image description here

答案 1 :(得分:1)

我找到了一个更适用于所有内嵌图像的解决方案。首先确保所有生成的图像都是使用比例因子 2 创建的。例如,对于 LaTeX 代码块和内联 LaTeX 片段,这可以通过

(plist-put org-format-latex-options :scale 2)

然后您让组织缩放所有内联图像。 对于 LaTeX 代码块,我们可以这样建议 org--create-inline-image

(defun my/image-scale-advice (image)
  (let* ((factor (image-property image :scale))
         (new-factor (if factor
                         (/ factor 2.0)
                       0.5)))
    (image--set-property image :scale new-factor)
    image))
(advice-add 'org--create-inline-image :filter-return #'my/image-scale-advice)

这会将任何已经存在的缩放因子除以 2,如果不存在,则将缩放因子设置为 0.5。

对于内联 LaTeX 片段,我们可以这样建议 org--make-preview-overlay

(defun my/overlay-scale-advice (beg end image &optional imagetype)
  (mapc (lambda (ov) (if (equal (overlay-get ov 'org-overlay-type) 'org-latex-overlay)
                                (overlay-put ov
                                             'display
                                             (list 'image :type (or (intern imagetype) 'png) :file image :ascent 'center :scale 0.5))))
        (overlays-at beg)))
(advice-add 'org--make-preview-overlay :after #'my/overlay-scale-advice)

这应该会在 Retina 显示器上产生更清晰的内嵌图像。

答案 2 :(得分:0)

我试过了 emacs-mac-port

如果我在同一个目录上创建了两个文件foo.png foo@2x.png,这将有效。

答案 3 :(得分:0)

默认情况下orgmode latex预览不支持视网膜,所以在带视网膜屏幕的mac上,乳胶预览会模糊不清。
但是,我们可以破解org.el来实现这个功能。请按照以下步骤操作:

获取正确版本的emacs

改为使用Yamamoto Mitsuharu版本的Emacs 25.1(具有更多mac特定功能):

brew tap railwaycat/emacsmacport
brew install emacs-mac

最后将其链接到您的Applications文件夹:

brew linkapps emacs-mac

此版本的emacs将支持视网膜图像显示。

更改org-format-latex-options

将比例从1.0更改为2.0,以生成2倍大小的图像。

删除org.elc

将功能添加到org.el

(defun galaxy-compose-image-filename-2x(image-file-name)
  (concat (file-name-directory image-file-name) (file-name-base image-file-name) "@2x." (file-name-extension image-file-name)))

并评估该功能。

修改函数org-format-latex

更改片段:

(unless (file-exists-p movefile)
  (org-create-formula-image value movefile options forbuffer processing-type)

(unless (file-exists-p movefile)
  (org-create-formula-image value movefile options forbuffer processing-type)
  (setq filename-2x (galaxy-compose-image-filename-2x movefile))
  (rename-file movefile filename-2x)
  (call-process-shell-command "convert" nil nil nil nil (concat "\"" filename-2x "\" -scale \"50%\" -quality \"100%\"" ) (concat "\"" movefile "\"" )))

并评估该功能。

现在,您可以使用2倍大小的图像预览乳胶视网膜屏幕。

相关问题