3
$\begingroup$

My system: Windows 10, Mathematica 11.2, MikTeX 2.9

I am in the process of learning more about the features of Szabolcs Horvát's nice paclet. This time I am toying with the color choices for the produced text. I have this (questionably) bright idea to match the colors of components of a figure with the accompanying MaTeX-outputs. Unfortunately the sets of available colors don't quite match.

After the start

In[1]:=<< MaTeX`
In[2]:=SetOptions[MaTeX, "Preamble" -> {"\\usepackage{color}"}]

many things work splendidly. But the input

In[3]:=Graphics[Text[MaTeX["\\color{orange}{\\bf{x}^\\perp}", FontSize -> 16], {2, 1.3}]];

gives the error message saying that the color orange is not defined. Hardly a surprise given that a bit of digging reveals that orange is not available in the prescribed LaTeX-package.

If I were writing either LaTeX or Mathematica code I would know what to do. In Mathematica I would use RGBColor with appropriate parameters. In LaTeX I would try something like \definecolor{grey}{rgb}{0.8, 0.8, 0.8} to define a color in a macro.

How can I do this with MaTeX?

  • load a different TeX-package, which?
  • define the desired color by inserting a macro, how?
$\endgroup$

1 Answer 1

2
$\begingroup$

I was at my dullest. Or, if not that, mostly oblivious to what the In[2] command in the snippet from the question body does.

Apparently it is possible to pass several LaTeX-commands within the preamble. A bit of testing shows that

   In[2]:=SetOptions[MaTeX, 
     "Preamble" -> {"\\usepackage{color}", 
       "\\definecolor{orange}{rgb}{1,0.6,0}"}]

does exactly what you might wistfully hope it would :-)

$\endgroup$
2
  • $\begingroup$ Also magenta may be more distinguishable from red than orange, and hence a better choice. $\endgroup$ Jan 22, 2021 at 6:46
  • 2
    $\begingroup$ Mathematica also uses the range $[0, 1]$ in RGBColor, as well as most other constructs. $\endgroup$
    – Szabolcs
    Jan 22, 2021 at 10:31

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.