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

CTex fontset `mac' is unavailable in current mode #64

Closed
Glidos opened this issue Dec 26, 2017 · 5 comments
Closed

CTex fontset `mac' is unavailable in current mode #64

Glidos opened this issue Dec 26, 2017 · 5 comments

Comments

@Glidos
Copy link

Glidos commented Dec 26, 2017

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?

@willsure
Copy link

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 ]

@Ogofo
Copy link

Ogofo commented Feb 13, 2018

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.

@Sreejeshgnair
Copy link

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.

@eulertour
Copy link
Collaborator

Closing, since this issue seems to be resolved.

@sharkdeng
Copy link

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

eulertour pushed a commit to eulertour/manim-3b1b that referenced this issue Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants