Skip to content

ManimCE 0.19.0 LaTeX environment parameters still wrong #4158

Closed
@uwezi

Description

@uwezi

Description of bug / unexpected behavior

In ManimCE 0.18.0 (if I remember correctly) the mandatory parameters of tex_environments could be added directly in the argument's string using braces, then in 0.18.1 a problem started to occur that the first brace was doubled up by Manim. This is still persistent in 0.19.0.

Expected behavior

Manim should not add an additional opening brace in the environments when given in this form:

tex_environment="{minipage}{7cm}"

How to reproduce the issue

Code for reproducing the problem pre ManimCE 0.18.1
class textex_old(Scene):
    def construct(self):
        t1 = Tex(r"This is plain text mode\\ in two centered lines.").to_edge(UP, buff=0)
        self.add(t1)
        t2 = Tex(
            r"This is a longer text block in a so-called minipage environment allowing for justified margins. And just because I can I also throw in some math $E=mc^2$.",
            tex_environment="{minipage}{7cm}"
        ).set_color(YELLOW).scale_to_fit_width(8).next_to(t1,DOWN)
        self.add(t1,t2)

now fails because it creates this LaTeX file (watch out for \begin{{minipage}{7cm}):

\documentclass[preview]{standalone}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{{minipage}{7cm}
This is a longer text block in a so-called minipage environment allowing for justified margins. And just because I can I also throw in some math $E=mc^2$.
\end{{minipage}
\end{document}

since 0.18.1 there are two non-intuitive workarounds:

a) omitting the opening brace in the argument tex_environment="minipage}{7cm}"

class textex_newA(Scene):
    def construct(self):
        t1 = Tex(r"This is plain text mode\\ in two centered lines.").to_edge(UP, buff=0)
        self.add(t1)
        t2 = Tex(
            r"This is a longer text block in a so-called minipage environment allowing for justified margins. And just because I can I also throw in some math $E=mc^2$.",
            tex_environment="minipage}{7cm}"
        ).set_color(YELLOW).scale_to_fit_width(8).next_to(t1,DOWN)
        self.add(t1,t2)

b) giving the parameters in braces at the beginning of the LaTeX string itself:

class textex_newB(Scene):
    def construct(self):
        t1 = Tex(r"This is plain text mode\\ in two centered lines.").to_edge(UP, buff=0)
        self.add(t1)
        t2 = Tex(
            r"{7cm}This is a longer text block in a so-called minipage environment allowing for justified margins. And just because I can I also throw in some math $E=mc^2$.",
            tex_environment="minipage"
        ).set_color(YELLOW).scale_to_fit_width(8).next_to(t1,DOWN)
        self.add(t1,t2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions