manim
manim copied to clipboard
latex error converting to dvi.
Describe the error
MathTex or Tex,Errors are reported when Chinese is included in latex
Code and Error
Code: def handle_parts(parts): handled_parts = [] latex_command = None for part in parts: if part and re.match(r"\[a-zA-Z]+", part): latex_command = part elif part and latex_command: handled_parts.append(latex_command + part) latex_command = None elif part: handled_parts.append(part) return handled_parts
pattern1 = r"(\[a-zA-Z]+)" pattern2 = r"($.?$)|($$.?$$)|(_{[^}]})|(\[()[]]+)|\[a-zA-Z]+{[^}]}" parts = re.split(pattern1 + "|" + pattern2, item["banshu"]) subtitles_parts_group = VGroup()
handled_parts = handle_parts(parts) for part in handled_parts: try: if re.match(r"\[a-zA-Z]+{[^}]}", part): subtitles_part = MathTex("$" + part + "$", font_size=30).set_color(BLACK) elif re.match(r"($.?$)|($$.?$$)|(_{[^}]})|(\[()[]]+)", part): subtitles_part = Tex(part, font_size=30).set_color(BLACK) else: subtitles_part = Text(part, font_size=20).set_color(BLACK) except Exception as e: print(f"Error in creating mobject for '{part}': {e}") continue
subtitles_parts_group.add(subtitles_part)
Error:
[01/22/24 20:45:32] ERROR LaTeX compilation error: tex_file_writing.py:312
LaTeX Error: Command
\end{center} invalid in
math mode.
ERROR Context of error: tex_file_writing.py:346
\begin{center}
-> \(
\end{center}
\end{document}
Error in creating mobject for '(': latex error converting to dvi. See log output above or the log file: voice/Tex/b6cba4c2ae4dd87e.log ERROR LaTeX compilation error: tex_file_writing.py:312 Missing } inserted.
ERROR Context of error: tex_file_writing.py:346
\begin{align*}
-> $\text{米}$
\end{align*}
\end{document}
Error in creating mobject for '\text{米}': latex error converting to dvi. See log output above or the log file: voice/Tex/60fd6be91e5e1d16.log
[01/22/24 20:45:33] ERROR LaTeX compilation error: tex_file_writing.py:312
LaTeX Error: Bad math
environment delimiter.
ERROR Context of error: tex_file_writing.py:346
\begin{document}
-> \begin{center}
\)
\end{center}
Error in creating mobject for ')': latex error converting to dvi. See log output above or the log file: voice/Tex/f9d96ae144d082cd.log
ERROR LaTeX compilation error: tex_file_writing.py:312
LaTeX Error: Command
\end{center} invalid in
math mode.
ERROR Context of error: tex_file_writing.py:346
\begin{center}
-> \(
\end{center}
\end{document}
Error in creating mobject for '(': latex error converting to dvi. See log output above or the log file: voice/Tex/b6cba4c2ae4dd87e.log [01/22/24 20:45:34] ERROR LaTeX compilation error: tex_file_writing.py:312 Interruption.
ERROR Context of error: tex_file_writing.py:346
\begin{document}
->
\begin{align*}
$\frac{米}{秒}$
\end{align*}
Error in creating mobject for '\frac{米}{秒}': latex error converting to dvi. See log output above or the log file: voice/Tex/a1b6128d0ce79376.log
[01/22/24 20:45:35] ERROR LaTeX compilation error: tex_file_writing.py:312
LaTeX Error: Bad math
environment delimiter.
ERROR Context of error: tex_file_writing.py:346
\begin{document}
-> \begin{center}
\)
\end{center}
Error in creating mobject for ')': latex error converting to dvi. See log output above or the log file: voice/Tex/f9d96ae144d082cd.log
Environment
OS System: macos 14.2.1 manim version: 0.18.0 python version:3.10