From e2ca1be1f0aa9fc88c2fa6339f30d983c9072e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Tue, 5 Jul 2022 08:32:39 +0200 Subject: [PATCH] LaTeX: keep the black/white defaults for rounded code-blocks frames --- doc/conf.py | 6 +++++- doc/latex.rst | 33 ++++++++++++++++++++++----------- sphinx/texinputs/sphinx.sty | 17 ++--------------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 464158e7f89..2f504f699f7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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 diff --git a/doc/latex.rst b/doc/latex.rst index 674da2e173a..4d16445040e 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -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, @@ -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 @@ -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 diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 0d881589b54..9b0b54c5624 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -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 @@ -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}