Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ENH]: Use\genfrac in display style? #23008

Closed
@tfpf

Description

@tfpf

Problem

Is it possible to render fractions in display style using\genfrac?

Thestyle argument of the_genfrac function in_mathtext.py is received as anHlist. As a result, fractions will never use display style (sincestyle andself._MathStyle.DISPLAYSTYLE will always compare unequal).

import matplotlib.pyplot as pltfig = plt.figure()fig.text(.2, .5, r'$\genfrac{}{}{0}{0}{1}{2}$')fig.text(.3, .5, r'$\genfrac{}{}{1}{1}{1}{2}$')plt.show()

Proposed solution

Change

        p.genfrac <<= r"\genfrac" - (            "{" + Optional(p.ambi_delim | p.left_delim)("ldelim") + "}"            + "{" + Optional(p.ambi_delim | p.right_delim)("rdelim") + "}"            + "{" + p.float_literal("rulesize") + "}"            + p.simple_group("style")                    # <- change this line            + p.required_group("num")            + p.required_group("den")            | Error("Expected "                    r"\genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}"))

to

        p.genfrac <<= r"\genfrac" - (            "{" + Optional(p.ambi_delim | p.left_delim)("ldelim") + "}"            + "{" + Optional(p.ambi_delim | p.right_delim)("rdelim") + "}"            + "{" + p.float_literal("rulesize") + "}"            + "{" + p.int_literal("style") + "}"                    # <- changed this line            + p.required_group("num")            + p.required_group("den")            | Error("Expected "                    r"\genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}"))

withp.int_literal defined using a regex (just like howp.float_literal is defined), following which, the_genfrac function should obtain the enumeration variable from the value. We can hard-code the enumerations

display_style = 0text_style = 2script_style = 4script_script_style = 6

since those are the values specified inTeX: The Program.

I could try to create a PR for this, but my knowledge of language parsing is very limited.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp