emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?


From: Ihor Radchenko
Subject: Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?
Date: Thu, 29 Dec 2022 10:04:00 +0000

Alain.Cochard@unistra.fr writes:

> Version used: release_9.6-149-g554935 
>
> With an org file containing only
>
>    #+begin_export latex
>    $x \text{foo $y$}$
>
>    \(x \text{foo \(y\)}\)
>
>    $x \text{foo \(y\)}$
>
>    \(x \text{foo $y$}\)
>    #+end_export
>
> the pdf generated upon latex export gives as expected, i.e., with 'x'
> and 'y' in mathematical font.

This is to be expected because of how Org parser works.

In particular, $-style math is tricky because Org allows "$" both as
math delimiter and also as standalone symbol. There are trade-offs.

For the \(...\), it is because Org parser does not understand nesting:
it takes first opening \( and match it with the first closing \) - thus
what you observe.

Unfortunately, I do not see an easy solution without hitting parser
performance. Our general approach is to avoid forward-parsing as much as
possible with an exception to paired brackets (because Elisp allows
parsing paired brackets fast using C-level code). However, AFAIK, there
is no easy way to parse brackets that are not single symbols. "\(" is
impossible to match using `scan-lists'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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