Skip to content

mathtext mishandling of certain exponents #5864

Closed

Description

@anntzer

From the second example for twin axes in AxesGrid1, where the intent was probably to have a "seconds of angle" symbol:

$ python
Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt; plt.gca().set_xlabel("$^{''}$/yr"); plt.show()
<matplotlib.text.Text object at 0x7f6451604f98>

(same result from within ipython with %matplotlib active)
screenshot_20160116_211600

EDIT: This part is invalid and should be ignored
Weirdly enough, running the same command from with python -c a different result:

$ python -c 'import matplotlib.pyplot as plt; plt.gca().set_xlabel("$^{''}$/yr"); plt.show()'

screenshot_20160116_211836

(checked without any matplotlibrc).

Preempting @tacaswell to @zblz this time :-)

Activity

  1. added this to the milestone on Jan 17, 2016
  2. QuLogic commented on Jan 17, 2016

    @QuLogic
    Member

    The result with python -c is different because the single quotes in the middle end and start two Bash strings.

  3. anntzer commented on Jan 17, 2016

    @anntzer
    ContributorAuthor

    Oops, failed at triple nesting my quotes. The main issue still stands though.

  4. changed the title [-]Strange mathtext behavior (for lack of better description...)[/-] [+]mathtext mishandling of certain exponents[/+] on Jan 17, 2016
  5. zblz commented on Jan 17, 2016

    @zblz
    Member

    The first result is definitely weird, I have no idea where that phi comes from. I'll take a look to try to find the culprit.

    For the record, the proper way of of typesetting arcseconds would be with primes $^{\prime\prime}$.

  6. zblz commented on Jan 17, 2016

    @zblz
    Member

    Also note that this only happens with the Computer Modern mathtext fontset (which is default in 1.5.x but will not be in 2.x). with the dejavusans fontset the rendering is better but there is still some weirdness with the first ':
    2016-01-17-122456_1366x768_scrot

  7. zblz commented on Jan 17, 2016

    @zblz
    Member

    So I narrowed the behaviour down to two effects:

    • mathtext will convert apostrophes into ^\prime, so that's why the second apostrophe gets typeset correctly, but it will only do this change to apostrophes coming after a nucleus (so it will change $a'$ into $a^{\prime}$ but not $'$ into $^\prime$). Because of this, {}'' would actually give the correct behaviour.
    • the latex_to_bakoma dictionary does not have an entry for ', and the Bakoma fonts included do not have a quotesingle character, only quoteleft and quoteright. I don't know why the lack of a entry results in \phi, though.

    The second part could be fixed by adding an entry in the latex_to_bakoma dict to, e.g., quoteleft. However, I think fixing the behaviour of the first part (converting all ' to superscripted primes) is better. I am still having some trouble implementing that, though.

  8. efiring commented on Jan 17, 2016

    @efiring
    Member

    On 2016/01/17 10:40 AM, Victor Zabalza wrote:

    However, I think fixing the behaviour of the first part (converting all
    |'| to superscripted primes) is better.

    If I understand correctly, this is making mathtext less compatible
    with LaTeX. Is this a desired result? Granted, $^\prime$ is clunky
    and ugly.

  9. anntzer commented on Jan 17, 2016

    @anntzer
    ContributorAuthor

    Actually I just learnt that ' is an active character in tex that gets converted to ^\prime (plus some more). So it's actually more compatible.

  10. added a commit that references this issue on Jan 18, 2016
  11. added a commit that references this issue on Jan 19, 2016
    ffe069d
  12. zblz commented on Jan 19, 2016

    @zblz
    Member

    @anntzer - I did not know about ' being an active character (hence my comment above about a proper way...), it looks very useful. I tried to add the full functionality of that in #5880 so that even apostrophes as first charachters get recognised as primes.

  13. added a commit that references this issue on Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions