Here is the code I have in my .emacs:
prepare
(defun advice:org-ctrl-c-ctrl-c (orig-func &rest args)
(let (org-latex-fragment-image-overlays)
(apply orig-func args)))
(advice-add 'org-ctrl-c-ctrl-c :around #'advice:org-ctrl-c-ctrl-c)
With the settings above, I can do things like this:
use
(defun org-toggle-preview-latex-fragment (arg)
"Toggle LaTeX fragments."
(interactive "P")
(if org-latex-fragment-image-overlays
(org-remove-latex-fragment-image-overlays)
(org-preview-latex-fragment arg)))
(define-key org-mode-map (kbd "C-c C-t") 'org-toggle-preview-latex-fragment)
(edited)
At first I wrote myself a piece of code, but I have found a thread talking about this and found the workaround.
The second piece of code is due to John Kitchin. The idea of the workaround is due to Aaron Ecay.
You can see them at https://lists.gnu.org/archive/html/emacs-orgmode/2014-07/msg00323.html .
(edited on March 24, 2016)
Toggling of latex fragments is part of org-mode as of March 24, 2016.
Latex fragments can be previewed by calling M-x org-toggle-latex-fragment
.
Personally I use the following setting in my init.el:
(define-key org-mode-map (kbd "C-c C-t") 'org-toggle-latex-fragment)
(define-key org-mode-map (kbd "<f6>") 'org-preview-latex-fragment)
Might do what you want. But I don't see whyC-c
should toggle the preview. In my setup, this function is bound to ` C-c C-x C-l` by default, withC-c C-c
untoggling it. Can you confirm that it is justC-c
that untoggles the preview for you, or is itC-c C-c
? – elethan Dec 10 '15 at 19:00f9
instead to toggle them off, try putting(define-key org-mode-map (kbd "<f9>") 'org-remove-latex-fragment-image-overlays)
in your init file. I am not sure if it will work, but it is worth a try. However, I am not sure if you will be able to remove theC-c C-c
binding – elethan Dec 10 '15 at 19:05org-remove-latex-fragment-image-overlays
seems not to be the right command for me, I havewrong type command
and I can't find it withM-x
. What I would really like is to unmap C-c C-c, this what annoyed me the most at the moment. Thank you thought. – user3593232 Dec 10 '15 at 19:14(remove-hook 'org-ctrl-c-ctrl-c-hook 'org-remove-latex-fragment-image-overlays)
in your init. Iforg-remove-latex-fragment-image-overlays
is not the relevent command, then replace it with the relevant command (I am not sure what it is, mine was just a guess). If you get the right command, this should unmapC-c C-c
from the command – elethan Dec 10 '15 at 19:21