I wish to "electrically" insert \rvert or \Bigr\rvert when typing \lvert or \Bigl\lvert in AucTeX.

  • What does that mean? Just what do you want to know how to do?
    – Drew
    Oct 21, 2022 at 21:43
  • I want to know if it is possible to automatically insert \rvert when I type \lvert (like with parenthesis for example).
    – Eskil
    Oct 22, 2022 at 0:29

1 Answer 1


Please consult the AucTeX user manual.

Use the search box in the right top corner of webpage to search for things of interest to you.

You are looking for C-c RET TeX-insert-macro

I had to do this

(setq TeX-parse-self t)

lvert comes from amsmath, and I believe you need to have \usepackage{amsmath} somewhere in your buffer.



TeX-insert-macro is an interactive byte-compiled Lisp function in tex.el.

(`TeX-insert-macro` `SYMBOL`)

Insert TeX macro SYMBOL with completion.

AUCTeX knows of some macros and may query for extra arguments, depending on the value of TeX-insert-macro-default-style and whether TeX-insert-macro is called with C-u.

(AucTex) Quotes


(info "(auctex) Quotes")

When writing complex math formulas in LaTeX documents, you sometimes need to adjust the size of braces with pairs of macros like \left-\right, \bigl-\bigr and so on. You can avoid unbalanced pairs with the help of TeX-insert-macro, bound to C-c C-m or C-c <RET> (note Completion::). If you insert left size adjusting macros such as \left, \bigl etc. with TeX-insert-macro, it asks for left brace to use and supplies automatically right size adjusting macros such as \right, \bigr etc. and corresponding right brace in addtion to the intended left macro and left brace.

The completion by TeX-insert-macro also applies when entering macros such as \langle, \lfloor and \lceil, which produce the left part of the paired braces. For example, inserting \lfloor by C-c C-m is immediately followed by the insertion of \rfloor. In addition, if the point was located just after \left or its friends, the corresponding \right etc. will be inserted in front of \rfloor. In both cases, active region is honored.

As a side effect, when LaTeX-math-mode (note Mathematics::) is on, just typing ( inserts not only \langle, but also \rangle.

If you do not like such auto completion at all, it can be disabled by a user option.

-- User Option: TeX-arg-right-insert-p If this option is turned off, the automatic supply of the right macros and braces is suppressed.

(AucTeX) Completion


(info "(auctex) Completion")

A more direct way to insert a macro is with TeX-insert-macro, bound to C-c C-m which is equivalent to C-c <RET>. It has the advantage over completion that it knows about the argument of most standard LaTeX macros, and will prompt for them. It also knows about the type of the arguments, so it will for example give completion for the argument to \include. Some examples are listed below.

-- Command: TeX-insert-macro (C-c C-m or C-c <RET>) Prompt (with completion) for the name of a TeX macro, and if AUCTeX knows the macro, prompt for each argument.

As a default selection, AUCTeX will suggest the macro last inserted or, as the first choice the value of the variable TeX-default-macro.

-- User Option: TeX-default-macro Default macro to insert when invoking TeX-insert-macro first time.

-- User Option: TeX-insert-macro-default-style Specifies whether TeX-insert-macro will ask for all optional arguments.

If set to the symbol show-optional-args, TeX-insert-macro asks for optional arguments of TeX marcos, unless the previous optional argument has been rejected. If set to show-all-optional-args, TeX-insert-macro asks for all optional arguments. mandatory-args-only, TeX-insert-macro asks only for mandatory arguments. When TeX-insert-macro is called with prefix argument (C-u), it`s the other way round.

Note that for some macros, there are special mechanisms, e.g. TeX-arg-cite-note-p and LaTeX-includegraphics-options-alist.

A faster alternative is to enable the option TeX-electric-escape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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