0

I am trying to use STIX Two Math for math. font as a non math font (symbol-wise, letters will be the only thing for math mode), but only for the letters involved in math, i. e. abcdefghijklmnopqrstuvwxyz and ABCDEFGHIJKLMNOPQRSTUVWXYZ.

enter image description here

\documentclass{article}

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

% ======================================================

\renewcommand{\normalsize}{\fontsize{10}{11}\selectfont}

\newcommand{\currentFont}{
    ItalicFont = font Italic,
    BoldFont = font Bold,
    BoldItalicFont = font Bold Italic,
}

\newcommand{\normalFontFeatures}{
    Kerning = On,
    Style = Historic,
    Ligatures = {Historic, Rare},
}

% ======================================================

\setmainfont[
    Language = English,
    \currentFont
    \normalFontFeatures
]{font}

\setmathfont[range = {"0028-"1D7CB}, StylisticSet = 008]{STIX Two Math}
\setmathfont[range = {"41-"7B,}]{font} % range = unicode range for alphabet

% ------------------------------------------------------

\setmathfont[range = {"41-"7B}]{font} % Ignore, check NOTE
\setmathfont[range = bfup -> up]{font Bold} % Ignore, check NOTE
\setmathfont[range = it -> up]{font Italic} % Ignore, check NOTE
\setmathfont[range = bfit -> up]{font Bold Italic} % Ignore, check NOTE

% ======================================================

\begin{document}

    \textit{F=ma}

    $$ \mathbfit{F=ma} \quad \mathbf{F=ma} \quad F=ma \quad \mathit{F=ma}$$

\end{document}

NOTE: unicode-math not deciding what font to use for Bold Italic is a problem with my particular font files. Because of this I am currently using a work-around for getting it to display the way the image shows. But this feels so unnatural and inconvenient to be the correct way though.

Will Robertson solved it But I still have a problem with bfit. It refuses to show \mathbfit{F=ma} with the proper font, this could be fixed though, just by adding

\setmathfont[range = bfit -> up]{Bold Italic}

in the preamble.

Thanks.

6
  • Please clarify why you mean by "latin alphabet". The font for $abc$ or $\mathrm{abc}$ or ... ? Have you tried [range=it] or [range=up] (or both?) ? It would be much clearer if you used a minimal example to demonstrate your problem. – Will Robertson Jan 24 '18 at 4:31
  • I mean whatever they meant in the unicode-math symbols documentation. [range = it] and [range = up] are fine but \nabla stops working since it search on my alphabet font for that symbol, which it does not have. – Suppboi Jan 24 '18 at 18:51
  • also [range = up] overlaps with \nabla, so it searches for \nabla in the font intended for just latin letters. – Suppboi Jan 24 '18 at 19:47
  • Before I look into this further, you know there’s a difference between \mathrm and \symup, \mathbf and \symbf, right? – Will Robertson Jan 25 '18 at 0:04
  • Also please use real fonts from CTAN in your example (like “texgyrepagella-bold.otf”, etc). I have no idea whether you’re trying to load maths fonts or text fonts. – Will Robertson Jan 25 '18 at 0:06
3

For a start, this seems to work for me:

\documentclass{article}
\usepackage{unicode-math}
\setmathfontface\mathrm{texgyreheros-regular.otf}
\begin{document}
$\mathrm{abc}$
\end{document}

Please provide a complete minimal example to demonstrate the rest and I might be able to answer in more detail.


Here's another example that will hopefully work for you:

\documentclass{article}
\usepackage[math-style=upright]{unicode-math}
\setmathfont{xits-math.otf}
\setmathfont{texgyreheros-regular.otf}[range=up/{Latin,latin}]
\begin{document}
    \[
       \symbfit{F=ma} \quad \symbf{F=ma} \quad F=ma \quad \symit{F=ma}
    \]
\end{document}

Is that what you're trying to achieve?

3
  • It does work, but i need to type \mathrm every time. Is there a way to set the math font to always use mathrm unless told otherwise? – Suppboi Jan 24 '18 at 18:46
  • @Suppboi — does this edit address your problem? – Will Robertson Jan 25 '18 at 0:19
  • it does, that [range = up/{Latin, latin}] bit is the key. Thanks a lot! – Suppboi Jan 25 '18 at 0:25

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.