manim icon indicating copy to clipboard operation
manim copied to clipboard

Nested Tex Environments

Open dakyion opened this issue 6 months ago • 0 comments

Description of proposed feature

It should be possible to set multiple tex enviroments such that they become nested inside each other.

Motivation for this suggestion

I had a problem a an arabic text that needed tex_enviroment="Arabic" with my custom template but this led to have a left aligned text. To solve that I needed another tex environment flushright, which I needed to add manually in my string

text= r"""
        \begin{flushright}
        تقوم الدالة $f$ بإسناد عدد وحيد من مجموعة عددية $R$ تسمى مجموعة الوصول أو مدى الدالة إلى عدد من مجموعة عددية $D$ تسمى مجموعة التعريف
        \end{flushright}
        """
arabicText = Tex(text, tex_template=my_template, tex_environment="Arabic")

How can the new feature be used?

The tex_enviroment parameter should take a list of strings as entry rather than a string. then it should use something similar to get_texcode_for_expression_in_env function (exist in tex.py) in a recursive manner. Finally, the code should be

text= r"""
        تقوم الدالة $f$ بإسناد عدد وحيد من مجموعة عددية $R$ تسمى مجموعة الوصول أو مدى الدالة إلى عدد من مجموعة عددية $D$ تسمى مجموعة التعريف
        """
arabicText = Tex(text, tex_template=my_template, tex_environment=["Arabic", "flushright"])

Additional comments

I know that I can create a custom function to achieve this nested enviroment behavior, just liked to share the idea that it might be implemented in a standard manner by the library.

dakyion avatar Jul 09 '25 20:07 dakyion