1

In AUCTex there is font-latex-math-face which makes color of string in between $ and $ as green.

Example output:

enter image description here

or:

enter image description here

Is is possible to disable/delete font-latex-math-face, where the green color won't apply?

Could be related to: How to delete a face

alper
  • 1,238
  • 11
  • 30

1 Answers1

1

There is no built-in way to enable font lock inside a math environment, but you can prevent AUCTeX from recognizing the dollar as a math delimiter replacing the definition of font-latex-match-dollar-math with

(with-eval-after-load 'font-latex
  (defun font-latex-match-dollar-math (limit)
    nil))
matteol
  • 1,868
  • 1
  • 9
  • 11
  • It made string color in between `$$` all white which is now more difficult to read. is it possible to keep the normal coloring – alper May 13 '22 at 09:49
  • @alper see updated answer – matteol May 13 '22 at 16:50
  • Prefered color is default face I believe , where it also changes coloring text based on the key words like \mathrm should be blue and so on. I have put the color change in my question. Is it possible to keep the original face colors? – alper May 13 '22 at 19:14
  • @alper I think now I understand what you asked – matteol May 14 '22 at 06:24
  • I still see the font color in between dolar sign as green :-( – alper May 14 '22 at 20:21
  • Did you reload the tex buffer or executed `font-lock-fontify-buffer` in it after changing the definition? What is the output of `C-h f font-latex-match-dollar-math`? – matteol May 15 '22 at 05:37
  • Yes, I have run `font-lock-fontify-buffer` but no change occurs :-( It looks like unchanged: `font-latex-match-dollar-math is a native compiled Lisp function in ‘font-latex.el’. (font-latex-match-dollar-math LIMIT) Match inline math $...$ or display math $$...$$ before LIMIT. `. I added the code piece in your answer at the bottom of my `.emacs` file – alper May 15 '22 at 11:38
  • The function must be re-defined after loading the original definition, see updated answer – matteol May 16 '22 at 05:37
  • It worked this time. Thanks for your patience to help out. Small question could only the dolar sign be green color? – alper May 16 '22 at 08:18
  • I don't know, the approach of my answer is an hack, and quite ugly, it prevents AUCTeX from recognizing the dollar as a math delimiter,. I noticed that if you use `\(` and `\)` as delimiters instead of dollars the syntax highlighting is partially preserved – matteol May 16 '22 at 16:36
  • But I need dolar signs for the math format in the latex file, will `\( \)` cause the same affect as math format? – alper May 16 '22 at 20:36
  • 1
    https://tex.stackexchange.com/questions/510/are-and-preferable-to-dollar-signs-for-math-mode – matteol May 17 '22 at 05:46