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

标签 manim

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/

相关文章:

ffmpeg - Manim 错误 : It's a sound problem that I haven't seen anywhere else

python - 导入 Manim 无法解决 Pylance

python - 尽管具有相同的 anchor / handle (manim),为什么会生成两条不同的贝塞尔曲线?

animation - 是否可以同时播放两个具有不同速率函数的动画?

python - 在 Python 3.7 环境中使用 manim 为 pycairo 构建轮子失败

python - 如何在manim中制作间距一致的虚线矩形?

python - Manim,无变换的 ReplacementTransform

python - Manim 展示 latex table

python - 如何设置manim渲染的图片/视频的大小?