# Wrong arrangement of LaTeX output within bounding box of text plot

When I run the command

text('$%s$' %latex(1/2),(1,1), background_color='red', typeset='latex')


I get an unsymmetric output of the bounding box. Or more precisely, the fraction is too far above.

It becomes worse when increasing the fontsize.

text('$%s$' %latex(1/2),(1,1), background_color='red', fontsize=50, typeset='latex')


The fraction line should be further down. This can be reproduced on the Sage cell server: http://sagecell.sagemath.org/?z=eJwdy...

Any ideas how to make it right?

I get a similar problem with

text('$%s$' %latex(1),(1,1), background_color='red', typeset='latex')


edit retag close merge delete

I see this in your screenshots, but I can't reproduce this on the Sage cell server: http://sagecell.sagemath.org/?z=eJxzy... Which version of Sage are you using, on which platform?

( 2017-06-19 19:27:12 +0100 )edit

I changed my matplotlibrc by setting text.usetex to True because I didn't want an asymmetric output of the fraction line as in your example. Look here: http://sagecell.sagemath.org/?z=eJwdz...

I added typeset='latex' to my code above.

'SageMath version 7.6, Release Date: 2017-03-25' on Manjaro (kernel 4.9.33-1).

( 2017-06-19 19:34:04 +0100 )edit

Thanks for the update - that clarifies a lot.

( 2017-06-20 14:47:42 +0100 )edit

Sort by » oldest newest most voted

Considering that typesetisn't even listed as a supported option at http://doc.sagemath.org/html/en/refer... it's not surprising it doesn't behave as you wish. In particular, we don't require LaTeX as a system dependency (though it is recommended) so we couldn't necessarily support that out of the box for all, though we do have optional doctests and if it were fixed that could be added.

If you know enough matplotlib to mess with it, then see https://github.com/sagemath/sage/blob... and hopefully there might be a way to deal with this in a fashion that "fixes" everything. My guess is that it's a combination of the bounding box options and the clip option, though setting that to True didn't seem to make a difference. My experience does say that a lot of these other options are hard to mix without going directly to matplotlib. Possibly see also Trac 15870.

Edit: This is now Trac 23293.

more

1

But typeset is a supported option of show. That means, you can first do a=text(...) and then show(a, typeset='latex').

( 2017-06-20 15:56:15 +0100 )edit

Ah! Okay, then this is a bug. Will update momentarily.

( 2017-06-21 14:12:46 +0100 )edit