Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I edit markdown in emacs I use markdown-mode. However I often have to type some math formulas in the markdown file (processed by mathjax). However for those math parts markdown mode is not very comfortable.

Is there a way to make emacs automatically switch to latex (auctex) mode (locally) when the point is between two $ signs for example ($\mathbb{R}$) or between two double $ signs for example

a = b


Edit I also want to have the font locking of the "local" mode.

Edit 2 I tried mmm-mode, but this doesn't handle font-locking correctly. I guess that multi-mode.el or MuMaMo-mode might be what I want. But I didn't figure out how to use this in my examples. So, if it is possible to do what I want with one of this or with another mode, it would be great if someone could post detailed steps howto apply it in my case as an answer.

share|improve this question
You should try Org Mode because it supports embedded latex with latex fragments that you can preview. Though Org Mode is a bit more than a markup language. – Daimrod Jul 7 '12 at 16:19
@Daimrod How can I use org-mode to write markdown?? – student Jul 8 '12 at 16:50
@student use org mode and export to markdown - orgmode.org/manual/Markdown-export.html . You can have multiple different languages in a markdown document.... – Ulrich Dangel Jun 10 '13 at 22:07

Emacs has several packages that help switching quickly and automatically between modes. The Emacs wiki has a page on multiple modes.

Mmm-mode is a common choice, but I expect each of the possibilities to have its ups and downs.

share|improve this answer
Thanks. I will try it. Can you add some details how to configure and use it in my case (I just installed mmm-mode via aptitude, what should I do next?) – student Jul 8 '12 at 18:16

If you are specifically interested in avoiding interference of markdown-mode with math enclosed in $...$ or $$...$$, you can do M-x markdown-enable-math while markdown major mode is on, see http://jblevins.org/projects/markdown-mode/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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