Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-mode buffer latex syntax highlighting

I have been using org-mode for publishing scientific notes. Most of what I publish is compiled latex code and I am looking for a way to highlight latex syntax in the org-mode buffer. I came across many solutions for displaying published latex code with syntax highlighting using listed, minted, pygments, etc. Is there a way to display highlighted latex syntax in the org-buffer?

like image 349
user2509577 Avatar asked Jun 21 '13 15:06

user2509577


2 Answers

The variable org-highlight-latex-and-related allows you to highlight inline math. However, LaTeX fragments will only be highlighted with a single face.

From the documentation of org-highligh-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.

E.g.:

(setq org-highlight-latex-and-related '(latex script entities))

The face org-latex-and-related is used to fontify LaTeX fragments.

like image 96
Dominik Schrempf Avatar answered Oct 22 '22 09:10

Dominik Schrempf


You can enclose your latex fragments in#+BEGIN_LaTeX latex and #+END_LaTex latex to have them highlighted. It is different from source blocs (#+BEGIN_SRC LaTeX....) that are exported verbatim (with potential highlighting via pygments as you mentioned).

It works well for environments (equations,aligns...):

emacs screenshot

As far as I know it does not work for inline math (well it does if you enclose the whole paragraph but you loose the point of using org-mode...)

Source: this answer in emacs.stackexchange and Reddit.

like image 45
Geeklhem Avatar answered Oct 22 '22 09:10

Geeklhem