Skip to content

\genfrac should accept a unit for thickness #19001

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

Closed
QuLogic opened this issue Nov 24, 2020 · 1 comment · May be fixed by #22171
Closed

\genfrac should accept a unit for thickness #19001

QuLogic opened this issue Nov 24, 2020 · 1 comment · May be fixed by #22171
Labels
keep Items to be ignored by the “Stale” Github Action topic: text/mathtext

Comments

@QuLogic
Copy link
Member

QuLogic commented Nov 24, 2020

In LaTeX, the third parameter (bar thickness) to genfrac requires a unit, but Matplotlib's mathtext parser does not accept it. This causes an inconsistency in the docs between Matplotlib and LaTeX, cf https://github.com/matplotlib/matplotlib/pull/18948/files#diff-9d1b2ab4b8a5e77dc635425c7e7ec00af5667d684d0809e46a973185e8f9918fR97

Code for reproduction

import matplotlib.pyplot as plt

plt.text(0, 0, r'$\genfrac{(}{)}{3pt}{0}{foo}{bar}$')
plt.draw()

Actual outcome

Traceback (most recent call last):
  File "/usr/lib64/python3.8/tkinter/__init__.py", line 1883, in __call__
    return self.func(*args)
  File "/usr/lib64/python3.8/tkinter/__init__.py", line 804, in callit
    func(*args)
  File "/usr/lib64/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 270, in idle_draw
    self.draw()
  File "/usr/lib64/python3.8/site-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super(FigureCanvasTkAgg, self).draw()
  File "/usr/lib64/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 393, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib64/python3.8/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python3.8/site-packages/matplotlib/figure.py", line 1735, in draw
    mimage._draw_list_compositing_images(
  File "/usr/lib64/python3.8/site-packages/matplotlib/image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib64/python3.8/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python3.8/site-packages/matplotlib/axes/_base.py", line 2630, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/usr/lib64/python3.8/site-packages/matplotlib/image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib64/python3.8/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python3.8/site-packages/matplotlib/text.py", line 685, in draw
    bbox, info, descent = textobj._get_layout(renderer)
  File "/usr/lib64/python3.8/site-packages/matplotlib/text.py", line 299, in _get_layout
    w, h, d = renderer.get_text_width_height_descent(
  File "/usr/lib64/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 209, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
  File "/usr/lib64/python3.8/site-packages/matplotlib/mathtext.py", line 3354, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
  File "/usr/lib64/python3.8/site-packages/matplotlib/mathtext.py", line 2583, in parse
    raise ValueError("\n".join(["",
ValueError: 
\genfrac{(}{)}{3pt}{0}{foo}{bar}
        ^
Expected \genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}, found '{'  (at char 8), (line:1, col:9)

Expected outcome

Draws as if passing 3 instead of 3pt, though possibly slightly different spacing, as I'm not sure in what unit we treat the 3 right now.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Sep 15, 2023
@github-actions github-actions bot added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label Nov 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
@oscargus oscargus added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. labels Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action topic: text/mathtext
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants