Replies: 2 comments
-
In general, these custom library calls will require you to read the documentation of said libraries. In this case, Pandas is emitting commands that require specific packages. Look at https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.to_latex.html under "Latex Packages", and then add the required packages using something like
It's possible that this won't work in general, since not all LaTeX packages are compatible with one another. But that's the route you'll need to take. |
Beta Was this translation helpful? Give feedback.
-
I ran into this today as well. It looks like a bug to me. I created this issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Im trying to display a HTML object generated by pandas.style.background_gradient.
This code:
Produces this output in VSCode. Using jupyter will yield a similar result.

When producing a PDF with latex, the style is ignored:
When I use
styled_df.to_latex()
, I get:If I try to print it instead with
print(styled_df.to_latex())
, I get:Finally, if I use
#| output: asis
, I run into a compilation error:If I try using .bar, I fall into another problem.
This code:
Gives this compilation error:
Is there a way to print this table with the style options to PDF?
Beta Was this translation helpful? Give feedback.
All reactions