Title: [ENH]: Use `\genfrac` in display style? · Issue #23008 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Use `\genfrac` in display style? · Issue #23008 · matplotlib/matplotlib
X Title: [ENH]: Use `\genfrac` in display style? · Issue #23008 · matplotlib/matplotlib
Description: Problem Is it possible to render fractions in display style using \genfrac? The style argument of the _genfrac function in _mathtext.py is received as an Hlist. As a result, fractions will never use display style (since style and self._M...
Open Graph Description: Problem Is it possible to render fractions in display style using \genfrac? The style argument of the _genfrac function in _mathtext.py is received as an Hlist. As a result, fractions will never us...
X Description: Problem Is it possible to render fractions in display style using \genfrac? The style argument of the _genfrac function in _mathtext.py is received as an Hlist. As a result, fractions will never us...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23008
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Use `\\genfrac` in display style?","articleBody":"### Problem\n\nIs it possible to render fractions in display style using `\\genfrac`?\r\n\r\nThe `style` argument of the `_genfrac` function in `_mathtext.py` is received as an `Hlist`. As a result, fractions will never use display style (since `style` and `self._MathStyle.DISPLAYSTYLE` will always compare unequal).\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\n\r\nfig = plt.figure()\r\nfig.text(.2, .5, r'$\\genfrac{}{}{0}{0}{1}{2}$')\r\nfig.text(.3, .5, r'$\\genfrac{}{}{1}{1}{1}{2}$')\r\nplt.show()\r\n```\n\n### Proposed solution\n\nChange\r\n```\r\n p.genfrac \u003c\u003c= r\"\\genfrac\" - (\r\n \"{\" + Optional(p.ambi_delim | p.left_delim)(\"ldelim\") + \"}\"\r\n + \"{\" + Optional(p.ambi_delim | p.right_delim)(\"rdelim\") + \"}\"\r\n + \"{\" + p.float_literal(\"rulesize\") + \"}\"\r\n + p.simple_group(\"style\") # \u003c- change this line\r\n + p.required_group(\"num\")\r\n + p.required_group(\"den\")\r\n | Error(\"Expected \"\r\n r\"\\genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}\"))\r\n\r\n```\r\nto\r\n```\r\n p.genfrac \u003c\u003c= r\"\\genfrac\" - (\r\n \"{\" + Optional(p.ambi_delim | p.left_delim)(\"ldelim\") + \"}\"\r\n + \"{\" + Optional(p.ambi_delim | p.right_delim)(\"rdelim\") + \"}\"\r\n + \"{\" + p.float_literal(\"rulesize\") + \"}\"\r\n + \"{\" + p.int_literal(\"style\") + \"}\" # \u003c- changed this line\r\n + p.required_group(\"num\")\r\n + p.required_group(\"den\")\r\n | Error(\"Expected \"\r\n r\"\\genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}\"))\r\n```\r\nwith `p.int_literal` defined using a regex (just like how `p.float_literal` is defined), following which, the `_genfrac` function should obtain the enumeration variable from the value. We can hard-code the enumerations\r\n```\r\ndisplay_style = 0\r\ntext_style = 2\r\nscript_style = 4\r\nscript_script_style = 6\r\n```\r\nsince those are the values specified in _TeX: The Program_.\r\n\r\nI could try to create a PR for this, but my knowledge of language parsing is very limited.","author":{"url":"https://github.com/tfpf","@type":"Person","name":"tfpf"},"datePublished":"2022-05-08T03:23:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/23008/matplotlib/issues/23008"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6e0af937-3454-9cc0-d5d6-9fec868fdece |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF88:1694AE:37710C:4B2C48:6A51C045 |
| html-safe-nonce | 4b15355f134ff55f29a3427e8dd2ab22f9b8d6c7c02732e830450d112daee08c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjg4OjE2OTRBRTozNzcxMEM6NEIyQzQ4OjZBNTFDMDQ1IiwidmlzaXRvcl9pZCI6IjM0Mzk4MTkwODg0NDQxMTI5NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3e11d5f921fba3b0de29727e4da4619e6996bda47a399c1ba65cce852c00005d |
| hovercard-subject-tag | issue:1228781040 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/23008/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d57e13ccd9ac25e6bdc48410b6794781c7b8b36ae4425774425344188157ab4/matplotlib/matplotlib/issues/23008 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d57e13ccd9ac25e6bdc48410b6794781c7b8b36ae4425774425344188157ab4/matplotlib/matplotlib/issues/23008 |
| og:image:alt | Problem Is it possible to render fractions in display style using \genfrac? The style argument of the _genfrac function in _mathtext.py is received as an Hlist. As a result, fractions will never us... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tfpf |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width