ManimCommunity / ManimCommunity/manim
Requirements for latex line operations
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
Add a new function to control latex content line by line
Using vgroup to manage multiple single-line latex content will break the multi-line typesetting of latex.
If you treat each line as a sub-string of MathTex(), you will lose the ability to operate more granularly.
If latex is manually split into small enough contents in MathTex(), latex becomes difficult to read when modifying the code.
So I hope this function can accept a long single latex string or multiple short strings, identify the latex newline character r "\\" from it, and then return the corresponding line as required without destroying the splitting of MathTex()
## How can the new feature be used?
Display mathematical derivation line by line and provide line-level control over latex content
## Additional comments
This is a simple example when writing r"\\\\" alone
```
def GetLine(txt, TargetLineIndex):
LineIndex = 0
LineStart = 0
LineEnd = 0
isNextLine = 0
for WordIndex in range(len(txt.submobjects)):
if isNextLine:
LineStart = WordIndex
isNextLine = 0
if txt.submobjects[WordIndex].get_tex_string() == r"\\":
LineIndex += 1
LineEnd = WordIndex
isNextLine = 1
if TargetLineIndex == LineIndex or WordIndex==len(txt.submobjects):
return txt.submobjects[LineStart:LineEnd]
WordIndex += 1
multiline_tex = MathTex(
r"a^2", "+"," b^2 &= c^2 ", r"\\",
r"x^3" , "+", "y^3 &= z^3 ", r"\\",r"E &= mc^2", r"\\")
self.play([Write(i)for i in GetLine(multiline_tex,1)])
self.play([Write(i)for i in GetLine(multiline_tex,2)])
self.play([Write(i)for i in GetLine(multiline_tex,3)])
self.wait()
all_x_parts = multiline_tex.get_parts_by_tex("+")
self.play(all_x_parts.animate.set_color(RED))
self.wait()
```
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 by reading the MathTex entry point and how its submobjects expose get_tex_string() and get_parts_by_tex(). Use the provided GetLine example to understand the requested line boundaries, then verify that the resulting API preserves MathTex splitting while enabling line-level animation control.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex, python
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100