Skip to content

Commit 8f18b57

Browse files
authored
Close #13597 (LaTeX table in merged cell of parent table) (#13629)
1 parent 0b0c039 commit 8f18b57

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Features added
2929
Patch by Jean-François B.
3030
* #13535: html search: Update to the latest version of Snowball (v3.0.1).
3131
Patch by Adam Turner.
32+
* #13597: LaTeX: table nested in a merged cell leads to invalid LaTeX mark-up
33+
and PDF cannot be built.
34+
Patch by Jean-François B.
3235
* #13704: autodoc: Detect :py:func:`typing_extensions.overload <typing.overload>`
3336
and :py:func:`~typing.final` decorators.
3437
Patch by Spencer Brown.

sphinx/writers/latex.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def __init__(self, node: Element) -> None:
134134
self.has_problematic = False
135135
self.has_oldproblematic = False
136136
self.has_verbatim = False
137+
self.entry_needs_linetrimming = 0
137138
self.caption: list[str] = []
138139
self.stubs: list[int] = []
139140

@@ -327,7 +328,6 @@ def __init__(
327328
self.in_footnote = 0
328329
self.in_caption = 0
329330
self.in_term = 0
330-
self.needs_linetrimming = 0
331331
self.in_minipage = 0
332332
# only used by figure inside an admonition
333333
self.no_latex_floats = 0
@@ -1331,7 +1331,7 @@ def visit_entry(self, node: Element) -> None:
13311331
r'\par' + CR + r'\vskip-\baselineskip'
13321332
r'\vbox{\hbox{\strut}}\end{varwidth}%' + CR + context
13331333
)
1334-
self.needs_linetrimming = 1
1334+
self.table.entry_needs_linetrimming = 1
13351335
if len(list(node.findall(nodes.paragraph))) >= 2:
13361336
self.table.has_oldproblematic = True
13371337
if (
@@ -1346,13 +1346,14 @@ def visit_entry(self, node: Element) -> None:
13461346
pass
13471347
else:
13481348
self.body.append(r'\sphinxstyletheadfamily ')
1349-
if self.needs_linetrimming:
1349+
if self.table.entry_needs_linetrimming:
13501350
self.pushbody([])
13511351
self.context.append(context)
13521352

13531353
def depart_entry(self, node: Element) -> None:
1354-
if self.needs_linetrimming:
1355-
self.needs_linetrimming = 0
1354+
assert self.table is not None
1355+
if self.table.entry_needs_linetrimming:
1356+
self.table.entry_needs_linetrimming = 0
13561357
body = self.popbody()
13571358

13581359
# Remove empty lines from top of merged cell
@@ -1362,7 +1363,6 @@ def depart_entry(self, node: Element) -> None:
13621363

13631364
self.body.append(self.context.pop())
13641365

1365-
assert self.table is not None
13661366
cell = self.table.cell()
13671367
assert cell is not None
13681368
self.table.col += cell.width

tests/roots/test-root/markup.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ Tables with multirow and multicol:
223223
| |
224224
+----+
225225

226+
+---+---+
227+
| +---+ |
228+
| | h | |
229+
| +---+ |
230+
+---+---+
231+
226232
.. list-table::
227233
:header-rows: 0
228234

0 commit comments

Comments
 (0)