Skip to content
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

Rogue mathtext rendered spaces #4333

Closed
ndevenish opened this issue Apr 13, 2015 · 7 comments
Closed

Rogue mathtext rendered spaces #4333

ndevenish opened this issue Apr 13, 2015 · 7 comments
Assignees
Milestone

Comments

@ndevenish
Copy link
Contributor

I'm aware that the built in mathtext rendered is not expected to be perfectly identical to tex, but I'm seeing some egregious behavior with spacing that I cannot seem to explain. With:

import matplotlib.pyplot as plt
plt.figure()
plt.figtext(0.1, 0.9, r"1. ($a^2$)", size=20)
plt.figtext(0.1, 0.8, r"2. $(a^2)$", size=20)
plt.figtext(0.1, 0.7, r"3. $\left(a^2\right)$", size=20)
plt.show()

In both 1.4.2 and a recent development version I get a rogue space before the bracket in all three cases:
screen shot 2015-04-13 at 22 16 54
Compared with turning text.usetex on:
screen shot 2015-04-13 at 23 06 26

Using a negative space (\!) fixes the issue rendering with matplotlib, but screws up the latex output.

@tacaswell tacaswell added this to the next point release milestone Apr 14, 2015
@tacaswell
Copy link
Member

attn @mdboom Could this be related to the recent spacing changes?

@u55
Copy link
Contributor

u55 commented Apr 18, 2015

I get slightly more-reasonable whitespace after the exponent if I enclose the exponent in curly brackets.

import matplotlib.pyplot as plt
s = 0.13
plt.figure(figsize=(3,2.5))
plt.figtext(0.1, 0.9-1*s, r"1a. ($a^2$)", size=20)
plt.figtext(0.1, 0.9-2*s, r"1b. ($a^{2}$)", size=20)
plt.figtext(0.1, 0.9-3*s, r"2a. $(a^2)$", size=20)
plt.figtext(0.1, 0.9-4*s, r"2b. $(a^{2})$", size=20)
plt.figtext(0.1, 0.9-5*s, r"3a. $\left(a^2\right)$", size=20)
plt.figtext(0.1, 0.9-6*s, r"3b. $\left(a^{2}\right)$", size=20)
plt.show()

whitespace

@jason-sachs
Copy link

another example:

plt.text(0.2,0.5,"$d^2 \\leq K^2(q^2 - q_0^2)$",fontsize=30)

image

vs. MathJax $d^2 \leq K^2(q^2 - q_0^2)$

image

@WeatherGod
Copy link
Member

In that example, I would wonder if the kerning is being turned off for
exponents, somehow.
On Apr 24, 2015 6:26 PM, "Jason Sachs" notifications@github.com wrote:

another example:

plt.text(0.2,0.5,"$d^2 \leq K^2(q^2 - q_0^2)$",fontsize=30)

[image: image]
https://cloud.githubusercontent.com/assets/10506541/7329623/193182b2-ea96-11e4-980c-ffd0a56223c5.png

vs. MathJax $d^2 \leq K^2(q^2 - q_0^2)$

[image: image]
https://cloud.githubusercontent.com/assets/10506541/7329629/2e21b156-ea96-11e4-939e-82f77ab64dd1.png


Reply to this email directly or view it on GitHub
#4333 (comment)
.

@ndevenish
Copy link
Contributor Author

That's an awful-looking example also - spacing screwed up next to the K and the contraction of the spacing in front of the q_0, along with the same spacing before the close bracket.

mdboom added a commit to mdboom/matplotlib that referenced this issue May 4, 2015
@mdboom mdboom self-assigned this May 4, 2015
@mdboom mdboom closed this as completed in 1886bc2 May 8, 2015
jenshnielsen added a commit that referenced this issue May 8, 2015
Fix #4333: Whitespace after sub/super cluster
@zblz
Copy link
Member

zblz commented Aug 7, 2015

@ndevenish , @jason-sachs , @u55 : I have been finetuning the super/subscript spacing in mathtext in PR #4873, and applied a fix suggested by @mdboom to the symbol spacing in PR #4872. Applying these two PRs, the examples mention in this thread render like this:
issue4333
The strings are:

$d^2 \\leq K^2(q^2 - q_0^2)$
($a^2$) $(a^2)$ $\left(a^2\right)$

It would be great if you could take a look at PR #4873 and make any comments you have on how the new script kerning works before it is merged. Thanks!

@jason-s
Copy link

jason-s commented Aug 14, 2015

It would be great if you could take a look at PR #4873 and make any comments you have on how the new script kerning works before it is merged.

Scanned it briefly. You've gone much more in depth than I have -- thanks, I trust your judgment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants