emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: Timothy <tecosaur@gmail.com>, emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Suggestion : Option enabling LaTeX blocks to non-latex exporters.
Date: Sun, 18 Jul 2021 19:10:27 +0200	[thread overview]
Message-ID: <defd755bee35a9c19f819a06edcad44d4f45c007.camel@free.fr> (raw)
In-Reply-To: <878s23y9ze.fsf@gmail.com>

[-- 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 --]

      reply	other threads:[~2021-07-18 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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=defd755bee35a9c19f819a06edcad44d4f45c007.camel@free.fr \
    --to=emm.charpentier@free.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=tecosaur@gmail.com \
    /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).