* LaTeX-producing code : how to export results to HTML/ODT ?
@ 2021-07-04 7:45 Emmanuel Charpentier
2021-07-04 18:10 ` John Kitchin
0 siblings, 1 reply; 8+ messages in thread
From: Emmanuel Charpentier @ 2021-07-04 7:45 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1144 bytes --]
Dear list,
Org-mode offers the ability to create functions returning LaTeX results
: such occurrences are frequent with Sagemath, Maxima, Mathematica, R,
and even emacs's Calc...
Such functions can be declared has having LaTeX output, and the
resulting =#+begin_export latex ... #+end_export latex= block is
exported as LaTeX and end up in the PDF versin.
But such blocks seem to export *only* to LaTeX/PDF ; more specically,
they do not export to HTML nor ODT. In order to insert those results at
export, one *has* to print them *raw*. See the attached examples, and
compare PDF, HTML and ODT outputs of the enclosed zip archive
(necessary to avoid the wrath of the spam filter of my provider ;-
)...)..
Unless I am mistaken, this is the *only* way to export LaTeX exports to
HTML/ODT ; I am not aware of any option allowing to force such exports.
So a couple questions :
* Am I mistaken ?
* Are there more steamlined ways to get LaTeX in HTML/ODF/whatever-
but-not-LaTeX ?
* Wouldn't an option to allow these exports be a welcome addition to
the export structure (or possibly to the various exporters) ?
Thanks in advance,
[-- Attachment #1.2: Type: text/html, Size: 1476 bytes --]
[-- Attachment #2: TestMathExport.zip --]
[-- Type: application/zip, Size: 100332 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 7:45 LaTeX-producing code : how to export results to HTML/ODT ? Emmanuel Charpentier
@ 2021-07-04 18:10 ` John Kitchin
2021-07-04 18:51 ` Emmanuel Charpentier
2021-07-04 21:11 ` Emmanuel Charpentier
0 siblings, 2 replies; 8+ messages in thread
From: John Kitchin @ 2021-07-04 18:10 UTC (permalink / raw)
To: Emmanuel Charpentier; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]
Can you declare the output as org so they will just be latex snippets?
On Sun, Jul 4, 2021 at 3:46 AM Emmanuel Charpentier <emm.charpentier@free.fr>
wrote:
> Dear list,
>
> Org-mode offers the ability to create functions returning LaTeX results :
> such occurrences are frequent with Sagemath, Maxima, Mathematica, R, and
> even emacs's Calc...
>
> Such functions can be declared has having LaTeX output, and the resulting
> =#+begin_export latex ... #+end_export latex= block is exported as LaTeX
> and end up in the PDF versin.
>
> But such blocks seem to export **only** to LaTeX/PDF ; more specically,
> they do not export to HTML nor ODT. In order to insert those results at
> export, one **has** to print them **raw**. See the attached examples, and
> compare PDF, HTML and ODT outputs of the enclosed zip archive (necessary to
> avoid the wrath of the spam filter of my provider ;-)...)..
>
> Unless I am mistaken, this is the *only* way to export LaTeX exports to
> HTML/ODT ; I am not aware of any option allowing to force such exports. So
> a couple questions :
>
> - Am I mistaken ?
> - Are there more steamlined ways to get LaTeX in
> HTML/ODF/whatever-but-not-LaTeX ?
> - Wouldn't an option to allow these exports be a welcome addition to
> the export structure (or possibly to the various exporters) ?
>
>
> Thanks in advance,
>
--
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
[-- Attachment #2: Type: text/html, Size: 2405 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 18:10 ` John Kitchin
@ 2021-07-04 18:51 ` Emmanuel Charpentier
2021-07-04 19:04 ` John Kitchin
2021-07-04 21:11 ` Emmanuel Charpentier
1 sibling, 1 reply; 8+ messages in thread
From: Emmanuel Charpentier @ 2021-07-04 18:51 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2407 bytes --]
I tried this :
#+property: header-args:sage :session
#+options: tex:t toc:nil author:nil
#+begin_src emacs-lisp :exports none
;; (customize-set-variable
;; 'org-latex-to-mathml-convert-command
;; "latexmlmath \"%i\" --presentationmathml=%o")
(custom-set-variables
'(org-latex-to-mathml-convert-command
"java -jar %j -unicode -force -df %o %I")
'(org-latex-to-mathml-jar-file
"/usr/local/bin/mathtoweb.jar"))
#+end_src
A "normal" function call with org result...
#+name: foo
#+begin_src emacs-lisp :exports both :results org
"Pseudo-function returning a LaTeX pseudo-result."
"\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
#+end_src
#+RESULTS: foo
#+begin_src org
\[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
#+end_src
Which exports the LaTeX *source* (uncompiled) in PDF, HTML and ODT.
I'm currently lookin into a =:post= workaround. But an option to export
=latex= blocks to selected exporters (ODT, HTML, possibly Morkdown via
pandoc).
I'll keep you posted.
Le dimanche 04 juillet 2021 à 14:10 -0400, John Kitchin a écrit :
Can you declare the output as org so they will just be latex snippets?
On Sun, Jul 4, 2021 at 3:46 AM Emmanuel Charpentier
<emm.charpentier@free.fr> wrote:
> Dear list,
>
> Org-mode offers the ability to create functions returning LaTeX
> results : such occurrences are frequent with Sagemath, Maxima,
> Mathematica, R, and even emacs's Calc...
>
> Such functions can be declared has having LaTeX output, and the
> resulting =#+begin_export latex ... #+end_export latex= block is
> exported as LaTeX and end up in the PDF versin.
>
> But such blocks seem to export *only* to LaTeX/PDF ; more specically,
> they do not export to HTML nor ODT. In order to insert those results
> at export, one *has* to print them *raw*. See the attached examples,
> and compare PDF, HTML and ODT outputs of the enclosed zip archive
> (necessary to avoid the wrath of the spam filter of my provider ;-
> )...)..
>
> Unless I am mistaken, this is the *only* way to export LaTeX exports
> to HTML/ODT ; I am not aware of any option allowing to force such
> exports. So a couple questions :
> * Am I mistaken ?
> * Are there more steamlined ways to get LaTeX in HTML/ODF/whatever-
> but-not-LaTeX ?
> * Wouldn't an option to allow these exports be a welcome addition to
> the export structure (or possibly to the various exporters) ?
>
> Thanks in advance,
[-- Attachment #2: Type: text/html, Size: 3403 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 18:51 ` Emmanuel Charpentier
@ 2021-07-04 19:04 ` John Kitchin
2021-07-04 21:13 ` Emmanuel Charpentier
2021-07-14 6:41 ` Timothy
0 siblings, 2 replies; 8+ messages in thread
From: John Kitchin @ 2021-07-04 19:04 UTC (permalink / raw)
To: Emmanuel Charpentier; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3353 bytes --]
This incantation worked for me:
#+name: foo
#+begin_src emacs-lisp :exports both :results drawer
"Pseudo-function returning a LaTeX pseudo-result."
"\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
#+end_src
#+RESULTS: foo
:results:
\[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
:end:
the key is the drawer I think.
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
On Sun, Jul 4, 2021 at 2:51 PM Emmanuel Charpentier <emm.charpentier@free.fr>
wrote:
> I tried this :
>
> #+property: header-args:sage :session
>
> #+options: tex:t toc:nil author:nil
>
> #+begin_src emacs-lisp :exports none
>
> ;; (customize-set-variable
>
> ;; 'org-latex-to-mathml-convert-command
>
> ;; "latexmlmath \"%i\" --presentationmathml=%o")
>
> (custom-set-variables
>
> '(org-latex-to-mathml-convert-command
>
> "java -jar %j -unicode -force -df %o %I")
>
> '(org-latex-to-mathml-jar-file
>
> "/usr/local/bin/mathtoweb.jar"))
>
> #+end_src
>
>
> A "normal" function call with org result...
>
>
> #+name: foo
>
> #+begin_src emacs-lisp :exports both :results org
>
> "Pseudo-function returning a LaTeX pseudo-result."
>
> "\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
>
> #+end_src
>
>
> #+RESULTS: foo
>
> #+begin_src org
>
> \[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
>
> #+end_src
>
>
> Which exports the LaTeX *source* (uncompiled) in PDF, HTML and ODT.
>
> I'm currently lookin into a =:post= workaround. But an option to export
> =latex= blocks to selected exporters (ODT, HTML, possibly Morkdown via
> pandoc).
>
> I'll keep you posted.
>
> Le dimanche 04 juillet 2021 à 14:10 -0400, John Kitchin a écrit :
> Can you declare the output as org so they will just be latex snippets?
>
> On Sun, Jul 4, 2021 at 3:46 AM Emmanuel Charpentier <
> emm.charpentier@free.fr> wrote:
>
> Dear list,
>
> Org-mode offers the ability to create functions returning LaTeX results :
> such occurrences are frequent with Sagemath, Maxima, Mathematica, R, and
> even emacs's Calc...
>
> Such functions can be declared has having LaTeX output, and the resulting
> =#+begin_export latex ... #+end_export latex= block is exported as LaTeX
> and end up in the PDF versin.
>
> But such blocks seem to export **only** to LaTeX/PDF ; more specically,
> they do not export to HTML nor ODT. In order to insert those results at
> export, one **has** to print them **raw**. See the attached examples, and
> compare PDF, HTML and ODT outputs of the enclosed zip archive (necessary to
> avoid the wrath of the spam filter of my provider ;-)...)..
>
> Unless I am mistaken, this is the *only* way to export LaTeX exports to
> HTML/ODT ; I am not aware of any option allowing to force such exports. So
> a couple questions :
>
> - Am I mistaken ?
> - Are there more steamlined ways to get LaTeX in
> HTML/ODF/whatever-but-not-LaTeX ?
> - Wouldn't an option to allow these exports be a welcome addition to
> the export structure (or possibly to the various exporters) ?
>
>
> Thanks in advance,
>
>
>
[-- Attachment #2: Type: text/html, Size: 4784 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 18:10 ` John Kitchin
2021-07-04 18:51 ` Emmanuel Charpentier
@ 2021-07-04 21:11 ` Emmanuel Charpentier
1 sibling, 0 replies; 8+ messages in thread
From: Emmanuel Charpentier @ 2021-07-04 21:11 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3239 bytes --]
The following does what I want : export ln a LaTeX block to latex and
beamer, export as a raw LaTeX snippet in HTML and ODT, no export
otherwise :
#+property: header-args:sage :session
#+options: tex:t toc:nil author:nil
#+begin_src emacs-lisp :exports none
;; (customize-set-variable
;; 'org-latex-to-mathml-convert-command
;; "latexmlmath \"%i\" --presentationmathml=%o")
(custom-set-variables
'(org-latex-to-mathml-convert-command
"java -jar %j -unicode -force -df %o %I")
'(org-latex-to-mathml-jar-file
"/usr/local/bin/mathtoweb.jar"))
#+end_src
#+RESULTS:
Current exporter src_emacs-lisp[:results raw]{org-export-current-backend}.
A printing auxilliary :
#+name: printme
#+begin_src emacs-lisp :exports both :var data=()
(if data
(cond ((memq org-export-current-backend '(latex beamer))
(format "#+begin_export latex\n%s\n#+end_export" data))
((memq org-export-current-backend '(odt html))
data)
(t data))
"")
#+end_src
A "normal" function call with filtered result...
#+name: foo
#+begin_src emacs-lisp :exports both :results value raw :post printme(data=*this*)
"Pseudo-function returning a LaTeX pseudo-result."
"\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
#+end_src
Real-life test :
#+name: gee
#+begin_src sage :exports both :results raw :post printme(data=*this*)
a, b = var("a, b")
R = str(LatexExpr("\\[\\displaystyle{%s}\\]"%latex(tan(a+b) == tan(a+b).trig_expand())))
R += "\n\n"
R += str(LatexExpr("\\[\\displaystyle{%s}\\]"%latex(tan(a-b) == tan(a-b).trig_expand())))
LatexExpr(R)
#+end_src
But this still has snags : you must not have evaluated results in the
buffer. Which is problematic if you want to use caching... Exporting
LaTeX blocks to ODT/HTML would be a better solution...
Ideas ?
Le dimanche 04 juillet 2021 à 14:10 -0400, John Kitchin a écrit :
> Can you declare the output as org so they will just be latex
> snippets?
>
> On Sun, Jul 4, 2021 at 3:46 AM Emmanuel Charpentier
> <emm.charpentier@free.fr> wrote:
> > Dear list,
> >
> > Org-mode offers the ability to create functions returning LaTeX
> > results : such occurrences are frequent with Sagemath, Maxima,
> > Mathematica, R, and even emacs's Calc...
> >
> > Such functions can be declared has having LaTeX output, and the
> > resulting =#+begin_export latex ... #+end_export latex= block is
> > exported as LaTeX and end up in the PDF versin.
> >
> > But such blocks seem to export *only* to LaTeX/PDF ; more
> > specically, they do not export to HTML nor ODT. In order to insert
> > those results at export, one *has* to print them *raw*. See the
> > attached examples, and compare PDF, HTML and ODT outputs of the
> > enclosed zip archive (necessary to avoid the wrath of the spam
> > filter of my provider ;-)...)..
> >
> > Unless I am mistaken, this is the *only* way to export LaTeX
> > exports to HTML/ODT ; I am not aware of any option allowing to
> > force such exports. So a couple questions :
> > * Am I mistaken ?
> > * Are there more steamlined ways to get LaTeX in HTML/ODF/whatever-
> > but-not-LaTeX ?
> > * Wouldn't an option to allow these exports be a welcome addition
> > to
> > the export structure (or possibly to the various exporters) ?
> >
> > Thanks in advance,
[-- Attachment #2: Type: text/html, Size: 4526 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 19:04 ` John Kitchin
@ 2021-07-04 21:13 ` Emmanuel Charpentier
2021-07-14 6:41 ` Timothy
1 sibling, 0 replies; 8+ messages in thread
From: Emmanuel Charpentier @ 2021-07-04 21:13 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3696 bytes --]
Yes, this works, indeed.
If I could just figure why
... and how to use it with captions, labels and cross-references.
But I still don't "get" drawers, I thonk.
Thanks a lot ! You gave me somethong to think about.
Le dimanche 04 juillet 2021 à 15:04 -0400, John Kitchin a écrit :
> This incantation worked for me:
> #+name: foo
> #+begin_src emacs-lisp :exports both :results drawer
> "Pseudo-function returning a LaTeX pseudo-result."
> "\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
> #+end_src
>
> #+RESULTS: foo
> :results:
> \[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
> :end:
>
> the key is the drawer I think.
> John
>
> -----------------------------------
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Sun, Jul 4, 2021 at 2:51 PM Emmanuel Charpentier
> <emm.charpentier@free.fr> wrote:
> > I tried this :
> >
> > #+property: header-args:sage :session
> > #+options: tex:t toc:nil author:nil
> > #+begin_src emacs-lisp :exports none
> > ;; (customize-set-variable
> > ;; 'org-latex-to-mathml-convert-command
> > ;; "latexmlmath \"%i\" --presentationmathml=%o")
> > (custom-set-variables
> > '(org-latex-to-mathml-convert-command
> > "java -jar %j -unicode -force -df %o %I")
> > '(org-latex-to-mathml-jar-file
> > "/usr/local/bin/mathtoweb.jar"))
> > #+end_src
> >
> > A "normal" function call with org result...
> >
> > #+name: foo
> > #+begin_src emacs-lisp :exports both :results org
> > "Pseudo-function returning a LaTeX pseudo-result."
> > "\\[\\displaystyle{\\sin\\left(\\frac{a}{b}\\right)}\\]"
> > #+end_src
> >
> > #+RESULTS: foo
> > #+begin_src org
> > \[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
> > #+end_src
> >
> > Which exports the LaTeX *source* (uncompiled) in PDF, HTML and ODT.
> >
> > I'm currently lookin into a =:post= workaround. But an option to
> > export =latex= blocks to selected exporters (ODT, HTML, possibly
> > Morkdown via pandoc).
> >
> > I'll keep you posted.
> >
> > Le dimanche 04 juillet 2021 à 14:10 -0400, John Kitchin a écrit :
> > Can you declare the output as org so they will just be latex
> > snippets?
> >
> > On Sun, Jul 4, 2021 at 3:46 AM Emmanuel Charpentier
> > <emm.charpentier@free.fr> wrote:
> > > Dear list,
> > >
> > > Org-mode offers the ability to create functions returning LaTeX
> > > results : such occurrences are frequent with Sagemath, Maxima,
> > > Mathematica, R, and even emacs's Calc...
> > >
> > > Such functions can be declared has having LaTeX output, and the
> > > resulting =#+begin_export latex ... #+end_export latex= block
> > > is exported as LaTeX and end up in the PDF versin.
> > >
> > > But such blocks seem to export *only* to LaTeX/PDF ; more
> > > specically, they do not export to HTML nor ODT. In order to
> > > insert those results at export, one *has* to print them *raw*.
> > > See the attached examples, and compare PDF, HTML and ODT outputs
> > > of the enclosed zip archive (necessary to avoid the wrath of the
> > > spam filter of my provider ;-)...)..
> > >
> > > Unless I am mistaken, this is the *only* way to export LaTeX
> > > exports to HTML/ODT ; I am not aware of any option allowing to
> > > force such exports. So a couple questions :
> > > * Am I mistaken ?
> > > * Are there more steamlined ways to get LaTeX in
> > > HTML/ODF/whatever-
> > > but-not-LaTeX ?
> > > * Wouldn't an option to allow these exports be a welcome addition
> > > to
> > > the export structure (or possibly to the various exporters) ?
> > >
> > > Thanks in advance,
> >
[-- Attachment #2: Type: text/html, Size: 5300 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-04 19:04 ` John Kitchin
2021-07-04 21:13 ` Emmanuel Charpentier
@ 2021-07-14 6:41 ` Timothy
2021-07-14 8:16 ` Emmanuel Charpentier
1 sibling, 1 reply; 8+ messages in thread
From: Timothy @ 2021-07-14 6:41 UTC (permalink / raw)
To: John Kitchin; +Cc: Emmanuel Charpentier, emacs-orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> #+RESULTS: foo
> :results:
> \[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
> :end:
>
> the key is the drawer I think.
FYI as of
https://code.orgmode.org/bzg/org-mode/commit/b90b850ae8be46a1ebe7d13b05ad79869e8d1032
a LaTeX environment will "just work". i.e.
#+RESULTS:
\begin{equation*}
\displaystyle{\sin\left(\frac{a}{b}\right)}
\end{equation*}
This is currently made use of in the new ob-julia (WIP).
--
Timothy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: LaTeX-producing code : how to export results to HTML/ODT ?
2021-07-14 6:41 ` Timothy
@ 2021-07-14 8:16 ` Emmanuel Charpentier
0 siblings, 0 replies; 8+ messages in thread
From: Emmanuel Charpentier @ 2021-07-14 8:16 UTC (permalink / raw)
To: Timothy, John Kitchin; +Cc: emacs-orgmode
"Raw" LaTeX code export to ODT always worked if =tex= (and possibly
=org-latex-to-mathml-convert-command=) were correctly set.
The problem is that "raw" output is no longer recognized as the
function result. If the function is reran, the result will be output
twice : once by the function execution and once by the "#+results:"
paragraph.
John's black magic with drawers allows to keep the link between
function and results.
HTH,
--
Emmanuel Charpentier
Le mercredi 14 juillet 2021 à 14:41 +0800, Timothy a écrit :
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > #+RESULTS: foo
> > :results:
> > \[\displaystyle{\sin\left(\frac{a}{b}\right)}\]
> > :end:
> >
> > the key is the drawer I think.
>
> FYI as of
> https://code.orgmode.org/bzg/org-mode/commit/b90b850ae8be46a1ebe7d13b05ad79869e8d1032
> a LaTeX environment will "just work". i.e.
>
> #+RESULTS:
> \begin{equation*}
> \displaystyle{\sin\left(\frac{a}{b}\right)}
> \end{equation*}
>
> This is currently made use of in the new ob-julia (WIP).
>
> --
> Timothy
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-07-14 8:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-04 7:45 LaTeX-producing code : how to export results to HTML/ODT ? Emmanuel Charpentier
2021-07-04 18:10 ` John Kitchin
2021-07-04 18:51 ` Emmanuel Charpentier
2021-07-04 19:04 ` John Kitchin
2021-07-04 21:13 ` Emmanuel Charpentier
2021-07-14 6:41 ` Timothy
2021-07-14 8:16 ` Emmanuel Charpentier
2021-07-04 21:11 ` Emmanuel Charpentier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.