If you must do this in markdown-mode
, I don't recommend using mmm
, which is quite difficult to configure and somewhat buggy.
Instead, consider using indirect buffers. This process is analogous to a feature that org-mode
has called org-edit-special
, where you can edit source blocks in separate buffers using the source language's major mode.
- Visit your Markdown file, e.g.
file.md
, usingmarkdown-mode
. - When you want to edit a LaTeX snippet, use
M-x clone-indirect-buffer
. Of course, you can bind this to some convenient key if you use it a lot. - You will now have two buffers visiting
file.md
. By default they will be something likefile.md
(the original buffer inmarkdown-mode
) andfile.md<2>
(the indirect buffer). - This step is optional, but I strongly recommend narrowing your
file.md<2>
buffer to the relevant LaTeX snippet. - In the
file.md<2>
buffer, change your major mode to AUCTeX.
The two buffers will be modifying the same file. Changes in one will be reflected in the other, and saving from either one will save the file. The difference is that one will use markdown-mode
and the other will use AUCTeX.
You can either kill file.md<2>
when you are done with it, or keep it around for the next snippet. Simply un-narrow it, find the new snippet, and narrow it again.