emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Babel: remove LaTeX environment -type #+results
@ 2021-04-25  9:06 Timothy
  2021-04-25 13:44 ` Greg Minshall
  2021-05-01 11:03 ` Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Timothy @ 2021-04-25  9:06 UTC (permalink / raw)
  To: org-mode-email

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

Hi All,

I think there's potential for some really nice experiences leveraging
Org's latex rendering in combination with some languages' symbolic maths
ability.

This is /very nearly/ already supported, `org-babel-result-end' just
needs to be tweaked to also remove LaTeX environment -type #+results.

This is what I'd like to make possible:


[-- Attachment #2: julia-org-inline-maths.png --]
[-- Type: image/png, Size: 22821 bytes --]

[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


--
Timothy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-ob-core-Remove-LaTeX-environment-results-type.patch --]
[-- Type: text/x-patch, Size: 1618 bytes --]

From e7e7eb698883348eeb404c0bc58ed7aed52344c4 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Sun, 25 Apr 2021 16:51:15 +0800
Subject: [PATCH] ob-core: Remove LaTeX environment #+results type

* lisp/ob-core.el (org-babel-result-end): By adding latex-enviroment to
the possible results types, a much richer experience is possible for
backends that can produce LaTeX-formatted maths as their results (for
example: Calc, Julia with Latexify, Python with SymPy, Octave with
symbolic). This is superior to a LaTeX export block as LaTeX
environments can be (1) rendered inline, and (2) better used in
non-LaTeX export formats (e.g. HTML with MathJax).  Without this,
backends can output a LaTeX environment, but new results will be added
in front instead of replacing the environment.
---
 lisp/ob-core.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 2e78ac3e6..12f67a8e2 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2559,8 +2559,9 @@ (defun org-babel-result-end ()
 	 (let ((element (org-element-at-point)))
 	   (if (memq (org-element-type element)
 		     ;; Possible results types.
-		     '(drawer example-block export-block fixed-width item
-			      plain-list special-block src-block table))
+                     '(drawer example-block export-block fixed-width
+                              special-block src-block item plain-list table
+                              latex-environment))
 	       (save-excursion
 		 (goto-char (min (point-max) ;for narrowed buffers
 				 (org-element-property :end element)))
-- 
2.31.1


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

* Re: [PATCH] Babel: remove LaTeX environment -type #+results
  2021-04-25  9:06 [PATCH] Babel: remove LaTeX environment -type #+results Timothy
@ 2021-04-25 13:44 ` Greg Minshall
  2021-04-25 18:09   ` Timothy
  2021-05-01 11:03 ` Bastien
  1 sibling, 1 reply; 6+ messages in thread
From: Greg Minshall @ 2021-04-25 13:44 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Timothy,

interesting.  would this show up in #+RESULTS blocks?  in (heaven
forbid!) #+BEGIN_SRC blocks?

cheers, Greg


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

* Re: [PATCH] Babel: remove LaTeX environment -type #+results
  2021-04-25 13:44 ` Greg Minshall
@ 2021-04-25 18:09   ` Timothy
  2021-04-26 11:25     ` Greg Minshall
  0 siblings, 1 reply; 6+ messages in thread
From: Timothy @ 2021-04-25 18:09 UTC (permalink / raw)
  To: Greg Minshall; +Cc: org-mode-email


Greg Minshall <minshall@umich.edu> writes:

> Timothy,
>
> interesting.  would this show up in #+RESULTS blocks?  in (heaven
> forbid!) #+BEGIN_SRC blocks?
>
> cheers, Greg

The screenshot where it shows up is from the following Org buffer
(manually constructed for the example):

#+begin_src julia
[1 2; 3 4]
#+end_src

#+RESULTS:
\begin{equation}
\left[
\begin{array}{cc}
1 & 2 \\
3 & 4 \\
\end{array}
\right]
\end{equation}

#+begin_src julia
using Symbolics
@variables t
2^sin(t) + cos(t)/t
#+end_src

#+RESULTS:
\begin{equation}
\frac{\cos\left( t \right)}{t} + 2^{\sin\left( t \right)}
\end{equation}

The rendering is just done by `org-latex-preview'.

Hope that clears things up.

--
Timothy


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

* Re: [PATCH] Babel: remove LaTeX environment -type #+results
  2021-04-25 18:09   ` Timothy
@ 2021-04-26 11:25     ` Greg Minshall
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Minshall @ 2021-04-26 11:25 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Timothy,

> The rendering is just done by `org-latex-preview'.

> Hope that clears things up.

yes, thanks.


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

* Re: [PATCH] Babel: remove LaTeX environment -type #+results
  2021-04-25  9:06 [PATCH] Babel: remove LaTeX environment -type #+results Timothy
  2021-04-25 13:44 ` Greg Minshall
@ 2021-05-01 11:03 ` Bastien
  2021-05-01 11:44   ` Timothy
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2021-05-01 11:03 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Hi Timothy,

Timothy <tecosaur@gmail.com> writes:

> I think there's potential for some really nice experiences leveraging
> Org's latex rendering in combination with some languages' symbolic maths
> ability.

Applied in master as commit b90b850ae.

Can you add a etc/ORG-NEWS entry for this?

-- 
 Bastien


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

* Re: [PATCH] Babel: remove LaTeX environment -type #+results
  2021-05-01 11:03 ` Bastien
@ 2021-05-01 11:44   ` Timothy
  0 siblings, 0 replies; 6+ messages in thread
From: Timothy @ 2021-05-01 11:44 UTC (permalink / raw)
  To: Bastien; +Cc: org-mode-email


Bastien <bzg@gnu.org> writes:

> Applied in master as commit b90b850ae.
>
> Can you add a etc/ORG-NEWS entry for this?

Great! News entry added.

--
Timothy


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

end of thread, other threads:[~2021-05-01 11:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-25  9:06 [PATCH] Babel: remove LaTeX environment -type #+results Timothy
2021-04-25 13:44 ` Greg Minshall
2021-04-25 18:09   ` Timothy
2021-04-26 11:25     ` Greg Minshall
2021-05-01 11:03 ` Bastien
2021-05-01 11:44   ` Timothy

Code repositories for project(s) associated with this 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).