Experienced coder but newbie on latex, I can't wrap my head around the way font and font packages behaves !

I would be glad to have a working snippet, but if you have some generic advises about the philosophy of the system, I take.

I'm trying to use the cochineal font for all text, and the stix2 font for all math. My first attempt was :


where I got:

! Undefined control sequence.
<recently read> \setmathfont

l.7 \setmathfont

which seems strange, since this control sequence is used by me on numerous other templates! So I tried some other random combinations, and also black magic, and rabbit paws, in vain.

How can I set a math font and a text font? How does fallback works? Where do the Latin and Greek letters come from in math, from the main font? And about unicode-math should I still use \usepackage[T1]{fontenc} with it? And what's the logic here?

1 Answer 1


The easiest way to use Cochineal for text and STIX2 for math is probably to use cochineal and newtxmath with stix2 option.

A test to see the cochineal text font.
f(z) = \frac{1}{2\pi i} \int \frac{f(\zeta)}{\zeta - z} \,\mathrm{d}\zeta.

Also, in your example, it's not surprising that \setmathfont is undefined: this command is defined by the unicode-math package, which is not loaded.

  • Thank you ! it seems to do the job :) I'm still struggling to understand what is the role of newtxmath and why \usepackage{stix2} \usepackage[T1]{fontenc} and \usepackage[stix2]{newtxmath} gives different symbols for integrals or sums... (I preferred the stix2 ones :D)
    – yota
    May 19, 2020 at 15:23

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.