emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] syntax highlighting of inline LaTeX fragments


From: Brady Trainor
Subject: Re: [O] syntax highlighting of inline LaTeX fragments
Date: Sun, 02 Nov 2014 19:41:31 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Ilya Shlyakhter <address@hidden> writes:

> dear org-moders,
> is it possible to syntax-highlight inline LaTeX fragments,
> such as $V$ or \cite{smith2012generating} ?
> I know you can highlight LaTeX code blocks, but I'm looking
> specifically for highlighting of inline fragments.
> thanks for help,
> ilya

:bump:

[feature-request]

I would also like this.

I may have to try out mmm-mode.

One solution is to use M-x latex-mode, then M-x orgstruct-mode, but headlines 
lose their syntax highlighting.

There is also a blob from 
[[http://stackoverflow.com/a/25048304/2533127][org-mode buffer latex syntax 
highlighting - Stack Overflow]], but I've so far only improved it to the 
following state:

#+BEGIN_SRC emacs-lisp
(font-lock-add-keywords
 'org-mode
 `(("\\$.+?\\$" . font-lock-keyword-face)
   ("\\$\\$.+\\$\\$" . font-lock-keyword-face)
   (,(concat "\\\\" "\\["       ; \[
             "\\("              ; \(
             "." "\\|" "\n"     ; .|\n
             "\\)" "*"          ; \)*
             "\\\\" "\\]")      ; \]
    . font-lock-keyword-face)))
#+END_SRC

So I now get some syntax highlighting on articles written in org like

#+BEGIN_SRC org
$$ W_{net} = \Delta KE. $$

On the other hand, the $i^{th}$ contribution to the work due to the $i^{th}$ 
force is /always/ 

\[
W_i = \int_{\textbf{a}}^{\textbf{b}} 
      \textbf{F}_i \cdot d\textbf{r}. 
\]
#+END_SRC

It's a little broken, for instance it doesn't react to changes in the buffer. 

Some links discussing similar issues include: 

- 
http://www.gnu.org/software/emacs/manual/html_node/elisp/Multiline-Font-Lock.html
- 
http://stackoverflow.com/questions/9452615/emacs-is-there-a-clear-example-of-multi-line-font-locking
- 
http://stackoverflow.com/questions/19623503/emacs-major-mode-font-lock-only-occurs-when-first-loading-file
- http://www.emacswiki.org/emacs/MultilineRegexp

--
Brady




reply via email to

[Prev in Thread] Current Thread [Next in Thread]