Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active January 12, 2026 13:03
Show Gist options
  • Select an option

  • Save uwezi/a5d674f6394897bd4abd5f4237a62663 to your computer and use it in GitHub Desktop.

Select an option

Save uwezi/a5d674f6394897bd4abd5f4237a62663 to your computer and use it in GitHub Desktop.
[Smileys in equations] Use smiley characters in LaTeX equations in Manim. #manim #latex #smiley #pdf
class smileyeqn(Scene):
def construct(self):
smiley = ImageMobject("bilder/slightly-smiling-face_1f642.png")
tex_templ = TexTemplate()
tex_templ.add_to_preamble(r"\DeclareMathOperator{\sinc}{sinc}")
eqn = MathTex(r"\sinc(x) = \frac{\sin(x)}{x}", tex_template=tex_templ).to_edge(UP)
self.add(eqn)
eqn2 = eqn.copy().next_to(eqn,DOWN)
smiley.scale_to_fit_width(eqn2[0][5].width*1.5)
smileys = Group(
*[smiley.copy().shift(eqn2[0][i].get_center()-smiley.get_center())
for i in [5, 12, 15]]
)
self.add(eqn2,smileys)
tex_templ.add_to_preamble(r"\usepackage{marvosym}")
eqn3 = MathTex(r"\sinc(\text{\Smiley{}}) = \frac{\sin(\text{\Smiley{}})}{\text{\Smiley{}}}", tex_template=tex_templ)
eqn3.next_to(eqn2,DOWN)
self.add(eqn3)
tex_templ = TexTemplate(
tex_compiler="xelatex",
output_format=".xdv"
)
tex_templ.add_to_preamble(r"\DeclareMathOperator{\sinc}{sinc}")
tex_templ.add_to_preamble(r"\usepackage{twemojis}")
eqn4 = MathTex(r"\sinc(\twemoji{smile}) = \frac{\sin(\twemoji{smile})}{\twemoji{smile}}", tex_template=tex_templ)
eqn4.next_to(eqn3,DOWN)
eqn4[0][11].set_stroke(width=2)
# self.add(eqn4,index_labels(eqn4[0]).set_color(RED))
self.add(eqn4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment