mirror of
https://github.com/3b1b/manim.git
synced 2026-04-26 03:00:23 -04:00
Better fix to \left \right issue in TexMobject
This commit is contained in:
@@ -81,17 +81,22 @@ class SingleStringTexMobject(SVGMobject):
|
||||
tex += filler
|
||||
|
||||
if tex == "\\substack":
|
||||
tex = ""
|
||||
for t1, t2 in ("\\left", "\\right"), ("\\right", "\\left"):
|
||||
should_replace = reduce(op.and_, [
|
||||
t1 in tex,
|
||||
t2 not in tex,
|
||||
len(tex) > len(t1) and tex[len(t1)] in ["(){}[]|.\\"]
|
||||
])
|
||||
if should_replace:
|
||||
tex = tex.replace(t1, "\\big")
|
||||
tex = "\\quad"
|
||||
|
||||
if tex == "":
|
||||
tex = "\\quad"
|
||||
|
||||
# Handle imbalanced \left and \right
|
||||
num_lefts, num_rights = [
|
||||
len(filter(
|
||||
lambda s: s[0] in "(){}[]|.\\",
|
||||
tex.split(substr)[1:]
|
||||
))
|
||||
for substr in "\\left", "\\right"
|
||||
]
|
||||
if num_lefts != num_rights:
|
||||
tex = tex.replace("\\left", "\\big")
|
||||
tex = tex.replace("\\right", "\\big")
|
||||
return tex
|
||||
|
||||
def remove_stray_braces(self, tex):
|
||||
|
||||
Reference in New Issue
Block a user