I would like to use CM Bright for formulas in Beamer slides with XeLaTeX.

Using CM Bright with pdfLaTeX is straightforward. The code

Formula: \(F = o^r \mu_l^a\)



However, the same code compiled with XeLaTeX gives


The greek µ is still replaced by the CM Bright version, but the latin letters are all CM Roman.

Now this looks like there is an incompatibility between cmbright and XeLaTeX. However, if I do the same thing as an article:

Formula: \(F = o^r \mu_l^a\)

and compile with XeLaTeX, I get


The text font is CM Roman, but the formula is consistently CM Bright. (See also this answer.)

So there appears to be a specific incompatibility of beamer + cmbright + xelatex.

Why is that so, and is there a way around it?

PS: Why XeLaTeX? Because I'm planning to use an OpenType font for text. Off topic, but if someone has a recommendation which OpenType sans serif font goes well with CM Bright, tell me!

  • Try loading the font as in the the question you linked to. This will produce the correct output. – Alan Munn Dec 16 '19 at 22:57

If you load the fonts as in the linked question, you get the desired output.

XeLaTeX needs OpenType or TrueType fonts rather than the Type1 fonts used by pdfLaTeX. So to use CMBright with XeLaTeX for text, you need to load the OpenType version of the font. But there isn't an OpenType version of the math fonts, so we first load the OpenType font as the sans serif font with the no-math option to suppress an changes fontspec might make to the math setup.

Then we load the cmbright package which will effectively load the math font. You can change the sans font again after loading cmbright, but this will not really work effectively, since even in math you will end up with a mixture of CMBright and whatever font you subsequently set, which will not look good.

% !TEX TS-program = XeLaTeX


\setsansfont{cmunb}[        %CMU Bright for text
    BoldFont=*sr, % semibold
    BoldItalicFont=*so, % semibold oblique

\usepackage{cmbright}       %CMU Bright for math
Formula: \(F = o^r \mu_l^a\)

output of code

|improve this answer|||||
  • Thanks! I omitted those lines because I didn't want to specify a sansfont (yet). I guess it's the no-math option? But I didn't load fontspec, so how can it meddle with the fonts? – A. Donda Dec 16 '19 at 23:04
  • I'm sorry, but I accepted your answer too soon. Yes, the code from the linked answer works. However, it only works if I use \setsansfont for CM Bright, too. It doesn't work for example with \setsansfont{Noto Sans}. And the answer does not explain why this problem occurs, and which part(s) exactly of the code circumvent it. no-math and professionalfonts don't seem to be sufficient. What does \setsansfont have to do with getting a math font working? – A. Donda Dec 17 '19 at 3:12
  • @A.Donda I've added some more explanation. You can't really do what you want to do, since the math part of CMBright will use both the sans font and the CMBright math characters in math, so you will always get a mixture unless you make CMBright the sans font. – Alan Munn Dec 17 '19 at 3:44
  • Thanks, now it becomes clearer. I did some experiments, and I found that a) professionalfonts doesn't make a difference b) no-math doesn't make a difference, and c) even \usepackage{cmbright} doesn't make a difference. I get the exact same result if I my preamble is \documentclass{beamer} \usepackage{fontspec} \setsansfont{cmunb}[Extension=.otf,UprightFont=*mr,ItalicFont=*mo,BoldFont=*sr,BoldItalicFont=*so,NFSSFamily=cmbr] – A. Donda Dec 17 '19 at 3:58
  • 1
    @A.Donda Yes, the solution will get you consistent sans math. I'm not a mathematician, but I use some math and I often use a serifed font for presentations. I like Cambria which also has an OpenType Math font, although it's not a free font (but it's likely you have a copy). See Which OpenType Math fonts are available? for lots of other options. – Alan Munn Dec 17 '19 at 4:43

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.