summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François B <2589111+jfbu@users.noreply.github.com>2023-03-14 23:42:38 +0100
committerJean-François B <2589111+jfbu@users.noreply.github.com>2023-03-14 23:52:32 +0100
commit78e14fb6ba92f1aa9723aee6346fd7f763b3d978 (patch)
tree12e0b360d5e18b025c45ea58156c11b2ff342eb9
parentee3c720cfa6d8fcbfbe01c52bbe78a6ba0e8ed49 (diff)
downloadsphinx-git-78e14fb6ba92f1aa9723aee6346fd7f763b3d978.tar.gz
LaTeX: add boolean option addstrut to \sphinxbox/\sphinxboxsetup
-rw-r--r--doc/latex.rst15
-rw-r--r--sphinx/texinputs/sphinx.sty8
-rw-r--r--sphinx/texinputs/sphinxpackageboxes.sty3
3 files changed, 22 insertions, 4 deletions
diff --git a/doc/latex.rst b/doc/latex.rst
index 2e1e05090..485613233 100644
--- a/doc/latex.rst
+++ b/doc/latex.rst
@@ -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``.
-
-Refer to :ref:`additionalcss` for important syntax information. The default
+- ``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``.
+
+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
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index 9b7b4e2ec..7586c84e8 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -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}}
diff --git a/sphinx/texinputs/sphinxpackageboxes.sty b/sphinx/texinputs/sphinxpackageboxes.sty
index f9e09b581..c0df4d88d 100644
--- a/sphinx/texinputs/sphinxpackageboxes.sty
+++ b/sphinx/texinputs/sphinxpackageboxes.sty
@@ -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]}%