emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble producing nicely aligned org tables from emacs-jupyter code


From: John Kitchin
Subject: Re: Trouble producing nicely aligned org tables from emacs-jupyter code blocks using latest org version
Date: Wed, 18 May 2022 16:16:11 -0400

I use a function in an after execute hook for this: https://github.com/jkitchin/scimax/blob/master/scimax-org.el#L205

This works on a subtree, which has been fine for me. You could adapt it to only work in the results section.

John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Wed, May 18, 2022 at 4:07 PM Richard Stanton <rhstanton@berkeley.edu> wrote:
I’m running Emacs 28.1 under macOS 12.4 and want to create tables from Python code blocks that can be exported to either LaTeX or HTML. The simplest way to do this seems to be to generate the output as an org table, and using the built-in version of org (9.4.6 (9.4.6-798-g738759.dirty-elpaplus @ /Users/stanton/.emacs.d/elpa/org-plus-contrib-20210929/)), this works fine using either a python or emacs-jupyter code block:

#+begin_src jupyter-python
[
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |

#+begin_src python
return [
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |


To use the latest version of org, I change just two lines in my init.el from

(straight-use-package '(org :type built-in))
(straight-use-package '(org-contrib :type built-in))

to

(straight-use-package '(org :type git :repo "https://code.orgmode.org/bzg/org-mode.git"))
(straight-use-package '(org-contrib :type git :repo "https://git.sr.ht/~bzg/org-contrib”))

Having done this, the python block still works fine, but the horizontal lines in the jupyter-python block are no longer properly aligned with the text:

#+begin_src jupyter-python
[
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|---+---+---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
|---+---+---|
| 7 | 8 | 9 |

#+begin_src python
return [
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |

By the way, the org version loaded this time is 9.5.3 (9.5.3-g277897 @ /Users/stanton/.emacs.d/straight/build/org/).

The table exports OK, but isn’t much fun to look at in the org file itself.

Since I like to use emacs-jupyter, any suggestions would be appreciated. I know this worked fine just a few weeks ago.

Thanks!

Richard Stanton






reply via email to

[Prev in Thread] Current Thread [Next in Thread]