Is there a text editor with support for the following (somewhat special) syntax highlightning. I want to be able to set a different background color for math mode and for normal mode. (I realize this may be tricky, as one would have to consider "nesting". However, an approximation would be fine.)

I've noticed that a lot of TeX-people swear by Emacs/AUCTeX. Could it be set up to produce the kind of syntax highlightning I want? If so, how?

  • TeXstudio?! Google for screenshots. – Sigur Feb 18 '15 at 18:25
  • @Sigur, downloaded and tried. I don't see how to achieve the desired coloring. For example, I want a space in text-mode and a space in math-mode to have different background colors. – hal46 Feb 18 '15 at 18:56
  • I don't change the default highlighting but did you check the configure on options menu? – Sigur Feb 18 '15 at 19:01
  • @Sigur, yes I checked the "Configure TeXstudio..." options. – hal46 Feb 18 '15 at 19:04
  • This is dead-simple in Emacs. – Sean Allred Feb 18 '15 at 19:09

For emacs, take a look at font-latex-math-face. Where the documentation says (customize this face), you can click that text to be brought to a GUI to set the various properties with previews.

Face: font-latex-math-face (sample) (customize this face)

Face used to highlight math.

Defined in `font-latex.el'.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: #AE81FF
DistantForeground: unspecified
       Background: unspecified    <--- note
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: unspecified
| improve this answer | |
  • Yes, this works! If there is a line break in the math, then coloring is done of the "entire remainder of the row" (virtual whitespace?). I think this is logical, but I would prefer if the background color was only applied to actual content, that is, no longer than to the linebreak (and then continuing on the next row). Is this also possible? – hal46 Feb 18 '15 at 19:37
  • @hal46 That is perhaps a better question for Emacs.SX :) It's certainly possible, but I don't have the time to find/implement a solution. – Sean Allred Feb 18 '15 at 19:38

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.