LaTeX: refactor how display environments use sphinxpackageboxes

This is to share code as much as possible and facilitate future
extensions.
This commit is contained in:
Jean-François B
2023-03-07 11:00:52 +01:00
parent 13c779b666
commit c499e090e8
5 changed files with 170 additions and 236 deletions

View File

@@ -6,7 +6,7 @@
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2023/03/06 v6.2.0 LaTeX package (Sphinx markup)]
\ProvidesPackage{sphinx}[2023/03/07 v6.2.0 LaTeX package (Sphinx markup)]
% provides \ltx@ifundefined
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
@@ -196,11 +196,15 @@ will be set to white}%
\DeclareStringOption[0.5pt]{hintborder}
\DeclareStringOption[0.5pt]{importantborder}
\DeclareStringOption[0.5pt]{tipborder}
\DeclareStringOption[1pt]{warningborder}
\DeclareStringOption[1pt]{cautionborder}
\DeclareStringOption[1pt]{attentionborder}
\DeclareStringOption[1pt]{dangerborder}
\DeclareStringOption[1pt]{errorborder}
% Compatibility layer to share for these notice types common code
% with the one for warning, danger, ..., in sphinxlatexadmonitions.sty
\def\spx@note@border {\spx@opt@noteborder}
\def\spx@hint@border {\spx@opt@hintborder}
\def\spx@important@border{\spx@opt@importantborder}
\def\spx@tip@border {\spx@opt@tipborder}
% The warning type notices are handled in the "CSS" section below.
% 6.2.0 does not define \spx@opt@warningborder etc... macros
% but only \spx@warning@border etc...
% footnotes
\DeclareStringOption[\mbox{ }]{AtStartFootnote}
% we need a public macro name for direct use in latex file
@@ -316,22 +320,9 @@ will be set to white}%
%
% Border keys
%
% The "special prefix" is for matters of keeping same naming conventions, for
% both "warning" and "note" type of notices, for the macro storing the border
% width (if setting same width for all borders). These macros were already
% defined above via a series of \DeclareStringOption and thus need a \spx@opt@
% prefix, whereas in general for matters of brievety only \spx@ prefix is being
% used by e.g. the macros storing the separate widths of the four borders.
%
% This \spx@opt@<notice type>border name is expected by sphinxadmonition
% environment, cf. file sphinxlatexadmonitions.sty, whereas we se for
% example \spx@pre@border not \spx@opt@preborder for code-blocks,
% or \spx@warning@border@top for macro holding top border width of
% warning type notice.
%
\def\spx@tempa#1#2{% #1 = macro prefix, #2 = special prefix
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
\csname #2border\expandafter\endcsname
\csname #1border\expandafter\endcsname
\csname #1border@top\expandafter\endcsname
\csname #1border@right\expandafter\endcsname
\csname #1border@bottom\expandafter\endcsname
@@ -356,20 +347,20 @@ will be set to white}%
\spx@tempc{#9}% option prefix
}
\def\spx@tempc #1#2{% #1 = option prefix, #2 = legacy option name
% keep backward legacy option as alias to new-named option
% keep legacy option names as aliases to new-named options
\expandafter\let\csname KV@sphinx@#2\expandafter\endcsname
\csname KV@sphinx@#1border-width\endcsname
% init border-width (fetches next argument)
\csname KV@sphinx@#1border-width\endcsname
}
% macro prefix special prefix option prefix legacy option init
\spx@tempa{spx@pre@} {spx@pre@} {pre_} {verbatimborder} \fboxrule
\spx@tempa{spx@topic@} {spx@topic@} {div.topic_} {shadowrule} \fboxrule
\spx@tempa{spx@warning@} {spx@opt@warning} {div.warning_} {warningborder} {1pt}
\spx@tempa{spx@caution@} {spx@opt@caution} {div.caution_} {cautionborder} {1pt}
\spx@tempa{spx@attention@}{spx@opt@attention}{div.attention_}{attentionborder}{1pt}
\spx@tempa{spx@danger@} {spx@opt@danger} {div.danger_} {dangerborder} {1pt}
\spx@tempa{spx@error@} {spx@opt@error} {div.error_} {errorborder} {1pt}
% macro prefix option prefix legacy option init value
\spx@tempa{spx@pre@} {pre_} {verbatimborder} \fboxrule
\spx@tempa{spx@topic@} {div.topic_} {shadowrule} \fboxrule
\spx@tempa{spx@warning@} {div.warning_} {warningborder} {1pt}
\spx@tempa{spx@caution@} {div.caution_} {cautionborder} {1pt}
\spx@tempa{spx@attention@}{div.attention_}{attentionborder}{1pt}
\spx@tempa{spx@danger@} {div.danger_} {dangerborder} {1pt}
\spx@tempa{spx@error@} {div.error_} {errorborder} {1pt}
% Set default box-decoration-break style for codeblocks to slice
\spx@pre@border@opentrue % new default at 6.0.0: slice, not clone
@@ -405,11 +396,11 @@ will be set to white}%
% from border width for warning type admonitions. The below
% keeps the legacy behavior of a constant borderwidth+padding.
% The dim expression is not evaluated yet, only at time of use.
\spx@tempa{spx@warning@} {div.warning_} {\dimexpr.6\baselineskip-\spx@opt@warningborder\relax}
\spx@tempa{spx@caution@} {div.caution_} {\dimexpr.6\baselineskip-\spx@opt@cautionborder\relax}
\spx@tempa{spx@attention@}{div.attention_} {\dimexpr.6\baselineskip-\spx@opt@attentionborder\relax}
\spx@tempa{spx@danger@} {div.danger_} {\dimexpr.6\baselineskip-\spx@opt@dangerborder\relax}
\spx@tempa{spx@error@} {div.error_} {\dimexpr.6\baselineskip-\spx@opt@errorborder\relax}
\spx@tempa{spx@warning@} {div.warning_} {\dimexpr.6\baselineskip-\spx@warning@border\relax}
\spx@tempa{spx@caution@} {div.caution_} {\dimexpr.6\baselineskip-\spx@caution@border\relax}
\spx@tempa{spx@attention@}{div.attention_} {\dimexpr.6\baselineskip-\spx@attention@border\relax}
\spx@tempa{spx@danger@} {div.danger_} {\dimexpr.6\baselineskip-\spx@danger@border\relax}
\spx@tempa{spx@error@} {div.error_} {\dimexpr.6\baselineskip-\spx@error@border\relax}
% define legacy verbatimsep key as alias of pre_padding key
\expandafter\let\expandafter\KV@sphinx@verbatimsep\csname KV@sphinx@pre_padding\endcsname
% define legacy shadowsep key as alias of div.topic_padding key

