diff --git a/doc/users/next_whats_new/mathtext_delimiters.rst b/doc/users/next_whats_new/mathtext_delimiters.rst new file mode 100644 index 000000000000..7c1c29f4b9ec --- /dev/null +++ b/doc/users/next_whats_new/mathtext_delimiters.rst @@ -0,0 +1,14 @@ +``mathtext`` has more sizable delimiters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``\lgroup`` and ``\rgroup`` sizable delimiters have been added. + +The following delimiter names have been supported earlier, but can now be sized with +``\left`` and ``\right``: + +* ``\lbrace``, ``\rbrace``, ``\leftbrace``, and ``\rightbrace`` +* ``\lbrack`` and ``\rbrack`` +* ``\leftparen`` and ``\rightparen`` + +There are really no obvious advantages in using these. +Instead, they are are added for completeness. diff --git a/lib/matplotlib/_mathtext.py b/lib/matplotlib/_mathtext.py index b1942d0c98e4..35f7f1c606cf 100644 --- a/lib/matplotlib/_mathtext.py +++ b/lib/matplotlib/_mathtext.py @@ -1808,8 +1808,12 @@ class _MathStyle(enum.Enum): _ambi_delims = set(r""" | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow . \vert \Vert""".split()) - _left_delims = set(r"( [ \{ < \lfloor \langle \lceil".split()) - _right_delims = set(r") ] \} > \rfloor \rangle \rceil".split()) + _left_delims = set(r""" + ( [ \{ < \lfloor \langle \lceil \lbrace \leftbrace \lbrack \leftparen \lgroup + """.split()) + _right_delims = set(r""" + ) ] \} > \rfloor \rangle \rceil \rbrace \rightbrace \rbrack \rightparen \rgroup + """.split()) _delims = _left_delims | _right_delims | _ambi_delims _small_greek = set([unicodedata.name(chr(i)).split()[-1].lower() for i in diff --git a/lib/matplotlib/_mathtext_data.py b/lib/matplotlib/_mathtext_data.py index 84136ffe8b3e..40ba4f96f103 100644 --- a/lib/matplotlib/_mathtext_data.py +++ b/lib/matplotlib/_mathtext_data.py @@ -957,6 +957,8 @@ 'cwopencirclearrow' : 8635, 'geqq' : 8807, 'rightleftarrows' : 8644, + 'lgroup' : 0x27EE, + 'rgroup' : 0x27EF, 'aa' : 229, 'ac' : 8766, 'ae' : 230, @@ -1016,7 +1018,7 @@ 'leftparen' : 40, 'rightparen' : 41, 'bigoplus' : 10753, - 'leftbrace' : 124, + 'leftbrace' : 123, 'rightbrace' : 125, 'jmath' : 567, 'bigodot' : 10752, diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext1_dejavusans_06.png b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext1_dejavusans_06.png new file mode 100644 index 000000000000..85d0adf15112 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext1_dejavusans_06.png differ diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py index 41619c18cf91..0a3354954280 100644 --- a/lib/matplotlib/tests/test_mathtext.py +++ b/lib/matplotlib/tests/test_mathtext.py @@ -135,6 +135,7 @@ r'$1.$ $2.$ $19680801.$ $a.$ $b.$ $mpl.$', r'$\text{text}_{\text{sub}}^{\text{sup}} + \text{\$foo\$} + \frac{\text{num}}{\mathbf{\text{den}}}\text{with space, curly brackets \{\}, and dash -}$', r'$\boldsymbol{abcde} \boldsymbol{+} \boldsymbol{\Gamma + \Omega} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$', + r'$\left\lbrace\frac{\left\lbrack A^b_c\right\rbrace}{\left\leftbrace D^e_f \right\rbrack}\right\rightbrace\ \left\leftparen\max_{x} \left\lgroup \frac{A}{B}\right\rgroup \right\rightparen$', ] digits = "0123456789"