I downloaded and installed MaTeX from here.

I installed texlive2019.And I configured Matex as follows, but there was a strange error:

 "pdfLaTeX" -> "D:\\texlive\\2019\\bin\\win32\\pdflatex.exe", 
 "Ghostscript" -> "D:\\texlive\\2019\\tlpkg\\tlgs\\bin\\gswin32c.exe"]

File::badfile: The specified argument should be a valid string or File.

MaTeX["\\int x \\, dx = \\frac{x^2}{2} + \\text{const.}"]

MaTeX::gserr: Error while running Ghostscript. GPL Ghostscript 9.26: Can't find initialization file gs_init.ps.

I want to know the cause of the error report and how to solve it.

  • $\begingroup$ Try MaTeX@..... $\endgroup$ Feb 7, 2020 at 10:24
  • 1
    $\begingroup$ have you read this? zhuanlan.zhihu.com/p/102478498 $\endgroup$ Feb 7, 2020 at 11:09
  • $\begingroup$ Have you tested if your TeXLive installation work? $\endgroup$
    – vi pa
    Feb 8, 2020 at 0:51
  • $\begingroup$ @vipa My texlive2019 can compile Chinese PDF. I think this error is probably caused by the slow update speed of Matex and the new change of texlive2019. $\endgroup$ Feb 8, 2020 at 1:09

1 Answer 1


Through this link, I found the cause of similar problems:

> gswin32c -h としてみると,

TeX Live に入っている Ghostscript は,直接「gswin32c」というコマンドで呼び出すことを想定していません。 あくまでそれは TeX と一緒に使うためのものなので,「rungs」という名前で呼び出すことになっていて, 外部ツールから呼び出すことはサポート外と書かれています。 tlpkg フォルダの中の tlgs/README.TEXLIVE を読んでください。Web 上で読むならここですね。

Translate this into English through Google translate as follows:

Ghostscript included in TeX Live is not supposed to be called directly with the command "gswin32c".

It is only for use with TeX, so it is called as "rungs", and calling from an external tool is not supported.

Read TLGS / readme.texlive in the tlpkg folder. It's here if you read on the web.

I found out how to correctly configure Matex in the environment of texlive2019 as follows:

<< MaTeX`
 "pdfLaTeX" -> "D:\\texlive\\2019\\bin\\win32\\xelatex.exe", 
 "Ghostscript" -> "D:\\texlive\\2019\\bin\\win32\\rungs.exe"]
MaTeX["\\ce{2H2 + O3 ->T[\\text{燃烧}] 2H2O}", 
 "Preamble" -> {"\\usepackage[version=4]{mhchem}", 
   "\\usepackage{ctex}"}, FontSize -> 20]

enter image description here

We can also download the independent Ghostscript from here and configure Matex after installation:

 "pdfLaTeX" -> "D:\\texlive\\2019\\bin\\win32\\xelatex.exe", 
 "Ghostscript" -> "C:\\gs\\gs9.50\\bin\\gswin32c.exe"]

In this way, the correct output can also be obtained.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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