-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Describe the bug
As indicated in the title, if a table is defined in a multi-row or multi-column (or both) cell of another table, then the produce latex file will not be valid.
How to Reproduce
This minimal rst is enough to trigger the problem:
(The + at the middle of the first line is intended to trigger a multi-column cell)
+---+---+
| +---+ |
| | | |
| +---+ |
+-------+Environment Information
Platform: linux; (Linux-5.10.0-18-amd64-x86_64-with-glibc2.31)
Python version: 3.12.8 (main, Apr 10 2025, 17:00:17) [GCC 10.2.1 20210110])
Python implementation: CPython
Sphinx version: 8.2.3
Docutils version: 0.20.1
Jinja2 version: 3.1.2
Pygments version: 2.19.1
Sphinx extensions
No extension needed.Additional context
I could dig a bit more into the issue and from what I found it seems that the needs_linetrimming value of the LatexTranslator class is not properly used.
With the example I gave above, we enter visit_entry and depart_entry both twice:
- First we go into
visit_entryfor the outer table, in which we setself.needs_linetrimmingto1- Then we go into
visit_entrya second time, this time for the inner table. In this case we wouldn't be settingself.needs_linetrimmingto1but in any case it is already set. - Then we go into
depart_entryfor the inner table, and sinceself.needs_linetrimming == 1we then callpopbodyeven though it was needed for the entry of the outer table.
- Then we go into
- Finally, we go into
depart_entrya second time, for the outer table, in which we will not callpopbodybecauseself.needs_linetrimmingwas set to0in the previous call ofdepart_entry
One way to fix this would be to use node attributes to set it on the entry node which actually needs line trimming.