Opened 2 years ago
Last modified 3 months ago
#23330 new defect
Broken typeset in pdf export of Jupyter notebook
Reported by: | egourgoulhon | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.0 |
Component: | notebook | Keywords: | jupyter pdf |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
In the Jupyter notebook, typeset outputs, either obtained by show
or by %display latex
, are no longer typeset in the pdf file generated by File->Download as->PDF via LaTeX (.pdf).
See https://groups.google.com/d/msg/sage-devel/LC_4PSjyx2M/I9ip8c0bCAAJ for more details, and in particular https://groups.google.com/d/msg/sage-devel/LC_4PSjyx2M/coAzvbo1CAAJ
Change History (5)
comment:1 Changed 2 years ago by
- Keywords jupyter pdf added
comment:2 Changed 2 years ago by
comment:3 Changed 13 months ago by
As discussed on sage-devel, we need to make the Sage kernel be more explicit about when the output's mimetype is text/latex (instead of using text/html, which is generally unnecessary--I don't think we need to wrap the output in an HTML fragment or <script type="text/math">
. I could be wrong, but I think that might be a vestige from older versions of IPython notebook...
comment:4 Changed 3 months ago by
A solution could be to use Jupyter's native rich output for LaTeX, not the Sage's mechanism through the IPython extension %display. For this, it suffices to implement the method _repr_latex_
to all Sage objects, i.e. add the following to SageObject
:
def _repr_latex_(self): from sage.misc.latex import latex return '$' + str(latex(self)) + '$'
See e.g. this presentation of Jupyter display logic. This solves the pdf issue reported here.
comment:5 Changed 3 months ago by
See https://groups.google.com/d/msg/sage-devel/nP7PKQyqxKw/IAWZb9nlAAAJ for a related sage-devel discussion.
See also: https://github.com/sagemathinc/cocalc/issues/2030