I agree with Emmanuel that this is not a question, though it is a valid issue. I would be helpful to at least see an example notebook.
That said I think I see what you're saying. Even if the notebook has %display latex
set, when exporting the notebook to tex it wraps all code output blocks in verbatim, and containing the plain-text output rather than the latex output. If you put latex in a markdown cell it does get converted properly but only if you have pandoc installed. And it seems Sage does not include pandoc by default (perhaps it should, assuming there's no license conflict, etc.)
I confirmed that this isn't just an issue with Sage. You can also test this easily in a plain Python notebook, e.g. by defining a class with a _repr_latex_
method (see https://ipython.readthedocs.io/en/sta...)
class Latex(object):
def __init__(self, latex):
self.latex = latex
def _repr_latex_(self):
return self.latex
pi = Latex(r'$$ \pi $$')
pi
When I run this, it sees the _repr_latex_
and indeed renders the output cell as latex. However, when I run "Download as PDF" it just shows the default plain-text in a verbatim block, as you pointed out. I don't like that either, and it's either a bug, or there should at least be an option to control that.
The "Download as Latex" feature in the Jupyter is, well, a Jupyter-specific feature. It doesn't know anything about Sage, and I'm not sure if the necessary APIs exist in Jupyter to ensure that a code block containing latex-formatted output actually renders the latex when converting to a tex file. This would be an issue for https://github.com/jupyter/nbconvert A quick search of the open issues didn't reveal anything obviously related to me though.
As we move towards emphasizing Jupyter more, we should definitely improve the latex handling story there. Latex is very important for Sage, and in general handled better overall by the classic sage notebook (which you can still try using if it does improve certain tasks for you). This might be an issue to add to https://trac.sagemath.org/ticket/25837
Edit : comment promoted to answer, see below...
Please provide a link to a Jupyter Notebook worksheet and the resulting .tex file. For example, you could do that using the "share" functionality in CoCalc.