How To Fix Manim LaTeX Error Converting To Dvi

When trying to animate math text with Manim using LaTeX, sometimes you can get a ValueEoror saying that it got an “error converting to DVI. See log output above or the log file”.

That’s what happened to me when I first installed Manim.

However, the issue for me was not a faulty Manim or LaTeX installation but my lack of understanding of LaTeX syntax.

Whenever you type math text with LaTeX in Manim add the letter r in front of your text and then inside of quotation marks surround your text with dollar signs.

You can test if this fix works with this code.

from manim import *

class dvi_error(Scene):
    def construct(self):
        t = Tex(r"$y = x^2$")
        t.scale(2)
        self.add(t)
        self.wait()

It should output this:

This fixed the issue for me. You don’t have to type the letter r or the dollar signs if your Tex() command contains only words and no math symbols.

The letter r tells Python to treat your text as an “r-string, ” essentially telling it to ignore backslashes (/) as escape symbols and treat them as normal text.

The dollar signs tell Python that this text is LaTeX math text, not regular text.

Let me help you learn Manim

If you want to skip the headache of trying to learn Manim from a bunch of scattered information, I put together a comprehensive 3-hour Manim course for complete beginners.

It will give you all the foundational skills you need to start creating stunning animations with code.

Enroll In Manim Course For Beginners