emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* syntax highlighting of inline LaTeX fragments
@ 2012-07-03 23:11 Ilya Shlyakhter
  2012-07-04  4:05 ` Jeffrey Spencer
  2014-11-03  3:41 ` Brady Trainor
  0 siblings, 2 replies; 5+ messages in thread
From: Ilya Shlyakhter @ 2012-07-03 23:11 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax highlighting of inline LaTeX fragments
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Jeffrey Spencer @ 2012-07-04  4:05 UTC (permalink / raw)
  To: Ilya Shlyakhter; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

Also interested in if this is possible and what do you use to highlight
LaTeX code blocks.

On Wed, Jul 4, 2012 at 9:11 AM, Ilya Shlyakhter <ilya_shl@alum.mit.edu>wrote:

> 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
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 736 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax highlighting of inline LaTeX fragments
  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
  2014-11-03  7:43   ` Rasmus
  1 sibling, 1 reply; 5+ messages in thread
From: Brady Trainor @ 2014-11-03  3:41 UTC (permalink / raw)
  To: Ilya Shlyakhter; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax highlighting of inline LaTeX fragments
  2014-11-03  3:41 ` Brady Trainor
@ 2014-11-03  7:43   ` Rasmus
  2014-11-03 16:16     ` Brady Trainor
  0 siblings, 1 reply; 5+ messages in thread
From: Rasmus @ 2014-11-03  7:43 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Brady Trainor <algebrat@uw.edu> writes:

> 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]

The variable `org-highlight-latex-and-related' should allow you to
highlight inline math.  For citations, one solution would be something
like [[cite:smith2012generatin][Smith (2012)]].

Hope it helps,
Rasmus

-- 
When in doubt, do it!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax highlighting of inline LaTeX fragments
  2014-11-03  7:43   ` Rasmus
@ 2014-11-03 16:16     ` Brady Trainor
  0 siblings, 0 replies; 5+ messages in thread
From: Brady Trainor @ 2014-11-03 16:16 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> The variable `org-highlight-latex-and-related' should allow you to
> highlight inline math.

Thank you.

Takes care of all,
- $..$
- $$..$$ (w/ newlines)
- \(..\)
- \[..\] (w/ newlines)
- \begin{equation}..\end{equation} (w/ newlines)

--
Brady

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-03 16:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2014-11-03  7:43   ` Rasmus
2014-11-03 16:16     ` Brady Trainor

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).