manim icon indicating copy to clipboard operation
manim copied to clipboard

russian text in TeX

Open leobreslav opened this issue 3 years ago • 1 comments

Description of bug / unexpected behavior

I want to add some russian text in TeX mode but get errors.

How to reproduce the issue

from manim import *
from manim.utils import tex_templates

my_preamble = r"""
\usepackage[english, russian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
"""

class a_scene(Scene):
    def construct(self):
        my_template = TexTemplate(preamble=my_preamble)

        t1 = Tex("Привет!", tex_template=my_template)

        self.play(Write(t1))
        self.wait()

Logs

Terminal output
C:\Users\leobr\Desktop\project>manim -v DEBUG try.py Example
Manim Community v0.15.2

C:\tools\Manim\Lib\site-packages\manim\mobject\svg\svg_mobject.py:344: UserWarning: media/Tex/3c93e77d664998b3.svg contains a reference to id #g1-76, which is not recognized
  warnings.warn(warning_text)
C:\tools\Manim\Lib\site-packages\manim\mobject\svg\svg_mobject.py:344: UserWarning: media/Tex/3c93e77d664998b3.svg contains a reference to id #g0-65, which is not recognized
  warnings.warn(warning_text)
C:\tools\Manim\Lib\site-packages\manim\mobject\svg\svg_mobject.py:344: UserWarning: media/Tex/3c93e77d664998b3.svg contains a reference to id #g1-84, which is not recognized
  warnings.warn(warning_text)
C:\tools\Manim\Lib\site-packages\manim\mobject\svg\svg_mobject.py:344: UserWarning: media/Tex/3c93e77d664998b3.svg contains a reference to id #g1-69, which is not recognized
  warnings.warn(warning_text)
C:\tools\Manim\Lib\site-packages\manim\mobject\svg\svg_mobject.py:344: UserWarning: media/Tex/3c93e77d664998b3.svg contains a reference to id #g1-88, which is not recognized
  warnings.warn(warning_text)
┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ C:\tools\Manim\Lib\site-packages\manim\cli\render\commands.py:118 in render                      │
│                                                                                                  │
│   115 │   │   for SceneClass in scene_classes_from_file(file):                                   │
│   116 │   │   │   try:                                                                           │
│   117 │   │   │   │   scene = SceneClass()                                                       │
│ > 118 │   │   │   │   scene.render()                                                             │
│   119 │   │   │   except Exception:                                                              │
│   120 │   │   │   │   error_console.print_exception()                                            │
│   121 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ C:\tools\Manim\Lib\site-packages\manim\scene\scene.py:222 in render                              │
│                                                                                                  │
│    219 │   │   """                                                                               │
│    220 │   │   self.setup()                                                                      │
│    221 │   │   try:                                                                              │
│ >  222 │   │   │   self.construct()                                                              │
│    223 │   │   except EndSceneEarlyException:                                                    │
│    224 │   │   │   pass                                                                          │
│    225 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ C:\Users\leobr\Desktop\project\try.py:19 in construct                                            │
│                                                                                                  │
│   16 │   │   │   font_size=144,                                                                  │
│   17 │   │   )                                                                                   │
│   18 │   │                                                                                       │
│ > 19 │   │   title = Tex(r"\LaTeX")                                                              │
│   20 │   │   basel = MathTex(r"\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}")               │
│   21 │   │   VGroup(title, basel).arrange(DOWN)                                                  │
│   22 │   │   self.play(                                                                          │
│                                                                                                  │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:434 in __init__               │
│                                                                                                  │
│   431 │   def __init__(                                                                          │
│   432 │   │   self, *tex_strings, arg_separator="", tex_environment="center", **kwargs           │
│   433 │   ):                                                                                     │
│ > 434 │   │   super().__init__(                                                                  │
│   435 │   │   │   *tex_strings,                                                                  │
│   436 │   │   │   arg_separator=arg_separator,                                                   │
│   437 │   │   │   tex_environment=tex_environment,                                               │
│                                                                                                  │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:288 in __init__               │
│                                                                                                  │
│   285 │   │   │   │   tex_template=self.tex_template,                                            │
│   286 │   │   │   │   **kwargs,                                                                  │
│   287 │   │   │   )                                                                              │
│ > 288 │   │   │   self._break_up_by_substrings()                                                 │
│   289 │   │   except ValueError as compilation_error:                                            │
│   290 │   │   │   if self.brace_notation_split_occurred:                                         │
│   291 │   │   │   │   logger.error(                                                              │
│                                                                                                  │
│ C:\tools\Manim\Lib\site-packages\manim\mobject\text\tex_mobject.py:362 in                        │
│ _break_up_by_substrings                                                                          │
│                                                                                                  │
│   359 │   │   │   │   # positioned in the right part of the MathTex                              │
│   360 │   │   │   │   sub_tex_mob.submobjects = [VectorizedPoint()]                              │
│   361 │   │   │   │   last_submob_index = min(curr_index, len(self.submobjects) - 1)             │
│ > 362 │   │   │   │   sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT)            │
│   363 │   │   │   else:                                                                          │
│   364 │   │   │   │   sub_tex_mob.submobjects = self.submobjects[curr_index:new_index]           │
│   365 │   │   │   new_submobjects.append(sub_tex_mob)                                            │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
IndexError: list index out of range

System specifications

System Details
  • Win 11 Home 21H2
  • RAM: 16
  • Python version 3.10.5
  • Installed modules (provide output from pip list):
  • Package Version

anyio 3.6.1 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 asttokens 2.0.5 attrs 21.4.0 Babel 2.10.3 backcall 0.2.0 beautifulsoup4 4.11.1 bleach 5.0.0 certifi 2022.6.15 cffi 1.15.0 charset-normalizer 2.0.12 click 8.1.3 click-default-group 1.2.2 cloup 0.13.1 colorama 0.4.5 colour 0.1.5 commonmark 0.9.1 debugpy 1.6.0 decorator 5.1.1 defusedxml 0.7.1 entrypoints 0.4 executing 0.8.3 fastjsonschema 2.15.3 glcontext 2.3.6 idna 3.3 ipykernel 6.15.0 ipython 8.4.0 ipython-genutils 0.2.0 isosurfaces 0.1.0 jedi 0.18.1 Jinja2 3.1.2 json5 0.9.8 jsonschema 4.6.0 jupyter-client 7.3.4 jupyter-core 4.10.0 jupyter-server 1.17.1 jupyterlab 3.4.3 jupyterlab-pygments 0.2.2 jupyterlab-server 2.14.0 manim 0.15.2 ManimPango 0.4.1 mapbox-earcut 0.12.11 MarkupSafe 2.1.1 matplotlib-inline 0.1.3 mistune 0.8.4 moderngl 5.6.4 moderngl-window 2.4.1 multipledispatch 0.6.0 nbclassic 0.3.7 nbclient 0.6.4 nbconvert 6.5.0 nbformat 5.4.0 nest-asyncio 1.5.5 networkx 2.8.4 notebook 6.4.12 notebook-shim 0.1.0 numpy 1.22.4 packaging 21.3 pandocfilters 1.5.0 parso 0.8.3 pickleshare 0.7.5 Pillow 9.1.1 pip 22.1.2 prometheus-client 0.14.1 prompt-toolkit 3.0.29 psutil 5.9.1 pure-eval 0.2.2 pycairo 1.21.0 pycparser 2.21 pydub 0.25.1 pyglet 1.5.26 Pygments 2.12.0 pyparsing 3.0.9 pyrr 0.10.3 pyrsistent 0.18.1 python-dateutil 2.8.2 pytz 2022.1 pywin32 304 pywinpty 2.0.5 pyzmq 23.1.0 requests 2.28.0 rich 12.4.4 scipy 1.8.1 screeninfo 0.8 Send2Trash 1.8.0 setuptools 58.1.0 six 1.16.0 skia-pathops 0.7.2 sniffio 1.2.0 soupsieve 2.3.2.post1 srt 3.5.2 stack-data 0.3.0 terminado 0.15.0 tinycss2 1.1.1 tornado 6.1 tqdm 4.64.0 traitlets 5.3.0 urllib3 1.26.9 watchdog 2.1.9 wcwidth 0.2.5 webencodings 0.5.1 websocket-client 1.3.2 wheel 0.37.1

PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020): MiKTeX 22.3
  • Installed LaTeX packages: all
FFMPEG

Output of ffmpeg -version:

PASTE HERE

Additional comments

leobreslav avatar Jun 24 '22 20:06 leobreslav

I can reproduce this issue, can't seem to figure out what's causing it though. I tried putting the text in a \foreignlanguage{russian} as described here and that made it write to TeX fine and generate the SVG as well. But for some reason the only character displayed is the exclamation mark. I tried checking the DVI file being produced and MiKTeX's DVI viewer couldn't open it saying something like Some PostScript specials could not be rendered. which might be a cause for it since it would run into problems later with dvisvgm later.

Requires more investigation, if anyone is willing to take this up.

a_scene_ManimCE_v0 15 2

kilacoda avatar Jul 19 '22 13:07 kilacoda