Search code examples
emacslatexorg-mode

Emacs org mode: background color of latex fragments (with `org-highlight-latex-and-related`) : which variable to change?


Ok, so my org-mode latex fragments have a slightly off background color, but only when I:

(setq org-highlight-latex-and-related '(native))

As seen here enter image description here

It looks similar to the background highlighting functionality as involved in ~~ (code).

Does anyone know what to do?

BONUS:

  • I'm using doom emacs and the gruvbox theme.

TRIED:

  • I don't think this is related to the fragments themselves a la org-format-latex-options (as seen in many other posts)
  • This is NOT helped by setting font-latex-math-face :background

HINTS:

  • I feel like it IS related to the face org-latex-and-related, but I can work out how the chance the background, when I 'customise' the face i get the following:
(defface org-latex-and-related
  (let ((font (cond ((assq :inherit custom-face-attributes)
             '(:inherit underline))
            (t '(:underline t)))))
    `((((class grayscale) (background light))
       (:foreground "DimGray" ,@font))
      (((class grayscale) (background dark))
       (:foreground "LightGray" ,@font))
      (((class color) (background light))
       (:foreground "SaddleBrown"))
      (((class color) (background dark))
       (:foreground "burlywood"))
      (t (,@font))))
  "Face used to highlight LaTeX data, entities and sub/superscript."
  :group 'org-faces
  :version "24.4"
  :package-version '(Org . "8.0"))

Solution

  • Answering my own question.

    As usual, tecosaur got there first and gives a good breakdown of the internals.

    The code that does the magic is

    (require 'org-src)
    (add-to-list 'org-src-block-faces '("latex" (:inherit default :extend t)))