@@ -1483,60 +1483,72 @@ Check the :confval:`latex_table_style`.
1483
1483
1484
1484
.. rst :directive :: .. tabularcolumns:: column spec
1485
1485
1486
- This directive influences only the LaTeX output for the next table in
1487
- source. The mandatory argument is a column specification (known as an
1488
- "alignment preamble" in LaTeX idiom). Please refer to a LaTeX
1486
+ This directive influences only the LaTeX output, and only for the next
1487
+ table in source. The mandatory argument is a column specification (known
1488
+ as an "alignment preamble" in LaTeX idiom). Please refer to a LaTeX
1489
1489
documentation, such as the `wiki page `_, for basics of such a column
1490
1490
specification.
1491
1491
1492
1492
.. _wiki page : https://en.wikibooks.org/wiki/LaTeX/Tables
1493
1493
1494
1494
.. versionadded :: 0.3
1495
1495
1496
- .. note ::
1496
+ Sphinx renders tables with at most 30 rows using ``tabulary `` (or
1497
+ ``tabular `` if at least one cell contains either a code-block or a nested
1498
+ table), and those with more rows with ``longtable ``. The advantage of
1499
+ using ``tabulary `` is that it tries to compute automatically (internally to
1500
+ LaTeX) suitable column widths.
1501
+
1502
+ :rst:dir: `tabularcolumns ` can serve to provide one's own "colspec" choice.
1503
+ Here is an advanced example:
1504
+
1505
+ .. code-block :: latex
1497
1506
1498
- :rst:dir: `tabularcolumns ` conflicts with ``:widths: `` option of table
1499
- directives. If both are specified, ``:widths: `` option will be ignored.
1507
+ .. tabularcolumns:: >{\r aggedright}\Y {.4}>{\c entering}\Y {.1}>{\s phinxcolorblend{!95!red}\centering\noindent\bfseries\color {red}}\Y {.12}>{\r aggedright\a rraybackslash}\Y {.38}
1500
1508
1501
- Sphinx renders tables with at most 30 rows using ``tabulary ``, and those
1502
- with more rows with ``longtable ``.
1509
+ This is used in Sphinx own PDF docs at :ref: `dev-deprecated-apis `.
1510
+ Regarding column widths, this "colspec" achieves the same as would
1511
+ ``:widths: `` option set to ``40 10 12 38 `` but it injects extra effects.
1503
1512
1504
- ``tabulary `` tries to compute automatically (internally to LaTeX) suitable
1505
- column widths. However, cells are then not allowed to contain
1506
- "problematic" elements such as lists, object descriptions,
1507
- blockquotes... Sphinx will fall back to using ``tabular `` if such a cell is
1508
- encountered (or a nested ``tabulary ``). In such a case the table will have
1509
- a tendency to try to fill the whole available line width.
1513
+ .. note ::
1510
1514
1511
- :rst:dir: `tabularcolumns ` can help in coercing the usage of ``tabulary `` if
1512
- one is careful to not employ the ``tabulary `` column types (``L ``, ``R ``,
1513
- ``C `` or ``J ``) for those columns with at least one "problematic" cell, but
1514
- only LaTeX's ``p{<width>} `` or Sphinx ``\X `` and ``\Y `` (described next).
1515
+ In case both :rst:dir: `tabularcolumns ` and ``:widths: `` option of table
1516
+ directives are used, ``:widths: `` option will be ignored by the LaTeX
1517
+ builder. Of course it is obeyed by other builders.
1515
1518
1516
- Literal blocks do not work at all with ``tabulary ``. Sphinx will fall back
1517
- to ``tabular `` or ``longtable `` environments depending on the number of
1518
- rows. It will employ the :rst:dir: `tabularcolumns ` specification only if it
1519
- contains no usage of the ``tabulary `` specific types.
1519
+ Literal blocks do not work at all with ``tabulary `` and Sphinx will then
1520
+ fall back to ``tabular `` LaTeX environment. It will employ the
1521
+ :rst:dir: `tabularcolumns ` specification in that case only if it contains no
1522
+ usage of the ``tabulary `` specific column types (which are ``L ``, ``R ``,
1523
+ ``C `` and ``J ``).
1520
1524
1521
1525
Besides the LaTeX ``l ``, ``r ``, ``c `` and ``p{width} `` column specifiers,
1522
- one can also use ``\X{a}{b} `` which configures the column width to be a
1523
- fraction ``a/b `` of the total line width and ``\Y{f} `` where ``f `` is a
1524
- decimal: for example ``\Y{0.2} `` means that the column will occupy ``0.2 ``
1525
- times the line width.
1526
+ and the ``tabulary `` specific ``L ``, ``R ``, ``C `` and ``J ``, one can also
1527
+ use (with all table types) ``\X{a}{b} `` which configures the column width
1528
+ to be a fraction ``a/b `` of the total line width and ``\Y{f} `` where ``f ``
1529
+ is a decimal: for example ``\Y{0.2} `` means that the column will occupy
1530
+ ``0.2 `` times the line width.
1526
1531
1527
1532
.. versionchanged :: 1.6
1528
1533
1529
- Use ``J `` (justified) by default with ``tabulary ``, not ``L ``
1534
+ Sphinx uses ``J `` (justified) by default with ``tabulary ``, not ``L ``
1530
1535
(flushed-left). To revert, include ``\newcolumntype{T}{L} `` in the LaTeX
1531
1536
preamble, as in fact Sphinx uses ``T `` and sets it by default to be an
1532
1537
alias of ``J ``.
1533
1538
1534
- .. hint ::
1539
+ .. versionchanged :: 8.3.0
1535
1540
1536
- A frequent issue with ``tabulary `` is that columns with little contents
1537
- appear to be "squeezed". One can add to the LaTeX preamble for example
1538
- ``\setlength{\tymin}{40pt} `` to ensure a minimal column width of ``40pt ``,
1539
- the ``tabulary `` default of ``10pt `` being too small.
1541
+ Formerly, Sphinx did not use ``tabulary `` if the table had at least one
1542
+ cell containing "problematic" elements such as lists, object descriptions,
1543
+ blockquotes (etc...) because such contents are not out-of-the-box
1544
+ compatible with ``tabulary ``. At ``8.3.0 `` a technique, which was already
1545
+ in use for merged cells, was extended to such cases, and the sole
1546
+ "problematic" contents are code-blocks and nested tables. So tables
1547
+ containing (only) cells with mutliple paragraphs, bullet or enumerated
1548
+ lists, or line blocks, will now better fit to their contents (if not
1549
+ rendered by ``longtable ``). Cells with object descriptions or admonitions
1550
+ will still have a tendency to induce the table to fill the full text area
1551
+ width, but columns in that table with no such contents will be tighter.
1540
1552
1541
1553
.. hint ::
1542
1554
0 commit comments