A community-maintained Python framework for creating mathematical animations.
added LaTeX examples to documentation
Aron Fischercbb472eecf21
diff --git a/docs/source/examples.rst b/docs/source/examples.rstindex fea2e23c5..a5f4ab933 100644--- a/docs/source/examples.rst+++ b/docs/source/examples.rst@@ -7,6 +7,7 @@ Examplesexamples/annotationsexamples/plotsexamples/text+ examples/texexamples/formulasexamples/3dexamples/camera_settingsdiff --git a/docs/source/examples/tex.rst b/docs/source/examples/tex.rstnew file mode 100644index 000000000..c70d302e5--- /dev/null+++ b/docs/source/examples/tex.rst@@ -0,0 +1,74 @@+LaTeX+=================================++.. manim:: Example1LaTeX+ :save_last_frame:++ class Example1LaTeX(Scene):+ def construct(self):+ tex = Tex(r'$\xrightarrow{Hello}$ \LaTeX').scale(3)+ self.add(tex)++.. manim:: Example2LaTeX+ :save_last_frame:++ class Example2LaTeX(Scene):+ def construct(self):+ tex = Tex(r'$\mathtt{Hello}$ \LaTeX', color=BLUE).scale(3)+ self.add(tex)+++.. manim:: Example3LaTeX+ :save_last_frame:++ class Example3LaTeX(Scene):+ def construct(self):+ myTemplate = TexTemplate()+ myTemplate.add_to_preamble(r"\usepackage{mathrsfs}")+ tex = Tex(r'$\mathscr{H}ello$ \LaTeX}', tex_template=myTemplate).scale(3)+ self.add(tex)+++.. manim:: Example4LaTeX+ :save_last_frame:++ class Example4LaTeX(Scene):+ def construct(self):+ tex = Tex('Hello', '$\\bigstar$', '\LaTeX').scale(3)+ tex.set_color_by_tex('igsta', RED)+ self.add(tex)++.. manim:: Example5LaTeX+ :save_last_frame:++ class Example5LaTeX(Scene):+ def construct(self):+ tex = Tex('Hello \LaTeX', tex_template=TexFontTemplates.french_cursive).scale(3)+ self.add(tex)++.. manim:: Example5bLaTeX+ :save_last_frame:++ class Example5bLaTeX(Scene):+ def construct(self):+ TemplateForFrenchCursive = TexTemplate(+ preamble=r"""+ \usepackage[english]{babel}+ \usepackage{amsmath}+ \usepackage{amssymb}+ \usepackage[T1]{fontenc}+ \usepackage[default]{frcursive}+ \usepackage[eulergreek,noplusnominus,noequal,nohbar,nolessnomore,noasterisk]{mathastext}+ """)+ tex = Tex('Hello \LaTeX', tex_template=TemplateForFrenchCursive).scale(3)+ self.add(tex)++.. manim:: Example6LaTeX+ :save_last_frame:++ class Example6LaTeX(Scene):+ def construct(self):+ tex = Tex('Hello 你好 \LaTeX', tex_template=CTEXTemplate()).scale(3)+ self.add(tex)++diff --git a/manim/utils/tex.py b/manim/utils/tex.pyindex 4cc4026f8..b4e1e488e 100644--- a/manim/utils/tex.py+++ b/manim/utils/tex.py@@ -155,13 +155,13 @@ class CTEXTemplate(TexTemplate):def __init__(self, **kwargs):tex_compiler = kwargs.pop("tex_compiler", "xelatex")output_format = kwargs.pop("output_format", ".xdv")- preamble = TexTemplate.default_preamble.replace(+ ctexpreamble = TexTemplate.default_preamble.replace(r"\DisableLigatures{encoding = *, family = * }", r"\usepackage[UTF8]{ctex}")super().__init__(tex_compiler=tex_compiler,output_format=output_format,- preamble=preamble,+ preamble=ctexpreamble,**kwargs)