MathTex¶
完整名称: manim.mobject.text.tex_mobject.MathTex
- class MathTex(*tex_strings, arg_separator=' ', substrings_to_isolate=None, tex_to_color_map=None, tex_environment='align*', **kwargs)[source]¶
-
在数学模式下使用LaTeX编译的字符串。
示例
示例: 公式 ¶
from manim import * class Formula(Scene): def construct(self): t = MathTex(r"\int_a^b f'(x) dx = f(b)- f(a)") self.add(t)
class Formula(Scene): def construct(self): t = MathTex(r"\int_a^b f'(x) dx = f(b)- f(a)") self.add(t)
测试
检查
MathTex
的创建是否正常工作>>> MathTex('a^2 + b^2 = c^2') MathTex('a^2 + b^2 = c^2')
检查双大括号组分割是否正确
>>> t1 = MathTex('{{ a }} + {{ b }} = {{ c }}') >>> len(t1.submobjects) 5 >>> t2 = MathTex(r"\frac{1}{a+b\sqrt{2}}") >>> len(t2.submobjects) 1
方法
按tex获取部分
按tex获取多个部分
部分的索引
按tex获取部分的索引
按tex设置颜色
按tex到颜色映射设置颜色
设置指定tex的不透明度。
按字母排序
属性
animate (动画)
用于动画化
self
的任何方法的应用。animation_overrides (动画覆盖)
颜色
depth (深度)
mobject 的深度。
fill_color (填充颜色)
如果存在多种颜色(用于渐变),则返回第一种颜色
字体大小
tex mobject 的字体大小。
哈希种子
代表生成的mobject点结果的唯一哈希值。
height (高度)
mobject 的高度。
n_points_per_curve (每条曲线的点数)
sheen_factor (光泽因子)
stroke_color (描边颜色)
width (宽度)
mobject 的宽度。
- 参数:
arg_separator (str)
substrings_to_isolate (Iterable[str] | None)
tex_to_color_map (dict[str, ManimColor])
tex_environment (str)
- _original__init__(*tex_strings, arg_separator=' ', substrings_to_isolate=None, tex_to_color_map=None, tex_environment='align*', **kwargs)¶
初始化自身。有关准确签名,请参阅 help(type(self))。
- 参数:
arg_separator (str)
substrings_to_isolate (Iterable[str] | None)
tex_to_color_map (dict[str, ManimColor])
tex_environment (str)