emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* (Feature Request) customise LaTeX-preview regex
@ 2020-05-18  7:10 Timothy
  0 siblings, 0 replies; 9+ messages in thread
From: Timothy @ 2020-05-18  7:10 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

Another email, another request 😀

Hoping that you aren't tired of me yet, I have … (drum-roll) another feature request!
This time, I'm wanting to be able to use the lovely org latex preview functionality for more than just the default blocks.
For instance, I'm interested in applying it to mhchem \ce{ … } fragments, as well as siunitx \SI{ … }{ … }.

I thought modifying org-latex-regexps may do the trick, yet despite trying a few different things, I was confused when unable to get it to work. It looks like I'm being confounded by the fact that org-format-latex doesn't even reference org-latex-regexps, and instead uses it's own hard-coded regexps.
Hopefully it may be possible to tweak this so that once can preview more than just the defaults hardcoded into org-format-latex.
Warm regards,
tecosaur

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

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

* (Feature Request) customise LaTeX-preview regex
@ 2020-05-19  1:59 Timothy
  2020-05-19  7:26 ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy @ 2020-05-19  1:59 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

Another email, another request 😀

Hoping that you aren't tired of me yet, I have … (drum-roll) another feature request!
This time, I'm wanting to be able to use the lovely org latex preview functionality for more than just the default blocks.
For instance, I'm interested in applying it to mhchem \ce{ … } fragments, as well as siunitx \SI{ … }{ … }.

I thought modifying org-latex-regexps may do the trick, yet despite trying a few different things, I was confused when unable to get it to work. It looks like I'm being confounded by the fact that org-format-latex doesn't even reference org-latex-regexps, and instead uses it's own hard-coded regexps.
Hopefully it may be possible to tweak this so that once can preview more than just the defaults hardcoded into org-format-latex.
Warm regards,
Timothy


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

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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-05-19  1:59 (Feature Request) customise LaTeX-preview regex Timothy
@ 2020-05-19  7:26 ` Nicolas Goaziou
  2020-05-19  7:49   ` Timothy
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-05-19  7:26 UTC (permalink / raw)
  To: Timothy; +Cc: emacs-orgmode@gnu.org

Hello,

Timothy <tecosaur@gmail.com> writes:

> This time, I'm wanting to be able to use the lovely org latex preview functionality for more than just the default blocks.
> For instance, I'm interested in applying it to mhchem \ce{ … }
> fragments, as well as siunitx \SI{ … }{ … }.

I think you can preview \ce{...} just fine, with appropriate LaTeX
headers.

> I thought modifying org-latex-regexps may do the trick, yet despite
> trying a few different things, I was confused when unable to get it to
> work. It looks like I'm being confounded by the fact that
> org-format-latex doesn't even reference org-latex-regexps, and instead
> uses it's own hard-coded regexps.
> Hopefully it may be possible to tweak this so that once can preview
> more than just the defaults hardcoded into org-format-latex.

This should not be possible. Org cannot recognize all LaTeX syntax. If
you cannot preview it, Org does not understand it. IOW, it would be
a poor experience if you preview something that doesn't exist, e.g.,
upon exporting the document.

OTOH, nothing prevents an external library to allow previewing any LaTeX
code (probably re-using AucTeX facilities).

Regards,

-- 
Nicolas Goaziou


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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-05-19  7:26 ` Nicolas Goaziou
@ 2020-05-19  7:49   ` Timothy
  2020-05-19 11:45     ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy @ 2020-05-19  7:49 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

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

Hi Nicolas,

Thanks for getting back to me on this. With regard to
> I think you can preview \ce{...} just fine, with appropriate LaTeX headers.

I'm entirely likely to be missing something, however from a minimal test in a document I'm unable to get org-latex-preview to do anything with the following:
#+LATEX_HEADER: \usepackage{mhchem}
\ce{CO2} @@latex:\ce{CO2}@@
> This should not be possible. Org cannot recognize all LaTeX syntax. If
> you cannot preview it, Org does not understand it. IOW, it would be
> a poor experience if you preview something that doesn't exist, e.g.,
> upon exporting the document.
in a doc
My thoughts were that perhaps what works for \( ... \) and \[ ... \] (in terms of org-latex-preview) could be extended to other forms of inline LaTeX as well?
Given your response I'm guessing there are technical challenges with this?
FYI it seems to work fine for exporting (see image below), I'd just quite like to benefit from the visual tidiness achieved by the current LaTeX maths fragment rendering.

Oh, it just comes to mind that you may be referring to non-TeX-based output formats, where I can see that this could be a huge hassle.

Once again, (at this point in time) I am very loosely familiar with the innards of org (I've just stumbled around loking for specifics with C-h f / C-h v),
so if I look like I'm making any strange/outragous statements, please apply a substantial pinch of salt :D

Timothy

On May 19 2020, at 3:26 pm, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello, Timothy writes: > This time, I'm wanting to be able to use the lovely org latex preview functionality for more than just the default blocks. > For instance, I'm interested in applying it to mhchem \ce{ … } > fragments, as well as siunitx \SI{ … }{ … }. I think you can preview \ce{...} just fine, with appropriate LaTeX headers. > I thought modifying org-latex-regexps may do the trick, yet despite > trying a few different things, I was confused when unable to get it to > work. It looks like I'm being confounded by the fact that > org-format-latex doesn't even reference org-latex-regexps, and instead > uses it's own hard-coded regexps. > Hopefully it may be possible to tweak this so that once can preview > more than just the defaults hardcoded into org-format-latex. This should not be possible. Org cannot recognize all LaTeX syntax. If you cannot preview it, Org does not understand it. IOW, it would be a poor experience if you preview something that doesn't exist, e.g., upon exporting the document. OTOH, nothing prevents an external library to allow previewing any LaTeX code (probably re-using AucTeX facilities). Regards, -- Nicolas Goaziou


[-- Attachment #2.1: Type: text/html, Size: 4357 bytes --]

[-- Attachment #2.2: Pasted File.png --]
[-- Type: image/png, Size: 1989 bytes --]

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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-05-19  7:49   ` Timothy
@ 2020-05-19 11:45     ` Eric S Fraga
  2020-05-19 14:27       ` Timothy
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2020-05-19 11:45 UTC (permalink / raw)
  To: Timothy; +Cc: emacs-orgmode@gnu.org

On Tuesday, 19 May 2020 at 15:49, Timothy wrote:
> #+LATEX_HEADER: \usepackage{mhchem}
> \ce{CO2} @@latex:\ce{CO2}@@

You probably need to add this to =org-latex-packages-alist= in your
emacs configuration:

  (add-to-list 'org-latex-packages-alist '("version=3" "mhchem"))

Also, you might be interested in using the org-fragtog MELPA package.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-640-g9bc0cc


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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-05-19 11:45     ` Eric S Fraga
@ 2020-05-19 14:27       ` Timothy
  2020-06-14 13:53         ` TEC
  0 siblings, 1 reply; 9+ messages in thread
From: Timothy @ 2020-05-19 14:27 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode@gnu.org

On May 19 2020, at 7:45 pm, Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> You probably need to add this to =org-latex-packages-alist= in your
emacs configuration:
> (add-to-list 'org-latex-packages-alist '("version=3" "mhchem"))

I tried adding that. Didn't change anything.

> Also, you might be interested in using the org-fragtog MELPA package.
I'm already using it :P https://tecosaur.github.io/emacs-config/config.html#visuals

> On Tuesday, 19 May 2020 at 15:49, Timothy wrote:
>> #+LATEX_HEADER: \usepackage{mhchem}
>> \ce{CO2} @@latex:\ce{CO2}@@
> 
> You probably need to add this to =org-latex-packages-alist= in your
> emacs configuration:
> 
>  (add-to-list 'org-latex-packages-alist '("version=3" "mhchem"))
> 
> Also, you might be interested in using the org-fragtog MELPA package.
> 
> -- 
> : Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-640-g9bc0cc
> 


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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-05-19 14:27       ` Timothy
@ 2020-06-14 13:53         ` TEC
  2020-06-14 17:30           ` Nicolas Goaziou
  2020-06-15  9:04           ` Eric S Fraga
  0 siblings, 2 replies; 9+ messages in thread
From: TEC @ 2020-06-14 13:53 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode@gnu.org


Hi All,

Just a quick note: I'm yet to resolve this, so any further 
comments/help on this would be much appreciated :)

Thanks,

Timothy.


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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-06-14 13:53         ` TEC
@ 2020-06-14 17:30           ` Nicolas Goaziou
  2020-06-15  9:04           ` Eric S Fraga
  1 sibling, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2020-06-14 17:30 UTC (permalink / raw)
  To: TEC; +Cc: emacs-orgmode@gnu.org, Eric S Fraga

Hello,

TEC <tecosaur@gmail.com> writes:

> Just a quick note: I'm yet to resolve this, so any further
> comments/help on this would be much appreciated :)

You're only able to preview LaTeX code supported by Org, so something
like `org-latex-regexp' is not really meant to be extended. 

Org has limited support for LaTeX macros, i.e., this is not AucTeX. In
particular, it supports macros with at most one argument. With a proper
"latex_header" keyword, it should be possible to preview \ce{...}, but
not \SI{ … }{ … }. Likewise, the former will be correctly exported, but
not the latter.

Regards,

-- 
Nicolas Goaziou


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

* Re: (Feature Request) customise LaTeX-preview regex
  2020-06-14 13:53         ` TEC
  2020-06-14 17:30           ` Nicolas Goaziou
@ 2020-06-15  9:04           ` Eric S Fraga
  1 sibling, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2020-06-15  9:04 UTC (permalink / raw)
  To: TEC; +Cc: emacs-orgmode@gnu.org

On Sunday, 14 Jun 2020 at 21:53, TEC wrote:
> Hi All,
>
> Just a quick note: I'm yet to resolve this, so any further
> comments/help on this would be much appreciated :)

If you put the snippet in a math environment, it works with LaTeX
preview:

\(\ce{CO2}\)

Of course, this only applies to things that can belong in a maths
environment.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-636-gaa32f6


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

end of thread, other threads:[~2020-06-15  9:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19  1:59 (Feature Request) customise LaTeX-preview regex Timothy
2020-05-19  7:26 ` Nicolas Goaziou
2020-05-19  7:49   ` Timothy
2020-05-19 11:45     ` Eric S Fraga
2020-05-19 14:27       ` Timothy
2020-06-14 13:53         ` TEC
2020-06-14 17:30           ` Nicolas Goaziou
2020-06-15  9:04           ` Eric S Fraga
  -- strict thread matches above, loose matches on Subject: below --
2020-05-18  7:10 Timothy

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