Table width fix for Read the Docs Sphinx theme
The Read the Docs Sphinx theme contains a bug that causes text in table cells not to wrap. This results in very wide tables with horizontal scroll bars.
You can workaround this issue by defining a custom CCS override file.
Change into your documentation directory. This is usually where the
index.rstandconf.pyfiles are located:cd docIf it does not already exist, create a
_staticdirectory:mkdir _staticCreate a
theme_overrides.cssfile in the_staticdirectory:touch _static/theme_overrides.cssOpen the
theme_overrides.cssfile and add the following CSS:/* override table width restrictions */ @media screen and (min-width: 767px) { .wy-table-responsive table td { /* !important prevents the common CSS stylesheets from overriding this as on RTD they are loaded after this stylesheet */ white-space: normal !important; } .wy-table-responsive { overflow: visible !important; } }Open the
conf.pyfile and add the following configuration options:html_static_path = ['_static'] html_context = { 'css_files': [ '_static/theme_overrides.css', # override wide tables in RTD theme ], }
Build your documentation using Sphinx and check the tables; cells should now wrap correctly.