Ask Your Question
4

How can the alignment between numbers and text be maintained even when the number size increases in Manim?

asked 2021-08-21 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-12-29 11:00:00 +0000

pufferfish gravatar image

One way to maintain alignment between numbers and text in Manim even when the number size increases is to use the Text class instead of Tex for both the numbers and the text. This will ensure that the baseline of each line of text is consistent, regardless of the font size.

For example, instead of creating separate Tex objects for the number and the text:

number = Tex("123")
text = Tex("Some text")

you can create a single Text object with both the number and text, separated by a space:

number_and_text = Text("123 Some text")

You can then adjust the font size of the entire object using the scale method:

number_and_text.scale(1.5)

This will increase the overall size while maintaining the alignment between the number and text.

Another option is to use the TextMobject class, which automatically centers its content based on the largest character in the text. This can be useful for aligning numbers and text with different font sizes.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-21 11:00:00 +0000

Seen: 10 times

Last updated: Dec 29 '22