From: Ihor Radchenko <yantar92@posteo.net>
To: alain.cochard@unistra.fr
Cc: emacs-orgmode@gnu.org
Subject: Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?
Date: Thu, 29 Dec 2022 10:04:00 +0000 [thread overview]
Message-ID: <87wn6av84v.fsf@localhost> (raw)
In-Reply-To: <25516.19256.621545.995694@gargle.gargle.HOWL>
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>
next prev parent reply other threads:[~2022-12-29 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-28 13:57 Problems with LaTeX export for $x\text{foo $x$}$-like construts? Alain.Cochard
2022-12-29 10:04 ` Ihor Radchenko [this message]
2022-12-29 10:39 ` Alain.Cochard
2022-12-29 10:44 ` Ihor Radchenko
2022-12-29 11:52 ` Ihor Radchenko
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=87wn6av84v.fsf@localhost \
--to=yantar92@posteo.net \
--cc=alain.cochard@unistra.fr \
--cc=emacs-orgmode@gnu.org \
/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).