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