【问题标题】:Org LaTeX preview is fuzzy on retina displaysOrg LaTeX 预览在视网膜显示器上很模糊
【发布时间】:2015-07-20 23:50:32
【问题描述】:

我的所有数学/科学笔记都使用 Emacs 24.4。 org-latex-preview 太棒了!但是最近,我升级到了带有视网膜显示屏的 macbook pro,现在我看到我在 org 模式下的所有方程都是......模糊的。有没有我可以更改这些设置的设置?

这是截图:

谢谢!

【问题讨论】:

  • 预览是使用 png 图像和 Ghostscript 完成的,后者以显示质量差而臭名昭著。要获得真正好的显示质量,您将需要使用在完全不同的框架中打开的单独 pdf 程序。至少有一个线程,用户努力为他/她自己的需要找到最清晰的字体(使用预览),但这最终归结为一个品味问题。
  • png 在我的旧 Mac 上看起来不错(视网膜显示前)。我只能猜测这个问题与视网膜显示器的高分辨率和自动缩放有关......?
  • 如果你在谷歌上搜索 ghostscript png emacs pdf 之类的东西,你会发现一些线程询问如何在里面获得更好的 pdf 图像质量Emacs。糟糕的质量在漂亮的显示屏上更加明显。我为 tex 生成的文档设置了外部查看器(Skim);并且,为了从 Emacs 文件管理器(例如,Dired 或我使用的自定义树视图管理器)查看 pdf 文档,我编写了一组回显区域选项来打开 pdf:doc-view(in-Emacs 选项) 、预览、Adobe、Skim、Omnipage。
  • 我很确定这与视网膜技术和这些图像的渲染方式的兼容性/设置有关......我还有其他应用程序不是“视网膜就绪”,如 QGIS 和 MS Office 2011 ,他们有同样的问题。所有图像都以 1/4 分辨率渲染,因此它们保持正确的大小,但图像分辨率较低。我还注意到我在旧 Mac 上截取的屏幕截图存在这个问题。但是必须有某种方法可以在设置上指定正确的分辨率...?
  • 这里是一些关于 doc-view 和 Retina 支持的有趣评论的链接,参考了可能支持更好图像质量的特定 Emacs 构建。 github.com/politza/pdf-tools/issues/51 这是相关的 sn-p:如果您使用的是 macports,则可以 port install emacs-mac-app 安装支持视网膜的版本。现在要在视网膜模式下查看 pdf,您应该将文件命名为“foo@2x.pdf”。我是从 github.com/railwaycat/emacs-mac-port/blob/…

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


【解决方案1】:

几年前,我决定解决这个问题并编写了一个补丁来添加dvisvgm 作为乳胶预览的渲染选项。虽然这很有效,但我从未提交过(没有时间或知道如何正式修补 org)。

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

要激活,首先检查您的系统上是否有dvisvgm。然后更新 org-mode 并将以下行添加到您的 init.el 文件中:

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

马上!

【讨论】:

  • 感谢您的回答!我按照你的建议做了,但是生成的 svg 没有被 emacs 显示。图像已生成(因为它们出现在文件夹 ltximg 中),但乳胶方程 $...$ 不会被图像取代。有什么想法吗?
  • 尝试将此添加到您的 init.el 文件中:dropbox.com/s/tcmva6outuwmq7f/latex.el?dl=0
  • 请注意,从 Emacs 26.1 开始:“此变量自 Org 9.0 以来已过时;请改用‘org-preview-latex-default-process’。”
  • 该初始化文件在 Dropbox 中不再可用。您可以在答案中添加相关位吗?
  • @HappyFace 很高兴成功了!如果您需要任何其他帮助,请告诉我,我会找到一种方法以更永久的方式重新发布我的 init 文件!
【解决方案2】:

默认orgmode latex preview不支持retina,所以在mac上使用retina屏幕,latex preview会模糊。
但是,我们可以破解 org.el 来实现该功能。只需按照以下步骤操作:

获取正确版本的 emacs

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

brew tap railwaycat/emacsmacport
brew install emacs-mac

最后将其链接到您的应用程序文件夹:

brew linkapps emacs-mac

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

更改 org-format-latex-options

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

删除 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 "\"" )))

并评估函数。

现在,您可以在 mac 视网膜屏幕上预览 2 倍尺寸图像的乳胶。

【讨论】:

    【解决方案3】:

    我找到了一个更适用于所有内联图像的解决方案。首先确保任何生成的图像都是以 2 的比例因子创建的。例如,对于 LaTeX 代码块和内联 LaTeX sn-ps,这是由

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

    然后你让 org 缩放所有内联图像。 对于 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 sn-ps,我们可以这样建议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 显示器上的内嵌图像更加清晰。

    【讨论】:

    • 对我来说,这会导致“错误:void-variable org-format-latex-options”
    【解决方案4】:

    我试过了 emacs-mac-port

    如果我在同一个目录上创建 2 个文件 foo.png foo@2x.png,这将起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多