Repository: ManimCommunity/manim

Issue:
Only the first parts of an equation are rendered with `Write`.
## Description of bug / unexpected behavior
Only the first parts of an equation are rendered with `Write`.


## Expected behavior
The entire equation to be displayed 


## How to reproduce the issue
Manim Community v0.11.0

```py
class TestWrite(Scene):
    def construct(self):
        text=MathTex(
            "&", " x", r"=0 \\& \texttt{while }", " x", r"\le 10:", r"\\&\qquad", " x", "=", " x", "+1"
        )
        self.play(Write(text))
        self.wait()
```


## Output

![output img](https://pasteboard.co/MHF5tPp2OpxW.png)
https://pasteboard.co/MHF5tPp2OpxW.png

Write is not working if a part is empty
## Description of bug / unexpected behavior
Consider this code:
```
class Debug(ThreeDScene):
    def construct(self):
        t0 = MathTex(r"{{ \mathsf{return} }} \  {{ z }}")
        t1 = MathTex(r"{{ \mathsf{return} }} + {{z}}")
        VGroup(t0,t1).arrange(DOWN)
        self.play(Write(t0))
        self.play(Write(t1))
        self.wait(2)
```

## Expected behavior
I would expect both lines to print the z.

## Observed behavior

Yet, I only see the z on the second line. It seems like if I enclose all terms in my equation and that only empty elements are left, then only the first group is displayed. This is also seen in the bot in discord https://discord.com/channels/581738731934056449/1019649969596153968/threads/1153663738717679728

## How to reproduce the issue

<details><summary>Code for reproducing the problem</summary>

```py
class Debug(ThreeDScene):
    def construct(self):
        t0 = MathTex(r"{{ \mathsf{return} }} \  {{ z }}")
        t1 = MathTex(r"{{ \mathsf{return} }} + {{z}}")
        VGroup(t0,t1).arrange(DOWN)
        self.play(Write(t0))
        self.play(Write(t1))
        self.wait(2)
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. -->

<details><summary>Images/GIFs</summary>

https://github.com/ManimCommunity/manim/assets/2164118/624b04c8-0b37-4f88-af1c-fe2e2f9d493d

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
Manim Community v0.16.0.post0

[09/19/23 14:11:33] DEBUG    Hashing ...                                                                                                                                                            hashing.py:343
                    DEBUG    Hashing done in 0.033854 s.                                                                                                                                            hashing.py:355
                    DEBUG    Hash generated :  464293708_920551792_223132457                                                                                                                        hashing.py:358
                    INFO     Animation 0 : Using cached data (hash : 464293708_920551792_223132457)                                                                                           cairo_renderer.py:75
                    DEBUG    List of the first few animation hashes of the scene: ['464293708_920551792_223132457']                                                                           cairo_renderer.py:84
                    DEBUG    Hashing ...                                                                                                                                                            hashing.py:343
                    DEBUG    Hashing done in 0.043908 s.                                                                                                                                            hashing.py:355
                    DEBUG    Hash generated :  450002260_815086484_120912710                                                                                                                        hashing.py:358
                    DEBUG    List of the first few animation hashes of the scene: ['464293708_920551792_223132457', '450002260_815086484_120912710']                                          cairo_renderer.py:84
[09/19/23 14:11:34] INFO     Animation 1 : Partial movie file written in                                                                                                                  scene_file_writer.py:514
                             '480p15/partial_movie_f                         
                             iles/Debug/450002260_815086484_120912710.mp4'                                                                                                                                        
                    DEBUG    Animation with empty mobject                                                                                                                                         animation.py:173
                    DEBUG    Hashing ...                                                                                                                                                            hashing.py:343
                    DEBUG    Hashing done in 0.037911 s.                                                                                                                                            hashing.py:355
                    DEBUG    Hash generated :  450002260_88469787_549839834                                                                                                                         hashing.py:358
                    DEBUG    List of the first few animation hashes of the scene: ['464293708_920551792_223132457', '450002260_815086484_120912710', '450002260_88469787_549839834']          cairo_renderer.py:84
                    INFO     Animation 2 : Partial movie file written in                                                                                                                  scene_file_writer.py:514
                             '480p15/partial_movie_files/Debug/450002260_88469787_549839834.mp4'                                                                                                                                         
                    INFO     Combining to Movie file.                                                                                                                                     scene_file_writer.py:607
                    DEBUG    Partial movie files to combine (3 files):                                                                                                                    scene_file_writer.py:548
                             ['480p15/partial_movie_                         
                             files/Debug/464293708_920551792_223132457.mp4',                                                                                                                                      
                             '480p15/partial_movie_f                         
                             iles/Debug/450002260_815086484_120912710.mp4',                                                                                                                                       
                             '480p15/partial_movie_f                         
                             iles/Debug/450002260_88469787_549839834.mp4']                                                                                                                                        
                    INFO                                                                                                                                                                  scene_file_writer.py:728
                             File ready at                                                                                                                                                                        
                             '480p15/Debug.mp4'                              
                                                                                                                                                                                                                  
                    INFO     Rendered Debug                                                                                                                                                           scene.py:240
                             Played 3 animations                                                                                                                                                                  
                    INFO     Previewed File at:                                                                                                                                                    file_ops.py:224
                             '/home/leo/Documents/Cours/2022_-_Postdoc_Amsterdam/Enseignement/2023_-_Modern_crypto/Animations/media/videos/2023_09_19_-_pseudo_otp/480p15/Debug.mp4'                              
You are using manim version v0.16.0.post0, but version v0.17.3 is available.
You should consider upgrading via pip install -U manim

```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS NixOs
- RAM: enough
- Python version (`python/py/python3 --version`): 3.10.9
- Installed modules (provide output from `pip list`): not installed via pip

</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
ffmpeg version 4.4.3 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.3.0 (GCC)
configuration: --disable-static --prefix=/nix/store/rgcvvkwmhng2zlxpj55p58dhhn1y8w9h-ffmpeg-full-4.4.3 --target_os=linux --arch=x86_64 --enable-gpl --enable-version3 --disable-nonfree --enable-shared --enable-pic --disable-small --enable-runtime-cpudetect --disable-lto --enable-gray --enable-swscale-alpha --enable-hardcoded-tables --enable-safe-bitstream-reader --enable-pthreads --disable-w32threads --disable-os2threads --enable-network --enable-pixelutils --enable-ffmpeg --enable-ffplay --enable-ffprobe --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avutil --enable-postproc --enable-swresample --enable-swscale --enable-doc --disable-htmlpages --enable-manpages --disable-podpages --disable-txtpages --enable-bzlib --enable-libcelt --enable-cuda --enable-cuda-llvm --enable-libdav1d --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --enable-libfribidi --enable-libgme --enable-gnutls --enable-libgsm --enable-ladspa --enable-libmp3lame --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdc1394 --enable-libdrm --enable-iconv --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmysofa --enable-libopenmpt --enable-libopus --enable-librsvg --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvmaf --enable-libvpx --enable-libwebp --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxml2 --enable-lzma --enable-cuvid --enable-nvdec --enable-nvenc --enable-openal --enable-opencl --enable-libopencore-amrnb --disable-opengl --enable-libopenh264 --enable-libopenjpeg --disable-openssl --enable-libpulse --enable-librav1e --enable-libsvtav1 --disable-librtmp --enable-sdl2 --enable-libsoxr --enable-libspeex --enable-libvidstab --enable-libvo-amrwbenc --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzimg --enable-zlib --enable-vulkan --enable-libglslang --enable-libsmbclient --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:
I finally figured out what triggers the bug:
The subequations which do not contain any characters and which are just for alignment like `"&"`.
The following works but is now what I want:

```py
class TestWrite2(Scene):
    def construct(self):
        text = MathTex(
            "&.",
            " x",
            r"=0 \\& \texttt{while }",
            " x",
            r"\le 10:",
            r"\\&\qquad.",
            " x",
            "=",
            " x",
            "+1",
        )
        self.play(Write(text))
        self.wait()
```
For that, I just added dots (`.`) in the otherwise empty subequations.

The bug is also only triggered with `Write` or `Create` but not with `self.add(` nor with `FadeIn`.
I've also found that lower render qualities make it further into the animation.


Resolving patch:
diff --git a/manim/mobject/text/tex_mobject.py b/manim/mobject/text/tex_mobject.py
--- a/manim/mobject/text/tex_mobject.py
+++ b/manim/mobject/text/tex_mobject.py
@@ -344,10 +344,6 @@ def _break_up_by_substrings(self):
                 curr_index + num_submobs + len("".join(self.arg_separator.split()))
             )
             if num_submobs == 0:
-                # For cases like empty tex_strings, we want the corresponding
-                # part of the whole MathTex to be a VectorizedPoint
-                # positioned in the right part of the MathTex
-                sub_tex_mob.submobjects = [VectorizedPoint()]
                 last_submob_index = min(curr_index, len(self.submobjects) - 1)
                 sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT)
             else:


Test patch:
diff --git a/tests/module/mobject/text/test_texmobject.py b/tests/module/mobject/text/test_texmobject.py
--- a/tests/module/mobject/text/test_texmobject.py
+++ b/tests/module/mobject/text/test_texmobject.py
@@ -2,6 +2,7 @@
 
 from pathlib import Path
 
+import numpy as np
 import pytest
 
 from manim import MathTex, SingleStringMathTex, Tex, TexTemplate, config, tempconfig
@@ -96,6 +97,23 @@ def test_tex_white_space_and_non_whitespace_args():
     assert len(tex[3]) == len("".join(str_part_4.split()))
 
 
+def test_multi_part_tex_with_empty_parts():
+    """Check that if a Tex or MathTex Mobject with multiple
+    string arguments is created where some of the parts render
+    as empty SVGs, then the number of family members with points
+    should still be the same as the snipped in one singular part.
+    """
+    tex_parts = ["(-1)", "^{", "0}"]
+    one_part_fomula = MathTex("".join(tex_parts))
+    multi_part_formula = MathTex(*tex_parts)
+
+    for one_part_glyph, multi_part_glyph in zip(
+        one_part_fomula.family_members_with_points(),
+        multi_part_formula.family_members_with_points(),
+    ):
+        np.testing.assert_allclose(one_part_glyph.points, multi_part_glyph.points)
+
+
 def test_tex_size():
     """Check that the size of a :class:`Tex` string is not changed."""
     text = Tex("what").center()