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

Support tectonic tex engine #4042

Open
memchr opened this issue Dec 5, 2024 · 2 comments
Open

Support tectonic tex engine #4042

memchr opened this issue Dec 5, 2024 · 2 comments
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Comments

@memchr
Copy link

memchr commented Dec 5, 2024

Description of proposed feature

Add support for using tectonic tex engine

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?

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

Additional comments

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

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

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
CauchyIntegralFormula.mp4
@memchr memchr added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Dec 5, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Dev Board Dec 5, 2024
@behackl
Copy link
Member

behackl commented Dec 5, 2024

Very good idea, thanks for the suggestion!

I've seen the issue with the fraction lines in the context of xelatex-rendered files before; there might even be some issues about it. It might justify spending some time to see whether we can get this fixed.

I suppose it would also be sufficient if we implemented some fairly general and flexible customization options for setting the TeX compiler.

@uwezi
Copy link
Contributor

uwezi commented Dec 5, 2024

The disappearing fraction lines are caused when the resulting SVG file contains strokes instead of filled areas - as for regular rendered text and equations. A general solution would be to not generally set stroke_width=0 on the imported SVG, but to try to parse the SVG file more detailed - which also would solve a lot of Tikz related issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants