1
$\begingroup$

I require assistance with installing and configuring Matex and Ghostscript for use with Mathematica on my Mac system. I have successfully installed Matex and executed the following codes on Mathematica notebook provided in this link, resulting in expected outputs

<< MaTeX`

MaTeX[HoldForm@Integrate[Exp[-x], {x, 0, Infinity}]]

MaTeX["\\sum_{k=1}^{\\infty} \\frac{1}{k^2} = \\frac{\\pi^2}{6}", 
 FontSize -> 24]

However, I am encountering difficulties installing Ghostscript on my system. I have attempted to run the following command in terminal -

gs -h

Output -

GPL Ghostscript 10.01.1 (2023-03-27)
Copyright (C) 2023 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
...

But the Mathematica code utilizing Matex and Ghostscript is still not functioning. Can someone please assist me with the installation process of Ghostscript, preferably by providing step-by-step guidance? I am not well-versed in this matter. Thank you in advance for your help.

While I run the following command

Plot[x^2, {x, 0, 10}, Frame -> True, 
 FrameLabel -> {{MaTeX["\\color{red}\\Omega_\\text{y}", 
     FontSize -> 30], 
    None}, {MaTeX["f \\;/\\; \\text{k}", FontSize -> 30], None}}]

I am getting the following error message - "MaTeX::texerr: Error while running LaTeX. ! Undefined control sequence. \color {red}\Omega \text {y} \MaTeX{\color{red}\Omega\text{y}} ! ==> Fatal error occurred, no output PDF file produced!"

The problem is coming from the part "\ \color{red}". If I remove this, there is no error.

$\endgroup$
3
  • 3
    $\begingroup$ Apparently, Ghostscript is installed on your system... Please describe what exactly happens when you try to use MaTeX. E.g., are there any error messages? Honestly, "still not functioning" is a quite useless description of the problem. It makes it very hard for others to guess what the cause is and how it can be resolved. $\endgroup$ Apr 18, 2023 at 6:02
  • $\begingroup$ I've included the error I'm getting. Thanks in advance. $\endgroup$
    – PoreyS
    Apr 18, 2023 at 10:35
  • $\begingroup$ Since this issue had nothing to do with Ghostscript, can you please edit the title (and preferably also the question contents) so future readers wouldn't be confused? $\endgroup$
    – Szabolcs
    Apr 21, 2023 at 15:52

1 Answer 1

3
$\begingroup$

Apparently, you simply have to add the xcolor package to MaTeX preamle. Try

SetOptions[MaTeX, "Preamble" -> {"\\usepackage{xcolor}"}]
$\endgroup$
5
  • 3
    $\begingroup$ Indeed, thanks for answering. If there is a problem with Ghostscript, then MaTeX will not work at all. The fact that some commands succeeded shows that Ghostscript is fine. $\endgroup$
    – Szabolcs
    Apr 18, 2023 at 12:56
  • 1
    $\begingroup$ @henrik-schumacher I am still getting the error. Kindly see here - imgur.com/a/oEzsLUk $\endgroup$
    – PoreyS
    Apr 21, 2023 at 15:42
  • 1
    $\begingroup$ Oops, MaTeX wants "Preamble" to be a list. (See my edit.) $\endgroup$ Apr 21, 2023 at 15:48
  • $\begingroup$ @henrik-schumacher Thank you very much.It is finally working. Your kind response is much appreciated. $\endgroup$
    – PoreyS
    Apr 21, 2023 at 16:45
  • 1
    $\begingroup$ You're welcome! $\endgroup$ Apr 21, 2023 at 22:03

Your Answer

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

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