pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
615 stars 319 forks source link

Expand DataFrame Table Width #1017

Closed seanlaw closed 2 years ago

seanlaw commented 2 years ago

Thank you for providing this wonderful theme! While using it, I noticed that some of my Pandas DataFrames appear to be squished horizontally (i.e., the columns aren't being expanded):

Screen Shot 2022-10-13 at 10 13 38 AM

The live example can be found here.

Is there a setting that I am missing that can help ensure that the DataFrames appear normally?

12rambau commented 2 years ago

What extension are you using to display notebooks in your documentation?

seanlaw commented 2 years ago

In my conf.py, I am seeing:

extensions = [
    "sphinx.ext.napoleon",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.intersphinx",
    "sphinx.ext.mathjax",
    "sphinx.ext.viewcode",
    "nbsphinx",
    "numpydoc",
]

I think nbsphinx is for notebooks

12rambau commented 2 years ago

I've looked at your documentation and it seems that nbsphinx is a very bad neighbor as it's not injecting its CSS in the <header> but in the <article> which prevents the fix I created here #954 to work.

Could you try to add to your custom css:

html div.rendered_html table {
display-table: auto;
}

Other solution is to change the notebook rendering lib and use the one we use for this theme: myst_nbw

seanlaw commented 2 years ago

With your guidance above, I ended up adding:

html div.rendered_html table {
    table-layout: auto;
}

And that seemed to do the trick

12rambau commented 2 years ago

I'll try to add it in our css so that it works for everyone