-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fraction issues fadeout rightaway #4208
Comments
I suggest that you at least try to write your messages in English. Very few of us have English as their native language, but as far as I am aware of it, none of the developers is Vietnamese. Also make sure that your code examples are at least so complete that they actually can be rendered without guessing additional settings... |
class fractions(Scene):
def construct(self):
# Nội dung bên trái - Tách từng dòng MathTex ra riêng biệt
line1 = MathTex(r"\text{VD: } y=f(x)=x^2. \text { some text } -2", font_size=26).to_edge(LEFT).shift(UP * 2)
line2 = MathTex(r"f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x}" , font_size=26).next_to(line1, DOWN, aligned_edge=LEFT)
line3 = MathTex(r"\text {Thay } x_0 = -2 \text{ other text }", font_size=26).next_to(line2, DOWN, aligned_edge=LEFT)
line3a = MathTex(r"f' ( -2 ) = \lim _ { \Delta x \to 0 } \dfrac{ f(-2 + \Delta x) - f(-2) }{ \Delta x }" , font_size=26).next_to(line3, DOWN, aligned_edge=LEFT)
line4 = MathTex(r"\text{more text:}", font_size=26).next_to(line3a, DOWN, aligned_edge=LEFT)
line5 = MathTex(r"f'(-2) = \lim_{\Delta x \to 0} \frac{f(-2 + \Delta x) - f(-2)}{\Delta x}", font_size=26).next_to(line4, DOWN, aligned_edge=LEFT)
line6 = MathTex(r"= \lim_{\Delta x \to 0} \frac{(-2 + \Delta x)^2 - (-2)^2}{\Delta x}", font_size=26).next_to(line5, DOWN, aligned_edge=LEFT)
line7 = MathTex(r"= \lim_{\Delta x \to 0} \frac{-4\Delta x + (\Delta x)^2}{\Delta x}", font_size=26).next_to(line6, DOWN, aligned_edge=LEFT)
line8 = MathTex(r"= \lim_{\Delta x \to 0} \left(-4 + \Delta x\right)", font_size=26).next_to(line7, DOWN, aligned_edge=LEFT)
line9 = MathTex(r"= -4", font_size=26).next_to(line8, DOWN, aligned_edge=LEFT)
self.play(Write(line1))
self.play(Write(line2))
self.play(Write(line3))
self.play(Write(line3a))
self.play(Write(line4))
self.play(Write(line5))
self.play(Write(line6))
self.play(Write(line7))
self.play(Write(line8))
self.play(Write(line9))
self.wait(3)
self.play(FadeOut(line1), FadeOut(line2), FadeOut(line3),FadeOut(line3a) , FadeOut(line4), FadeOut(line5), FadeOut(line6), FadeOut(line7), FadeOut(line8), FadeOut(line9)) gives the following, expected video. What exactly is your problem with this? fractions.mp4 |
Thank you. Could you explain the phenomenon where the fraction bar in my numerator and denominator automatically disappears when it first appears in the video, as per the initial code? DerivativeConcept3.mp4 |
from manim import * Sử dụng xelatex làm trình biên dịch LaTeX và định dạng đầu ra .pdfconfig.tex_template.tex_compiler = "xelatex" class DerivativeConcept3(Scene):
|
It still does not on my system when I run this slightly modified version of your code: class DerivativeConcept3(Scene):
def construct(self):
textempl = TexTemplate(
tex_compiler="xelatex",
output_format=".pdf"
)
MathTex.set_default(tex_template=textempl)
# Mở đầu: Tiêu đề chính
title = Text("Bản chất của đạo hàm, tiếp tuyến", font_size=48, color=YELLOW, font="Arial")
title.to_edge(UP)
self.play(Write(title))
self.wait(2)
# Tiêu đề phụ
subtitle = Text("3. Ví dụ", font_size=36, color=BLUE, font="Arial")
subtitle.next_to(title, DOWN)
self.play(Write(subtitle))
self.wait(2)
# Nội dung bên trái - Tách từng dòng MathTex ra riêng biệt
line1 = MathTex(r"\text{VD: } y=f(x)=x^2. \text { some text } -2", font_size=26).to_edge(LEFT).shift(UP * 2)
line2 = MathTex(r"f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x}" , font_size=26).next_to(line1, DOWN, aligned_edge=LEFT)
line3 = MathTex(r"\text {Thay } x_0 = -2 \text{ other text }", font_size=26).next_to(line2, DOWN, aligned_edge=LEFT)
line3a = MathTex(r"f' ( -2 ) = \lim _ { \Delta x \to 0 } \dfrac{ f(-2 + \Delta x) - f(-2) }{ \Delta x }" , font_size=26).next_to(line3, DOWN, aligned_edge=LEFT)
line4 = MathTex(r"\text{more text:}", font_size=26).next_to(line3a, DOWN, aligned_edge=LEFT)
line5 = MathTex(r"f'(-2) = \lim_{\Delta x \to 0} \frac{f(-2 + \Delta x) - f(-2)}{\Delta x}", font_size=26).next_to(line4, DOWN, aligned_edge=LEFT)
line6 = MathTex(r"= \lim_{\Delta x \to 0} \frac{(-2 + \Delta x)^2 - (-2)^2}{\Delta x}", font_size=26).next_to(line5, DOWN, aligned_edge=LEFT)
line7 = MathTex(r"= \lim_{\Delta x \to 0} \frac{-4\Delta x + (\Delta x)^2}{\Delta x}", font_size=26).next_to(line6, DOWN, aligned_edge=LEFT)
line8 = MathTex(r"= \lim_{\Delta x \to 0} \left(-4 + \Delta x\right)", font_size=26).next_to(line7, DOWN, aligned_edge=LEFT)
line9 = MathTex(r"= -4", font_size=26).next_to(line8, DOWN, aligned_edge=LEFT)
self.play(Write(line1))
self.play(Write(line2))
self.play(Write(line3))
self.play(Write(line3a))
self.play(Write(line4))
self.play(Write(line5))
self.play(Write(line6))
self.play(Write(line7))
self.play(Write(line8))
self.play(Write(line9))
self.wait(3)
self.play(FadeOut(line1), FadeOut(line2), FadeOut(line3),FadeOut(line3a) , FadeOut(line4), FadeOut(line5), FadeOut(line6), FadeOut(line7), FadeOut(line8), FadeOut(line9))
# Nội dung từng dòng MathTex
line10 = MathTex(r"\text{Đạo hàm tại } -2 \text{ của } y = f(x) = x^2 \text{ là } f'(-2) = -4", font_size=26).to_edge(LEFT).shift(UP * 2)
line11 = MathTex(r"\Rightarrow \text{Tiếp tuyến tại } -2 \text{ có dạng } y = -4x + b", font_size=26).next_to(line10, DOWN, aligned_edge=LEFT)
line12 = MathTex(r"\text{Tổng quát: Tiếp tuyến tại điểm } x_0 \text{ có dạng } y = f'(x_0) \cdot x + b", font_size=26).next_to(line11, DOWN, aligned_edge=LEFT)
line13 = MathTex(r"\text{Điểm } A(x_0, y_0) \text{ thuộc tiếp tuyến }", font_size=26).next_to(line12, DOWN, aligned_edge=LEFT)
line14 = MathTex(r"\Rightarrow \text{Thay tọa độ } A \text{ vào PT tiếp tuyến thỏa mãn:}", font_size=26).next_to(line13, DOWN, aligned_edge=LEFT)
line15 = MathTex(r"y_0 = f'(x_0) \cdot x_0 + b", font_size=26).next_to(line14, DOWN, aligned_edge=LEFT)
line16 = MathTex(r"\Rightarrow b = y_0 - f'(x_0) \cdot x_0", font_size=26).next_to(line15, DOWN, aligned_edge=LEFT)
line17 = MathTex(r"\text{Thay vào PT tiếp tuyến ban đầu:}", font_size=26).next_to(line16, DOWN, aligned_edge=LEFT)
line18 = MathTex(r"y = f'(x_0) \cdot x + y_0 - f'(x_0) \cdot x_0", font_size=26).to_edge(RIGHT).shift(UP * 2)
line19 = MathTex(r"\Rightarrow y = f'(x_0) \cdot (x - x_0) + y_0", font_size=26).next_to(line18, DOWN, aligned_edge=LEFT)
line20 = MathTex(r"\Rightarrow y = f'(x_0) \cdot (x - x_0) + f(x_0)", font_size=26).next_to(line19, DOWN, aligned_edge=LEFT)
line21 = MathTex(r"\text{Áp dụng vào tiếp tuyến tại } A(-2, 4):", font_size=26).next_to(line20, DOWN, aligned_edge=LEFT)
line22 = MathTex(r"y = f'(-2) \cdot (x - (-2)) + f(-2)", font_size=26).next_to(line21, DOWN, aligned_edge=LEFT)
line23 = MathTex(r"\text{Chú ý: } f'(-2) = -4 \text{ và } f(-2) = 4", font_size=26).next_to(line22, DOWN, aligned_edge=LEFT)
line24 = MathTex(r"y = -4 \cdot (x + 2) + 4", font_size=26).next_to(line23, DOWN, aligned_edge=LEFT)
line25 = MathTex(r"\Rightarrow y = -4x - 4", font_size=26).next_to(line24, DOWN, aligned_edge=LEFT)
# Hiển thị từng dòng MathTex
self.play(Write(line10))
self.play(Write(line11))
self.play(Write(line12))
self.play(Write(line13))
self.play(Write(line14))
self.play(Write(line15))
self.play(Write(line16))
self.play(Write(line17))
self.play(Write(line18))
self.play(Write(line19))
self.play(Write(line20))
self.play(Write(line21))
self.play(Write(line22))
self.play(Write(line23))
self.play(Write(line24))
self.play(Write(line25))
self.wait(3) DerivativeConcept3.mp4(please use the correct code formatting here on github for better readability) However, I think I can identify the cause of the behavior: LaTeX generally produces fraction bars as thin, filled rectangles, not as strokes, essentially all LaTeX output is filled polygons for the characters. The animation In some implementations and output formats, LaTeX can produce lines like the fraction bar as single stroked lines, not rectangles. Then these will become visible during Can you check if setting the output format from ".pdf" to ".xdv" changes the result on your system? It might be necessary to remove the contents of the class DerivativeConcept3(Scene):
def construct(self):
textempl = TexTemplate(
tex_compiler="xelatex",
output_format=".xdv"
)
MathTex.set_default(tex_template=textempl)
# Mở đầu: Tiêu đề chính
title = Text("Bản chất của đạo hàm, tiếp tuyến", font_size=48, color=YELLOW, font="Arial")
title.to_edge(UP)
self.play(Write(title))
self.wait(2)
# Tiêu đề phụ
subtitle = Text("3. Ví dụ", font_size=36, color=BLUE, font="Arial")
subtitle.next_to(title, DOWN)
self.play(Write(subtitle))
self.wait(2)
# Nội dung bên trái - Tách từng dòng MathTex ra riêng biệt
line1 = MathTex(r"\text{VD: } y=f(x)=x^2. \text { some text } -2", font_size=26).to_edge(LEFT).shift(UP * 2)
line2 = MathTex(r"f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x}" , font_size=26).next_to(line1, DOWN, aligned_edge=LEFT)
line3 = MathTex(r"\text {Thay } x_0 = -2 \text{ other text }", font_size=26).next_to(line2, DOWN, aligned_edge=LEFT)
line3a = MathTex(r"f' ( -2 ) = \lim _ { \Delta x \to 0 } \dfrac{ f(-2 + \Delta x) - f(-2) }{ \Delta x }" , font_size=26).next_to(line3, DOWN, aligned_edge=LEFT)
line4 = MathTex(r"\text{more text:}", font_size=26).next_to(line3a, DOWN, aligned_edge=LEFT)
line5 = MathTex(r"f'(-2) = \lim_{\Delta x \to 0} \frac{f(-2 + \Delta x) - f(-2)}{\Delta x}", font_size=26).next_to(line4, DOWN, aligned_edge=LEFT)
line6 = MathTex(r"= \lim_{\Delta x \to 0} \frac{(-2 + \Delta x)^2 - (-2)^2}{\Delta x}", font_size=26).next_to(line5, DOWN, aligned_edge=LEFT)
line7 = MathTex(r"= \lim_{\Delta x \to 0} \frac{-4\Delta x + (\Delta x)^2}{\Delta x}", font_size=26).next_to(line6, DOWN, aligned_edge=LEFT)
line8 = MathTex(r"= \lim_{\Delta x \to 0} \left(-4 + \Delta x\right)", font_size=26).next_to(line7, DOWN, aligned_edge=LEFT)
line9 = MathTex(r"= -4", font_size=26).next_to(line8, DOWN, aligned_edge=LEFT)
self.play(Write(line1))
self.play(Write(line2))
self.play(Write(line3))
self.play(Write(line3a))
self.play(Write(line4))
self.play(Write(line5))
self.play(Write(line6))
self.play(Write(line7))
self.play(Write(line8))
self.play(Write(line9))
self.wait(3)
self.play(FadeOut(line1), FadeOut(line2), FadeOut(line3),FadeOut(line3a) , FadeOut(line4), FadeOut(line5), FadeOut(line6), FadeOut(line7), FadeOut(line8), FadeOut(line9))
# Nội dung từng dòng MathTex
line10 = MathTex(r"\text{Đạo hàm tại } -2 \text{ của } y = f(x) = x^2 \text{ là } f'(-2) = -4", font_size=26).to_edge(LEFT).shift(UP * 2)
line11 = MathTex(r"\Rightarrow \text{Tiếp tuyến tại } -2 \text{ có dạng } y = -4x + b", font_size=26).next_to(line10, DOWN, aligned_edge=LEFT)
line12 = MathTex(r"\text{Tổng quát: Tiếp tuyến tại điểm } x_0 \text{ có dạng } y = f'(x_0) \cdot x + b", font_size=26).next_to(line11, DOWN, aligned_edge=LEFT)
line13 = MathTex(r"\text{Điểm } A(x_0, y_0) \text{ thuộc tiếp tuyến }", font_size=26).next_to(line12, DOWN, aligned_edge=LEFT)
line14 = MathTex(r"\Rightarrow \text{Thay tọa độ } A \text{ vào PT tiếp tuyến thỏa mãn:}", font_size=26).next_to(line13, DOWN, aligned_edge=LEFT)
line15 = MathTex(r"y_0 = f'(x_0) \cdot x_0 + b", font_size=26).next_to(line14, DOWN, aligned_edge=LEFT)
line16 = MathTex(r"\Rightarrow b = y_0 - f'(x_0) \cdot x_0", font_size=26).next_to(line15, DOWN, aligned_edge=LEFT)
line17 = MathTex(r"\text{Thay vào PT tiếp tuyến ban đầu:}", font_size=26).next_to(line16, DOWN, aligned_edge=LEFT)
line18 = MathTex(r"y = f'(x_0) \cdot x + y_0 - f'(x_0) \cdot x_0", font_size=26).to_edge(RIGHT).shift(UP * 2)
line19 = MathTex(r"\Rightarrow y = f'(x_0) \cdot (x - x_0) + y_0", font_size=26).next_to(line18, DOWN, aligned_edge=LEFT)
line20 = MathTex(r"\Rightarrow y = f'(x_0) \cdot (x - x_0) + f(x_0)", font_size=26).next_to(line19, DOWN, aligned_edge=LEFT)
line21 = MathTex(r"\text{Áp dụng vào tiếp tuyến tại } A(-2, 4):", font_size=26).next_to(line20, DOWN, aligned_edge=LEFT)
line22 = MathTex(r"y = f'(-2) \cdot (x - (-2)) + f(-2)", font_size=26).next_to(line21, DOWN, aligned_edge=LEFT)
line23 = MathTex(r"\text{Chú ý: } f'(-2) = -4 \text{ và } f(-2) = 4", font_size=26).next_to(line22, DOWN, aligned_edge=LEFT)
line24 = MathTex(r"y = -4 \cdot (x + 2) + 4", font_size=26).next_to(line23, DOWN, aligned_edge=LEFT)
line25 = MathTex(r"\Rightarrow y = -4x - 4", font_size=26).next_to(line24, DOWN, aligned_edge=LEFT)
# Hiển thị từng dòng MathTex
self.play(Write(line10))
self.play(Write(line11))
self.play(Write(line12))
self.play(Write(line13))
self.play(Write(line14))
self.play(Write(line15))
self.play(Write(line16))
self.play(Write(line17))
self.play(Write(line18))
self.play(Write(line19))
self.play(Write(line20))
self.play(Write(line21))
self.play(Write(line22))
self.play(Write(line23))
self.play(Write(line24))
self.play(Write(line25))
self.wait(3) |
Thank you so much! I deleted all the files in the /media/tex folder, and the bars no longer disappear. I am new to this and don’t really know how to use Manim and GitHub yet. Thank you again for your help! |
Câu hỏi về lỗi trong đoạn code sử dụng MathTex
Xin chào mọi người,
Mình đang gặp vấn đề với đoạn code sử dụng MathTex. Khi mình chạy đoạn code này, các dấu gạch chia tử mẫu vừa hiện ra đã tự biến mất ngay. Dưới đây là đoạn code của mình:
The text was updated successfully, but these errors were encountered: