Manim: CTex fontset `mac' is unavailable in current mode

Created on 26 Dec 2017  路  5Comments  路  Source: 3b1b/manim

I'm trying to run manim on a mac with latex installed via the Tex Live Utility. I'm trying to run old_projects/eoc/chapter1.py. Perhaps that's not intended to work any longer.

I see this error in a tex log:

.................................................
. LaTeX info: "xparse/define-command"
.
. Defining command \CTeX with sig. '' on line 746.
.................................................

(/usr/local/texlive/2017/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def
File: ctex-fontset-mac.def 2017/11/22 v2.4.11 Mac OS X fonts definition (CTEX)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Critical ctex error: "fontset-unavailable"
!
! CTeX fontset `mac' is unavailable in current mode.
!
! See the ctex documentation for further information.
!
! For immediate help type H .
!...............................................

Any thoughts anyone?

Most helpful comment

For me, what helped was to replace the above with

def tex_to_dvi(tex_file):
    result = tex_file.replace(".tex", ".xdv")
    if not os.path.exists(result):
        commands = [
            "xelatex",
            "-no-pdf",
            "-interaction=batchmode",
            "-halt-on-error",
            "-output-directory=" + TEX_DIR,
            tex_file,
            ">",
            get_null()
        ]
        exit_code = os.system(" ".join(commands))
        if exit_code != 0:
            latex_output = ''
            log_file = tex_file.replace(".tex", ".log")
            if os.path.exists(log_file):
                with open(log_file, 'r') as f:
                    latex_output = f.read()
            raise Exception(
                "Latex error converting to dvi. "
                "See log output above or the log file: %s" % log_file)
    return result

def dvi_to_svg(dvi_file, regen_if_exists = False):
    """
    Converts a dvi, which potentially has multiple slides, into a
    directory full of enumerated pngs corresponding with these slides.
    Returns a list of PIL Image objects for these images sorted as they
    where in the dvi
    """
    result = dvi_file.replace(".xdv", ".svg")
    if not os.path.exists(result):
        commands = [
            "dvisvgm",
            dvi_file,
            "-n",
            "-v",
            "0",
            "-o",
            result,
            ">",
            get_null()
        ]
        os.system(" ".join(commands))
    return result

what this does is forces xelatex to output an xdv that dvisvgm can then use.

All 5 comments

modify mobject/tex_mobject.py
348 commands = [
349 "latex",
350 "-interaction=batchmode",
351 "-halt-on-error",
352 "-output-directory=" + TEX_DIR,
353 tex_file,
354 ">",
355 get_null()
356 ]

to:

348 commands = [
349 "xelatex",
350 "-interaction=batchmode",
351 "-halt-on-error",
352 "-output-directory=" + TEX_DIR,
353 tex_file,
354 ">",
355 get_null()
356 ]

What helped me to resolve this issue, was to not use CTEX. In the manim root folder you have two .tex templates. You can comment out the \usepackage[UTF8]{ctex} line and uncomment the \usepackage[utf8x]{inputenc} line. This helped me and the examples, as well as the old projects, seem to run without any latex problems.

For me, what helped was to replace the above with

def tex_to_dvi(tex_file):
    result = tex_file.replace(".tex", ".xdv")
    if not os.path.exists(result):
        commands = [
            "xelatex",
            "-no-pdf",
            "-interaction=batchmode",
            "-halt-on-error",
            "-output-directory=" + TEX_DIR,
            tex_file,
            ">",
            get_null()
        ]
        exit_code = os.system(" ".join(commands))
        if exit_code != 0:
            latex_output = ''
            log_file = tex_file.replace(".tex", ".log")
            if os.path.exists(log_file):
                with open(log_file, 'r') as f:
                    latex_output = f.read()
            raise Exception(
                "Latex error converting to dvi. "
                "See log output above or the log file: %s" % log_file)
    return result

def dvi_to_svg(dvi_file, regen_if_exists = False):
    """
    Converts a dvi, which potentially has multiple slides, into a
    directory full of enumerated pngs corresponding with these slides.
    Returns a list of PIL Image objects for these images sorted as they
    where in the dvi
    """
    result = dvi_file.replace(".xdv", ".svg")
    if not os.path.exists(result):
        commands = [
            "dvisvgm",
            dvi_file,
            "-n",
            "-v",
            "0",
            "-o",
            result,
            ">",
            get_null()
        ]
        os.system(" ".join(commands))
    return result

what this does is forces xelatex to output an xdv that dvisvgm can then use.

Closing, since this issue seems to be resolved.

I encounter the same problem for ctex package not suitable in Mac.

Was this page helpful?
0 / 5 - 0 ratings