Skip to content

Commit 62198d8

Browse files
authored
LaTeX: test better if tabularcolumns colspec is tabulary-specific (#13648)
1 parent d20d348 commit 62198d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sphinx/writers/latex.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ def get_table_type(self) -> str:
171171
elif self.has_verbatim:
172172
return 'tabular'
173173
elif self.colspec:
174-
if any(c in 'LRCJT' for c in self.colspec):
174+
assert len(self.colspec) > 2
175+
_colspec = re.sub(r'\{.*?\}', '', self.colspec[1:-2])
176+
if any(c in 'LRCJT' for c in _colspec):
175177
# tabulary would complain "no suitable columns" if none of its
176178
# column type were used so we ensure at least one matches.
177179
# It is responsability of user to make sure not to use tabulary
@@ -1212,8 +1214,13 @@ def depart_table(self, node: Element) -> None:
12121214
for _ in self.tables[:-1]:
12131215
_.has_problematic = True
12141216
else:
1217+
# We try to catch a tabularcolumns using L, R, J, C, or T.
1218+
# We can not simply test for presence in the colspec of
1219+
# one of those letters due to syntax such as >{\RaggedRight}.
12151220
if self.table.colspec:
1216-
if any(c in self.table.colspec for c in 'LRJCT'):
1221+
assert len(self.table.colspec) > 2
1222+
_colspec = re.sub(r'\{.*?\}', '', self.table.colspec[1:-2])
1223+
if any(c in _colspec for c in 'LRJCT'):
12171224
logger.warning(
12181225
__(
12191226
'colspec %s was given which uses '

0 commit comments

Comments
 (0)