0

I am trying to incorporate nicematrix objects in a Manim video and I am getting some spacing issues.

The code

from manim import *

class Chap8_Recap36b(Scene):
    def construct(self):
        # self.camera.background_color = WHITE

        myTex = TexTemplate()
        myTex.add_to_preamble(r'\usepackage{nicematrix}')

        self.wait()

        line1 = MathTex(r'\begin{bNiceMatrix}a & b \end{bNiceMatrix}', tex_template = myTex)
        # line1.scale(0.5)

        self.play(Write(line1))
        self.wait()

gives me the following output :

bNiceMatrix output

I took a look at the temp tex/log/dvi files generated by Manim during compilation, and everything seems normal, as if the problem occurred later in the process, when dvi is converted to svg If I swap the bNiceMatrix for a simple bmatrix, the rendering is correct :

enter image description here

Any idea what's happening? I hope to find a matrix & Manim specialist here. Thanks in advance.

2
  • 2
    The documentation of nicematrix say: "As usual with pgf, the coordinates of these nodes are written in the aux to be used on the next compilation and that’s why nicematrix may need several compilations."
    – vi pa
    Nov 26 at 7:22
  • Could it still be the reason since the dvi output is rendered correctly?
    – Zork
    Nov 26 at 10:25
1

The problem was when Manim is using dvisvgm to convert the dvi file to svg. Although no error was outputted by Manim, dvisvgm had problems converting the file and if you called it on its own, it showed a problem related to Ghostscript being needed for the conversion of special characters, but not being found.

I had no success with linking manually to Ghostscript by using the --libgs=/usr/... argument when calling dvisvgm. I finally found a working solution which consists of

  1. Installing Ghostscript using Homebrew
  2. Adjusting the permissions in the /usr/local folder (not ideal, but it works)
  3. Adding a LIBGS environment variable that points to the Homebrew version of Ghostscript (since Manim doesn't use manual links when calling dvisvgm)

That solution was found in that chain of messages : https://tug.org/pipermail/macostex-archives/2020-October/057374.html

Hopefully this can help future Manim users.

My setup :

  • OS X Big Sur 11.4
  • MacTex 2021
  • Manim Community v0.12.0
  • dvisvgm 2.11.1
  • Ghostscript 9.55.0 (Homebrew)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.