In auctex if one has a selected region and then apply the command c-c c-e (LaTeX-environment) then by selecting an environment, the selected region will be folded between that environment.

Is there a similar command to put a selected region between an ordinary command (not begin-end environments, but ordinary latex environment)?

As a specific example assume that one would like to put the selected region between the braces in \underline{}. Is there a command which takes the name of the environment (in this case unerline) then put the selected region between the braces in \underline{}?


If I understand your question correctly, you're looking for C-c RET which invokes TeX-insert-macro.


AUCTeX provides Font-Specifiers that one can use for such environments as described in the question and which are used often. For instance the following code

(add-to-list 'LaTeX-font-list
  '(?\C-q "\\underline{" "}"))

will add underline to the list of font specifiers. This code must be called after LaTeX-font-list is defined. Then when you press C-c C-f C-q without selected region \underline{} will be created and the cursor is put between the braces. If you have a marked region then the result will be \underline{region}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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