Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active October 27, 2025 16:16
Show Gist options
  • Save uwezi/ddebd2eff0c6222f7c0b275454f60081 to your computer and use it in GitHub Desktop.
Save uwezi/ddebd2eff0c6222f7c0b275454f60081 to your computer and use it in GitHub Desktop.
[Tikz and XeLaTeX] Rednering Tikz code using XeLaTeX in Manim. #manim #latex #xelatex #dvisvgm #tikz
from manim import *
class tikztest(Scene):
def construct(self):
MyTexTemplate = TexTemplate(
tex_compiler="xelatex",
output_format=".xdv",
documentclass=r"\documentclass[preview,dvisvgm]{standalone}"
)
MyTexTemplate.add_to_preamble(r"\usepackage{tikz}")
tex = Tex(r"""
\begin{tikzpicture}[x=10mm,y=10mm]
\draw (0,0)--(2.9,2.9) node[pos=0,anchor=east]{A} node[pos=1,anchor=west]{B};
\end{tikzpicture}""",
tex_template=MyTexTemplate
).set_stroke(width=3)
self.add(tex)

When using XeLaTeX and Tikz in Manim you need to give the additional argument dvisvgm to the documentclass (or just tikz) in order for XeLaTeX to produce an output which is compatible with dvisvgm and which can be converted to SVG for the import into Manim.

bild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment