4

I am starting to use XeLaTeX. I tried, as an example, to use cmbright. But I do not obtain a sans serif output. Do I need to tell something else in the preamble?

\documentclass[10pt,a4paper]{article}

\usepackage{fontspec}
\usepackage{cmbright}
\usepackage{polyglossia}
\setmainlanguage{french}


\author{Plop}
\title{Test fonts xelatex}

\usepackage{lipsum}

\begin{document}

\maketitle

\lipsum[1-4]

\end{document}

enter image description here

1
  • Yes, it does. Thus how shoudl I generally set up a prehamble using xelatex ?
    – Ger
    May 18, 2016 at 12:43

1 Answer 1

3

The package cmbright doesn't make sense with XeLaTeX/fontspec, because it loads legacy fonts.

You can use the CM-Unicode version of CMBright.

\documentclass[10pt,a4paper]{article}

\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}

\setmainfont{cmunb}[
  Extension=.otf,
  UprightFont=*mr,
  ItalicFont=*mo,
  BoldFont=*bx,
  BoldItalicFont=*xo,
]

\author{Plop}
\title{Test fonts xelatex}

\usepackage{lipsum}

\begin{document}

\maketitle

Abc \textbf{Abc} \textit{Abc} \textbf{\textit{Abc}}

\lipsum[1-4]

\end{document}

enter image description here

You may want to use semibold, in this case change the declaration into

\setmainfont{cmunb}[
  Extension=.otf,
  UprightFont=*mr,
  ItalicFont=*mo,
  BoldFont=*so,       % semibold
  BoldItalicFont=*sr, % semibold oblique
]

enter image description here

If the CM-Unicode fonts are installed also as system fonts, you can declare them more easily by name

\setmainfont{CMU Bright}

that would choose the semibold variant. For getting the bold variant use

\setmainfont{CMU Bright}[
  BoldFont=* Bold Extended,
  BoldItalicFont=* Bold Extended Oblique,
]

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.