ManimCommunity / ManimCommunity/manim
Nested Tex Environments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in tex.py by reading get_texcode_for_expression_in_env and the handling of tex_environment in Tex. Trace how a string environment is converted into TeX code, then determine how a list such as ["Arabic", "flushright"] should be processed recursively. Done means the listed environments are nested in order without requiring manually embedded TeX.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex, python
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100