我在org-mode中有一些latex公式,它们是用以前的emacs主题生成的。现在我换了主题,旧的latex公式仍然保留着以前的背景颜色,而不是新的。我该如何清除它们并重新生成它们(在Linux环境下)?
我正在使用Doom Emacs,我的预览缓存在以下目录中:
~/.emacs.d/.local/cache/org-latex/
C-c C-x C-l
绑定到org-toggle-latex-fragment
。执行一次以消除覆盖层,再执行一次以重新生成覆盖层。根据您在缓冲区中的位置以及是否使用一个C-u
、两个C-u
或没有C-u
来调用它,它会执行不同的操作(影响当前latex片段、子树中的所有片段或缓冲区中的所有片段)。您应该阅读该函数的文档字符串。
C-h C-f org-toggle-latex-fragment RET
load-theme
时,它将自动更改缓存文件夹。它也会更新图像。为了避免不必要的操作,这仅在已调用org-toggle-latex-fragment
的缓冲区中完成。'(16)
,这样就不会发生这种情况。相反,只有当前部分将被更新(其余缓冲区中的latex图像将被简单地删除)。my/org-latex-set-options
。这是因为如果您使用#+STARTUP: latexpreview
,将这些选项保留在org-mode-hook
中将无效。(defun my/org-latex-set-options ()
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5)))
(defvar my/org-latex-toggle-fragment-has-been-called nil
"Tracks if org-toggle-latex-fragment has ever been called (updated locally).")
(defadvice org-toggle-latex-fragment (before my/latex-fragments-advice activate)
"Keep Org LaTeX fragments in a directory with background color name."
(if (not my/org-latex-toggle-fragment-has-been-called) (my/org-latex-set-options))
(setq-local my/org-latex-toggle-fragment-has-been-called t)
(my/org-latex-set-directory-name-to-background))
(defadvice load-theme (after my/load-theme-advice-for-latex activate)
"Conditionally update Org LaTeX fragments for current background."
(if my/org-latex-toggle-fragment-has-been-called (my/org-latex-update-fragments-for-background)))
(defadvice disable-theme (after my/disable-theme-advice-for-latex activate)
"Conditionally update Org LaTeX fragments for current background."
(if my/org-latex-toggle-fragment-has-been-called (my/org-latex-update-fragments-for-background)))
(defun my/org-latex-set-directory-name-to-background ()
"Set Org LaTeX directory name to background color name: c_Red_Green_Blue."
(setq org-preview-latex-image-directory
(concat "ltximg/c"
(let ((color (color-values (alist-get 'background-color (frame-parameters)))))
(apply 'concat (mapcar (lambda (x) (concat "_" x)) (mapcar 'int-to-string color))))
"/")))
(defun my/org-latex-update-fragments-for-background ()
"Remove Org LaTeX fragment layout, switch directory for background, turn fragments back on."
;; removes latex overlays in the whole buffer
(org-remove-latex-fragment-image-overlays)
;; background directory switch
(my/org-latex-set-directory-name-to-background)
;; recreate overlay
;; Argument '(16) is same as prefix C-u C-u,
;; means create images in the whole buffer instead of just the current section.
;; For many new images this will take time.
(org-toggle-latex-fragment '(16)))
~/.emacs.d/.local/cache/org/latex/
目录下(Org 版本:9.7)。 - undefined