2

I've recently been experimenting with typesetting and I stumbled upon an issue, where the following preamble:

\documentclass[12pt,a4paper]{memoir}

\usepackage{stix2}
\usepackage{mathspec}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{fontspec}

\setmainfont[
Extension={.otf},
UprightFont={*-Regular},
BoldFont={*-Bold}, 
ItalicFont={*-Italic},
BoldItalicFont={*-BoldItalic}
]{StixTwoText}

\setmathfont(Latin,Greek){StixTwoText-Italic.otf}
\setmathfont(Digits){StixTwoText-Regular.otf} 
\setmathrm[BoldFont={StixTwoText-Bold.otf}]{StixTwoText-Regular.otf}

Generates errors written in the title. Removing both the \setmathfont and \setmathrm OR \usepackage{stix2} commands fixes the issue, but changes the math fonts.

Can I somehow use the STIX Two Text Italic font in math mode while still having the alternate math symbols defined in stix2?

2
  • 1
    Do you need mathspec at all? I believe that unicode-math is better with the fonts you want.
    – egreg
    Jul 19 at 17:02
  • @egreg Perhaps that would be a good idea. I've never used unicode-math. How would I go about implementing the above code with it?
    – J0K3R_12QQ
    Jul 19 at 17:07
3

You should use unicode-math for this, which supports STIX2 Math.

\documentclass[12pt,a4paper]{memoir}

\usepackage{fontspec}
\usepackage[math-style=ISO]{unicode-math}

\setmainfont[
  Extension=.otf,
  UprightFont=*-Regular,
  BoldFont=*-Bold, 
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
]{STIXTwoText}

\setmathfont[
  Extension=.otf,
]{STIXTwoMath-Regular}

\begin{document}

$\alpha+x+\Gamma+\symrm{A}+\symbf{B}+123$

\end{document}

enter image description here

If you remove the math-style=ISO option, you get

enter image description here

Note that STIX should be spelled all capitals; on case-insensitive file systems Stix might find the font, but the document wouldn't be portable.

2
  • Thanks, that seems to work. One more question: is it possible to change the other math fonts in this setup? For example, with mathspec I was able to change the mathfrak font style with \setmathfrak. Can I do something similar in unicode-math?
    – J0K3R_12QQ
    Jul 19 at 18:49
  • Ok, I seem to have found an answer to that question here: tex.stackexchange.com/questions/437834/… Thanks again for your help.
    – J0K3R_12QQ
    Jul 19 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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