mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
LaTeX: support for booktabs-style and zebra-striped tables (#10759)
This is a combination of 2 + 28 + 7 + and some more commits...
* Cherry-pick: Add support for booktabs-style tables to LaTeX builder
* Cherry-pick: Add support for zebra-striped tables to LaTeX builder
Co-authored-by: Stefan Wiehler <stefan.wiehler@missinglinkelectronics.com>
Above work originally initiated by @sephalon (thanks!)
Development refactored and continued by @jfbu
* latex_table_style configuration, support booktabs, colorrows, borderless
Some details:
- Simplify a bit a conditional in the longtable template
This also puts the target for a longtable with a label but no caption
above the toprule for better hyperlinking (testing shows hyperlink
target can not end up alone at bottom of previous page).
- Extend allowed syntax for colour assignments via 'sphinxsetup'
- latex_table_style new configuration value and coloured rows
For the user interface I tried to look for inspiration in
https://docutils.sourceforge.io/docs/user/config.html#table-style
which mentions booktabs and borderless. They also mention
captionbelow which we can implement later, now that architecture
is here. They don't mention coloured rows.
- Test on our own document... looks fine!
- Work-around an incompatibility of \cline with row colours
- Reverse priority of classes to allow overruling booktabs by standard
after parsing source but before letting LaTeX writer act
- Closes #8220
Commit
bb859c6696
already improved a bit, this finishes it (as :rst:dir:`rst-class` was
actually not linking to anywhere).
- Let booktabs style defaults to *not* using \cmidrule. They actually
don't make much sense there, as all \hline's are removed.
- Add \sphinxnorowcolor which allows construct such as this one in
a tabularcolumns directive:
>{\columncolor{blue}\sphinxnorowcolor}
else LaTeX always overrides column colour by row colour
- Add TableMergeColorHeader, TableMergeColorOdd, TableMergeColorEven
so single-row merged cells can be styled especially
- Extend row colours to all header rows not only the first one
(all header rows will share same colour settings)
- Auto-adjust to a no '|'-colspec for optimal handling of merged cell
- Add \sphinxcolorblend
- Workaround LaTeX's \cline features and other grid tables matters
- Add \sphinxbuildwarning for important warnings
- Fix some white gaps in merged cells of tables with vlines and
colorrows
- Work around LaTeX's \cline serious deficiencies for complex grid
tables
This commit corrects \cline badly impacting vertical spacing and
making tables look even more cramped as they usually are in LaTeX
(although one sees it clearly only with \arrarrulewidth a bit more
than the LaTeX default of 0.4pt).
Most importantly this commit solves the problem that \cline's got
masked by colour panels from the row below.
- Update CHANGES for PR #10759
- Improve documentation of new latex_table_style regarding colours
This commit is contained in:
@@ -823,16 +823,31 @@ Do not use quotes to enclose values, whether numerical or strings.
|
||||
definition of the continuation symbol was changed at 1.5 to accommodate
|
||||
various font sizes (e.g. code-blocks can be in footnotes).
|
||||
|
||||
.. note::
|
||||
|
||||
Values for colour keys must either:
|
||||
|
||||
- obey the syntax of the ``\definecolor`` LaTeX command, e.g. something
|
||||
such as ``VerbatimColor={rgb}{0.2,0.3,0.5}`` or ``{RGB}{37,23,255}`` or
|
||||
``{gray}{0.75}`` or (only with package ``xcolor``) ``{HTML}{808080}`` or
|
||||
...
|
||||
|
||||
- or obey the syntax of the ``\colorlet`` command from package ``xcolor``
|
||||
(which then must exist in the LaTeX installation),
|
||||
e.g. ``VerbatimColor=red!10`` or ``red!50!green`` or ``-red!75`` or
|
||||
``MyPreviouslyDefinedColour`` or... Refer to xcolor_ documentation for
|
||||
this syntax.
|
||||
|
||||
.. _xcolor: https://ctan.org/pkg/xcolor
|
||||
|
||||
.. versionchanged:: 5.2.0
|
||||
Formerly only the ``\definecolor`` syntax was accepted.
|
||||
|
||||
``TitleColor``
|
||||
The colour for titles (as configured via use of package "titlesec".)
|
||||
|
||||
Default: ``{rgb}{0.126,0.263,0.361}``
|
||||
|
||||
.. warning::
|
||||
|
||||
Colours set via ``'sphinxsetup'`` must obey the syntax of the
|
||||
argument of the ``color/xcolor`` packages ``\definecolor`` command.
|
||||
|
||||
``InnerLinkColor``
|
||||
A colour passed to ``hyperref`` as value of ``linkcolor`` and
|
||||
``citecolor``.
|
||||
@@ -862,10 +877,47 @@ Do not use quotes to enclose values, whether numerical or strings.
|
||||
|
||||
.. versionadded:: 1.6.6
|
||||
|
||||
.. note::
|
||||
.. _tablecolors:
|
||||
|
||||
Starting with this colour, and for all others following, the
|
||||
names declared to "color" or "xcolor" are prefixed with "sphinx".
|
||||
``TableRowColorHeader``
|
||||
Sets the background colour for (all) the header rows of tables.
|
||||
|
||||
It will have an effect only if either the :confval:`latex_table_style`
|
||||
contains ``'colorrows'`` or if the table is assigned the ``colorrows``
|
||||
class. It is ignored for tables with ``nocolorrows`` class.
|
||||
|
||||
As for the other ``'sphinxsetup'`` keys, it can also be set or modified
|
||||
from a ``\sphinxsetup{...}`` LaTeX command inserted via the :dudir:`raw`
|
||||
directive, or also from a LaTeX environment associated to a `container
|
||||
class <latexcontainer_>`_ and using such ``\sphinxsetup{...}``.
|
||||
|
||||
Default: ``{gray}{0.86}``
|
||||
|
||||
There is also ``TableMergeColorHeader``. If used, sets a specific colour
|
||||
for merged single-row cells in the header.
|
||||
|
||||
.. versionadded:: 5.2.0
|
||||
|
||||
``TableRowColorOdd``
|
||||
Sets the background colour for odd rows in tables (the row count starts at
|
||||
``1`` at the first non-header row). Has an effect only if the
|
||||
:confval:`latex_table_style` contains ``'colorrows'`` or for specific
|
||||
tables assigned the ``colorrows`` class.
|
||||
|
||||
Default: ``{gray}{0.92}``
|
||||
|
||||
There is also ``TableMergeColorOdd``.
|
||||
|
||||
.. versionadded:: 5.2.0
|
||||
|
||||
``TableRowColorEven``
|
||||
Sets the background colour for even rows in tables.
|
||||
|
||||
Default ``{gray}{0.98}``
|
||||
|
||||
There is also ``TableMergeColorEven``.
|
||||
|
||||
.. versionadded:: 5.2.0
|
||||
|
||||
``verbatimsep``
|
||||
The separation between code lines and the frame.
|
||||
@@ -1425,6 +1477,8 @@ Miscellany
|
||||
Formerly, use of *fncychap* with other styles than ``Bjarne`` was
|
||||
dysfunctional.
|
||||
|
||||
.. _latexcontainer:
|
||||
|
||||
- Docutils :dudir:`container` directives are supported in LaTeX output: to
|
||||
let a container class with name ``foo`` influence the final PDF via LaTeX,
|
||||
it is only needed to define in the preamble an environment
|
||||
|
||||
Reference in New Issue
Block a user