Opened 14 months ago

Last modified 14 months ago

#26101 new enhancement

Inline `view` in the Jupyter notebook

Reported by: nthiery Owned by:
Priority: major Milestone: sage-8.4
Component: notebook Keywords:
Cc: zerline, embray, jdemeyer Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

In the Jupyter notebook, view(...) currently displays the pdf in an external pdf viewer, launched from the server. An inline view as in sagenb would be nicer and would work remotely as well.

  • Recycle the logic to produce the pdf from the existing view
  • Convert the pdf to svg
  • Have view return a Widget displaying that SVG

As a bonus, one could use view to produce widgets to be included into larger widgets. If we insist that view should return None and rather display the svg as a side effect, it would be useful to expose the functionality latex->Jupyter widget one way or the other.

Change History (5)

comment:1 Changed 14 months ago by nthiery

Viviane has experimental code doing that, though going through png, therefore with quality loss:

https://github.com/VivianePons/public-notebooks/blob/master/viewLatex.py

comment:2 Changed 14 months ago by nthiery

  • Cc zerline embray jdemeyer added

comment:3 Changed 14 months ago by embray

The IPython display formatters supposedly support PDF as a data type: https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.formatters.html#IPython.core.formatters.DisplayFormatter

I'm not sure exactly what it does with PDFs though. For certain objects (e.g. graphs) going directly to SVG and outputting that (or a widget for something more sophisticated) would also make sense.

comment:4 Changed 14 months ago by nthiery

Ah, good to know. Thanks!

This prompted me to do a search, and the IFrame trick suggested below may be relevant:

https://stackoverflow.com/questions/19470099/view-pdf-image-in-an-ipython-notebook

(yeah, I know, I should be writing my reports instead ...)

comment:5 Changed 14 months ago by slabbe

I wrote some code during the last year in my optional package so that tikzpicture gets displayed inline in the jupyter notebook:

https://github.com/seblabbe/slabbe/blob/develop/slabbe/tikz_picture.py#L188

Note: See TracTickets for help on using tickets.