View File

@@ -1,7 +1,7 @@
%% NOTICES AND ADMONITIONS
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexadmonitions.sty}[2023/03/06 admonitions]
\ProvidesFile{sphinxlatexadmonitions.sty}[2023/03/07 admonitions]
% Provides support for this output mark-up from Sphinx latex writer:
%
@@ -70,59 +70,17 @@
\definecolor{sphinxtipBgColor}{rgb}{1,1,1}
% Others get more distinction
% This setup macro has somewhat peculiar names for colors, this is
% heritage of the evolution of code while keeping a common base for both
% "warning"-type and "note"-type notices and backward compatibility
\def\spx@admonitions@boxes@fcolorbox@setup{%
\spx@boxes@border@top \@nameuse{spx@\spx@noticetype @border@top}%
\spx@boxes@border@right \@nameuse{spx@\spx@noticetype @border@right}%
\spx@boxes@border@bottom\@nameuse{spx@\spx@noticetype @border@bottom}%
\spx@boxes@border@left \@nameuse{spx@\spx@noticetype @border@left}%
\spx@boxes@border \spx@notice@border
%
\spx@boxes@padding@top \@nameuse{spx@\spx@noticetype @padding@top}%
\spx@boxes@padding@right \@nameuse{spx@\spx@noticetype @padding@right}%
\spx@boxes@padding@bottom\@nameuse{spx@\spx@noticetype @padding@bottom}%
\spx@boxes@padding@left \@nameuse{spx@\spx@noticetype @padding@left}%
%
\spx@boxes@radius@topleft \@nameuse{spx@\spx@noticetype @radius@topleft}%
\spx@boxes@radius@topright \@nameuse{spx@\spx@noticetype @radius@topright}%
\spx@boxes@radius@bottomright \@nameuse{spx@\spx@noticetype @radius@bottomright}%
\spx@boxes@radius@bottomleft \@nameuse{spx@\spx@noticetype @radius@bottomleft}%
\relax
\iftrue\@nameuse{ifspx@\spx@noticetype @withshadow}%
\spx@boxes@withshadowtrue
\spx@boxes@shadow@xoffset \@nameuse{spx@\spx@noticetype @shadow@xoffset}%
\spx@boxes@shadow@yoffset \@nameuse{spx@\spx@noticetype @shadow@yoffset}\relax
\else
\spx@boxes@withshadowfalse
\fi\@nameuse{fi}%
\iftrue\@nameuse{ifspx@\spx@noticetype @insetshadow}%
\spx@boxes@insetshadowtrue
\else
\spx@boxes@insetshadowfalse
\fi\@nameuse{fi}%
%
\iftrue\@nameuse{ifspx@\spx@noticetype @withbackgroundcolor}%
\spx@boxes@withbackgroundcolortrue
\else
\spx@boxes@withbackgroundcolorfalse
\fi\@nameuse{fi}%
\sphinxcolorlet{spx@boxes@backgroundcolor}{spx@notice@bgcolor}%
%
\iftrue\@nameuse{ifspx@\spx@noticetype @withbordercolor}%
\spx@boxes@withbordercolortrue
\else
\spx@boxes@withbordercolorfalse
\fi\@nameuse{fi}%
\sphinxcolorlet{spx@boxes@bordercolor}{spx@notice@bordercolor}%
%
\iftrue\@nameuse{ifspx@\spx@noticetype @withshadowcolor}%
\spx@boxes@withshadowcolortrue
\else
\spx@boxes@withshadowcolorfalse
\fi\@nameuse{fi}%
\sphinxcolorlet{spx@boxes@shadowcolor}{sphinx\spx@noticetype ShadowColor}%
\spx@boxes@fcolorbox@setup
{\spx@noticetype}{spx@notice@bordercolor}%
{spx@notice@bgcolor}%
{sphinx\spx@noticetype ShadowColor}%
}
% rescue code in case sphinxheavybox is used for note-like notices
% (executed if there is no radius.topleft associated macro)
% (this is executed if there is no radius.topleft associated macro)
\def\spx@admonitions@boxes@fcolorbox@setup@fallback{%
\spx@boxes@border@top \spx@notice@border
\spx@boxes@border@right \spx@notice@border
@@ -151,6 +109,7 @@
% time there is a public interface)
\spx@boxes@withbordercolortrue
\sphinxcolorlet{spx@boxes@bordercolor}{spx@notice@bordercolor}%
\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
}
% Code adapted from framed.sty's "snugshade" environment.
% Nesting works (inner frames do not allow page breaks).
@@ -193,21 +152,8 @@
\fi
\fi
\fi
\if1% use rounded boxes only if needed and possible
\ifdim\spx@boxes@radius@topleft >\z@0\fi
\ifdim\spx@boxes@radius@topright >\z@0\fi
\ifdim\spx@boxes@radius@bottomright>\z@0\fi
\ifdim\spx@boxes@radius@bottomleft >\z@0\fi
1\spx@boxes@fcolorbox{##1}%
\else
\spx@ifpackageloaded@pictiie
{\ifspx@boxes@insetshadow
\spx@boxes@fcolorbox{##1}%
\else
\spx@boxes@fcolorbox@rounded{##1}%
\fi}%
{\spx@boxes@fcolorbox{##1}}%
\fi
% "setup" macro MUST have been called before
\spx@boxes@fcolorbox{##1}%
\ifspx@boxes@withshadow
\ifspx@boxes@insetshadow\else
\ifdim\spx@boxes@shadow@xoffset>\z@\hskip-\spx@boxes@shadow@xoffset\relax
@@ -267,7 +213,7 @@
% set parameters of heavybox/lightbox
\sphinxcolorlet{spx@notice@bordercolor}{sphinx#1BorderColor}%
\sphinxcolorlet{spx@notice@bgcolor}{sphinx#1BgColor}%
\spx@notice@border \dimexpr\csname spx@opt@#1border\endcsname\relax
\spx@notice@border \dimexpr\csname spx@#1@border\endcsname\relax
% start specific environment, passing the heading as argument
\begin{sphinx#1}{#2}}
% workaround some LaTeX "feature" of \end command

View File

@@ -1,7 +1,7 @@
%% LITERAL BLOCKS
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexliterals.sty}[2023/03/06 code-blocks and parsed literals]
\ProvidesFile{sphinxlatexliterals.sty}[2023/03/07 code-blocks and parsed literals]
% Provides support for this output mark-up from Sphinx latex writer:
%
@@ -119,7 +119,7 @@
% interline penalties and glues.
%
\long\def\spx@verb@FrameCommand #1#2#3{%
% The \spx@verb@boxes@fcolorbox@setup must have been executed beforehand.
% The \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
% These \hskips are for fancyvrb.sty measuring and will make the
% framing "adapt" to an indented context.
\hskip\@totalleftmargin
@@ -141,7 +141,7 @@
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
}%
\long\def\spx@verb@fcolorbox #1#2#3{%
% The \spx@verb@boxes@fcolorbox@setup must have been executed beforehand.
% The \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
%
% MEMO: in the context of framed.sty this will always expand inside some
% \hbox isolated from other code, so we can use \box\z@, \box\tw@,...
@@ -159,21 +159,8 @@
+\spx@boxes@border@right\relax sp}%
\vbox{#1% continuation hint attached above frame, uses \spx@verb@fcolorbox@width@sp
% the boxes@fcolorbox constructs an \hbox with bbox containing the border
\if1% use rounded boxes only if needed and possible
\ifdim\spx@boxes@radius@topleft >\z@0\fi
\ifdim\spx@boxes@radius@topright >\z@0\fi
\ifdim\spx@boxes@radius@bottomright>\z@0\fi
\ifdim\spx@boxes@radius@bottomleft >\z@0\fi
1\spx@boxes@fcolorbox{\box\z@}% all radii vanish, do not use pict2e
\else
\spx@ifpackageloaded@pictiie
{\ifspx@boxes@insetshadow
\spx@boxes@fcolorbox{\box\z@}% inset shadow forces straight corners
\else
\spx@boxes@fcolorbox@rounded{\box\z@}% yes, rounded corners!
\fi}%
{\spx@boxes@fcolorbox{\box\z@}}% pict2e package not loaded, force straight
\fi
% \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
\spx@boxes@fcolorbox{\box\z@}%
% This \nointerlineskip to maintain legacy spacing when a \hrule was
% formerly last prior item in vertical list. TODO: remove this at 6.0.0 ?
\nointerlineskip
@@ -233,56 +220,17 @@
}%
%
\def\spx@verb@boxes@fcolorbox@setup{%
%
\spx@boxes@border@top \spx@pre@border@top
\spx@boxes@border@right \spx@pre@border@right
\spx@boxes@border@bottom\spx@pre@border@bottom
\spx@boxes@border@left \spx@pre@border@left
\spx@boxes@border \spx@pre@border\relax
%
\ifspx@opt@verbatimwithframe
\else
\spx@boxes@border@top\z@
\spx@boxes@border@right\z@
\spx@boxes@border@bottom\z@
\spx@boxes@border@left\z@
\spx@boxes@border\z@
\fi
%
\spx@boxes@padding@top \spx@pre@padding@top
\spx@boxes@padding@right \spx@pre@padding@right
\spx@boxes@padding@bottom\spx@pre@padding@bottom
\spx@boxes@padding@left \spx@pre@padding@left
%
\spx@boxes@radius@topleft \spx@pre@radius@topleft
\spx@boxes@radius@topright \spx@pre@radius@topright
\spx@boxes@radius@bottomright \spx@pre@radius@bottomright
\spx@boxes@radius@bottomleft \spx@pre@radius@bottomleft
%
%
\ifspx@pre@withshadow
\spx@boxes@withshadowtrue
\spx@boxes@shadow@xoffset \spx@pre@shadow@xoffset
\spx@boxes@shadow@yoffset \spx@pre@shadow@yoffset\relax
\else
\spx@boxes@withshadowfalse
\fi
\ifspx@pre@insetshadow\spx@boxes@insetshadowtrue\else
\spx@boxes@insetshadowfalse\fi
\ifspx@pre@withshadowcolor\spx@boxes@withshadowcolortrue\else
\spx@boxes@withshadowcolorfalse\fi
%
\ifspx@pre@withbackgroundcolor\spx@boxes@withbackgroundcolortrue\else
\spx@boxes@withbackgroundcolorfalse\fi
\sphinxcolorlet{spx@boxes@backgroundcolor}{VerbatimColor}%
%
\ifspx@pre@withbordercolor\spx@boxes@withbordercolortrue\else
\spx@boxes@withbordercolorfalse\fi
\sphinxcolorlet{spx@boxes@bordercolor}{VerbatimBorderColor}%
%
\ifspx@pre@withshadowcolor\spx@boxes@withshadowcolortrue\else
\spx@boxes@withshadowcolorfalse\fi
\sphinxcolorlet{spx@boxes@shadowcolor}{sphinxVerbatimShadowColor}%
% Prepares usage of \spx@boxes@fcolorbox
\spx@boxes@fcolorbox@setup
{pre}{VerbatimBorderColor}{VerbatimColor}{sphinxVerbatimShadowColor}%
\ifspx@opt@verbatimwithframe
\else
\spx@boxes@border@top\z@
\spx@boxes@border@right\z@
\spx@boxes@border@bottom\z@
\spx@boxes@border@left\z@
\spx@boxes@border\z@
\fi
}%
\def\spx@verb@boxes@fcolorbox@setuphook@openbottom{%
\spx@boxes@border@bottom \z@

View File

@@ -1,7 +1,7 @@
%% TOPIC AND CONTENTS BOXES
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexshadowbox.sty}[2023/03/06 sphinxShadowBox]
\ProvidesFile{sphinxlatexshadowbox.sty}[2023/03/07 sphinxShadowBox]
% Provides support for this output mark-up from Sphinx latex writer:
%
@@ -19,46 +19,8 @@
\RequirePackage{sphinxpackageboxes}
\def\spx@shadowbox@boxes@fcolorbox@setup{%
%
\spx@boxes@border@top \spx@topic@border@top
\spx@boxes@border@right \spx@topic@border@right
\spx@boxes@border@bottom\spx@topic@border@bottom
\spx@boxes@border@left \spx@topic@border@left
\spx@boxes@border \spx@topic@border
%
\spx@boxes@padding@top \spx@topic@padding@top
\spx@boxes@padding@right \spx@topic@padding@right
\spx@boxes@padding@bottom\spx@topic@padding@bottom
\spx@boxes@padding@left \spx@topic@padding@left
%
\spx@boxes@radius@topleft \spx@topic@radius@topleft
\spx@boxes@radius@topright \spx@topic@radius@topright
\spx@boxes@radius@bottomright \spx@topic@radius@bottomright
\spx@boxes@radius@bottomleft \spx@topic@radius@bottomleft\relax
%
\ifspx@topic@withshadow
\spx@boxes@withshadowtrue
\spx@boxes@shadow@xoffset \spx@topic@shadow@xoffset
\spx@boxes@shadow@yoffset \spx@topic@shadow@yoffset\relax
\else
\spx@boxes@withshadowfalse
\fi
\ifspx@topic@insetshadow\spx@boxes@insetshadowtrue\else
\spx@boxes@insetshadowfalse\fi
\ifspx@topic@withshadowcolor\spx@boxes@withshadowcolortrue\else
\spx@boxes@withshadowcolorfalse\fi
%
\ifspx@topic@withbackgroundcolor\spx@boxes@withbackgroundcolortrue\else
\spx@boxes@withbackgroundcolorfalse\fi
\sphinxcolorlet{spx@boxes@backgroundcolor}{sphinxtopicBgColor}%
%
\ifspx@topic@withbordercolor\spx@boxes@withbordercolortrue\else
\spx@boxes@withbordercolorfalse\fi
\sphinxcolorlet{spx@boxes@bordercolor}{sphinxtopicBorderColor}%
%
\ifspx@topic@withshadowcolor\spx@boxes@withshadowcolortrue\else
\spx@boxes@withshadowcolorfalse\fi
\sphinxcolorlet{spx@boxes@shadowcolor}{sphinxtopicShadowColor}%
\spx@boxes@fcolorbox@setup
{topic}{sphinxtopicBorderColor}{sphinxtopicBgColor}{sphinxtopicShadowColor}%
}%
% At 5.1.0 the code formerly here has been refactored and incorporated
@@ -72,21 +34,8 @@
\fi
\fi
\fi
\if1% use rounded boxes only if needed and possible
\ifdim\spx@topic@radius@topleft >\z@0\fi
\ifdim\spx@topic@radius@topright >\z@0\fi
\ifdim\spx@topic@radius@bottomright>\z@0\fi
\ifdim\spx@topic@radius@bottomleft >\z@0\fi
1\spx@boxes@fcolorbox{\box\z@}%
\else
\spx@ifpackageloaded@pictiie
{\ifspx@topic@insetshadow
\spx@boxes@fcolorbox{\box\z@}%
\else
\spx@boxes@fcolorbox@rounded{\box\z@}%
\fi}%
{\spx@boxes@fcolorbox{\box\z@}}%
\fi
% \spx@shadowbox@boxes@fcolorbox@setup MUST have been called before
\spx@boxes@fcolorbox{\box\z@}%
\ifspx@topic@withshadow
\ifspx@topic@insetshadow\else
% A strangely unnoticed 5.1.0 breakage of the legacy placement of the

View File

@@ -1,7 +1,7 @@
%% COLOURED BOXES
%
% change this info string if making any custom modification
\ProvidesPackage{sphinxpackageboxes}[2023/03/06 v6.2.0 advanced colored boxes]
\ProvidesPackage{sphinxpackageboxes}[2023/03/07 v6.2.0 advanced colored boxes]
% Optionally executes \RequirePackage for:
%
% - pict2e. Ideally we would like to use the v0.4a 2020/08/16 release of this
@@ -13,8 +13,10 @@
\newbox\spx@tempboxa
\newbox\spx@tempboxb
% Internal dimens, conditionals, and colour parameters to be configured
% by callers in "setup" macros
%%%%%%%%%%%%%%%%
% Internal registers, conditionals, colors to be configured by each caller
% via a preliminary "setup" call
%
\newif\ifspx@boxes@withshadow
\newif\ifspx@boxes@insetshadow
\newif\ifspx@boxes@withbackgroundcolor
@@ -46,13 +48,111 @@
% spx@boxes@backgroundcolor
% spx@boxes@shadowcolor
%%%%%%%%%%%%%%%%
% "setup" macro
%
% It must be called prior to \spx@boxes@fcolorbox{@rounded,@insetshadow} for
% initializing its parameters.
%
% It also prepares \spx@boxes@fcolorbox to expand to one of
% \spx@boxes@fcolorbox@rectangle or \spx@boxes@fcolorbox@rounded depending on
% the configuration and availability of the pict2e package.
%
% Due to varying conventions regarding Color names (border, background,
% and shadow), they have to be passed as parameters #2, #3, #4.
% The #1 is one of: pre, topic, warning, danger, etc....
\def\spx@boxes@fcolorbox@setup#1#2#3#4{%
% All right sides expand to non-terminated dimen expressions (except for
% shadow@xoffset, shadow@yoffset, where the space of EOL terminates <N>sp)
% The \relax are not strictly needed, except the one before the first
% \iftrue, but in case some input is "2.5" in place of "2.5pt" they help
% avoiding LaTeX to issue e.g. some "Missing \begin{document}" error
% rather than more apt "Illegal unit of measure (pt inserted)."
\spx@boxes@border@top \@nameuse{spx@#1@border@top}\relax
\spx@boxes@border@right \@nameuse{spx@#1@border@right}\relax
\spx@boxes@border@bottom\@nameuse{spx@#1@border@bottom}\relax
\spx@boxes@border@left \@nameuse{spx@#1@border@left}\relax
\spx@boxes@border \@nameuse{spx@#1@border}\relax
%
\spx@boxes@padding@top \@nameuse{spx@#1@padding@top}\relax
\spx@boxes@padding@right \@nameuse{spx@#1@padding@right}\relax
\spx@boxes@padding@bottom\@nameuse{spx@#1@padding@bottom}\relax
\spx@boxes@padding@left \@nameuse{spx@#1@padding@left}\relax
%
\spx@boxes@radius@topleft \@nameuse{spx@#1@radius@topleft}\relax
\spx@boxes@radius@topright \@nameuse{spx@#1@radius@topright}\relax
\spx@boxes@radius@bottomright \@nameuse{spx@#1@radius@bottomright}\relax
\spx@boxes@radius@bottomleft \@nameuse{spx@#1@radius@bottomleft}\relax
%
\@nameuse{ifspx@#1@withshadow}%
\spx@boxes@withshadowtrue
\spx@boxes@shadow@xoffset \@nameuse{spx@#1@shadow@xoffset}\relax
\spx@boxes@shadow@yoffset \@nameuse{spx@#1@shadow@yoffset}\relax
\else
\spx@boxes@withshadowfalse
\fi
% not nesting in previous to avoid TeX conditional subtleties
\@nameuse{ifspx@#1@insetshadow}%
\spx@boxes@insetshadowtrue
\else
\spx@boxes@insetshadowfalse
\fi
%
\@nameuse{ifspx@#1@withbordercolor}%
\spx@boxes@withbordercolortrue
\sphinxcolorlet{spx@boxes@bordercolor}{#2}%
\else
\spx@boxes@withbordercolorfalse
\fi
%
\@nameuse{ifspx@#1@withbackgroundcolor}%
\spx@boxes@withbackgroundcolortrue
\sphinxcolorlet{spx@boxes@backgroundcolor}{#3}%
\else
\spx@boxes@withbackgroundcolorfalse
\fi
%
\@nameuse{ifspx@#1@withshadowcolor}%
\spx@boxes@withshadowcolortrue
\sphinxcolorlet{spx@boxes@shadowcolor}{#4}%
\else
\spx@boxes@withshadowcolorfalse
\fi
\if1% use rounded boxes only if needed and possible
\ifdim\spx@boxes@radius@topleft >\z@0\fi
\ifdim\spx@boxes@radius@topright >\z@0\fi
\ifdim\spx@boxes@radius@bottomright>\z@0\fi
\ifdim\spx@boxes@radius@bottomleft >\z@0\fi
1\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
\else
\spx@ifpackageloaded@pictiie
{\ifspx@boxes@insetshadow
\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
\else
\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rounded}%
\fi}%
{\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}}%
\fi
}
%%%%%%%%%%%%%%%%
% MACROS
%
% - \spx@boxes@fcolorbox (4 padding parameters, 4 border widths, 2 shadow widths,
% \spx@boxes@fcolorbox expands either to \spx@boxes@fcolorbox@rectangle
% or \spx@boxes@fcolorbox@rounded depending on preliminary set-up.
% Let's give it some default fall-back:
% (but preliminary "setup" of \spx@boxes@fcolorbox@rectangle parameters
% is mandatory requirement for it to work)
\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}
% Then:
%
% - \spx@boxes@fcolorbox@rectangle (4 padding parameters, 4 border widths, 2 shadow widths,
% and three colours: background, border and shadow; same as in CSS styling)
%
% - \spx@boxes@fcolorbox@insetshadow (same as in CSS styling)
% It branches to one of:
% - \spx@boxes@fcolorbox@externalshadow
% - \spx@boxes@fcolorbox@insetshadow (same concept of "inset" as in CSS styling)
%
% - \spx@boxes@fcolorbox@rounded: rounded corners using the picture environment
% and pict2e package for its low-weight interface to PDF graphics operations
@@ -73,7 +173,7 @@
% if nothing else is changed (perhaps in future the title itself could be also
% rendered in a rounded box?)
%//// \spx@boxes@fcolorbox
%//// \spx@boxes@fcolorbox@rectangle
% This box will have the same baseline as its argument (which is typeset in
% horizontal mode). It takes into account four border widths parameters, four
% padding parameters, two shadow widths (each possibly negative), and three
@@ -85,13 +185,13 @@
% of TeX boxes (and interline glues).
%
% The customization of the various parameters are under responsability of
% the caller, before exapnsion of \spx@boxes@fcolorbox.
% An extra hook is provided:
% the caller, before expansion of \spx@boxes@fcolorbox.
% An extra hook is provided which is used by \sphinxVerbatim@FirstFrameCommand
% from sphinxlatexliterals.sty and others.
\let\spx@boxes@fcolorbox@setuphook\@empty
%
% The parameters are interpreted as they would as CSS properties.
% For inset shadows see separate \spx@boxes@fcolorbox@insetshadow.
\long\def\spx@boxes@fcolorbox#1{%
\long\def\spx@boxes@fcolorbox@rectangle#1{%
\hbox\bgroup
\spx@boxes@fcolorbox@setuphook
\setbox\spx@tempboxa