From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brady Trainor Subject: Re: syntax highlighting of inline LaTeX fragments Date: Sun, 02 Nov 2014 19:41:31 -0800 Message-ID: <87a949gdck.fsf@uw.edu> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8Wa-0007Fi-3u for emacs-orgmode@gnu.org; Sun, 02 Nov 2014 22:41:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xl8WU-0008Ag-Tg for emacs-orgmode@gnu.org; Sun, 02 Nov 2014 22:41:48 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:36244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8WU-0008AD-Gu for emacs-orgmode@gnu.org; Sun, 02 Nov 2014 22:41:42 -0500 Received: by mail-pd0-f174.google.com with SMTP id p10so10697374pdj.19 for ; Sun, 02 Nov 2014 19:41:40 -0800 (PST) In-Reply-To: (Ilya Shlyakhter's message of "Tue, 03 Jul 2012 19:11:36 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ilya Shlyakhter Cc: emacs-orgmode@gnu.org Ilya Shlyakhter 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