Bug - Part 1
Relates to #2440. A few days ago i stumbled upon a strange bug when compiling a latex file. The error ocurrs in the module utils/tex_file_writing.py in the function full_tex_to_svg(), it pops out from the constructor of Tex. Specifically it is the line 108
process = subprocess.run(
[
compiler,
*(['-no-pdf'] if compiler == "xelatex" else []),
"-interaction=batchmode",
"-halt-on-error",
f"-output-directory={temp_dir}",
tex_path
],
capture_output=True,
text=True
)
When executing this process it fails miserably despite previously being able to write the complete latex file:
tex_path.write_text(full_tex) # Writes the file properly
Meaning that both tex_path and temp_dir (which relates to the declaration tex_path = temp_dir / "working.tex") are correct paths. I debugged it a little for a while but it didn't make much sense and it also didn't help that the error message was not explicit at all.
Solution
A few days later I now come back to the issue and the problem was simply that python or latex was getting confused with the directories. Replacing the command with
process = subprocess.run(
[
compiler,
*(['-no-pdf'] if compiler == "xelatex" else []),
"-interaction=batchmode",
"-halt-on-error",
"working.tex"
],
capture_output=True,
text=True,
cwd=temp_dir
)
Fixed it for me.
python version: 3.13.12
manimgl version: 1.7.2
Latex:
pdfTeX 3.141592653-2.6-1.40.29 (TeX Live 2026)
Bug - Part 2
After having solved the latex compilation issue (so the only change I made to my local copy of manim is the above substitution), now I run into the issue of an svg not creating properly. I haven't looked exhaustively into the issue but upon a quick inspection while debugging I noticed the first time the function latex_to_svg() runs it outputs a non-empty svg xml. The first time it runs is inside the parent constructor of Tex() in line 69:
super().__init__(
tex_string,
use_labelled_svg=use_labelled_svg,
isolate=isolate,
**kwargs
)
ends up calling
def get_svg_string_by_content(self, content: str) -> str:
return latex_to_svg(content, self.template, self.additional_preamble, short_tex=self.tex_string)
However right after when running get_tex_mob_scale_factor() the call latex_to_svg("0", show_message_during_execution=False) gives an empty svg. This is:
super().__init__(
tex_string,
use_labelled_svg=use_labelled_svg,
isolate=isolate,
**kwargs
)
self.set_color_by_tex_to_color_map(self.tex_to_color_map)
self.scale(get_tex_mob_scale_factor() * font_size)
that last line calls:
@lru_cache(maxsize=1)
def get_tex_mob_scale_factor() -> float:
# Render a reference "0" and calibrate so that font_size_for_unit_height
# gives a height of 1 manim unit. Compensates for platform dvisvgm differences.
font_size_for_unit_height = manim_config.tex.font_size_for_unit_height
svg_string = latex_to_svg("0", show_message_during_execution=False)
svg_height = get_svg_content_height(svg_string)
return 1.0 / (font_size_for_unit_height * svg_height)
and svg_string ends up being an xml containing an empty svg.
Another weird thing is the following: when latex_to_svg("0", show_message_during_execution=False) gets called it leads to the second time of full_tex_to_svg() being called. The first time full_tex_to_svg() is called is to create my latex text and this second time it should create a tex document with a "0". However, the execution seems to completely skip the second time full_tex_to_svg() is called because the debugger does not stop at the breakpoints the second time but the first time it does.
I'm fairly new to this so forgive me if I'm making some sort of mistake or misunderstanding but I feel like it is a strange error.
python version: 3.13.12
manimgl version: 1.7.2
Latex:
pdfTeX 3.141592653-2.6-1.40.29 (TeX Live 2026)
dvisvgm version: 3.6
Note: This all happens when just calling the Tex constructor.
PS: Windows 11 OS
Bug - Part 1
Relates to #2440. A few days ago i stumbled upon a strange bug when compiling a latex file. The error ocurrs in the module
utils/tex_file_writing.pyin the functionfull_tex_to_svg(), it pops out from the constructor ofTex. Specifically it is the line 108When executing this process it fails miserably despite previously being able to write the complete latex file:
Meaning that both
tex_pathandtemp_dir(which relates to the declarationtex_path = temp_dir / "working.tex") are correct paths. I debugged it a little for a while but it didn't make much sense and it also didn't help that the error message was not explicit at all.Solution
A few days later I now come back to the issue and the problem was simply that python or latex was getting confused with the directories. Replacing the command with
Fixed it for me.
python version: 3.13.12
manimgl version: 1.7.2
Latex:
pdfTeX 3.141592653-2.6-1.40.29 (TeX Live 2026)
Bug - Part 2
After having solved the latex compilation issue (so the only change I made to my local copy of manim is the above substitution), now I run into the issue of an svg not creating properly. I haven't looked exhaustively into the issue but upon a quick inspection while debugging I noticed the first time the function
latex_to_svg()runs it outputs a non-empty svg xml. The first time it runs is inside the parent constructor ofTex()in line 69:ends up calling
However right after when running
get_tex_mob_scale_factor()the calllatex_to_svg("0", show_message_during_execution=False)gives an empty svg. This is:that last line calls:
and
svg_stringends up being an xml containing an empty svg.Another weird thing is the following: when
latex_to_svg("0", show_message_during_execution=False)gets called it leads to the second time offull_tex_to_svg()being called. The first timefull_tex_to_svg()is called is to create my latex text and this second time it should create a tex document with a "0". However, the execution seems to completely skip the second timefull_tex_to_svg()is called because the debugger does not stop at the breakpoints the second time but the first time it does.I'm fairly new to this so forgive me if I'm making some sort of mistake or misunderstanding but I feel like it is a strange error.
python version: 3.13.12
manimgl version: 1.7.2
Latex:
pdfTeX 3.141592653-2.6-1.40.29 (TeX Live 2026)
dvisvgm version: 3.6
Note: This all happens when just calling the
Texconstructor.PS: Windows 11 OS