Skip to content

LaTex Error in combination of MathTex and SurroundingRectangle. #1907

@Igittigitt24

Description

@Igittigitt24

Description of bug / unexpected behavior

In preparation for SurroundingRectangle() I called MathTex() with several items.
One of them contains an opening brace (the corresponding closing brace comes later on).
But this leads to a Latex Error couple:

ERROR LaTeX compilation error: Missing } inserted.
ERROR Context for error: \begin{align*} \frac{} \end{align*}

Expected behavior

An error should not occur like can be seen in the small example program below, because both open- and close-brace are given!

How to reproduce the issue

Here is an illustrating example (containing both the error version and an (unwanted) error-free version):

from manim import *

class MovingFrameBoxDiv(Scene):

    def construct(self):

        if 1: # try to write            ... = \frac { u'v - uv' } {v^2} 
              # for boxes:                           └─3─┘ └─5─┘
                
            text = MathTex(                    
               r"\left( \frac{u}{v} \right)'", # 0
                "="                          , # 1
               r"\frac {",                     # 2   ⇐ error-stop at opening brace
                "u' v"                       , # 3 *
                "-"                          , # 4
                "u v'"                       , # 5 *
                "} {v^2}",                     # 6   ⇐ closing brace 
            )  # ⇑                                   ⇐ is here!

        else: # instead use unwanted   ... = { u'v - uv' } \frac {1} {v^2}
              # for boxes:                    └─3─┘ └─5─┘
                
            text = MathTex(                    
               r"\left( \frac{u}{v} \right)'", # 0
                "="                          , # 1
               r"\left( \, "                 , # 2         
                "u' v"                       , # 3 *
                "-"                          , # 4
                "u v'"                       , # 5 *
               r"\, \right) \frac{1}{v^2}"   , # 6         
            )
            
        box1 = SurroundingRectangle(text[3], buff = .1)
        box2 = SurroundingRectangle(text[5], buff = .1, color=RED)

        self.play( Write (text) )
        self.play( Create(box1) )
        self.play( TransformFromCopy(box1, box2) )

        self.wait(5)
        
MovingFrameBoxDiv().render(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue:bugSomething isn't working... For use in issues

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions