# Using different text and math fonts with unicode-math

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

• Welcome to TeX.SE! A quick hint: if you indent lines by four spaces, they will be autoformatted as LaTeX code. – Mico Oct 14 '13 at 12:24
• Thanks for the edits and the hints. I'm new to TeX.SE (and to unicode-math). – GeoffV Oct 14 '13 at 13:02

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.

• Thanks. Your solution almost works but not quite because upright operators like \nabla need to be taken from the original math font and not the text font. Building on your code it seems that a working solution mimicking the 'onlymath' option is: \documentclass{article} \usepackage{unicode-math} \setmainfont{Charis SIL} % Charis is a charter clone \setmathfont[Scale=MatchLowercase]{LucidaBrightMathOT.otf} \setmathfont[range=\mathup/{latin,Latin,num}]{Charis SIL} \begin{document} sin $\sin x=y$ \textit{x} and $\nabla x = 123$123 \end{document} – GeoffV Oct 14 '13 at 17:07
• @Geoff Check with the new version. – egreg Oct 14 '13 at 17:11
• @egeg Or, to get the numbers in the text font: \setmathfont[range={A-Z,a-z,1-9}]{Charis SIL} (I haven't figured out the proper formatting in posts yet, sorry!) – GeoffV Oct 14 '13 at 17:19
• I guess that range=\mathup/{latin,Latin,num} is the best approach. – egreg Oct 14 '13 at 17:24
• Yes I agree. I consider this question answered and will so mark it if I can figure that out... – GeoffV Oct 14 '13 at 17:36