Skip to content

Commit

Permalink
LaTeX: switch to some nicer defaults for tables and code-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbu committed Oct 16, 2022
1 parent ae42de4 commit 72c2db0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
7 changes: 0 additions & 7 deletions doc/conf.py
Expand Up @@ -77,16 +77,9 @@
{\footnotesize\raggedright\printindex}
{\begin{sphinxtheindex}\end{sphinxtheindex}}
''',
'sphinxsetup': """%
VerbatimColor=black!5,% tests 5.3.0 extended syntax
VerbatimBorderColor={RGB}{32,32,32},%
pre_border-radius=3pt,%
pre_box-decoration-break=slice,%
""",
}
latex_show_urls = 'footnote'
latex_use_xindy = True
latex_table_style = ['booktabs', 'colorrows']

autodoc_member_order = 'groupwise'
autosummary_generate = False
Expand Down
24 changes: 13 additions & 11 deletions doc/latex.rst
Expand Up @@ -863,12 +863,16 @@ Do not use quotes to enclose values, whether numerical or strings.
``VerbatimColor``
The background colour for :rst:dir:`code-block`\ s.

Default: ``{rgb}{1,1,1}`` (white)
Default: ``{gray}{0.95}``

.. versionchanged:: 6.0.0

``VerbatimBorderColor``
The frame color.

Default: ``{rgb}{0,0,0}`` (black)
Default: ``{RGB}{32,32,32}``

.. versionchanged:: 6.0.0

``VerbatimHighlightColor``
The color for highlighted lines.
Expand Down Expand Up @@ -1070,7 +1074,7 @@ Options for code-blocks:
default, and the ones of the separate widths is the setting of
``\fboxrule`` in the preamble, i.e. normally ``0.4pt``.
- ``pre_box-decoration-break`` can be set to ``clone`` or ``slice``, default
is ``clone`` for backwards compatibility.
is ``slice`` since 6.0.0. (former default was ``clone``).
- | ``pre_padding-top``,
| ``pre_padding-right``,
| ``pre_padding-bottom``,
Expand All @@ -1082,7 +1086,7 @@ Options for code-blocks:
| ``pre_border-bottom-right-radius``,
| ``pre_border-bottom-left-radius``,
| ``pre_border-radius``, are all single dimensions (rounded corners are
circular arcs only), which default to ``0pt``.
circular arcs only), which default (since 6.0.0) to ``3pt``.
- ``pre_box-shadow`` is special in so far as it may be the ``none`` keyword,
or a single dimension
which will be assigned to both x-offset and y-offset, or two dimensions, or
Expand All @@ -1092,9 +1096,9 @@ Options for code-blocks:
| ``pre_background-TeXcolor``,
| ``pre_box-shadow-TeXcolor``.
They must all be of the format as accepted by LaTeX ``\definecolor``. They
default to ``{rgb}{0,0,0}``, ``{rgb}{1,1,1}`` and ``{rgb}{0,0,0}``
respectively.
They
default to ``{RGB}{32,32,32}``, ``{gray}{0.95}`` and ``{rgb}{0,0,0}``
respectively (since 6.0.0).

If one of the radius parameters is positive, the separate border widths will
be ignored and only the value set by ``pre_border-width`` will be used. Also,
Expand Down Expand Up @@ -1138,8 +1142,7 @@ Options for topic boxes:
| ``div.topic_background-TeXcolor``,
| ``div.topic_box-shadow-TeXcolor``.
They must all be of the format as accepted by
LaTeX ``\definecolor``. They default to ``{rgb}{0,0,0}``, ``{rgb}{1,1,1}``
They default to ``{rgb}{0,0,0}``, ``{rgb}{1,1,1}``
and ``{rgb}{0,0,0}`` respectively.

Options for ``warning`` (and similarly for ``caution``, ``attention``,
Expand Down Expand Up @@ -1180,8 +1183,7 @@ Options for ``warning`` (and similarly for ``caution``, ``attention``,
| ``div.warning_background-TeXcolor``,
| ``div.warning_box-shadow-TeXcolor``.
They must all be of the format as accepted by
LaTeX ``\definecolor``. They default to ``{rgb}{0,0,0}``, ``{rgb}{1,1,1}``
They default to ``{rgb}{0,0,0}``, ``{rgb}{1,1,1}``
and ``{rgb}{0,0,0}`` respectively.

In the above replace ``warning`` by one of ``caution``, ``attention``,
Expand Down
7 changes: 4 additions & 3 deletions doc/usage/configuration.rst
Expand Up @@ -2236,12 +2236,13 @@ These options influence LaTeX output.
update your project to use instead
the :ref:`latex table color configuration <tablecolors>` keys.

Default: ``[]``
Default: ``['booktabs','colorrows']``

.. versionadded:: 5.3.0

If using ``'booktabs'`` or ``'borderless'`` it seems recommended to also
opt for ``'colorrows'``...
.. versionchanged:: 6.0.0

Modify default from ``[]`` to ``['booktabs','colorrows']``.

Each table can override the global style via ``:class:`` option, or
``.. rst-class::`` for no-directive tables (cf. :ref:`table-directives`).
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/latex/__init__.py
Expand Up @@ -527,7 +527,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('latex_show_pagerefs', False, False)
app.add_config_value('latex_elements', {}, False)
app.add_config_value('latex_additional_files', [], False)
app.add_config_value('latex_table_style', [], False, [list])
app.add_config_value('latex_table_style', ['booktabs','colorrows'], False, [list])
app.add_config_value('latex_theme', 'manual', False, [str])
app.add_config_value('latex_theme_options', {}, False)
app.add_config_value('latex_theme_path', [], False, [list])
Expand Down
17 changes: 10 additions & 7 deletions sphinx/texinputs/sphinx.sty
Expand Up @@ -234,8 +234,8 @@ will be set to white}%
\sphinxDeclareColorOption{TitleColor}{{rgb}{0.126,0.263,0.361}}
\sphinxDeclareColorOption{InnerLinkColor}{{rgb}{0.208,0.374,0.486}}
\sphinxDeclareColorOption{OuterLinkColor}{{rgb}{0.216,0.439,0.388}}
\sphinxDeclareColorOption{VerbatimColor}{{rgb}{1,1,1}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareColorOption{VerbatimColor}{{gray}{0.95}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{RGB}{32,32,32}}
% all other colours will be named with a "sphinx" prefix
\newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
% set the initial default; only \definecolor syntax for defaults!
Expand Down Expand Up @@ -321,7 +321,8 @@ will be set to white}%
\let\spx@pre@border@left \spx@pre@border@top
\expandafter\let\expandafter\KV@sphinx@verbatimborder
\csname KV@sphinx@pre_border-width\endcsname
\newif\ifspx@pre@border@open % defaults to false (at least for 5.x series)
\newif\ifspx@pre@border@open
\spx@pre@border@opentrue % 6.0.0 (i.e. "slice")
\define@key{sphinx}{pre_box-decoration-break}%
{\begingroup\edef\spx@tempa{#1}\expandafter\endgroup
\ifx\spx@tempa\spxstring@clone
Expand Down Expand Up @@ -361,10 +362,10 @@ will be set to white}%
}
% MEMO: keep in mind in using these macros in code elsewhere that they can
% thus be dimen registers or simply dimensional specs such as 3pt
\let\spx@pre@radius@topleft \z@
\let\spx@pre@radius@topright \z@
\let\spx@pre@radius@bottomright\z@
\let\spx@pre@radius@bottomleft \z@
\def\spx@pre@radius@topleft {3pt}%
\let\spx@pre@radius@topright \spx@pre@radius@topleft
\let\spx@pre@radius@bottomright\spx@pre@radius@topleft
\let\spx@pre@radius@bottomleft \spx@pre@radius@topleft
\AtBeginDocument{\if1\ifdim\spx@pre@radius@topleft>\z@0\fi
\ifdim\spx@pre@radius@topright>\z@0\fi
\ifdim\spx@pre@radius@bottomright>\z@0\fi
Expand Down Expand Up @@ -395,13 +396,15 @@ will be set to white}%
\spx@pre@box@shadow@setter none {} {} \@nnil
%
\newif\ifspx@pre@withbordercolor
\spx@pre@withbordercolortrue % 6.0.0
\define@key{sphinx}{pre_border-TeXcolor}{%
\spx@pre@withbordercolortrue
\spx@defineorletcolor{VerbatimBorderColor}#1\relax
}
\expandafter\let\expandafter\KV@sphinx@VerbatimBorderColor
\csname KV@sphinx@pre_border-TeXcolor\endcsname
\newif\ifspx@pre@withbackgroundcolor
\spx@pre@withbackgroundcolortrue % 6.0.0
\define@key{sphinx}{pre_background-TeXcolor}{%
\spx@pre@withbackgroundcolortrue
\spx@defineorletcolor{VerbatimColor}#1\relax
Expand Down

0 comments on commit 72c2db0

Please sign in to comment.