0

我正在尝试在 manim 中使用 tikz。我使用的 manim 版本是 3feb2019。我已将必要的包添加到 tex_template 文件中。但它会抛出一个错误:

IndexError:列表索引超出范围

我不知道要解决这个错误。有人可以帮我吗?

在此处输入图像描述

编辑:这是我尝试渲染的代码。

# These are in the example_scenes.py file
class TikzMobject(TextMobject):
    CONFIG = {
        "stroke_width":3,
        "fill_opacity":0,
        "stroke_opacity":1
        }

class TikzExample3(Scene):
    def construct(self):
    example_tex = TikzMobject(
        r"""
\begin{tikzpicture}
\draw (-1,0)--(1,0);
\end{tikzpicture}
    """
    )
    self.play(Write(example_tex))
    self.wait()

我已经尝试了最新版本的 manim 和 3feb 版本,但它只是抛出了同样的错误:list index out of range。我可以在输出 tex 文件中编译 tikz 代码。我使用的平台是Windows。

4

1 回答 1

0

我已经在 2 个 Windows 上尝试过了,它运行良好,可能是您没有正确配置 tex_template.tex,或者您使用的是旧版本的 Python(至少需要 Python 3.7.3),这里是证明它对我有用。

在此处输入图像描述

tex_template.tex 配置:

\documentclass[preview]{standalone}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\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{tikz} %<------------------------- TIKZ PACKAGE
\DisableLigatures{encoding = *, family = * }
%\usepackage[UTF8]{ctex}
\linespread{1}

\begin{document}

YourTextHere

\end{document}

输出

在此处输入图像描述

于 2020-02-25T02:54:04.830 回答