emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Suggestion : Option enabling LaTeX blocks to non-latex exporters.
@ 2021-07-18 12:24 Emmanuel Charpentier
  2021-07-18 14:25 ` Timothy
  0 siblings, 1 reply; 3+ messages in thread
From: Emmanuel Charpentier @ 2021-07-18 12:24 UTC (permalink / raw)
  To: emacs-orgmode

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

Dear list,

"raw" LaTeX can already be successfully exported by some exporters :
both html and odt exporters can translate (a limited subset of) such
latex expressions in something palatable to their respective targets
(Mathjax and representation MathML respectively).

This does *not* apply to LaTeX marked as such. To be clear :

babble babble $\int_a^b f(x) dx$ noise noise

will export the math expression to  html and odt (if tex:t or
tex:dvipng or tex:dvisvgm) ; on the other hand

babble babble @@latex:$\int_a^b f(x) dx$@@ noise noise

will not. Neither will :

#+latex: \[\Phi_{\mu, \sigma}(x) = \frac{e^-{\frac{(x-\mu)^2}{2\sigma^2}}}{\sigma\sqrt{2\pi}}\,.\]

nor :

#+begin_export latex
\[\Phi_{\mu, \sigma}(x) = \frac{e^-{\frac{(x-\mu)^2}{2\sigma^2}}}{\sigma\sqrt{2\pi}}\,.\]
#+end_export

This has an annoying consequence : a function cannot (easily) return a
LaTeX block. One can return a raw result, but this loses the link
between the function and its result(s).

John Kitchin has suggested
(https://lists.gnu.org/archive/html/emacs-orgmode/2021-07/msg00099.html)
 to wrap raw latex code in a drawer ; this works, but I am unable to
understand how, and I do not know what are the consequences.

Having an option allowing latex code marked as such to be passed to
other exporters (possibly with conversion) would allow a "cleaner"
solution.

What do you think ?

--
Emmanuel Charpentier


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

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

* Re: Suggestion : Option enabling LaTeX blocks to non-latex exporters.
  2021-07-18 12:24 Suggestion : Option enabling LaTeX blocks to non-latex exporters Emmanuel Charpentier
@ 2021-07-18 14:25 ` Timothy
  2021-07-18 17:10   ` Emmanuel Charpentier
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy @ 2021-07-18 14:25 UTC (permalink / raw)
  To: Emmanuel Charpentier; +Cc: emacs-orgmode


Hi Emmanuel,

It may interest you to hear that I submitted a patch a month or two ago
(which was merged) to support LaTeX environments as results.

That means that this is now possible:


#+begin_src something
...stuff...
#+end_src

#+results:
\begin{equation*}
  some latex which will be exported nicely
\end{equation*}


All the best,

Timothy


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

* Re: Suggestion : Option enabling LaTeX blocks to non-latex exporters.
  2021-07-18 14:25 ` Timothy
@ 2021-07-18 17:10   ` Emmanuel Charpentier
  0 siblings, 0 replies; 3+ messages in thread
From: Emmanuel Charpentier @ 2021-07-18 17:10 UTC (permalink / raw)
  To: Timothy, emacs-orgmode

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

Well... this :


#+begin_src sage :exports both :results output raw
  a, b = var("a, b");
  print("\\begin{equation*}\n%s\n\\end{equation*}"%latex(sin(a+b)==sin(a+b).trig_expand()))
  # print("\\(%s\n\\)"%latex(sin(a+b)==sin(a+b).trig_expand()))
#+end_src

#+RESULTS:
\begin{equation*}
\sin\left(a + b\right) = \cos\left(b\right) \sin\left(a\right) + \cos\left(a\right) \sin\left(b\right)
\end{equation*}

will get you the expected result, in ODT as in PDF. But this might be
happenstance : the slightly simpler

#+begin_src sage :exports both :results output raw
  a, b = var("a, b");
 #  print("\\begin{equation*}\n%s\n\\end{equation*}"%latex(sin(a+b)==sin(a+b).trig_expand()))
  print("\\(%s\n\\)"%latex(sin(a+b)==sin(a+b).trig_expand()))
#+end_src

#+RESULTS:
\(\sin\left(a + b\right) = \cos\left(b\right) \sin\left(a\right) + \cos\left(a\right) \sin\left(b\right)
\)

will print the expected results *twice* (in ODT and in PDF).

The more straightforward) 

#+begin_src sage :exports both :results value latex
  var("a, b")
  latex(cos(a+b)==cos(a+b).trig_expand())
#+end_src

#+RESULTS:
#+begin_export latex
\cos\left(a + b\right) = \cos\left(a\right) \cos\left(b\right) - \sin\left(a\right) \sin\left(b\right)
#+end_export

gives the expected result in PDF (i. e. results *once*,whether the code
has #+results: or not), but not in ODT.

The "Kitchin's workaround" :


#+begin_src sage :exports both :results drawer
  print("\\(\\displaystyle{%s}\\)"%latex(tan(a+b)==tan(a+b).trig_expand()))
#+end_src

#+RESULTS:
:results:
\(\displaystyle{\tan\left(a + b\right) = -\frac{\tan\left(a\right) + \tan\left(b\right)}{\tan\left(a\right) \tan\left(b\right) - 1}}\)
:end:

works as (un)expected, but is still less straightforward. I'd rather
have a documented, understood way to export LaTeX snippets/ blocks
marked as such explicitly exported to ODT...

Hope this is clearer,

--
Emmanuel Charpentier

 
Le dimanche 18 juillet 2021 à 22:25 +0800, Timothy a écrit :
> 
> Hi Emmanuel,
> 
> It may interest you to hear that I submitted a patch a month or two
> ago
> (which was merged) to support LaTeX environments as results.
> 
> That means that this is now possible:
> 
> 
> #+begin_src something
> ...stuff...
> #+end_src
> 
> #+results:
> \begin{equation*}
>   some latex which will be exported nicely
> \end{equation*}
> 
> 
> All the best,
> 
> Timothy


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

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

end of thread, other threads:[~2021-07-18 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18 12:24 Suggestion : Option enabling LaTeX blocks to non-latex exporters Emmanuel Charpentier
2021-07-18 14:25 ` Timothy
2021-07-18 17:10   ` Emmanuel Charpentier

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