From: Brady Trainor <algebrat@uw.edu>
To: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: syntax highlighting of inline LaTeX fragments
Date: Sun, 02 Nov 2014 19:41:31 -0800 [thread overview]
Message-ID: <87a949gdck.fsf@uw.edu> (raw)
In-Reply-To: <jsvu79$c5$1@dough.gmane.org> (Ilya Shlyakhter's message of "Tue, 03 Jul 2012 19:11:36 -0400")
Ilya Shlyakhter <ilya_shl@alum.mit.edu> 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
next prev parent reply other threads:[~2014-11-03 3:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-03 23:11 syntax highlighting of inline LaTeX fragments Ilya Shlyakhter
2012-07-04 4:05 ` Jeffrey Spencer
2014-11-03 3:41 ` Brady Trainor [this message]
2014-11-03 7:43 ` Rasmus
2014-11-03 16:16 ` Brady Trainor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a949gdck.fsf@uw.edu \
--to=algebrat@uw.edu \
--cc=emacs-orgmode@gnu.org \
--cc=ilya_shl@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).