I'm using emacs with cdlatex-mode to edit LaTeX files. I would like to know how to insert a LaTeX environment around a block of text that is already written so that the \begin{}
goes before the selected text and the \end{}
goes after the selected text. I've tried to use cdlatex-environment function but doing so erases the selected text.
相关问题
- Symbol's function definition is void: declare-
- Library to convert latex to png in Java
- How can I set the SVN password with Emacs 23.1 bui
- Emacs shell: save commit message
- Error: missing \begin{document} in LaTeX [closed]
相关文章
- ess-rdired: I get this error “no ESS process is as
- Emacs/xterm color annoyance on Linux
- Pipe less to Emacs
- Capturing the output of “diff” with org-babel
- emacs terminal mode: how to copy and paste efficie
- How to permanently enable the hs-minor-mode in ema
- Markdown: How to reference an item in a numbered l
- Pipe emacs shell output to a new buffer
AUCTeX
If you use auctex:
See the manual for details.
Note that there is a similar method to enclose marked text in macros. Do as 1–3 but instead press C-c C-e or C-c Enter instead. See the manual for details.
YASnippet
If you use YASnippet you can create a snippet with similar behavior as above. For example you can use the following (you have replace "keybinding" with a proper keybinding):
If you want a snippet for macros too you can use something like the following:
Elisp
Even if I recommend the above approaches there might be situations where you want instead to use some simple elisp function. The following is just something rough which has far less functionality than the above approaches:
And for macros if you want that too:
To use them put them in your .emacs and do M-x
ltx-environment
orltx-macro
respectively.Following the suggestion in an answer here by Tikhon Jelvis, I had a look at the latex mode documentation (C-h m) and found mention of the function
which seems to do exactly what you want.
The shortcut key is C-c C-t (whenever you are in latex mode).