3b1b / manim

Animation engine for explanatory math videos
MIT License
70.84k stars 6.23k forks source link

Can't Write Tex After Fix "Xelatex error converting to xdv" #2247

Open TheRealYifan opened 1 hour ago

TheRealYifan commented 1 hour ago

I fixed error "Xelatex error converting to xdv" and it runs the animation. But it didn't write the TexMobject witch cause the error

Code and Error

Code:

def construct(self):
        ax = Axes(
            x_range = [-10,10,PI],
            y_range = [-1.5,1.5,1],
            axis_config={"include_numbers": True, "custom_lables": True},
        )

        tex_sin = TexMobject("sin(x)",color = BLUE)
        tex_cos = TexMobject("cos(x",color = RED)
        tex_bracket = TexMobject(")",color = RED)
        tex_pi_over_two = TexMobject("\\pi \\over 2")

        updatefunc = UPDATE_FUNCTION(tex_cos,RIGHT/2)

        g = VGroup(tex_cos)

        g.add(tex_bracket.add_updater(updatefunc))

        sin = FunctionGraph(lambda x: np.sin(x),color = BLUE)
        sp_cos = FunctionGraph(lambda x: np.cos(x-PI/2),color = RED)
        cos = FunctionGraph(lambda x: np.cos(x),color = RED)

        tex_sin.move_to(sin.get_end()+UL)
        g.move_to(cos.get_end()+DL)
        TEX_EQUEL.next_to(tex_bracket)
        TEX_MINUIES.next_to(tex_cos,RIGHT)
        tex_pi_over_two.next_to(TEX_MINUIES,RIGHT)

        self.play(ShowCreation(ax),run_time = 2)
        self.play(ShowCreation(sin),run_time= 3.5)
        self.play(ShowCreation(cos),run_time= 3.5)
        self.play(Write(tex_sin))
        self.play(Write(g))
        self.play(g.to_corner,UL)
        self.play(tex_sin.next_to,tex_cos)
        self.play(tex_sin.shift,RIGHT)
        g.remove(tex_bracket)
        tex_bracket.remove_updater(updatefunc)
        self.play(tex_bracket.shift,RIGHT*3/4)
        self.play(
            Write(TEX_MINUIES),
            Write(tex_pi_over_two)
        )
        self.play(
            cos.shift,[PI/2,0,0],
            ShowCreation(sp_cos),
        )

Environment

OS System: Windows 11 manim version: cario-backend python version:3.12.7

I change ctex_template.tex from

Code:

\documentclass[preview]{standalone}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage[UTF8]{ctex}
\DisableLigatures{encoding = *, family = * }
\linespread{1}

\begin{document}

YourTextHere

\end{document}

to

Code:

\documentclass[preview]{standalone}
\usepackage[UTF8]{ctex}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
%\DisableLigatures{encoding = *, family = * }
\linespread{1}

\begin{document}

YourTextHere

\end{document}
TheRealYifan commented 1 hour ago

change ctex_template.tex is to fix "Xelatex error converting to xdv"