How does one add set symbols in manim?

Question:

I’m trying to write the set of natural and real numbers in manim using MathTex, but I haven’t found a way that works. Every time I try to use shortcuts I’ve searched up about LaTeX, such as N, natnums, mathbb{N}, and such don’t work, returning the error message:

TypeError: ‘numpy.ndarray’ object is not callable

Does anyone have a solution to this?

Here is the troublesome part in the current version of my code:

NtoR=MathTex(r"natnums","longrightarrow",r"reals")
self.play(Write(NtoR,RIGHT*2))

As previously mentioned, I get the following error message:

TypeError: ‘numpy.ndarray’ object is not callable.

Asked By: Tejas Avyaan

||

Answers:

Try adding the amsfonts package to your manim code:

class WriteNaturalNumber(Scene):
    def construct(self):
        myTemplate = TexTemplate()
        myTemplate.add_to_preamble(r"usepackage{amsfonts}") # adds package to construct
        # Write the symbol
        tex = Tex(
            r"$mathbb{N}$",
            tex_template=myTemplate,
            font_size=144,
        )
        self.add(tex)

Result:

Natural number symbol

Answered By: Jason Grace
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.