Open amueller opened 8 years ago
Hm, I guess html is generally punted? converting to rst inserts a whole bunch of ..raw: html
lines (maybe it should just add one?). Is this out of scope? Should I use markdown instead?
I think it's whatever pandoc does. I'm a bit surprised that it doesn't make an effort to convert HTML tables to Latex, though.
I had a pretty trivial table. Using markdown it creates a nice booktabs thing in the pdf, using html it creates the content of each cell one by one in a line. So maybe this is a pandoc issue?
This was not my main issue, but it is a bit inconvenient for pandas dataframes, which by default outputs as html. I just tried
from IPython.display import Latex
Latex(data.to_latex())
but that didn't result in anything useful (the table was not rendered)
From the pandoc docs:
The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous, DZSlides, EPUB, Markdown, and Textile output, and suppressed in other formats.
this seems relevant
I guess this is somehow related to the possible nesting of markdown and html?
Can you give me a point to where pandoc is invoked?
Some time ago, we tried to get both raw html and raw latex be processed when converting to latex, see ipython/ipython#3503. However, this got rather complicated and was finally not included.
hm good to know. It seems the old conversation was mostly about formulas, not tables, though, right? Not sure if that makes any difference. I feel that pandas dataframes are a really common object, and not being able to display them seems not great. Also, I was just really really surprised that there was a difference in rendering a html table and a markdown table. They look the same in the notebook (I guess because the markdown is converted to html) but markdown is exported sensibly, while markdown is not (looking at the rst generated for a simple html table is not great)
Oh, I just realized something else happens do pandas dataframes. Doe they output different stuff depending on the backend?
also images if included according to the docs are not rendered because the img tag is stripped. Is there a way to specify the size of an image using markdown [I often use width=100% for example]? It looks to me at the moment that I can either use html and specify the size and not have it render in pdf, or use markdown and not be able to specify the size. Or should the default way to include an image be latex? That also seems odd...
Oh, I just realized something else happens do pandas dataframes. Doe they output different stuff depending on the backend?
Without diving to deeply in here: pandoc has some funny idea what is code and what is html and pandas pretty printing tables was one of the cases where pandoc assumed it was code and not a table. I ended up removing all spaces at the front of the line: https://github.com/JanSchulz/knitpy/blob/master/knitpy/documents.py#L337
For dataframes in particular, it would be helpful to embed the latex data in the notebook, which currently doesn't happen. It looks like _repr_latex_
exists but returns None?
Solution: pd.set_option("display.latex.repr", True)
For dataframes in particular, it would be helpful to embed the latex data in the notebook, which currently doesn't happen. It looks like
_repr_latex_
exists but returns None?Solution:
pd.set_option("display.latex.repr", True)
Any idea why display.latex.repr
is not True
by default?
@kenaycock It conflicted with qtconsole. See https://github.com/pandas-dev/pandas/issues/12182
Also: pd.set_option("display.latex.longtable", True)
may be useful to people. It'll make sure that pandas tables page break properly in the conversion.
would be great to have something like knitr result='asis'
option, tables could then be output to markdown and be truly generic
I'm having trouble with this solution here, the styled data frame shows up as:
<pandas.io.formats.style.Styler at 0x1202eed90>
I set the option as: pd.set_option("display.latex.repr", True)
Any advice?
I'm having trouble with this solution here, the styled data frame shows up as:
<pandas.io.formats.style.Styler at 0x1202eed90>
I set the option as:
pd.set_option("display.latex.repr", True)
Any advice?
Hey did you solve this by any chance?
not a solution by any means but some folks might find it helpful: https://github.com/timkpaine/nbconvert_templates/blob/formalize/nbcx_templates/utils/utils.py#L34
Hey did you solve this by any chance?
I have the same problem. Is there a known workaround?
All
<table>
formatting seems completely lost, and each cell is surrounded by newlines.