Skip to content

Commit c4eeb2e

Browse files
authored
Always use / when calling LaTeX (#3061)
* Add a test to reproduce #3060 * Always use `/` when calling LaTeX Using `\` isn't supported by LaTeX and simply errors out saying it can't find the file. In this commit, the path is converted to POSIX like path (ie. use `/`) before calling LaTeX. Fixes #3060
1 parent bd0ba12 commit c4eeb2e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

manim/utils/tex_file_writing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ def tex_compilation_command(
129129
"-interaction=batchmode",
130130
f'-output-format="{output_format[1:]}"',
131131
"-halt-on-error",
132-
f'-output-directory="{tex_dir}"',
133-
f'"{tex_file}"',
132+
f'-output-directory="{tex_dir.as_posix()}"',
133+
f'"{tex_file.as_posix()}"',
134134
">",
135135
os.devnull,
136136
]
@@ -146,8 +146,8 @@ def tex_compilation_command(
146146
outflag,
147147
"-interaction=batchmode",
148148
"-halt-on-error",
149-
f'-output-directory="{tex_dir}"',
150-
f'"{tex_file}"',
149+
f'-output-directory="{tex_dir.as_posix()}"',
150+
f'"{tex_file.as_posix()}"',
151151
">",
152152
os.devnull,
153153
]
@@ -229,10 +229,10 @@ def convert_to_svg(dvi_file: Path, extension: str, page: int = 1):
229229
"dvisvgm",
230230
"--pdf" if extension == ".pdf" else "",
231231
"-p " + str(page),
232-
f'"{dvi_file}"',
232+
f'"{dvi_file.as_posix()}"',
233233
"-n",
234234
"-v 0",
235-
"-o " + f'"{result}"',
235+
"-o " + f'"{result.as_posix()}"',
236236
">",
237237
os.devnull,
238238
]

tests/module/mobject/text/test_texmobject.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ def test_tex():
3333
assert Path(config.media_dir, "Tex", "f2e45e6e82d750e6.svg").exists()
3434

3535

36+
def test_tex_temp_directory(tmpdir, monkeypatch):
37+
# Adds a test for #3060
38+
# It's not possible to reproduce the issue normally, because we use
39+
# tempconfig to change media directory to temporary directory by default
40+
# we partially, revert that change here.
41+
monkeypatch.chdir(tmpdir)
42+
Path(tmpdir, "media").mkdir()
43+
with tempconfig({"media_dir": "media"}):
44+
Tex("The horse does not eat cucumber salad.")
45+
assert Path("media", "Tex").exists()
46+
assert Path("media", "Tex", "f2e45e6e82d750e6.svg").exists()
47+
48+
3649
def test_percent_char_rendering():
3750
Tex(r"\%")
3851
assert Path(config.media_dir, "Tex", "3f48edf8ebaf82c8.tex").exists()

0 commit comments

Comments
 (0)