Skip to content

get_parts_by_tex return wrong SVG element #2367

@Sourish07

Description

@Sourish07

Describe the bug

When I try to grab an element from a fraction with get_parts_by_tex, there's an off by one error

Code:

from manimlib import *

class Test(Scene):
    def construct(self):
        s = Tex(r"\frac{ 1 }{ 2 }")
        s.get_parts_by_tex(r"1").set_color(GREEN)
        self.add(s)

Wrong display or Error traceback:

Image

Additional context

I think this is because there's a mismatch between the order of the Tex commands vs the order of the svg elements.

  • tex_commands = ["\\frac", "1", "2"]
  • get_parts_by_tex(1) points to idx value 1 (because "1" is second element in tex_commands)
  • svg_map = ["1", "/", "2"] (idx value 1 returns the "/")

We need a way to tell manim that when it sees \frac, to make sure the items in the numerator come before the "/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions