ManimCommunity / ManimCommunity/manim

Support tectonic tex engine

Open
#4,042 5 comments 0 reactions 0 assignees View on GitHub
new feature
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of proposed feature
Add support for using [tectonic tex engine](https://github.com/tectonic-typesetting/tectonic)

Per project page, Tectonic is derived from Xelatex. It downloads the required files on demand, so the installation size is much smaller than a full Latex system.

For example, a typical Texlive installation on Linux is about 2.5 GB, whereas Tectonic is a single binary of about 20 Mb, and 50 Mb of files need to be downloaded to work with manim.

## How can the new feature be used?

```py
config.tex_template = TexTemplate(tex_compiler="tectonic", output_format=".pdf")
```

## Additional comments
With this modification, I was able to get Manim to use Teconic.

```py
diff --git a/manim/utils/tex_file_writing.py b/manim/utils/tex_file_writing.py
index 45e84d4..0393551 100644
--- a/manim/utils/tex_file_writing.py
+++ b/manim/utils/tex_file_writing.py
@@ -160,6 +160,18 @@ def make_tex_compilation_command(
f"-output-directory={tex_dir.as_posix()}",
f"{tex_file.as_posix()}",
]
+ elif tex_compiler == "tectonic":
+ if output_format == ".xdv":
+ outflag = ["--outfmt", "xdv"]
+ elif output_format == ".pdf":
+ outflag = []
+ command = [
+ "tectonic",
+ *outflag,
+ "-o",
+ tex_dir.as_posix(),
+ tex_file.as_posix(),
+ ]
else:
raise ValueError(f"Tex compiler {tex_compiler} unknown.")
return command
```

However, with this configuration I had some problems rendering the fraction lines, which disappear during the animation. So there may be some incompatibilities.
For example

```py
from manim import *

config.tex_template = TexTemplate(tex_compiler="tectonic", output_format=".pdf")
config.verbosity = "WARNING"
class CauchyIntegralFormula(Scene):
def construct(self):
formula = MathTex(r"[z^n]f(z) = \frac{1}{2\pi i}\oint_{\gamma} \frac{f(z)}{z^{n+1}}~dz")
self.play(Write(formula), run_time=3)
self.wait()

%manim -qm CauchyIntegralFormula
```

https://github.com/user-attachments/assets/db88a0a2-5a2c-4b65-9be4-bdd44d71ba80

Contributor guide

Open the contributing guide

Research direction

The proposed change is in manim/utils/tex_file_writing.py, inside make_tex_compilation_command; start by examining the existing compiler branches and TexTemplate options. Run the provided CauchyIntegralFormula example with Tectonic for both PDF and XDV output, and verify that formulas, including fraction lines, render correctly without disappearing during animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, python
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.