Fix #2707: (latex) the column width is badly computed for tabular

MEMO: the used formula is correct as long as package array is loaded.
Package array (which modifies how the width of vertical rules is counted
in the total width of the tabular) is a dependency of packages tabulary,
and eqparbox, and possibly others which are currently loaded by
sphinx.sty. Even if usage of package tabulary is dropped in future
version of sphinx.sty, there would still remain the dependency on array
via eqparbox, and the formula configured in latex.py will remain
correct.
This commit is contained in:
jfbu 2016-06-21 22:37:41 +02:00
parent 452c8b162c
commit 303f163b0a

View File

@ -1052,9 +1052,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(self.table.colspec)
else:
if self.table.has_problematic:
colwidth = 0.95 / self.table.colcount
colspec = ('p{%.3f\\linewidth}|' % colwidth) * \
self.table.colcount
colspec = ('p{\\dimexpr(\\linewidth-\\arrayrulewidth)/%d'
'-2\\tabcolsep-\\arrayrulewidth\\relax}|' % \
self.table.colcount) * self.table.colcount
self.body.append('{|' + colspec + '}\n')
elif self.table.longtable:
self.body.append('{|' + ('l|' * self.table.colcount) + '}\n')