GIFs and screenshots

On a plain Emacs installation:

screenshot-default-colored.png
Figure 1: Notebook rendering in a fresh Emacs with no customization.

The same notebook with the wombat theme, in my setup:

screenshot-dark-colored.png
Figure 2: Notebook rendering in with my emacs config (wombat dark theme).

Plotly figures and interactive plots open in an external window or browser (see Interactive output):

interactive-plotly.gif
Figure 3: Opening a plotly figure, and rotating it.
interactive-widgets.gif
Figure 4: An interact slider, stepped from 3 to 6.

N.B.: Screenshots may be out of date.

Cell appearance

Cells are marked out by their rules alone, on the buffer's normal background. Cell outputs gets a faint emjupy-output-color background overlay, removed when the output is cleared.

The default, 'auto, blends the background toward the foreground by emjupy-output-blend (8%), darker/lighter on a light/dark theme.

elisp
(setq emjupy-output-color "#f0f0f0")   ;; pin a colour
(setq emjupy-output-color nil)         ;; no band at all

The band fills each output line edge to edge: the emjupy-output face sets :extend t. M-x emjupy-refresh-appearance re-derives the colour and redraws. The faces are emjupy-output (the band) and emjupy-box-line (the rules).

Inline images need a graphical Emacs

Images are drawn only where Emacs can display them: display-graphic-p and image-type-available-p. On a terminal frame, or in a build without images (emacs-nox), create-image signals an error. In a WebSocket callback, that would leave the box blank. So emjupy shows the output's text/plain instead, with a note that says why.

Supported inline types: image/png, image/jpeg, image/gif and image/svg+xml.

Duplicate figures

A cell that ends with a figure can receive it twice: as the execute_result repr, and as the inline backend's display_data. emjupy draws such a repeat once. A repeat means the same bytes: two sizes are two pictures. emjupy does this at render time only: the cell's outputs and the saved .ipynb keep what the kernel sent. emjupy-deduplicate-image-outputs nil draws both.

Scrolling past figures

A tall inline image is one screen line, so line scrolling passes it in one step. Either:

elisp
(pixel-scroll-precision-mode 1)          ; built in, Emacs 29 and later

or the ultra-scroll package, smoother with tall images and mixed line heights, recommended for notebooks with figures:

elisp
(use-package ultra-scroll
  :config (ultra-scroll-mode 1))

Since these are global, emjupy does not enables either by default.

Cell outlines

emjupy-box-width sizes the rules. The default, 'window, fits the window rather than a fixed 80 columns. An integer fixes the width. emjupy-box-min-width (60) is the floor when fitting. Rules follow the window through splits, dragged mode lines and full screen, so they do not wrap unless the window is narrower than the floor. Only overlay strings are rebuilt, so point, markers and undo are untouched. When the buffer shows in two windows, the narrower one wins, because a rule sized for the wide window would wrap in the narrow one.

Inspecting the cell outlines

The rule above an output box is an overlay string, so M-x describe-char cannot reach its columns. M-x emjupy-report-box-geometry reports the width the rules are drawn at, the rule's in place, and the column the output background is aligned to.

Cell outline artifacts

An outline is an overlay property, drawn even when the overlay is empty, so one whose cell is gone shows as a border with no cell. A full redraw deletes emjupy overlays no live cell owns: M-x emjupy-re-render clears them.

Line numbers

With display-line-numbers-mode, numbers fall on the lines you write and on output, not on the outlines. Each rule is drawn as a continuation of the line above it, and the empty line between cells is hidden. The numbers are the buffer's own, so they skip one value at the end of each cell. The rules narrow to make room for the number column. There are two exceptions. The first cell's header has no line above it, and takes line 1's number. The last cell's footer is on a numbered line at the end of the buffer.

LaTeX in markdown cells

Off by default. M-x emjupy-toggle-latex-preview turns it on or off in one notebook; for all of them:

elisp
(setq emjupy-render-latex t)

Math between $...$, $$...$$, \\(...\\) and \\[...\\] is then shown on screen as an image. The first and third forms are inline, and the others are displayed, as in LaTeX. The image is an overlay. The cell holds and saves the LaTeX as written, and hovering shows the source.

org renders it, with Emacs, so only LaTeX is needed:

bash
sudo apt install texlive-latex-base dvipng

emjupy uses math-preview if that is what is installed. It works well, but it needs nodejs and npm, so it is not the default. emjupy-latex-backend chooses explicitly.

Formulae are drawn in the theme's foreground on a transparent background; emjupy-latex-foreground overrides the colour, emjupy-latex-scale the size. Images are cached by content and colour: redrawing does not re-run LaTeX, and a theme switch regenerates them. emjupy uses a minimal preamble (amsmath and amssymb), not org's full package list, which a small TeX install lacks.

Editing a rendered formula

LaTeX is rendered as an image over its source. The source stays in the buffer, hidden but editable. DEL at the end of a rendered fragment removes the image, point after the source's last character; a second DEL deletes as usual. M-x emjupy-toggle-latex-preview renders it again (C-c C-c in a markdown cell).