ZhangZhihui's Blog  

https://docs.manim.community/en/stable/guides/using_text.html

 

You might sometimes be working with a very complicated MathTex mobject that makes it difficult to work with its individual components. This is where the debugging function index_labels() is very useful.

The method shows the index of a mobject’s submobjects, allowing you to easily find the components of the mobject you would like to change.

 

class IndexLabelsMathTex(Scene):
    def construct(self):
        text = MathTex(r"\binom{2n}{n+2}", font_size=96)

        # index the first (and only) term of the MathTex mob
        self.add(index_labels(text[0]))

        text[0][1:3].set_color(YELLOW)
        text[0][3:6].set_color(RED)
        self.add(text)

 

1

 

posted on 2026-05-14 17:05  ZhangZhihuiAAA  阅读(14)  评论(0)    收藏  举报