Skip to content

Commit ffe069d

Browse files
committed
Fix apostrophes as primes
Fixes #5864
1 parent fbb9bbc commit ffe069d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/matplotlib/mathtext.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2852,12 +2852,15 @@ def subsuper(self, s, loc, toks):
28522852
sub = None
28532853
super = None
28542854

2855-
# Pick all of the apostrophe's out
2855+
# Pick all of the apostrophes out, including first apostrophes that have
2856+
# been parsed as characters
28562857
napostrophes = 0
28572858
new_toks = []
28582859
for tok in toks[0]:
28592860
if isinstance(tok, six.string_types) and tok not in ('^', '_'):
28602861
napostrophes += len(tok)
2862+
elif isinstance(tok, Char) and tok.c == "'":
2863+
napostrophes += 1
28612864
else:
28622865
new_toks.append(tok)
28632866
toks = new_toks
@@ -2912,6 +2915,9 @@ def subsuper(self, s, loc, toks):
29122915
super = Hlist([])
29132916
for i in range(napostrophes):
29142917
super.children.extend(self.symbol(s, loc, ['\prime']))
2918+
# kern() and hpack() needed to get the metrics right after extending
2919+
super.kern()
2920+
super.hpack()
29152921

29162922
# Handle over/under symbols, such as sum or integral
29172923
if self.is_overunder(nucleus):

lib/matplotlib/tests/test_mathtext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
r"$\gamma = \frac{x=\frac{6}{8}}{y} \delta$",
4444
r'$\limsup_{x\to\infty}$',
4545
r'$\oint^\infty_0$',
46-
r"$f'$",
46+
r"$f'\quad f'''(x)\quad ''/\mathrm{yr}$",
4747
r'$\frac{x_2888}{y}$',
4848
r"$\sqrt[3]{\frac{X_2}{Y}}=5$",
4949
r"$\sqrt[5]{\prod^\frac{x}{2\pi^2}_\infty}$",

0 commit comments

Comments
 (0)