Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brace doesn't work with unicode-math #2288

Open
xiao-ming-hub opened this issue Jan 1, 2025 · 0 comments
Open

Brace doesn't work with unicode-math #2288

xiao-ming-hub opened this issue Jan 1, 2025 · 0 comments
Labels

Comments

@xiao-ming-hub
Copy link

xiao-ming-hub commented Jan 1, 2025

Describe the bug

When I use unicode-math package in tex_templates.yml and I use Brace to draw a curly brace, an error has occurred.

Code:

# custom_config.yml
tex:
  template: "basic"
# tex_templates.yml
# Line 8 and 9 are added
basic:
  description: ""
  compiler: latex
  preamble: |-
    \usepackage[english]{babel}
    \usepackage[mathrm=sym]{unicode-math}
    \setmathfont{Noto Sans Math}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{xcolor}
square = Square().set_fill(BLUE_E, 1)
# Here's where the error happens:
brace = Brace(square, UP)

Wrong display or Error traceback:

Traceback (most recent call last):
  ...
  File "/.../manimlib/scene/scene.py", line 155, in run
    self.construct()
    ~~~~~~~~~~~~~~^^
  File "/.../tmp.py", line 5, in construct
    brace = Brace(square, UP)
  File "/.../manimlib/mobject/svg/brace.py", line 50, in __init__
    self.set_initial_width(target_width)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/.../manimlib/mobject/svg/brace.py", line 58, in set_initial_width
    for tip, rect, vect in [(self[0], self[1], RIGHT), (self[5], self[4], LEFT)]:
                                      ~~~~^^^
  File "/.../manimlib/mobject/svg/string_mobject.py", line 551, in __getitem__
    return super().__getitem__(value)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/.../manimlib/mobject/mobject.py", line 405, in __getitem__
    return self.split().__getitem__(value)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range

Additional context

The pack unicode-math is a convenient way to set the math font, but it also changes the way curly braces are rendered. LaTeX's original method was to use six characters to adjust the length by stretching, but in this package, the length is spliced according to the desired length, resulting in the subscript of self not corresponding.

xiao-ming-hub added a commit to xiao-ming-hub/manim that referenced this issue Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant