# Using cmbright in XeLaTex for Math and Text

I would like to use XeTex and use a Sans Serif font for Math and Text. When I use cmbright I always get warning messages.

\documentclass[12pt, a4paper]{article}

\usepackage{cmbright}       %CMU Bright for math
\usepackage{fontspec}
\setsansfont{cmunb}[        %CMU Bright for text
Extension=.otf,
UprightFont=*mr,
ItalicFont=*mo,
BoldFont=*sr, % semibold
BoldItalicFont=*so, % semibold oblique
]

\begin{document}
% I get 2 warnings:
% Warning: cmbright.sty
% LaTeX Font Warning: Font shape TU/cmbr/m/n' undefined (Font) using TU/lmr/m/n' instead on input line 144.
% Warning: root.tex
% LaTeX Font Warning: Some font shapes were not available, defaults substituted.
\end{document}

• The warnings are harmless. – Ulrike Fischer Mar 14 '17 at 13:48
• Ok. They might be harmless but is there a way to define the missing font shape by myself? So that I can get rid of the warning? – Georg Mar 15 '17 at 13:29

You can get rid of the warnings by changing the loading order of the packages and giving your sans font the family name used by cmbright.

\documentclass[12pt, a4paper]{article}

\usepackage[no-math]{fontspec}
\setsansfont{cmunb}[        %CMU Bright for text
Extension=.otf,
UprightFont=*mr,
ItalicFont=*mo,
BoldFont=*sr, % semibold
BoldItalicFont=*so, % semibold oblique
NFSSFamily=cmbr
]

\usepackage{cmbright}       %CMU Bright for math

% as cmbright sets \ttdefault to cmtl either:
%\setmonofont{whatever}[NFSSFamily=cmtl]
% or
%\renewcommand{\ttdefault}{lmtt}

\begin{document}
abc $a=b$
\end{document}


But it would naturally simpler if cmbright wouldn't issue a \normalfont command. It looks quite useless.