Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program brakes on "full_tex_to_svg" method #2303

Open
ghost opened this issue Jan 15, 2025 · 4 comments
Open

program brakes on "full_tex_to_svg" method #2303

ghost opened this issue Jan 15, 2025 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 15, 2025

Describe the bug

When running ManimGL with MiKTeX on Windows, the LaTeX subprocess fails due to the -no-pdf option, which is not supported by certain versions of MiKTeX. This results in an error during LaTeX compilation, preventing the rendering of scenes that use LaTeX, such as Tex or MathTex.

from manimlib import *

class LatexTest(Scene):
    def construct(self):
        text = Tex("Hello, World!")
        self.add(text)
        self.wait()

Error:

with the above code i got the following error which is not related to the issue

in full_tex_to_svg
    raise LatexError(error_str or "LaTeX compilation failed")
manimlib.utils.tex_file_writing.LatexError: LaTeX compilation failed

Code Snippet:

In the following path: Lib\site-packages\manimlib\utils\tex_file_writing.py, inside the full_tex_to_svg method, it creates a subprocess and the -no-pdf option is passed as an argument:

#the manimgl source code inside the full_tex_to_svg method
    process = subprocess.run(
        [
            compiler,
           'no-pdf',  #where the issue comes from
            "-interaction=batchmode",
            "-halt-on-error",
            f"-output-directory={temp_dir}",
            tex_path
        ],
        capture_output=True,
        text=True
        )

How to solve the problem and why it's happening

Since ManimGL uses the latex command to create the SVG file, the output of the latex command is never going to be a PDF file, so the no-pdf option is not recognized. To have a PDF file as output, you should use the pdflatex command.

To overcome the issue, you need to remove the -no-pdf argument in the full_tex_to_svg method located inside the Lib\site-packages\manimlib\utils\tex_file_writing.py file, and the issue should be resolved.

Additional context

Environment:

Operating System: Windows 10
ManimGL Version: 1.7.2
MiKTeX Version: 24.4
Python Version: 3.x

@ghost ghost added the bug label Jan 15, 2025
@DragosDeac
Copy link

Faced this too. I did more or less the same workaround.
In manimlib/utils/tex_file_writing.py you can delete line 108: "*(['-no-pdf'] if compiler == "xelatex" else []),"

@Voice-less
Copy link

Still facing this error even after removing the -no-pdf argument. Could the problem be that I am only using the 24.1 version? available on the MikTeX site.

@TheMathematicFanatic
Copy link

TheMathematicFanatic commented Feb 4, 2025

I have also ran into the same problem and the same solution worked for me. Thanks!

I see that this conditional fix mentioned above was already added by 3b1b and will be in the next version. Cool

@ghost
Copy link
Author

ghost commented Mar 2, 2025

Still facing this error even after removing the -no-pdf argument. Could the problem be that I am only using the 24.1 version? available on the MikTeX site.

IDK it might be the reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants