Here is the source code of the documentation page of Table in Manim:
class TableExamples(Scene):
def construct(self):
t0 = Table(
[["This", "is a"],
["simple", "Table in \n Manim."]])
t1 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")])
t1.add_highlighted_cell((2,2), color=YELLOW)
t2 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")],
top_left_entry=Star().scale(0.3),
include_outer_lines=True,
arrange_in_grid_config={"cell_alignment": RIGHT})
t2.add(t2.get_cell((2,2), color=RED))
t3 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")],
top_left_entry=Star().scale(0.3),
include_outer_lines=True,
line_config={"stroke_width": 1, "color": YELLOW})
t3.remove(*t3.get_vertical_lines())
g = Group(
t0,t1,t2,t3
).scale(0.7).arrange_in_grid(buff=1)
self.add(g)
I'm trying to strikethrough something. To do so I got inspired by this documentation page. Hence why, I've tried:
class TableExamples(Scene):
def construct(self):
t0 = Table(
[['``<span strikethrough="true" strikethrough_color="red">This</span>``', "is a"],
["simple", "Table in \n Manim."]])
t1 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")])
t1.add_highlighted_cell((2,2), color=YELLOW)
t2 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")],
top_left_entry=Star().scale(0.3),
include_outer_lines=True,
arrange_in_grid_config={"cell_alignment": RIGHT})
t2.add(t2.get_cell((2,2), color=RED))
t3 = Table(
[["This", "is a"],
["simple", "Table."]],
row_labels=[Text("R1"), Text("R2")],
col_labels=[Text("C1"), Text("C2")],
top_left_entry=Star().scale(0.3),
include_outer_lines=True,
line_config={"stroke_width": 1, "color": YELLOW})
t3.remove(*t3.get_vertical_lines())
g = Group(
t0,t1,t2,t3
).scale(0.7).arrange_in_grid(buff=1)
self.add(g)
But it doesn't work. I've also tried using LaTeX tags, but Manim doesn't understand it as LaTeX because (I think?) this is interpreted as Text
and not Tex
.
Any ideas?
CodePudding user response:
Take a look at the documentation of Table
, you want to adapt the element_to_mobject
keyword argument (because you are trying to use MarkupText
syntax in a "normal" Text
class, which does not work.
This does though:
class TableExamples(Scene):
def construct(self):
t0 = Table(
[['<span strikethrough="true" strikethrough_color="red">This</span>', "is a"],
["simple", "Table in \n Manim."]],
element_to_mobject=MarkupText)
self.add(t0)