我正在尝试使用 Manim(Youtuber 3Blue1Brown python 的库)来制作动画。我已经安装了必要的软件,包括最新版本的 MikTex 和 python。我可以运行 SquareToCircle 动画,但是每当我尝试运行任何涉及文本的动画时,都会出现以下错误:
Exception: Latex error converting to dvi. See log output above or the log file: C:\Animation Programs\Manim\manim_3_feb\manimlib\files\Tex\47f78a457bde38f5.log
没有这样的 .log 文件,但是在完全相同的文件夹中有一个具有完全相同名称的 .tex 文件。.tex 文件读取(在记事本中打开)
\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{textcomp}
\usepackage{microtype}
\DisableLigatures{encoding = *, family = * }
%\usepackage[UTF8]{ctex}
\linespread{1}
\begin{document}
\centering This is some \LaTeX
\end{document}
这个问题似乎在下面的帖子中得到了解决,建议我“在 mobject/tex_mobject.py 中更改命令 = [...]”,但 tex_mobject 中的任何地方都没有“命令行”。 .py 文件。
我复制了以下函数(显然应该已经存在于文件中,但没有)并将它们粘贴到 tex_mobject.py
def tex_to_dvi(tex_file):
result = tex_file.replace(".tex", ".dvi")
if not os.path.exists(result):
commands = [
"latex",
"-interaction=batchmode",
"-halt-on-error",
"-output-directory=" + TEX_DIR,
tex_file,
]
exit_code = os.system(" ".join(commands))
if exit_code != 0:
latex_output = ''
log_file = tex_file.replace(".tex", ".log")
if os.path.exists(log_file):
with open(log_file, 'r') as f:
latex_output = f.read()
if latex_output:
sys.stderr.write(latex_output)
raise Exception(
"Latex error converting to dvi. "
"See log output above or the log file: %s" % log_file)
return result
.
def dvi_to_svg(dvi_file, regen_if_exists = False):
"""
Converts a dvi, which potentially has multiple slides, into a
directory full of enumerated pngs corresponding with these slides.
Returns a list of PIL Image objects for these images sorted as they
where in the dvi
"""
result = dvi_file.replace(".dvi", ".svg")
if not os.path.exists(result):
commands = [
"dvisvgm",
dvi_file,
"-n",
"-v",
"0",
"-o",
result,
]
os.system(" ".join(commands))
return result
但是我仍然遇到同样的错误。
在同一篇文章中,其他人建议查看引用的 .log 文件,因为这会让我知道是否缺少任何包。正如我所说,我没有这样的 .log 文件,并且相应的 .tex 文件似乎没有提到任何丢失的包。
我真的很感激任何帮助!