🌐 AI搜索 & 代理 主页
Skip to content

Commit cd8cfdc

Browse files
committed
Do not space symbols in sub- and superscripts
1 parent 5647b79 commit cd8cfdc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,9 +2163,11 @@ def symbol(self, s, loc, toks):
21632163
# such as ${ -2}$, $ -2$, or $ -2$.
21642164
prev_char = next((c for c in s[:loc][::-1] if c != ' '), '')
21652165
# Binary operators at start of string should not be spaced
2166-
if (c in self._binary_operators and
2167-
(len(s[:loc].split()) == 0 or prev_char == '{' or
2168-
prev_char in self._left_delims)):
2166+
# Also, operators in sub- or superscripts should not be spaced
2167+
if (self._in_subscript_or_superscript or (
2168+
c in self._binary_operators and (
2169+
len(s[:loc].split()) == 0 or prev_char == '{' or
2170+
prev_char in self._left_delims))):
21692171
return [char]
21702172
else:
21712173
return [Hlist([self._make_space(0.2),

0 commit comments

Comments
 (0)