MathTypst¶
Qualified name: manim.mobject.text.typst\_mobject.MathTypst
- class MathTypst(math_expression, **kwargs)[source]¶
Bases:
TypstConvenience wrapper: wraps the input in Typst math delimiters.
The expression is rendered as a display-level equation (
$ ... $with surrounding spaces).Supports the
{{ ... }}double-brace notation for grouping sub-expressions. Each{{ content }}is wrapped in a labeledmanimgrpcall so that the resulting SVG contains identifiable groups accessible viaselect().Groups can optionally be given explicit labels:
{{ content : label }}. Without a label, groups are auto-numbered (_grp-0,_grp-1, …).- Parameters:
math_expression (str) – Typst math-mode content without the
$ ... $delimiters. May contain{{ ... }}groups.**kwargs (Any) – Forwarded to
Typst.
Examples
Example: DisplayMath ¶
from manim import * class DisplayMath(Scene): def construct(self): eq = MathTypst(r"sum_(k=0)^n k = (n(n+1)) / 2") self.add(eq)
class DisplayMath(Scene): def construct(self): eq = MathTypst(r"sum_(k=0)^n k = (n(n+1)) / 2") self.add(eq)References:
MathTypstExample: GroupedMath ¶
from manim import * class GroupedMath(Scene): def construct(self): eq = MathTypst("{{ a^2 + b^2 : lhs }} = {{ c^2 }}") eq.select("lhs").set_color(RED) # "a^2 + b^2" eq.select(0).set_color(BLUE) # "c^2" (auto-numbered: "grp-0") self.add(eq)
class GroupedMath(Scene): def construct(self): eq = MathTypst("{{ a^2 + b^2 : lhs }} = {{ c^2 }}") eq.select("lhs").set_color(RED) # "a^2 + b^2" eq.select(0).set_color(BLUE) # "c^2" (auto-numbered: "grp-0") self.add(eq)Methods
Attributes
alwaysCall a method on a mobject every frame.
animateUsed to animate the application of any method of
self.animation_overridesbaseline_framesCurrent Typst baseline frames for all tracked leaf submobjects.
colordepthThe depth of the mobject.
fill_colorIf there are multiple colors (for gradient) this returns the first one
font_sizeThe font size of the Typst mobject.
hash_seedInclude baseline tracking in the SVG cache key.
heightThe height of the mobject.
n_points_per_curvesheen_factorstroke_colorwidthThe width of the mobject.
targetoriginal_id- _original__init__(math_expression, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
math_expression (str)
kwargs (Any)