问题
I'm attempting to use Manim (Youtuber 3Blue1Brown python's library) to animate. I have installed the necessary software including the newest versions of MikTex and python. I'm able to run the SquareToCircle animation, but whenever I try to run any animation involving text I get the following error:
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
There is no such .log file, however there is a .tex file in the exact same folder with the exact same name. The .tex file reads (opening in NotePad)
\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}
The issue seemed to be solved for some in the following post, where it is advised that I "change the commands = [...] in mobject/tex_mobject.py", yet there is no 'command' line anywhere in the tex_mobject.py file.
I copied the following functions (which apparently should already exist in the file, but didn't) and pasted them in 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
Yet I'm still getting the same error.
In the same post others advise to take a look at the referenced .log file, since this will let me know if any packages are missing. As I said, I have no such .log file, and the corresponding .tex file seems to make no mention of any missing packages.
I would really appreciate any help!
回答1:
That answer is no longer useful now because Manim has already solved that problem. So this may be due to two things: To give us a hint of what is wrong, go to the manimlib folder with the terminal and run the following:
latex tex_template.tex
We distinguish the two possible errors:
Recognized the latex command but the compilation could not be completed because you are missing libraries, to solve this you can install the missing packages indicated by the terminal.
That LaTeX is not recognized as a command, in this case surely the PATH variable is not set correctly, here is the solution.
来源:https://stackoverflow.com/questions/57779514/issues-with-manim-error-converting-to-dvi