From c59a0ccae1a04fd2466f6f6c03d09849a0ca233e Mon Sep 17 00:00:00 2001 From: jfbu Date: Wed, 28 Mar 2018 10:03:18 +0200 Subject: [PATCH] Fix autosummary latex table colspec (closes #4790) --- sphinx/ext/autosummary/__init__.py | 2 +- tests/test_ext_autosummary.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index bf2c6fba0..becb69e58 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -358,7 +358,7 @@ class Autosummary(Directive): *items* is a list produced by :meth:`get_items`. """ table_spec = addnodes.tabular_col_spec() - table_spec['spec'] = r'p{0.5\linewidth}p{0.5\linewidth}' + table_spec['spec'] = r'\X{1}{2}\X{1}{2}' table = autosummary_table('') real_table = nodes.table('', classes=['longtable']) diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index 3c707b65f..1138fe4a6 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -188,6 +188,16 @@ def test_autosummary_generate(app, status, warning): ' \n' in Foo) +@pytest.mark.sphinx('latex', **default_kw) +def test_autosummary_latex_table_colspec(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(status.getvalue()) + print(warning.getvalue()) + assert r'\begin{longtable}{\X{1}{2}\X{1}{2}}' in result + assert r'p{0.5\linewidth}' not in result + + def test_import_by_name(): import sphinx import sphinx.ext.autosummary