* LaTeX math mode and export @ 2013-10-11 9:13 Fabrice Popineau 2013-10-11 15:43 ` Nicolas Goaziou 0 siblings, 1 reply; 6+ messages in thread From: Fabrice Popineau @ 2013-10-11 9:13 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 2966 bytes --] Hi, The status of when warious LaTeX related markers are escaped or not has moved over time, but the situation reached is still not very clear. If I do the following test with yesterday's git org-mode : #+LaTeX_CLASS: article #+OPTIONS: H:2 <:nil toc:nil * Test [2013-10-11 ven. 10:45] ** Subsection [2013-10-11 ven. 10:46] Let blah blah blah ... \[ \tilde{\delta}(q, w) = \left\{\begin{array}{ll} q & \text{ si } w = \epsilon \\ \delta(\tilde{\delta}(q,w'),a) & \text{ si } w = w'a \text{ et } a \in \Sigma \end{array}\right. \] ** Subsection [2013-10-11 ven. 10:48] Let blah blah blah ... \[\begin{array}{c} \begin{array}{|c|c|c|} \hline \delta_{1} & 0 & 1 \\ \hline p & \{p, q\} & \{q\} \\ \hline q & \{r\} & \{q, r\} \\ \hline r & \{s\} & \{p\} \\ \hline s & \{s\} & \{p\} \\ \hline \end{array} \] The first \[ is left as-is but the second one is translated into $\backslash$[ which is obviously weird. Moreover Mathjax being able to interpret this, it should be better if these equations where all left as-is in the text for both html and latex exporters. Unless there is something I can't see that prevents to do it? I have two other examples of the same kind of problem: 1- Same thing with \( ... \) instead of \[ ...\] : ** Subsection [2013-10-11 ven. 11:05] - \(\min(x,y)\) , \(\max(x,y)\) - \(\operatorname{Prime}(x) = \left\{ \begin{array}{cl} 1 & \text{ if } x \text{ is prime } \\ 0 & \text{ if } x \text{ is not prime } \end{array} \right. \) I ended up in surrounding the second item text into #+begin_latex ... #+end_latex. 2 - Quoting of {} may also happen in unwanted places. If I write a complex author line like : #+AUTHOR: \IEEEauthorblockN{Foo, Bar} \IEEEauthorblockA{ Somewhere\\ Over the Rainbow \\ Email: \{foo,bar\}@baz.fr } \and \IEEEauthorblockN{foobar} \IEEEauthorblockA{somewhere else \\ Email: foobar@baz.fr} I get with the latex export : \author{\IEEEauthorblockN{Foo, Bar} \IEEEauthorblockA\{ Somewhere\\ Over the Rainbow \\ Email: \{foo,bar\}@baz.fr \} \and \IEEEauthorblockN{foobar} \IEEEauthorblockA{somewhere else \\ Email: foobar@baz.fr}} It seems impossible to avoid that the curly braces of \IEEEauthorblockA be left as-is. I guess all of this is about tweaking regular expressions, but I'm afraid I won't be aware of other side effects. I would be glad to whoever can offer a better handling of these situations. Another related question also : did anybody managed to hilghlight LaTeX equations inside org-mode ? It could be very helpful to detect missing end markers. Thanks for your work on Org mode and for you help :-) -- Fabrice Popineau ----------------------------- SUPELEC Département Informatique 3, rue Joliot Curie 91192 Gif/Yvette Cedex Tel direct : +33 (0) 169851950 Standard : +33 (0) 169851212 ------------------------------ [-- Attachment #2: Type: text/html, Size: 4432 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: LaTeX math mode and export 2013-10-11 9:13 LaTeX math mode and export Fabrice Popineau @ 2013-10-11 15:43 ` Nicolas Goaziou 2013-10-11 22:03 ` Fabrice Popineau 0 siblings, 1 reply; 6+ messages in thread From: Nicolas Goaziou @ 2013-10-11 15:43 UTC (permalink / raw) To: Fabrice Popineau; +Cc: emacs-orgmode@gnu.org Hello, Fabrice Popineau <fabrice.popineau@supelec.fr> writes: > \[\begin{array}{c} > \begin{array}{|c|c|c|} > \hline > \delta_{1} & 0 & 1 \\ > \hline > p & \{p, q\} & \{q\} \\ > \hline > q & \{r\} & \{q, r\} \\ > \hline > r & \{s\} & \{p\} \\ > \hline > s & \{s\} & \{p\} \\ > \hline > \end{array} > \] This isn't correct syntax: "\begin{array}{|c|c|c|}...\end{array}" is parsed as a latex environment, so it breaks the paragraph you started the line before. You can use "\begin{equation}" instead of "\[". > - \(\min(x,y)\) , \(\max(x,y)\) > - \(\operatorname{Prime}(x) = \left\{ \begin{array}{cl} 1 & \text{ if } > x \text{ is prime } \\ 0 & \text{ if } x \text{ is not prime } > \end{array} \right. \) The last line is not correctly indented: it doesn't belong to the last item and therefore, the math snippets is not recognized. > 2 - Quoting of {} may also happen in unwanted places. If I write a complex > author line like : > > #+AUTHOR: \IEEEauthorblockN{Foo, Bar} \IEEEauthorblockA{ Somewhere\\ Over > the Rainbow \\ Email: \{foo,bar\}@baz.fr } \and \IEEEauthorblockN{foobar} > \IEEEauthorblockA{somewhere else \\ Email: foobar@baz.fr} You cannot write raw non-math LaTeX in an Org buffer (unless it is also an entity). You ought to use export snippets, i.e., @@latex:...@@. > Another related question also : did anybody managed to hilghlight LaTeX > equations inside org-mode ? See `org-highlight-latex-and-related'. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: LaTeX math mode and export 2013-10-11 15:43 ` Nicolas Goaziou @ 2013-10-11 22:03 ` Fabrice Popineau 2013-10-12 7:58 ` Nicolas Goaziou 0 siblings, 1 reply; 6+ messages in thread From: Fabrice Popineau @ 2013-10-11 22:03 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 3894 bytes --] > > \[\begin{array}{c} > > \begin{array}{|c|c|c|} > > \hline > > \delta_{1} & 0 & 1 \\ > > \hline > > p & \{p, q\} & \{q\} \\ > > \hline > > q & \{r\} & \{q, r\} \\ > > \hline > > r & \{s\} & \{p\} \\ > > \hline > > s & \{s\} & \{p\} \\ > > \hline > > \end{array} > > \] > > This isn't correct syntax: "\begin{array}{|c|c|c|}...\end{array}" is > parsed as a latex environment, so it breaks the paragraph you started > the line before. You can use "\begin{equation}" instead of "\[". > > I'm not sure why it is not correct : I guess you mean not correct Org syntax? (I broke my example by shortening it, one \end{array} is missing and there used to be other arrays below) The problem as I feel it is that \[ \] works sometimes, but not as often as with LaTeX, which is disconcerting. I know that theparagraph entity in Org mode is different than what it is is in LaTeX, but still. Why \[ ... \] couldn't be handled as if it where \begin{equation} ... \end{equation} ? Is there any other use of \[ that would prevent its detection ? Sorry to be such an hassle, but that would help to smooth the conversion of previous LaTeX files/users to Org. If I fix it and I use #+begin_equation ... #+end_equation , I still hit something with these math delimiters: #+begin_equation \begin{array}{c} \begin{array}{|c|c|c|} \hline \delta_{1} & 0 & 1 \\ \hline p & \{p, q\} & \{q\} \\ \hline q & \{r\} & \{q, r\} \\ \hline r & \{s\} & \{p\} \\ \hline s & \{s\} & \{p\} \\ \hline \end{array} \vspace{1em} \\ (\{p,q,r,s\}, \{0,1\}, \delta_{2}, p, \{q,s\}) \end{array} #+end_equation The last line but two is translated : (\{p,q,r,s\}, \{0,1\}, $\delta$$_{\text{2}}$, p, \{q,s\}) This time, given that we are in an equation environment, things should be left as-is surely? > - \(\min(x,y)\) , \(\max(x,y)\) > > - \(\operatorname{Prime}(x) = \left\{ \begin{array}{cl} 1 & \text{ if } > > x \text{ is prime } \\ 0 & \text{ if } x \text{ is not prime } > > \end{array} \right. \) > > The last line is not correctly indented: it doesn't belong to the last > item and therefore, the math snippets is not recognized. True, didn't notice that it could make a difference, because Org-mode refuses to indent it. I mean I used <Tab> on all lines and thought that it wasn't indented because it could have been the previous line that was wrapped. Org-mode is able to indent the second line but what is preventing it to indent the third line? > > 2 - Quoting of {} may also happen in unwanted places. If I write a complex > > author line like : > > > > #+AUTHOR: \IEEEauthorblockN{Foo, Bar} \IEEEauthorblockA{ Somewhere\\ Over > > the Rainbow \\ Email: \{foo,bar\}@baz.fr } \and > \IEEEauthorblockN{foobar} > > \IEEEauthorblockA{somewhere else \\ Email: foobar@baz.fr} > > You cannot write raw non-math LaTeX in an Org buffer (unless it is also > an entity). You ought to use export snippets, i.e., @@latex:...@@. Ok. I understand that curly braces in plain text need to be backslahed in LaTeX. But again what is surprising is that the backslash itself in \IEEEAuthorBlockA and \IEEEAuthorBlockN are not translated to LaTeX syntax. Actually, it is only the second curly brace that gets backslashed, not even the first one. > Another related question also : did anybody managed to hilghlight LaTeX > > equations inside org-mode ? > > See `org-highlight-latex-and-related'. > > I hope my comments do not seem too rude. I try to report the feeling of someone who doesn't know the internals. I think that the less suprised the user is, the more it is willing to accept the tool. In the area of maths delimiters, I start to wonder if Org-mode doesn't push too far its guessing of what the user had intended. But maybe I don't see the whole picture. Thanks a lot for your help and your work, -- Fabrice [-- Attachment #2: Type: text/html, Size: 6368 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: LaTeX math mode and export 2013-10-11 22:03 ` Fabrice Popineau @ 2013-10-12 7:58 ` Nicolas Goaziou 2013-10-12 8:31 ` Nicolas Goaziou 2013-10-12 10:56 ` Suvayu Ali 0 siblings, 2 replies; 6+ messages in thread From: Nicolas Goaziou @ 2013-10-12 7:58 UTC (permalink / raw) To: Fabrice Popineau; +Cc: emacs-orgmode@gnu.org Hello, Fabrice Popineau <fabrice.popineau@supelec.fr> writes: > I'm not sure why it is not correct : I guess you mean not correct Org > syntax? Correct. > The problem as I feel it is that \[ \] works sometimes, but not as > often as with LaTeX, which is disconcerting. \[...\] is more limited in Org than in LaTeX, indeed. > I know that theparagraph entity in Org mode is different than what it is is > in LaTeX, but still. > > Why \[ ... \] couldn't be handled as if it where \begin{equation} ... > \end{equation} ? > Is there any other use of \[ that would prevent its detection ? There are two types of structures in Org syntax: inline (i.e. contained in a paragraph) and not inline. inlined structures always belong to a non-inlined one. Therefore, the parser always gives precedence to non-inlined syntax over inlined one. Thus, the following example will be a single paragraph with some maths inside: A paragraph with \[1+1=2\] maths. But the following one: A paragraph \[1 + 1 = 2 \] with maths. will be a paragraph, a list and another paragraph: "A paragraph\n\[1", " + 1" and " = 2\n\]\nwith maths." If \[...\] constructs were to be changed into non-inlined, the maths snippet in the first example would not be recognized. It is theoretically possible to make "\[...\]" both inline and non-inline. Though, I have the feeling that it would come with its own set of problems. > Sorry to be such an hassle, but that would help to smooth the conversion of > previous LaTeX files/users > to Org. I think that a major pitfall for these users is to think that you can wrap LaTeX syntax in Org structures. Actually, Org only supports a limited set of LaTeX syntax. > IF I fix it and I use #+begin_equation ... #+end_equation , I still hit > something with these math delimiters: No, you should use \begin{equation}...\end{equation} in order to make it a full LaTeX environment. #+begin_equation is not an equation environment, it's a special block, which can contain Org syntax (and you don't want Org syntax here). > > - \(\min(x,y)\) , \(\max(x,y)\) >> > - \(\operatorname{Prime}(x) = \left\{ \begin{array}{cl} 1 & \text{ if } >> > x \text{ is prime } \\ 0 & \text{ if } x \text{ is not prime } >> > \end{array} \right. \) >> >> The last line is not correctly indented: it doesn't belong to the last >> item and therefore, the math snippets is not recognized. > > True, didn't notice that it could make a difference, because Org-mode > refuses to indent it. > I mean I used <Tab> on all lines and thought that it wasn't indented > because it could have > been the previous line that was wrapped. Org-mode is able to indent the > second line but > what is preventing it to indent the third line? The last line doesn't belong to the list above. "Indenting" it at the "x" level would actually change the structure of the list, which is more than what a simple indentation command is allowed to do (I know about python mode and I don't think it is a good behaviour for Org). > Ok. I understand that curly braces in plain text need to be backslahed in > LaTeX. > But again what is surprising is that the backslash itself > in \IEEEAuthorBlockA and \IEEEAuthorBlockN are not translated to LaTeX > syntax. Honestly, it surprised me too, as I thought that every curly bracket would be escaped. But I don't have time to look into it at the moment. > I hope my comments do not seem too rude. I try to report the feeling of > someone > who doesn't know the internals. I think that the less suprised the user is, > the more it is > willing to accept the tool. In the area of maths delimiters, I start to > wonder if Org-mode doesn't push too far > its guessing of what the user had intended. But maybe I don't see the whole > picture. I think the behaviour is not surprising once you know that Org you can't mix raw LaTeX and regular Org syntax without some precautions. In particular, Org can only parse very simple LaTeX syntax, but provides ways to deal with more more complex one. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: LaTeX math mode and export 2013-10-12 7:58 ` Nicolas Goaziou @ 2013-10-12 8:31 ` Nicolas Goaziou 2013-10-12 10:56 ` Suvayu Ali 1 sibling, 0 replies; 6+ messages in thread From: Nicolas Goaziou @ 2013-10-12 8:31 UTC (permalink / raw) To: Fabrice Popineau; +Cc: emacs-orgmode@gnu.org Completing myself, > Fabrice Popineau <fabrice.popineau@supelec.fr> writes: >> But again what is surprising is that the backslash itself >> in \IEEEAuthorBlockA and \IEEEAuthorBlockN are not translated to LaTeX >> syntax. > > Honestly, it surprised me too, as I thought that every curly bracket > would be escaped. But I don't have time to look into it at the moment. Actually, the reason is that regexp matching a macro is: "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*" IOW, brackets (even escaped) are not allowed in the arguments of a LaTeX macro. So the first \IEEEAuthorBlockN is correctly recognized but \IEEEauthorblockA fails. This is not optimal, but I think it is sufficient, since, again, Org handles only simple raw LaTeX syntax. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: LaTeX math mode and export 2013-10-12 7:58 ` Nicolas Goaziou 2013-10-12 8:31 ` Nicolas Goaziou @ 2013-10-12 10:56 ` Suvayu Ali 1 sibling, 0 replies; 6+ messages in thread From: Suvayu Ali @ 2013-10-12 10:56 UTC (permalink / raw) To: emacs-orgmode On Sat, Oct 12, 2013 at 09:58:27AM +0200, Nicolas Goaziou wrote: > Fabrice Popineau <fabrice.popineau@supelec.fr> writes: > > > The problem as I feel it is that \[ \] works sometimes, but not as > > often as with LaTeX, which is disconcerting. > > \[...\] is more limited in Org than in LaTeX, indeed. > > > I know that theparagraph entity in Org mode is different than what it is is > > in LaTeX, but still. > > > > Why \[ ... \] couldn't be handled as if it where \begin{equation} ... > > \end{equation} ? > > Is there any other use of \[ that would prevent its detection ? > > There are two types of structures in Org syntax: inline (i.e. contained > in a paragraph) and not inline. inlined structures always belong to > a non-inlined one. Therefore, the parser always gives precedence to > non-inlined syntax over inlined one. > > Thus, the following example will be a single paragraph with some maths > inside: > > A paragraph with \[1+1=2\] maths. > > But the following one: > > A paragraph > \[1 > + 1 > = 2 > \] > with maths. > > will be a paragraph, a list and another paragraph: "A paragraph\n\[1", > " + 1" and " = 2\n\]\nwith maths." > > If \[...\] constructs were to be changed into non-inlined, the maths > snippet in the first example would not be recognized. > > It is theoretically possible to make "\[...\]" both inline and > non-inline. Though, I have the feeling that it would come with its own > set of problems. A very nice explanation. Thank you. > > Sorry to be such an hassle, but that would help to smooth the conversion of > > previous LaTeX files/users > > to Org. > > I think that a major pitfall for these users is to think that you can > wrap LaTeX syntax in Org structures. Actually, Org only supports > a limited set of LaTeX syntax. If I may, I think these users are better off using some of the Org outside Org libraries. <http://orgmode.org/worg/org-tutorials/org-outside-org.html> One of Org's goals, with regards to exporters, is to be uniform across all backends so that one can export the same document using multiple backends without major changes. Including more and more LaTeX source deviates from that goal. Hope this helps, -- Suvayu Open source is the future. It sets us free. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-12 10:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-11 9:13 LaTeX math mode and export Fabrice Popineau 2013-10-11 15:43 ` Nicolas Goaziou 2013-10-11 22:03 ` Fabrice Popineau 2013-10-12 7:58 ` Nicolas Goaziou 2013-10-12 8:31 ` Nicolas Goaziou 2013-10-12 10:56 ` Suvayu Ali
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).