gpt4 book ai didi

manim - 如何为分数的一部分着色,例如分母

转载 作者:行者123 更新时间:2023-12-02 00:12:57 30 4
gpt4 key购买 nike

txt11 = TexMobject(r"-7", color=BLACK)
txt12 = TexMobject(r"\frac{1}{7}", color=BLACK).next_to(txt11, RIGHT)

我想为 txt12 的分母着色,尝试将 txt12 拆分为:

txt12 = TexMobject(r"\frac{1}", r"{7}", color=BLACK).next_to(txt11, RIGHT)
txt12.set_color_by_tex("{7}", BLUE)

但不起作用,然后我创建了一个新的 txt13 与 txt12 重叠但是一个空分子:

txt13 = TexMobject(r"\frac{}{7}", color=BLUE).move_to(txt12.get_center())

也不行。

有没有可行的方法给方程式的一部分着色,比如分数?谢谢!

最佳答案

特别是分数,你可以使用

TexMobject(r"1", r"\over", r"7").set_color_by_tex("7", BLUE)

set_color_by_tex("7", BLUE) 将带有文本 7 的子对象设置为 BLUE

LaTeX {a\over b} 命令是 \frac{a}{b} 的简写。

Grant Sanderson 有时就是这样做的,例如,在 this recent video 中.

关于manim - 如何为分数的一部分着色,例如分母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58255616/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com