一个穷人的解决方案与建议和钩子一起工作如下所示。将代码粘贴到您的 .emacs 配置文件中并重新启动 emacs。之后,方程图像应该被缩放在 如果您按C-+/-/0,则与文本一起显示。他们只是预览和他们的 不好的是,分辨率没有放大。要获得具有良好分辨率的方程图像,请点击 Cc Cx Cl 以重新生成图像。请注意,这会设置自定义变量 org-format-latex-options 的 :scale 属性。对于当前的 emacs 会话,此变量的自定义将丢失。
你需要一个带有内置 imagemagick 的 gnu-emacs。现在应该是标准的。
(defvar text-scale-mode-hook nil
"Hook run at end of command `text-scale-mode'.")
(defadvice text-scale-mode (after text-scale-mode-hooks nil activate)
"Run `text-scale-mode-hook' at end of command `text-scale-mode'."
(if (functionp text-scale-mode-hook)
(funcall text-scale-mode-hook)
(loop for hook in text-scale-mode-hook do
(if (eq hook 't)
(run-hooks (default-value text-scale-mode-hook))
(run-hooks hook)))))
(defun org-text-scale-eye ()
"Scale equation images according to text-scale-mode-amount."
(when (boundp 'text-scale-mode-amount)
(let ((relwidth (* (expt text-scale-mode-step text-scale-mode-amount))))
(loop for ol in (overlays-in (point-min) (point-max)) do
(when (eq (overlay-get ol 'org-overlay-type) 'org-latex-overlay)
(unless (overlay-get ol 'org-image-original-width)
(overlay-put ol 'org-image-original-width (car (image-size (overlay-get ol 'display) t))))
(let ((ol-disp-plist (cdr (overlay-get ol 'display))))
(setq ol-disp-plist (plist-put ol-disp-plist :type 'imagemagick))
(setq ol-disp-plist (plist-put ol-disp-plist :width (round (* relwidth (overlay-get ol 'org-image-original-width)))))
(overlay-put ol 'display (append '(image) ol-disp-plist))
))))
(force-window-update)
))
(add-hook 'org-mode-hook '(lambda () (add-hook 'text-scale-mode-hook 'org-text-scale-eye)))
(defadvice org-format-latex (before set-scale activate)
"Set :scale in `org-format-latex-options' to the scaling factor resulting from `text-scale-mode' and clear cache."
(let ((relwidth (expt text-scale-mode-step text-scale-mode-amount)))
(unless (= (plist-get org-format-latex-options :scale) relwidth)
(plist-put org-format-latex-options :scale relwidth))))
实际上,我看了一下org.el中的代码:在函数org-create-formula-image-with-dvipng中考虑了字体高度,并设置了分辨率选项-D。也许,出了点问题。此外,遗憾的是,在 org-format-latex 中,图像被缓存并且在字体大小更改后不会被复制。
如果您想以良好的质量增加一个会话的乳胶公式的大小,您可以将“org-latex”组中自定义选项“Org Format Latex Options”的 :scale 值设置为更高的值。
编辑 2013-10-10(在整个答案中标记为斜体,除了代码,自然):选项 org-format-latex-options 的 :scale 属性现在自动设置。因此,上面的hack应该是相当有用的(比如下面提到的latex版本)。
您在原始帖子中描述的相同问题存在于乳胶预览中。但是,对于这种情况,有一个更好的解决方案:
(require 'face-remap)
(defadvice preview-inherited-face-attribute (after preview-inherit-local-face nil activate)
"Scale preview images with respect to buffer-local face"
(when (and text-scale-mode (eq attribute :height))
(setq ad-return-value (* (expt text-scale-mode-step text-scale-mode-amount) ad-return-value))))
在 C-+/-/0 之后键入 Cc Cp Cd 以重新生成文档的所有公式。之后,公式的大小和分辨率都恰到好处。
如果您可以选择切换到带有预览的 Latex 文档,我会推荐它。我只将 org 用于带有简单链接的笔记和时间表。
对于更具描述性的文档,我使用带有 auctex/preview 的乳胶文档。但是,我实际上很少将它们编译成最终的 pdf 文档。预览足够好。请参见下图。
![在此处输入图像描述](https://i.stack.imgur.com/7RihX.png)