I have a problem with syntax highlighting in the Emacs editor using AUCTeX. The problem occurs in particular with the Verbatim environment from the fancyvrb package. Consider the following code:


This produces the following screenshot:

enter image description here

The problem seems to be the $ sign in the Verbatim environment, and AUCTeX believes that I have entered some math code that I have not yet terminated with an ending $ sign.. Is there a way to tell AUCTeX to ignore syntax highlighting within a particular environment?

  • 3
    You can insert " %$" after \end{Verbatim} to fix the syntax highlight for the rest of the text. But that's not a solution, not even a workaround (because the syntax highlight is still broken in the verbatim environment). – T. Verron Apr 29 '13 at 7:07

Here's what I add to my Preferences.el file (the .emacs equivalent for Aquamacs):

(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting"))

This makes Verbatim and lstlisting behave like verbatim

enter image description here

  • Is it possible to obtain the same result with what included in \Sexpr{}? – Francesco Sep 20 '13 at 0:32
  • @Francesco Sorry, but my knowledge of the Emacs arcana is not so deep. Maybe you can ask a fresh question. – egreg Sep 20 '13 at 8:55
  • 1
    Is there some similar setting for \verb|$foo|? – NobbZ Feb 16 '16 at 20:22
  • 1
    OK, found it myself. The list one has to set is LaTeX-verbatim-macros-with-delims-local – NobbZ Feb 16 '16 at 20:24

M-x font-lock-mode

will disable syntax highlighting


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.