All skills
adithya-s-k avatar

/manimce-best-practices

@6668663
by Adithya S Kadithya-s-k/manim_skill1.1k stars
94

Trigger when: (1) User mentions "manim" or "Manim Community" or "ManimCE", (2) Code contains `from manim import *`, (3) User runs `manim` CLI commands, (4) Working with Scene, MathTex, Create(), or ManimCE-specific classes. Best practices for Manim Community Edition - the community-maintained Python animation engine. Covers Scene structure, animations, LaTeX/MathTex, 3D with ThreeDScene, camera control, styling, and CLI usage. NOT for ManimGL/3b1b version (which uses `manimlib` imports and `manimgl` CLI).

Use this Skill: https://skilld.dev/gh/adithya-s-k/manim_skill/manimce-best-practices

This session only. Nothing lands on disk.

ruleslatex.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

LaTeX in Manim

Manim uses LaTeX to render mathematical expressions and formatted text.

MathTex vs Tex

  • MathTex: Automatically wraps content in math mode (align* environment)
  • Tex: Raw LaTeX - you control the mode
from manim import *

class LaTeXComparison(Scene):
    def construct(self):
        # MathTex - auto math mode
        math = MathTex(r"E = mc^2")

        # Tex - need explicit math delimiters
        tex = Tex(r"$E = mc^2$")

        # Both render the same
        VGroup(math, tex).arrange(DOWN)
        self.add(math, tex)

Basic MathTex

class MathTexExample(Scene):
    def construct(self):
        # Simple equation
        eq1 = MathTex(r"x^2 + y^2 = z^2")

        # Fractions
        eq2 = MathTex(r"\frac{a}{b}")

        # Square roots
        eq3 = MathTex(r"\sqrt{2}")

        # Greek letters
        eq4 = MathTex(r"\alpha + \beta = \gamma")

        # Integrals
        eq5 = MathTex(r"\int_0^\infty e^{-x} dx")

        # Summations
        eq6 = MathTex(r"\sum_{n=1}^{\infty} \frac{1}{n^2}")

        equations = VGroup(eq1, eq2, eq3, eq4, eq5, eq6).arrange_in_grid(2, 3)
        self.add(equations)

Coloring Parts of Equations

Using set_color_by_tex

class ColoredEquation(Scene):
    def construct(self):
        eq = MathTex(r"e^{i\pi} + 1 = 0")
        eq.set_color_by_tex("e", RED)
        eq.set_color_by_tex(r"\pi", BLUE)
        eq.set_color_by_tex("i", GREEN)
        self.add(eq)

Using substrings_to_isolate

For precise coloring, isolate substrings first:

class IsolatedColoring(Scene):
    def construct(self):
        eq = MathTex(
            r"e^x = x^0 + x^1 + \frac{1}{2}x^2 + \cdots",
            substrings_to_isolate=["x"]
        )
        eq.set_color_by_tex("x", YELLOW)
        self.add(eq)

Using index_labels for debugging

class DebugLabels(Scene):
    def construct(self):
        eq = MathTex(r"\frac{a}{b}")
        # Add index labels to see which index is which part
        self.add(index_labels(eq[0]))
        self.add(eq)

Direct indexing

eq = MathTex(r"a + b = c")
eq[0][0].set_color(RED)   # 'a'
eq[0][2].set_color(BLUE)  # 'b'
eq[0][4].set_color(GREEN) # 'c'

Multi-part Equations

Split equations into parts for individual control:

class MultiPartEquation(Scene):
    def construct(self):
        eq = MathTex("a", "^2", "+", "b", "^2", "=", "c", "^2")

        eq[0].set_color(RED)    # a
        eq[3].set_color(BLUE)   # b
        eq[6].set_color(GREEN)  # c

        self.play(Write(eq))

Text with Math (Tex)

class MixedContent(Scene):
    def construct(self):
        # Mix text and math
        tex = Tex(r"The area is $A = \pi r^2$")
        self.play(Write(tex))

Custom LaTeX Packages

class CustomPackage(Scene):
    def construct(self):
        template = TexTemplate()
        template.add_to_preamble(r"\usepackage{mathrsfs}")

        eq = Tex(
            r"$\mathscr{L}$",
            tex_template=template
        )
        self.add(eq)

Equation Alignment

class AlignedEquations(Scene):
    def construct(self):
        eqs = MathTex(
            r"a &= b + c \\",
            r"d &= e + f + g \\",
            r"h &= i"
        )
        self.add(eqs)

Common LaTeX Symbols

# Greek letters
MathTex(r"\alpha \beta \gamma \delta \epsilon")
MathTex(r"\Gamma \Delta \Theta \Lambda \Pi")

# Operators
MathTex(r"\times \div \pm \mp \cdot")

# Relations
MathTex(r"\leq \geq \neq \approx \equiv")

# Arrows
MathTex(r"\rightarrow \leftarrow \Rightarrow \Leftrightarrow")

# Sets
MathTex(r"\in \notin \subset \supset \cup \cap")

# Calculus
MathTex(r"\int \iint \oint \partial \nabla")

Font Size

# Using font_size parameter
eq = MathTex(r"E = mc^2", font_size=72)

# Using scale
eq = MathTex(r"E = mc^2").scale(2)

Best Practices

  1. Use raw strings - Always use r"..." for LaTeX
  2. Use MathTex for pure math - Simpler than adding $...$
  3. Use Tex for mixed content - When combining text and math
  4. Split for animation control - Separate parts you'll animate differently
  5. Use substrings_to_isolate - For reliable coloring of repeated elements

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill is a comprehensive educational resource for the Manim Community Edition library. It provides best practices, templates, and example scripts for creating mathematical animations and visualizations. No security risks or malicious patterns were identified.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    37 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 6668663. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
  • Python
  • manim
  • animation
  • latex
  • mathtex
  • 3d
  • rendering
  • scene
  • visualization

README badge

README badge for adithya-s-k/manim_skill/manimce-best-practices

Provides best practices and patterns for Manim Community Edition, the Python animation library for mathematical visualizations. Covers Scene structure, animations, LaTeX rendering, 3D graphics, positioning, and CLI usage with organized rule files, working examples, and templates.

Generated from the current SKILL.md.

Does this skill cover ManimGL or just Manim Community Edition?
Only Manim Community Edition (ManimCE). It does not apply to ManimGL/3b1b version, which uses `manimlib` imports and the `manimgl` CLI instead.
What topics are included in this skill?
Scene structure, mobjects, animations (creation, transformation, groups), text and LaTeX rendering, styling, positioning, 3D visualization, timing and updaters, camera control, CLI usage, and common geometric shapes.
Does this skill include working examples?
Yes. It includes five complete example files demonstrating basic animations, math visualization, updater patterns, graph plotting, and 3D visualization, plus three scene templates for 2D, camera-controlled, and 3D scenes.
What should I do if text rendering fails in my Manim scripts?
Check your manimpango installation requirements, as text rendering failures often stem from manimpango configuration issues. The skill also recommends running `manim checkhealth` to verify your overall installation.
How do I render a scene with different quality levels?
Use quality flags with the manim CLI: `-ql` for low quality (fast, development), `-qm` for medium, `-qh` for high, and `-qk` for 4K. For example: `manim -pqh scene.py MyScene`.

Generated from the current SKILL.md. These answers refresh after source changes.