LaTeX: add boolean option addstrut to \sphinxbox/\sphinxboxsetup

This commit is contained in:
Jean-François B 2023-03-14 23:42:38 +01:00
parent ee3c720cfa
commit 78e14fb6ba
3 changed files with 21 additions and 3 deletions

View File

@ -1536,9 +1536,18 @@ Here is the complete list of keys:
- ``border-top-left-radius``, ``border-top-right-radius``,
``border-bottom-right-radius``, ``border-bottom-left-radius``,
- ``box-shadow``,
- ``border-TeXcolor``, ``background-TeXcolor``, ``box-shadow-TeXcolor``.
- ``border-TeXcolor``, ``background-TeXcolor``, ``box-shadow-TeXcolor``,
- and ``addstrut`` which is a boolean key, i.e. to be used as ``addstrut=true``,
or ``addstrut`` alone where ``=true`` is omitted, or ``addstrut=false``.
Refer to :ref:`additionalcss` for important syntax information. The default
This last key is specific to ``\sphinxbox`` and it means to add a ``\strut``
so that heights and depths are equalized across various instances,
independently of text content. The combination ``addstrut,
padding-bottom=0pt, padding-top=1pt`` is often satisfactory. The default is
``addstrut=false``.e
Refer to :ref:`additionalcss` for important syntax information regarding the
other keys. The default
configuration uses no shadow, a border-width of ``\fboxrule``, a padding of
``\fboxsep``, rounded corners (with radius ``\fboxsep``) and background and
border colors as for the default rendering of code-blocks. One can modify

View File

@ -698,6 +698,13 @@ will be set to white}%
\spx@tempa{div.important_} {important}
\spx@tempa{div.tip_} {tip}
\newif\ifspx@opt@box@addstrut
\expandafter\def\csname KV@sphinx@box_addstrut\endcsname#1{%
\csname spx@opt@box@addstrut#1\endcsname
}
\expandafter\def\csname KV@sphinx@box_addstrut@default\endcsname{%
\spx@opt@box@addstruttrue
}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
@ -818,6 +825,7 @@ will be set to white}%
{border-bottom-right-radius}{border-bottom-left-radius}%
{box-shadow}%
{border-TeXcolor}{background-TeXcolor}{box-shadow-TeXcolor}%
{addstrut}{addstrut@default}%
\do{\expandafter\let\csname KV@sphinxbox@\x\expandafter\endcsname
\csname KV@sphinx@box_\x\endcsname}
\newcommand\sphinxboxsetup{\setkeys{sphinxbox}}

View File

@ -258,7 +258,8 @@
\setbox0\hbox\bgroup\aftergroup\spx@boxes@sphinxbox@a
\let\next=%
}
\def\spx@boxes@sphinxbox@a{\spx@boxes@fcolorbox{\box\z@}\endgroup}
\def\spx@boxes@sphinxbox@a{\spx@boxes@fcolorbox{%
\ifspx@opt@box@addstrut\strut\fi\box\z@}\endgroup}
\newcommand\newsphinxbox[2][]{%
\newcommand#2[1][]{\sphinxbox[#1,##1]}%