I don't like that C-c C-c is untoggle the org-latex-preview fragment because it's the "magic key" in org and whenever I press it it untoggle my latex-fragment so I have to toggle it again manually.

I would like to unmap this function from C-c C-c and map it to another key like [f9].

I don't understand quite well the part on remapping in the GNU manual so I am asking here. Also I apologize for my lack of vocubalary...

  • (define-key org-mode-map (kbd "<f6>") 'org-preview-latex-fragment) Might do what you want. But I don't see why C-c should toggle the preview. In my setup, this function is bound to ` C-c C-x C-l` by default, with C-c C-c untoggling it. Can you confirm that it is just C-c that untoggles the preview for you, or is it C-c C-c? – elethan Dec 10 '15 at 19:00
  • My bad, you're right it's C-c C-c ! But C-c C-c IS the magic command in org mode so... I correct the post. – user3593232 Dec 10 '15 at 19:02
  • If you want to use f9 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 the C-c C-c binding – elethan Dec 10 '15 at 19:05
  • org-remove-latex-fragment-image-overlays seems not to be the right command for me, I have wrong type command and I can't find it with M-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
  • Try (remove-hook 'org-ctrl-c-ctrl-c-hook 'org-remove-latex-fragment-image-overlays) in your init. If org-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 unmap C-c C-c from the command – elethan Dec 10 '15 at 19:21

Here is the code I have in my .emacs:


(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:


(defun org-toggle-preview-latex-fragment (arg)
  "Toggle LaTeX fragments."
  (interactive "P")
  (if org-latex-fragment-image-overlays
      (org-preview-latex-fragment arg)))
(define-key org-mode-map (kbd "C-c C-t") 'org-toggle-preview-latex-fragment)


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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.