[Tex/LaTex] Using different text and math fonts with unicode-math

fontsluatexunicode-mathxetex

When using pdfLaTeX it is sometimes possible, when using different text and math font sets, to take the fonts for operators like sin and cos from the text font even within formulae. Thus, using the lucimatx package, I can write

\renewcommand{\rmdefault}{bch}
\usepackage[onlymath=true]{lucimatx}

and then formulae will be set using lucida for math fonts, but charter (i.e., bch) for text-like objects like sin and cos, so matching the text using in the document body. This is what one wants from a typographic standpoint.

Is something similar possible using unicode-math? If I use

\usepackage{unicode-math}
\setmainfont{Charis SIL}   % Charis is a charter clone
\setmathfont{LucidaBrightMathOT.otf}

It seems to use lucida fonts for everything in math mode. The same if I use xits math fonts. I may, of course, be missing the equivalent of the onlymath option in unicode-math. Any help would be appreciated.

Regards
Geoff Vallis

Best Answer

I'm not really sure you want to mix Charis SIL and Lucida Bright Math. However, here's the workaround you're looking for:

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Charis SIL}   % Charis is a charter clone
\setmathfont[Scale=MatchLowercase]{LucidaBrightMathOT.otf}
\setmathfont[range={`A-`Z,`a-`z}]{Charis SIL}

\begin{document}
sin $\sin x=y$ \textit{x}
\end{document}

The “sin” outside the formula is just to show that Charis SIL is really used for the operator. The trailing italic “x” is for comparing with the math mode “x”.

You'll get warnings such as

Font 'Charis SIL' does not contain script 'Math'.

that are unavoidable. Note the Scale option for loading Lucida Bright Math.

enter image description here