Skip to content

Table cell text does not wrap in ".. list-table::" #1505

Open
@jsquyres

Description

@jsquyres

Problem

When using the sphinx_rtd_theme, text does not wrap in RST .. list-table:: cells like it does with the default Sphinx HTML theme. For example, the default Sphinx HTML builder theme renders like this:

Screenshot 2023-08-19 at 2 44 43 PM

(FWIW: the LaTeX and text Sphinx builders also render with wrapped text in the cell)

But the sphinx_rtd_theme renders the same RST like this:

Screenshot 2023-08-19 at 2 45 53 PM

The HTML difference between the two appears to be that the sphinx_rtd_theme has this set:

.wy-table-responsive table td, .wy-table-responsive table th {
    white-space: nowrap;
    white-space-collapse: collapse;
    text-wrap: nowrap;
}

Reproducible Project

conf.py:

html_theme = 'sphinx_rtd_theme'

index.rst:

Hello world.

.. list-table::
   :header-rows: 1
   :widths: 10 25

   * - Col 1
     - Col 2

   * - Content
     - This is a long sentence that should wrap nicely in the rendered
       table, but just to make sure, we'll make it super, extra,
       incredibly long.

Error Logs/Results

$ rm -rf _build && sphinx-build -M html . _build 
Running Sphinx v6.2.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                        
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                         
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in _build/html.

Expected Results

I expect the words to wrap in the cell, like they do with the default Sphinx HTML builder theme, and with other Sphinx builders.

Environment Info

  • Python Version: 3.11.4
  • Sphinx Version: 6.2.1
  • RTD Theme Version: same results with 1.3.0rc1 and 1.2.2 (didn't manually test back further). This behavior has been around for a long time; I didn't realize that other Sphinx themes / builders wrapped words in a cell until very recently (which is why I didn't file this issue until now).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions