Manim: How to add a new line when using TextMobject like arrays

Created on 27 Mar 2020  Â·  6Comments  Â·  Source: 3b1b/manim

When I use:

t = TextMobject('aaaaa', '''a

 a''', 'aaaaa')

批注 2020-03-27 173840

but when I use:
t = TextMobject('aaaaaaaaa', '\n\n', 'aaaaaaa')
or:

t = TextMobject('aaaaa', '''

         ''', 'aaaaa')

批注 2020-03-27 173932

It's not what I want. Are there other ways to add a new line when using TextMobject like arrays?

Most helpful comment

I think this is much better:

text = VGroup(
    TextMobject(“First\_line”),
    TextMobject(“Second\_line”),
    TextMobject(“Third\_line”)
).arrange(DOWN, aligned_edge=LEFT)

If you want to use “\n”, Text() class supports it.
Text(“a\nb\nc”, font=“your font”)

All 6 comments

'\n'.join(['First_line', 'Second_line', 'Third_line'])
TextMobject('First_line\nSecond_line\nThird_line')
'\n'.join(['First_line', 'Second_line', 'Third_line'])
TextMobject('First_line\nSecond_line\nThird_line')

sorry for replying too late

but it doesn't work

image

and they're in the same list index

I can't use ApplyMethord for one of them

@nosnakeob
TextMobject(“First\_line\\\\”, “Second\_line\\\\”, “Third\_line”)

TextMobject use LaTeX to display text, so you need to obey the rule of LaTeX.

I think this is much better:

text = VGroup(
    TextMobject(“First\_line”),
    TextMobject(“Second\_line”),
    TextMobject(“Third\_line”)
).arrange(DOWN, aligned_edge=LEFT)

If you want to use “\n”, Text() class supports it.
Text(“a\nb\nc”, font=“your font”)

Yes, I made a mistake: replace TextMobject with Text:

'\n'.join(['First_line', 'Second_line', 'Third_line'])
Text('First_line\nSecond_line\nThird_line', font='Arial', stroke_width=0)

I think this is much better:

text = VGroup(
    TextMobject(“First\_line”),
    TextMobject(“Second\_line”),
    TextMobject(“Third\_line”)
).arrange(DOWN, aligned_edge=LEFT)

If you want to use “\n”, Text() class supports it.
Text(“a\nb\nc”, font=“your font”)

That's useful, Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SuperVegetaSon picture SuperVegetaSon  Â·  4Comments

WeiruLin picture WeiruLin  Â·  5Comments

samsamson33 picture samsamson33  Â·  5Comments

Sir-Teo picture Sir-Teo  Â·  6Comments

AliNear picture AliNear  Â·  3Comments