kirilsolo
kirilsolo

Reputation: 196

LaTeX math mode ($...$) font color in org mode

I have just started using org-mode and it looks awesome. The only issue that I have so far is that when I write a text in mathmode ($...$) it appears in the standard-text font color.

So, I would like to make org-mode to identify the mathmode text and be able to present it in some other color. Note that I don't need to change the color of the actual equation, just the source text in org-mode.

Here is an example of how the text is currently presented

A paper by Rohnert, titled "Moving a disc between polygons" introduces a structure using which one can generate a solution (path) for a given query in $O(\log n) + k$ time.

and how I would like it to look

A paper by Rohnert, titled "Moving a disc between polygons" introduces a structure using which one can generate a solution (path) for a given query in $O(\log n) + k$ time.

(Note that I would prefer to display in some given color, e.g. red, and not bold face.)

Upvotes: 8

Views: 3007

Answers (1)

Chris
Chris

Reputation: 136910

In Emacs version 24.4 and later, this is controlled via the variable org-highlight-latex-and-related:

Non-nil means highlight LaTeX related syntax in the buffer. When non nil, the value should be a list containing any of the following symbols:

  • `latex' Highlight LaTeX snippets and environments.
  • `script' Highlight subscript and superscript.
  • `entities' Highlight entities.

So something like

(eval-after-load 'org
  '(setf org-highlight-latex-and-related '(latex)))

in your init should help. Such code is formatted according to the face org-latex-and-related.

In earlier versions, the variable org-highlight-latex-fragments-and-specials, which is a simpler nil / non-nil variable:

(eval-after-load 'org
  '(setf org-highlight-latex-fragments-and-specials t))

In this case, the face org-latex-and-export-specials is used.

Upvotes: 12

Related Questions