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

Skip to content

Commit 655ec51

Browse files
committed
Do not space symbols in limits
1 parent fcf75dd commit 655ec51

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

doc/sphinxext/math_symbol_table.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
\hslash \blacksquare \blacktriangle \sharp \increment
6868
\prime \blacktriangledown \Im \flat \backprime \Re \natural
6969
\circledS \P \copyright \circledR \S \yen \checkmark \$
70-
\cent \triangle \QED \sinewave \dag \ddag \perthousand
71-
\lambdabar \L \l \degree \danger \maltese
70+
\cent \triangle \QED \sinewave \dag \ddag \perthousand \ac
71+
\lambdabar \L \l \degree \danger \maltese \clubsuitopen
7272
\i \hermitmatrix \sterling \nabla \mho""".split()],
7373
]
7474

@@ -83,7 +83,7 @@ def render_symbol(sym, ignore_variant=False):
8383
if sym not in (_mathtext.Parser._overunder_functions |
8484
_mathtext.Parser._function_names):
8585
sym = chr(_mathtext_data.tex2uni[sym])
86-
return f'\\{sym}' if sym in ('\\', '|') else sym
86+
return f'\\{sym}' if sym in ('\\', '|', '+', '-', '*') else sym
8787

8888
lines = []
8989
for category, columns, syms in symbols:
@@ -145,6 +145,7 @@ def setup(app):
145145

146146
# Add accents
147147
all_symbols.update({v[1:]: k for k, v in _mathtext.Parser._accent_map.items()})
148+
all_symbols.update({v: v for v in _mathtext.Parser._wide_accents})
148149
print("SYMBOLS NOT IN TABLE:")
149150
for sym, val in _mathtext_data.tex2uni.items():
150151
if sym not in all_symbols:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``mathtext`` spacing corrections
2+
--------------------------------
3+
4+
As consequence of the updated documentation, the spacing on a number of relational and
5+
operator symbols were classified like that and therefore will be spaced properly.

lib/matplotlib/_mathtext.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ class _MathStyle(enum.Enum):
17781778
\triangleright \ntriangleleft \ntriangleright
17791779
\trianglelefteq \ntrianglelefteq \trianglerighteq
17801780
\ntrianglerighteq \blacktriangleleft \blacktriangleright
1781-
\equalparallel \measuredrightangle \lrtriangle
1781+
\equalparallel \measuredrightangle \varlrtriangle
17821782
\Doteq \Bumpeq \Subset \Supset
17831783
\backepsilon \because \therefore \bot
17841784
\top \bumpeq \circeq \coloneq
@@ -1799,7 +1799,7 @@ class _MathStyle(enum.Enum):
17991799
\varniobar \niobar \bagmember \ratio
18001800
\Equiv \stareq \measeq \arceq
18011801
\rightassert \rightModels \smallin \smallowns
1802-
\notsmallowns'''.split())
1802+
\notsmallowns \nsimeq'''.split())
18031803

18041804
_arrow_symbols = set(r"""
18051805
\leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow
@@ -2154,9 +2154,11 @@ def symbol(self, s, loc, toks):
21542154
# such as ${ -2}$, $ -2$, or $ -2$.
21552155
prev_char = next((c for c in s[:loc][::-1] if c != ' '), '')
21562156
# Binary operators at start of string should not be spaced
2157-
if (c in self._binary_operators and
2158-
(len(s[:loc].split()) == 0 or prev_char == '{' or
2159-
prev_char in self._left_delims)):
2157+
# Also, operators in sub- or superscripts should not be spaced
2158+
if (self._in_subscript_or_superscript or (
2159+
c in self._binary_operators and (
2160+
len(s[:loc].split()) == 0 or prev_char == '{' or
2161+
prev_char in self._left_delims))):
21602162
return [char]
21612163
else:
21622164
return [Hlist([self._make_space(0.2),

lib/matplotlib/_mathtext_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@
910910
'O' : 216,
911911
'hookleftarrow' : 8617,
912912
'trianglerighteq' : 8885,
913-
'nsime' : 8772,
913+
'nsimeq' : 8772,
914914
'oe' : 339,
915915
'nwarrow' : 8598,
916916
'o' : 248,
@@ -1068,7 +1068,7 @@
10681068
'hermitmatrix' : 8889,
10691069
'barvee' : 8893,
10701070
'measuredrightangle' : 8894,
1071-
'lrtriangle' : 8895,
1071+
'varlrtriangle' : 8895,
10721072
'equalparallel' : 8917,
10731073
'npreccurlyeq' : 8928,
10741074
'nsucccurlyeq' : 8929,

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def test_mathtext_operators():
525525
\ngtrsim \nlessgtr \ngtrless
526526
\cupleftarrow \oequal \rightassert
527527
\rightModels \hermitmatrix \barvee
528-
\measuredrightangle \lrtriangle
528+
\measuredrightangle \varlrtriangle
529529
\equalparallel \npreccurlyeq \nsucccurlyeq
530530
\nsqsubseteq \nsqsupseteq \sqsubsetneq
531531
\sqsupsetneq \disin \varisins

0 commit comments

Comments
 (0)