stargazer icon indicating copy to clipboard operation
stargazer copied to clipboard

Render LaTeX output for Jupyter

Open MaxGhenis opened this issue 5 years ago • 5 comments

I couldn't find a way to render LaTeX output in a Jupyter notebook. Do you know of a way? Or could the package render it behind the scenes and have an image (e.g. png) output in a Jupyter cell?

MaxGhenis avatar Feb 09 '20 03:02 MaxGhenis

The question goes beyond stargazer: is there a way to render generic LaTeX (that is, not just formulae) in jupyter? And the answer, I'm afraid, is no, as jupyter uses MathJax to render LaTeX, and MathJax only supports formulae.

I guess your best option is to create a small command that takes some text, saves it in an empty document template, calls rubber on it and opens the result in a separate pdf viewer.

(Then it would not be too hard to convert the result to png and feature it in jupyter... but I wonder: why not just using the html output then?)

toobaz avatar Feb 09 '20 08:02 toobaz

why not just using the html output then?

Doesn't look as nice ;)

MaxGhenis avatar Feb 09 '20 15:02 MaxGhenis

I think the rendered HTML looks quite nice in a Jupyter notebook. It also has the added benefit of integrating well with the browser (e.g. for selecting cells, copying content). To implement it, we can use rich display:

    def _repr_html_(self):
        return self.render_html()

csemken avatar Jun 03 '20 14:06 csemken

To implement it, we can use rich display:

Great idea: #40

toobaz avatar Jun 03 '20 14:06 toobaz

As to this issue: I could understand the use of checking the LaTeX output inside Jupyter, but running LaTeX behind the scenes is out of the scope of this package. If some other library provides a simple way to do it we can consider supporting it.

toobaz avatar Jun 03 '20 14:06 toobaz