Skip to content

Commit

Permalink
Fix bug with xelatex rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Dec 11, 2024
1 parent 1794e4d commit 8246d0d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions manimlib/utils/tex_file_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ def latex_to_svg(
compiler = tex_config["compiler"]

if compiler == "latex":
program = "latex"
dvi_ext = ".dvi"
elif compiler == "xelatex":
program = "xelatex -no-pdf"
dvi_ext = ".xdv"
else:
raise NotImplementedError(f"Compiler '{compiler}' is not implemented")
Expand All @@ -111,18 +109,18 @@ def latex_to_svg(
dvi_path = base_path + dvi_ext

# Write tex file
with open(tex_path, "w", encoding="utf-8") as tex_file:
tex_file.write(full_tex)
Path(tex_path).write_text(full_tex)

# Run latex compiler
process = subprocess.run(
[
program.split()[0], # Split for xelatex case
compiler,
"-no-pdf",
"-interaction=batchmode",
"-halt-on-error",
"-output-directory=" + temp_dir,
f"-output-directory={temp_dir}",
tex_path
] + (["--no-pdf"] if compiler == "xelatex" else []),
],
capture_output=True,
text=True
)
Expand Down

3 comments on commit 8246d0d

@traavnik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think this broke latex rendering by indiscriminately invoking -no-pdf

@3b1b
Copy link
Owner Author

@3b1b 3b1b commented on 8246d0d Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My expectation is that in all cases one only needs the .dvi or .xdv file here, which is what's then converted to .svg, and you never need the pdf. When I run this on my system, both for latex and xelatex, it seems to work. Can you describe more about the issue you're seeing?

@traavnik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was setting up manimgl on Windows today for the first time and couldn't get the example scene running. It was throwing manimlib.utils.tex_file_writing.LatexError: LaTeX compilation failed which was a result of MiKTeX-pdfTeX 4.19 (called by latex env var) error. I could see the following in MiKTeX log:

FATAL latex.core - The command line options could not be processed.
FATAL latex.core - Data: optionError="unknown option"

The "unknown option" turned out to be -no-pdf. xelatex (MiKTeX-XeTeX 4.11), on the other hand, doesn't mind this option.
MiKTeX-pdfTeX only produces .aux, .dvi, and .log for me when ran without -no-pdf.

p.s. This is probably obvious to you but I had to make sure to clear the cache in order to properly test argument/option changes after a prior successful compilation.

Sorry, I probably should've opened an issue, but thought it was somehow an edge case on my setup. This commit seem like a plausible culprit tho.

Please sign in to comment.