From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] curly nested latex fragments Date: Mon, 30 Jun 2014 14:31:28 +0200 Message-ID: <87pphqmvdr.fsf@nicolasgoaziou.fr> References: <86simqocpz.fsf@moguhome00.in.awa.tohoku.ac.jp> <878uoiy3bd.fsf@nicolasgoaziou.fr> <86pphshr82.fsf_-_@moguhome00.in.awa.tohoku.ac.jp> <87simng6tw.fsf@nicolasgoaziou.fr> <86k37zi63g.fsf@moguhome00.in.awa.tohoku.ac.jp> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1aja-0008VQ-Jl for emacs-orgmode@gnu.org; Mon, 30 Jun 2014 08:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1ajT-0000Es-Tg for emacs-orgmode@gnu.org; Mon, 30 Jun 2014 08:30:58 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:41652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1ajT-0000Ei-JQ for emacs-orgmode@gnu.org; Mon, 30 Jun 2014 08:30:51 -0400 In-Reply-To: <86k37zi63g.fsf@moguhome00.in.awa.tohoku.ac.jp> (heroxbd@gentoo.org's message of "Mon, 30 Jun 2014 09:38:59 +0900") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: heroxbd@gentoo.org Cc: emacs-orgmode@gnu.org Hello, heroxbd@gentoo.org writes: > Nicolas Goaziou writes: > >> I do not mind extending syntax for LaTeX macros a bit if it helps users, >> but first, I would like a clear definition of what subset of macros >> should be supported in Org. >> >> See, for example, >> >> http://orgmode.org/worg/dev/org-syntax.html#Entities_and_LaTeX_Fragments > > \ce{^{238}U} falls into \NAME POST, doesn't it? Sorry I wasn't clear. I suggested to not use a regexp to describe the syntax, as regular expressions may not be sufficient to describe the object. Try to use something like the link above. Also, bear in mind that a complicated regexp slows down parsing. > Ha, I don't even aware of <...> syntex as a part of the LaTeX macro; I > just copied the regex from org-latex.el. So let's strip it out, and > advise the users to use explicit LaTeX block for <...> constructs. > > + (looking-at (concat > + "\\\\\\([a-zA-Z]+\\*?\\)" > + "\\(?:\\[[^][\n]*?\\]\\)*" > + "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")) Unfortunately, this is ambiguous with Org macro syntax. For example, it would match: \alpha{{{macro(arg)}}} which is an entity followed by a macro. > Do you mean this[2] and this[3] threads? I've read them through, and > remotely understood the difficulty coming from the ambiguity of the > syntax. And as discussed above, the difficulty manifests in the > definition of LaTeX fragments, too. There is no ambiguity in LaTeX fragments, as Org is not required to support full raw LaTeX syntax (and never did anyway), as long as we provide markup to insert LaTeX in the buffer anyway. If we can support a bit more without introducing corner cases, that's fine. But, as you say, that's just syntactic sugar, so pure Org syntax goes first. > At the same time, these syntax sugar is great. And that's the reason > why we prefer org-mode in composing LaTeX to pristine LaTeX. There is a > sincere need to compromise the cleanness of the implementation for the > sake of an ambiguous-but-human-intuitive syntax. @@l:\ce{^{238}U}@@ is not so bad, nor is {{{ce(^{238)U)}}} with a properly defined macro template. Anyway, let me stress it again: a change to macro syntax is fine if it introduces no ambiguity. Obviously, the same holds for sub/superscript. > To resolve this dilemma, we need a formal (mathematically rigorous) org > syntex specification, like the rules drafted in > > http://orgmode.org/worg/dev/org-syntax.html#Entities_and_LaTeX_Fragments > > together with a set of test suites to demonstrate the spec. There would > be a lot of work, but we could start from embedded LaTeX fragments and > super(sub)scripts/underline. > > It might be mentally overwhelming for one single guy to do the spec and > the implementation at the same time, because they require different > mindsets. The spec is long term and should be stable while the > implementation is always being optimized. After all, it is considered > good practice to make the two processes independent to each other. I'm not sure what do you mean. "org-syntax.html" describes, well, the syntax (although it could be better, with, e.g., EBNF, help is welcome), "org-element.el" implements it, with optimizations, and "test-org-element.el" tests the implementation. Anyway, let's concentrate on LaTeX macros. Regards, -- Nicolas Goaziou