I am completely new to markdown and would like to know if there is any package/mode which allows to live preview only parts of the document (mainly equations, tables and images) like it is possible with preview-latex?

Until now, I could only see the preview in a different buffer.

Thanks! Fab

2 Answers 2


You can use texfrag-mode. It can be installed from melpa.

After installation customize the variable texfrag-setup-alist by adding markdown-mode to the entry for texfrag-trac-wiki.

Afterwards you can open your markdown file and run M-x texfrag-mode RET.

Therewith you get the preview-latex menu as TeX in the menu bar.

If you always want to turn on texfrag-mode for a specific document you can run texfrag-mode in the local variables.


# Some Heading

Test of formula: $y=\sqrt{x^2+y^2}$

We also include a picture:
  \caption{First picture.}

[//]: # Local Variables:
[//]: # eval: (texfrag-mode)
[//]: # End:

The buffer looks like follows after hitting C-c C-p C-d.

TeXfrag Preview

If you want to run texfrag-mode for all your markdown files you can add the following line to your init file:

(add-hook 'markdown-mode-hook #'texfrag-mode)

With that configuration you don't need the local variables section from the last example.

  • Hi, thank you very much, this seems exactly what I am looking for. Actually, I getting the setup so far to get the TeX menu for my markdown buffer, but running the C-c-C-p-C-d command for previewing will not do anything. Showin texfrag-log just says that nothing is running; I have a working preview-latex setup on macos with spacemacs. I am not sure, if I should ask further here or jump to the texfrag issues on github? Thank you very much!
    – Fabian
    Apr 22, 2020 at 9:32
  • ok, this works now, I am not sure, what I did different now, thank you very much!
    – Fabian
    Apr 22, 2020 at 19:12

You have a few options to achieve this, from within emacs you can can simply use org-toggle-latex-fragment which is the simplest solution, putting the following into your ~/emacs.d/init.el file will fix the binding to C-c C-x C-l just like it is in org-mode:

 (add-hook 'mardkown-mode-hook
   (lambda ()
     (local-set-key (kbd "C-c C-x C-l") 'org-toggle-latex-fragment)
     (local-set-key (kbd "C-c C-x C-u") 'markdown-toggle-url-hiding)

My current solution is to basically manage all my notes in VNote and org-mode and then build them with mkdocs to read them on a server / gitpage on my phone. So I'll edit them in emacs, manage them in Vnote and then if I want to include some math I usually use vim with a plugin.

Another option is to use one of the markdown preview packages that are available, the doom starter kit (which I'm using atm) includes one but I don't use it.

An easier option is to use this chrome extension in conjuction with a local server (e.g. python3 -m http.server) and view the files in the browser, this also means links will work. It would also be possible to build the markdown with pandoc, tie that to a keybinding and then view the HTML in the browser seperately.

I usually write my markdown and LaTeX in vim because the snippets are better and I'll use this function to open vim from emacs, if that's something you're interested in then I'd recommend this plugin.

If you don't like any of that you could use the live preview offered by Marktext, Zettlr, VSCode or Typora and simply edit the source in markdown.

I would really recommend looking at VNote though, It's become indispensable to me.

  • Thank you for your help, the texfrag-mode seems exactly what I need.
    – Fabian
    Apr 22, 2020 at 9:32
  • Thank you. Since Org 9.3 org-toggle-latex-fragment is obsolete and org-latex-preview should be used.
    – fjesser
    Apr 28, 2022 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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