Skip to content

LaTeX: if a cell contains a table, row coloring is turned off for the next table cells #13635

@jfbu

Description

@jfbu

Describe the bug

If a table cell itself contains a table, row coloring is off from that point on.

Image

This was first observed when working on PR #13629 which made possible (to some extent) for a merged cell of a grid table to contain itself a table. Next screenshot first table is a normal merged cell and row colors are ok. The second table has a table in the merged cell and row colors are off. But as pointed above this is not intrinsically related to merged cells (I wish I had known that first because I spent quite some time digging in the awfully complicated sphinxlatextables.sty code for handling merge cells).

Image

How to Reproduce

Use sphinx-quickstart move to the created directory and execute:

$ cat <<EOF >index.rst
FOO documentation
=================

Nested table
============

+---------+----+
| +-----+ |    |
| | |h| | | b1 |
| +-----+ |    |
+---------+----+
| a2      | b2 |
+---------+----+
| a3      | b3 |
+---------+----+


+-----+-----+
| |h|       |
+-----+-----+
| a2  | b2  |
+-----+-----+
| a3  | b3  |
+-----+-----+

.. I accidentally discovered that we can influence the width
   of first column if shifting the "+" in first line below...

+----+----+
| +-----+ |
| | |h| | |
| +-----+ |
+----+----+
| a2 | b2 |
+----+----+
| a3 | b3 |
+----+----+

.. |h| replace:: hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh hhh 

EOF
$ make latexpdf

Environment Information

macOS
Python version:        3.13.3 (v3.13.3:6280bb54784, Apr  8 2025, 10:47:54) [Clang 15.0.0 (clang-1500.3.9.4)])
Python implementation: CPython
Sphinx version:        8.3.0+/1580f5f7f
Docutils version:      0.21.2
Jinja2 version:        3.1.6
Pygments version:      2.19.1

Sphinx extensions

None

Additional context

The mechanism is known (somewhat miraculously in view of the accumulated complexities). Quite a few things regarding tables are not compatible with nesting, maybe this can be "fixed" nevertheless (to some extent).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions