My emacs version is 24.3.1, and I need to input many latex code (e.g. math formula) in the markdown mode. So I want to use the autocompleting function provided by auctex. But markdown and latex are two major modes, and I can't use them in a same buffer. There is package named mmm-mode which supports multiple major modes in one buffer. The problem is that I don't know how to configure it in my .emacs files, please give me some suggestion about it. If you have other methods which can do such things, it is also welcome.
Asked
Active
Viewed 315 times
1
-
I've never had much luck with `mmm-mode`. Do you *need to* do this with `markdown-mode`, or is that just a tool on your way to something else like HTML or PDF? You may have better luck using `org-mode`. – ChrisGPT was on strike Jan 28 '14 at 13:01
-
Thanks for your reply. I need to do this with `markdown-mode`. Our team use it to write doc and it is more easily to read and write. – why_math Jan 29 '14 at 03:52
1 Answers
2
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.

ChrisGPT was on strike
- 127,765
- 105
- 273
- 257