Skip to content

Commit

Permalink
LaTeX: keep the black/white defaults for rounded code-blocks frames
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbu committed Jul 5, 2022
1 parent 4e911a8 commit e2ca1be
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
6 changes: 5 additions & 1 deletion doc/conf.py
Expand Up @@ -74,7 +74,11 @@
{\footnotesize\raggedright\printindex}
{\begin{sphinxtheindex}\end{sphinxtheindex}}
''',
'sphinxsetup': "verbatimradius=3pt",
'sphinxsetup': """%
VerbatimColor={RGB}{242,242,242},%
VerbatimBorderColor={RGB}{32,32,32},%
verbatimradius=3pt%
""",
}
latex_show_urls = 'footnote'
latex_use_xindy = True
Expand Down
33 changes: 22 additions & 11 deletions doc/latex.rst
Expand Up @@ -583,11 +583,17 @@ start of the chapter::

\begingroup
\sphinxsetup{%
verbatimborder=2pt,
verbatimsep=5pt,
verbatimradius=5pt,
% These were used as defaults for the whole sphinx.pdf
% VerbatimColor={RGB}{242,242,242},%
% VerbatimBorderColor={RGB}{32,32,32},%
% verbatimradius=3pt,%
% New definitions for this chapter code-blocks only:
VerbatimColor={named}{OldLace},
VerbatimBorderColor={named}{Gold},
verbatimradius=5pt,
verbatimsep=5pt,
verbatimborder=2pt,
% Other configuration for this chapter only:
TitleColor={named}{DarkGoldenrod},
hintBorderColor={named}{LightCoral},
attentionborder=3pt,
Expand All @@ -599,7 +605,8 @@ start of the chapter::
cautionBorderColor={named}{Cyan},
cautionBgColor={named}{LightCyan}}

The below is included at the end of the chapter::
And this is placed at the end of the chapter source to end the scope of
the configuration::

.. raw:: latex

Expand Down Expand Up @@ -856,16 +863,20 @@ Do not use quotes to enclose values, whether numerical or strings.

.. caution::

This is an experimental addition during the 5.x cycle. The feature
will remain, but the interface to it may evolve to include other
display elements such as admonitions. But for the latter it is
already possible for LaTeX-aware Sphinx users to re-define their
LaTeX rendering and use functionalities of LaTeX packages such as
tcolorbox_ (cf. the ``sphinxheavybox`` and ``sphinxlightbox``
`Environments`_). This is more complex for code-blocks.
The interface will remain experimental during the 5.x cycle: the
feature itself will remain, but the interface may evolve to include
other display elements such as admonitions. For the latter it is
actually already possible for LaTeX-expert Sphinx users to use
functionalities of LaTeX packages such as tcolorbox_, via
redefinitions of the ``sphinxheavybox`` and ``sphinxlightbox``
`Environments`_. This would be more difficult for code-blocks, and
this key achieves it. The pict2e_ interface to some basic PDF
graphics operations is much more light-weight than the pgf_
framework used by tcolorbox_.

.. _pict2e: https://ctan.org/pkg/pict2e
.. _tcolorbox: https://ctan.org/pkg/tcolorbox
.. _pgf: https://ctan.org/pkg/pgf

``shadowsep``
The separation between contents and frame for :dudir:`contents` and
Expand Down
17 changes: 2 additions & 15 deletions sphinx/texinputs/sphinx.sty
Expand Up @@ -150,15 +150,8 @@
\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}}
% TODO: clean-up this somewhat messy thing (cf verbatimradius)
\definecolor{VerbatimColor}{rgb}{1,1,1}% white
\define@key{sphinx}{VerbatimColor}%
{\csname spx@VerbatimColorIsSet\endcsname
\definecolor{VerbatimColor}#1}
\definecolor{VerbatimBorderColor}{rgb}{0,0,0}% black
\define@key{sphinx}{VerbatimBorderColor}%
{\csname spx@VerbatimBorderColorIsSet\endcsname
\definecolor{VerbatimBorderColor}#1}
\sphinxDeclareColorOption{VerbatimColor}{{rgb}{1,1,1}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{rgb}{0,0,0}}
% now the colours defined with "sphinx" prefix in their names
\newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
% set the initial default
Expand Down Expand Up @@ -190,12 +183,6 @@

\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
\AtBeginDocument{\ifdim\sphinxverbatimradius=\z@\else
\ifdefined\spx@VerbatimColorIsSet\else\definecolor{VerbatimColor}{RGB}{242,242,242}\fi
% these colors are copied over from tcolorbox defaults ;-)
\ifdefined\spx@VerbatimBorderColorIsSet\else\definecolor{VerbatimBorderColor}{RGB}{32,32,32}\fi
\fi
}%
% don't allow use of maxlistdepth via \sphinxsetup.
\DisableKeyvalOption{sphinx}{maxlistdepth}
\DisableKeyvalOption{sphinx}{numfigreset}
Expand Down

0 comments on commit e2ca1be

Please sign in to comment.