Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add more sizeable delimiters #26176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/users/next_whats_new/mathtext_delimiters.rst
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 6 additions & 2 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/_mathtext_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@
'cwopencirclearrow' : 8635,
'geqq' : 8807,
'rightleftarrows' : 8644,
'lgroup' : 0x27EE,
'rgroup' : 0x27EF,
'aa' : 229,
'ac' : 8766,
'ae' : 230,
Expand Down Expand Up @@ -1016,7 +1018,7 @@
'leftparen' : 40,
'rightparen' : 41,
'bigoplus' : 10753,
'leftbrace' : 124,
'leftbrace' : 123,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be a vertical bar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the comment. Yes, it was wrong and is now correct?

Or are you saying that people have used \leftbrace to get a vertical bar? (Which I think was wrong until recently...)

'rightbrace' : 125,
'jmath' : 567,
'bigodot' : 10752,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down