I'm indexing a LaTeX document using Emacs and AUCTeX and RefTeX. One thing that makes it harder to match delimiters in the document (or to spot mismatched ones) is the propensity of Emacs (or maybe AUCTeX or RefTeX—I'm not sure which is responsible) to misunderstand the |( and |) page range specifiers in \index commands.

For example, when I type something like \index{ferrets|(}, then as soon as I type the } I get a spurious "Mismatched parentheses" warning in the minibuffer. And from this point on, all delimiter matching the document gets screwed up. For example, take the following snippet:


When I type the final }, Emacs wrongly tells me that the matching opening brace is at \index, not at \somecommand.

Is there any way I can teach Emacs (or AUCTeX or RefTeX) to ignore the contents of \index commands for the purpose of brace matching?

1 Answer 1


A possibility is to tell AUCTeX index is a verbatim-like macro. This isn't really true, but verbatim-like macros ignore brace pairing. Add the following code to your init file and restart Emacs:

(eval-after-load "latex"
  '(add-to-list 'LaTeX-verbatim-macros-with-braces "index"))
  • This seems to have no effect on the problem for me.
    – Psychonaut
    Commented Dec 15, 2015 at 8:03
  • Can you please expand your comment? What do you expect exactly and what's wrong with this answer? Any kind of parenthesis is ignored inside the argument of index in this way.
    – giordano
    Commented Dec 15, 2015 at 9:12
  • On further testing, it seems the only problem is that putting this code in my Emacs init file does not suppress the "mismatched parentheses" minibuffer warning when typing the final brace of something like \index{foo|(}. I had mistakenly assumed that this meant the code had no effect at all. However, I see now that it does restore proper brace matching for subsequently typed braces (as in the \somecommand example of my original question).
    – Psychonaut
    Commented Dec 15, 2015 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .