Matching the delimiters \{ and \} in AUCTeX

I was also annoyed by this, so I defined a few macros to just put parens/braces/brackets around an argument.

\newcommand*{\braces}[1]{ \{ #1 \} }
\newcommand*{\parens}[1]{\left( #1 \right)}
\newcommand*{\brackets}[1]{ \left[ #1 \right] }

This turns something like: $ x = \{ stuff \}$ into $ x = \braces{stuff}$

I find it slightly more readable in my source, and emacs correctly matches the open/close braces (even if they are nested).


Change the syntax class of the \ character for TeX mode buffers by adding the following form to your Emacs initialization file:

(add-hook 'TeX-mode-hook
      (lambda ()
        (modify-syntax-entry ?\\ ".")))

After evaluation of this form, \ acts as a punctuation character rather than an escape character. But beware of potential side effects!