← ClaudeAtlas

math-typographylisted

Mathematical rendering with MathTex, Tex, tex_to_color_map, custom equation classes, and formula animation patterns.
choxos/MathVizAgent · ★ 1 · Web & Frontend · score 63
Install: claude install-skill choxos/MathVizAgent
# Math Typography Mathematical typography patterns for Manim animations. ## MathTex vs Tex ### MathTex - Mathematical Expressions ```python # Single equation (entire string is math mode) eq = MathTex(r"E = mc^2") # Multiple parts for animation control eq = MathTex(r"E", r"=", r"m", r"c^2") # eq[0] = "E", eq[1] = "=", eq[2] = "m", eq[3] = "c^2" ``` ### Tex - Mixed Text and Math ```python # Text with inline math label = Tex(r"The equation $E = mc^2$ is famous") # Multiple parts label = Tex(r"The value is ", r"$x = 5$") label[1].set_color(BLUE) # Color the math part ``` ## Semantic Coloring ### tex_to_color_map ```python # Automatic coloring of matched substrings. Manim splits the string at each # key and compiles the pieces as separate LaTeX, so every key must sit at the # TOP LEVEL -- never inside a braced group such as \frac{...}{...} (that # orphans the braces and fails to compile). Color top-level tokens only: formula = MathTex( r"P(A \mid B) = P(B \mid A)\, P(A) / P(B)", tex_to_color_map={ r"A": BLUE, r"B": ORANGE, r"P": GREEN, }, ) ``` > ⚠️ **Coloring inside fractions:** a `tex_to_color_map` key that lands inside > `\frac{...}{...}` (or any `{...}`) breaks LaTeX compilation. To color variables > in a fraction, use the multi-argument form and color submobjects directly > (see **Manual Coloring** below), e.g. > `MathTex(r"P(A|B)", r"=", r"\frac{P(B|A)P(A)}{P(B)}").set_color_by_tex("frac", GREEN)`. ### Manual Coloring ```pyt