In a document I need to use both TrueType and some Type1, so I switched to LuaLatex. But I found a problem when setting math fonts. Here is what I need:
the document uses a TrueType serif font (Crimson) as its main font, but apparently the only suitable match for math is the Type1 font Cochineal, available through newtxmath
in certain parts of the document I need to switch to a sans font (Asap), and there is some math, which I want to be printed with the same font. I rely on the package
sansmath
for this.
The problems is that the no-math
option in fontspec
seems to be an all-or-nothing option.
Here is my setup (I use my specific fonts, but I guess it would be the same with any other similar font setup)
\documentclass{article}
\usepackage[cochineal]{newtxmath}
\usepackage{sansmath}
\usepackage[no-math]{fontspec} % luatex
\setmainfont{Crimson-Roman}[Ligatures=TeX,
ItalicFont = {Crimson-Italic},
BoldFont = {Crimson-Semibold},
BoldItalicFont = {Crimson-SemiboldItalic}]
\setsansfont{Asap-Regular}[
ItalicFont ={Asap-Italic},
BoldFont = {Asap-SemiBold},
BoldItalicFont = {Asap-SemiboldItalic}]
\DeclareSymbolFont{operators}{\encodingdefault}{\familydefault}{m}{n}
\begin{document}
This is a text with the main font, and some math: $\sum_ix_i^2$
\sffamily\sansmath and here is some other text in sans, with some math too $\sum_ix_i^2/2$.
\end{document}
However, because I set the math font with newtxmath
(and the no-math
option in fontspec
) the result is that not all symbols are printed properly when the formula is sans (namely, the "/" symbol disappears from the formula).
On the other hand, if I don't set newtxmath
(or, equivalently, if I don't set the option no-math
), everything is fine with the math in sans, but the main math formulas (in serif) are printed in ComputerModern instead of Crimson.
It seems there is no way to tell LuaTex to rely selectively on a Type1 font only for one math font (the one matching the main/serif font) and not the other (the one used with the sans font).
Or maybe there is something wrong with my setup.
There's an additional problem with \DeclareSymbolFont{operators}...
: this command seems necessary, otherwise numbers are not printed properly with the (cochineal) math font; however, the command affect all math fonts.