ManimCommunity / ManimCommunity/manim

ManimCE 0.20.1: MathTex bounding box changes size when shifted

Open
#4,643 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

Description of bug / unexpected behavior

When shifting a MathTex() object which has an argument in the form of a list of substrings, the bounding box of the object grows, both vertically and horizontally.

As reported by TomBC on Discord https://discord.com/channels/1453870851807117363/1482938671190511748/1482938671190511748

Expected behavior

The bounding box should not change and just be the bounding box of the object.

How to reproduce the issue

Code for reproducing the problem
class TryMathTex(Scene):
    def construct(self):
        li = ['\\overrightarrow{', 'C', 'A', '}', '=', '\\bold{', 'm', '}']
        # str = r"\overrightarrow{BD}=\bold{m}"
        math_tex = MathTex(*li) 
        self.add(math_tex)
        bg1 = BackgroundRectangle(math_tex, color=GRAY, fill_opacity=0.5)
        self.play(Create(bg1))                    
        print(math_tex.width, math_tex.height) # 1.870 0.606 when I use li to MathTex
        self.play(math_tex.animate.shift(RIGHT+UP))
        print(math_tex.width, math_tex.height) # 1.935 1.303 when I use li to MathTex
        bg2 = BackgroundRectangle(math_tex, color=GRAY, fill_opacity=0.5)
        self.play(Create(bg2))

Additional media files

Images/GIFs Image

Logs

Terminal output

Bounding box before .shift()

1.8702728500000008 0.60589355

Bounding box after .shift()

1.9351364250000005 1.302946775000001

System specifications

System Details
  • OS: Windows 11 (my system) and Linux (Manimator)
  • Python version: 3.12.8
LaTeX details
  • LaTeX distribution: MikTex (my system) and TexLive (Manimator)

Additional comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the listed TryMathTex reproduction with MathTex(*li), BackgroundRectangle, and a shifted object, comparing width and height before and after the shift. Then trace MathTex bounding-box behavior around shifted objects; done means the bounding box remains unchanged after the shift and the reported reproduction is covered by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.