-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Milestone
Description
Describe the bug
The following source:
.. table:: Test table
:widths: auto
:class: longtable
===== =====
A not A
===== =====
False True
True +---+
| h |
+---+
===== =====is intercepted on build by an error:
sphinx.writers.latex.UnsupportedError: index:: longtable does not support nesting a table.
If one does not explicitly use the longtable class but trigger it via enough many rows, then no error is triggered by the latex builder. However the nesting of tabulary inside a longtable causes a crash when building the PDF:
! Extra alignment tab has been changed to \cr.
<template> \endtemplate
l.156 \end{tabulary}
? X
How to Reproduce
Use above source
Environment Information
Platform: darwin
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+/a5366394a
Docutils version: 0.21.2
Jinja2 version: 3.1.6
Pygments version: 2.19.1
Sphinx extensions
Additional context
It is definitely possible to nest a (simple) tabular inside longtable, and even a (simple) tabulary. For example this is legal LaTeX source:
\begin{longtable}{|c|c|}
\hline
A&B\\
\hline
C&D\\
\hline
E&
\begin{tabulary}{\linewidth}{|c|c|}
A&B\\\hline
C&D\\\hline
\end{tabulary}
\\\hline
\end{longtable}
and produces (not quite correct, due to horizontal grid lines of sub-table merging with outer table) output.
In the Sphinx case of tabulary inside longtable via enough many rows to trigger it, the PDF though can not be built.
Following possibilities of treatment of this report:
- make sure all cases of a
longtabledo raise an error if a cell contains a table, - force a nested
tablein alongtableto never usetabularybut onlytabularwhich seems to work with no issue, - understand why the Sphinx LaTeX mark-up for
tabularyinsidelongtablecauses a PDF build crash and fix that, so thatlongtablewill only explicitly forbid nesting anotherlongtable.