Closed zhangsn closed 4 months ago
You cannot use color inside your LaTeX, that is a known limitation in Manim. (Otherwise almost all text would always be invisible since the default color in LaTeX is black, while by default Manim uses a white background...)
You will have to color your LaTeX objects in Manim afterwards using .set_color()
. Or the different additional commands for "automatic" coloring - which might fail though, because of their respective limitations.
class Demo(Scene):
def construct(self):
myTemplate = TexTemplate()
mtex1 = MathTex(
r"\text{red}\,\int_0^\infty x\,\text{d}x",
tex_template=myTemplate
)
mtex2 = Tex(
r"red blue yellow",
).next_to(mtex1,DOWN)
mtex1.set_color(RED)
mtex2[0][0:3].set_color(RED)
mtex2[0][3:7].set_color(BLUE)
mtex2[0][7:].set_color(YELLOW)
self.add(mtex1,mtex2)
Thanks for the reply.😄
Description of bug / unexpected behavior
Same as title
Expected behavior
Should render the text in red color
How to reproduce the issue
Code for reproducing the problem
```py from manim import * class Demo(Scene): def construct(self): myTemplate = TexTemplate() myTemplate.add_to_preamble(r"\usepackage{color}") mtex = MathTex( "\\textcolor{red}{red}", tex_template=myTemplate) self.add(mtex) ```Logs
Terminal output
``` docker run --rm -it -v "/Users/zhangsn/Dev/manim:/manim" manimcommunity/manim manim -qm scenes.py Demo Manim Community v0.18.1 [05/23/24 09:09:46] INFO scene_file_writer.py:737 File ready at '/manim/media/images/scenes/Demo_ManimCE_v0.18.1.png' INFO Rendered Demo scene.py:247 Played 0 animations ``` ![Demo_ManimCE_v0 18 1](https://github.com/ManimCommunity/manim/assets/1401172/9bbb541d-7f27-4aaa-8a65-81c4bf1db202)System specifications
System Details
``` use docker manimcommunity/manim Manim Community v0.18.1 ```LaTeX details
+ LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:Additional comments