ValueError: xelatex error converting to xdv, cannot display Chinese character
Description of bug / unexpected behavior
I'm learning https://docs.manim.community/en/stable/guides/using_text.html#latex-maths-fonts-the-template-library, the second sample, and make it simpler with only Chinese character: 你好.
from manim import *
class LaTeXTemplateLibrary(Scene):
def construct(self):
tex = Tex(
r"{你好}",
tex_template=TexTemplateLibrary.ctex,
font_size = 96
# font = "simhei"
)
self.add(tex)
but get this error:
manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py demo
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python> cd .\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10
PS D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10> manim -pql .\TemplateLib.py LaTeXTemplateLibrary
Manim Community v0.18.1
Sorry, but miktex-makemf did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log
Couldn't open `OT:script=hani;language=dfl.cfg'
hbf2gf (CJK ver. 4.8.4)
Sorry, but miktex-maketfm did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log
Sorry, but miktex-makemf did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log
Couldn't open `OT:script=hani;language=dfl.cfg'
hbf2gf (CJK ver. 4.8.4)
Sorry, but miktex-maketfm did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log
Sorry, but miktex-makemf did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log
Couldn't open `OT:script=hani;language=dfl.cfg'
hbf2gf (CJK ver. 4.8.4)
Sorry, but miktex-maketfm did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log
Sorry, but miktex-makemf did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log
Couldn't open `OT:script=hani;language=dfl.cfg'
hbf2gf (CJK ver. 4.8.4)
Sorry, but miktex-maketfm did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log
Sorry, but miktex-makemf did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log
Couldn't open `OT:script=hani;language=dfl.cfg'
hbf2gf (CJK ver. 4.8.4)
Sorry, but miktex-maketfm did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\v0cn037\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log
[12/10/24 10:19:01] ERROR LaTeX compilation error: Package fontspec Error: tex_file_writing.py:314
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\tools\Manim\Lib\site-packages\manim\cli\render\commands.py:120 in render │
│ │
│ 117 │ │ │ try: │
│ 118 │ │ │ │ with tempconfig({}): │
│ 119 │ │ │ │ │ scene = SceneClass() │
│ ❱ 120 │ │ │ │ │ scene.render() │
│ 121 │ │ │ except Exception: │
│ 122 │ │ │ │ error_console.print_exception() │
│ 123 │ │ │ │ sys.exit(1) │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\scene\scene.py:229 in render │
│ │
│ 226 │ │ """ │
│ 227 │ │ self.setup() │
│ 228 │ │ try: │
│ ❱ 229 │ │ │ self.construct() │
│ 230 │ │ except EndSceneEarlyException: │
│ 231 │ │ │ pass │
│ 232 │ │ except RerunSceneException as e: │
│ │
│ D:\GitHub\python\Manim\2_Thematic\2.3_Text-Formula\2_text_with_LaTeX\2.3_2_10\TemplateLib.py:5 │
│ in construct │
│ │
│ 2 │
│ 3 class LaTeXTemplateLibrary(Scene): │
│ 4 │ def construct(self): │
│ ❱ 5 │ │ tex = Tex( │
│ 6 │ │ │ r"{你好}", │
│ 7 │ │ │ tex_template=TexTemplateLibrary.ctex, │
│ 8 │ │ │ font_size = 96 │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:443 in __init__ │
│ │
│ 440 │ def __init__( │
│ 441 │ │ self, *tex_strings, arg_separator="", tex_environment="center", **kwargs │
│ 442 │ ): │
│ ❱ 443 │ │ super().__init__( │
│ 444 │ │ │ *tex_strings, │
│ 445 │ │ │ arg_separator=arg_separator, │
│ 446 │ │ │ tex_environment=tex_environment, │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:293 in __init__ │
│ │
│ 290 │ │ │ │ │ │ """, │
│ 291 │ │ │ │ │ ), │
│ 292 │ │ │ │ ) │
│ ❱ 293 │ │ │ raise compilation_error │
│ 294 │ │ self.set_color_by_tex_to_color_map(self.tex_to_color_map) │
│ 295 │ │ │
│ 296 │ │ if self.organize_left_to_right: │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:272 in __init__ │
│ │
│ 269 │ │ self.brace_notation_split_occurred = False │
│ 270 │ │ self.tex_strings = self._break_up_tex_strings(tex_strings) │
│ 271 │ │ try: │
│ ❱ 272 │ │ │ super().__init__( │
│ 273 │ │ │ │ self.arg_separator.join(self.tex_strings), │
│ 274 │ │ │ │ tex_environment=self.tex_environment, │
│ 275 │ │ │ │ tex_template=self.tex_template, │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:81 in __init__ │
│ │
│ 78 │ │ │
│ 79 │ │ assert isinstance(tex_string, str) │
│ 80 │ │ self.tex_string = tex_string │
│ ❱ 81 │ │ file_name = tex_to_svg_file( │
│ 82 │ │ │ self._get_modified_expression(tex_string), │
│ 83 │ │ │ environment=self.tex_environment, │
│ 84 │ │ │ tex_template=self.tex_template, │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\utils\tex_file_writing.py:63 in tex_to_svg_file │
│ │
│ 60 │ if svg_file.exists(): │
│ 61 │ │ return svg_file │
│ 62 │ │
│ ❱ 63 │ dvi_file = compile_tex( │
│ 64 │ │ tex_file, │
│ 65 │ │ tex_template.tex_compiler, │
│ 66 │ │ tex_template.output_format, │
│ │
│ C:\tools\Manim\Lib\site-packages\manim\utils\tex_file_writing.py:213 in compile_tex │
│ │
│ 210 │ │ if exit_code != 0: │
│ 211 │ │ │ log_file = tex_file.with_suffix(".log") │
│ 212 │ │ │ print_all_tex_errors(log_file, tex_compiler, tex_file) │
│ ❱ 213 │ │ │ raise ValueError( │
│ 214 │ │ │ │ f"{tex_compiler} error converting to" │
│ 215 │ │ │ │ f" {output_format[1:]}. See log output above or" │
│ 216 │ │ │ │ f" the log file: {log_file}", │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: xelatex error converting to xdv. See log output above or the log file:
media\Tex\feef9d8b4eb4a6d8.log
Program 'manim.exe' failed to run: Index was outside the bounds of the array.At line:1 char:1
+ manim -pql .\TemplateLib.py LaTeXTemplateLibrary
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ manim -pql .\TemplateLib.py LaTeXTemplateLibrary
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
Expected behavior
Should have the Chinese word displayed
How to reproduce the issue
See the code already pasted
Additional media files
None
Logs
None
System specifications
System Details
- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Windows 11
- RAM: 64GB
- Python version (
python/py/python3 --version): 3.13 - Installed modules (provide output from
pip list):
Package Version
----------------- -----------
click 8.1.7
cloup 3.0.5
colorama 0.4.6
decorator 5.1.1
glcontext 3.0.0
isosurfaces 0.1.2
manim 0.18.1
ManimPango 0.6.0
mapbox_earcut 1.0.2
markdown-it-py 3.0.0
mdurl 0.1.2
moderngl 5.12.0
moderngl-window 3.0.3
networkx 3.4.2
numpy 2.2.0
pillow 11.0.0
pip 24.3.1
pycairo 1.27.0
pydub 0.25.1
pyglet 2.0.20
PyGLM 2.7.3
Pygments 2.18.0
rich 13.9.4
scipy 1.14.1
screeninfo 0.8.1
setuptools 75.6.0
skia-pathops 0.8.0.post2
srt 3.5.3
svgelements 1.9.6
tqdm 4.67.1
typing_extensions 4.12.2
watchdog 6.0.0
wheel 0.45.1
Thanks, Xiaoqi
ValueError: xelatex error converting to xdv. See log output above or the log file: media\Tex\feef9d8b4eb4a6d8.log
this log-file might hold the crucial information needed to understand what the cause of the problem is. But I suggest you come over to Discord where we have discussed similar problems before and there is also a Chines-language group https://docs.manim.community/en/stable/faq/general.html?highlight=discord#where-can-i-find-more-resources-for-learning-manim
I almost assume that you are lacking a certain font on your system which would be necessary to render the code in LaTeX. On my system the example works without a problem:
Thanks and I'll follow up as you mentioned