# General guide on how to set up font families for luaLatex

In A Survey of Free Math Fonts for TEX and LATEX are great examples of harmonizing fonts in Latex.

For example consider the text fragment for CM Bright: With pdfLatex it was sufficient to just use \usepackage{cmbright}, but I have a hard time reproducing this text fragment under luaLatex. It seems much more complicated.

After hours of trying and reading the fontspec doc I'm close to returning to pdfLatex.

Can you please guide me, how to reproduce the above example with CM Bright in luaLatex?

What would be the general approach for setting up a new font family (including math) in luaLatex?

It is explained in the doc somehow, but LaTeX dudes are not the best in writing comprehensive documentations, I'm sorry.

Here is a MWE:

preamble:

\documentclass[a4paper]{article}

\usepackage{unicode-math}
\usepackage{amsmath}
\usepackage{fontspec}          % lualatex font engine

\setmainfont[Numbers = Uppercase,
Ligatures = TeX,
BoldFont  = CMU Bright SemiBold,
ItalicFont = CMU Bright Oblique,
]{CMU Bright Roman}


document:

\begin{document}

\section{Let's try!}

\textbf{Theorem 1 (Residue Theorem).}
Let $f$ be analytic in the region $G$ except for the isolated singularities $a_1,a_2,\ldots,a_m$. If $\gamma$ is a closed rectifiable curve in $G$ which does not pass through any of the points $a_k$ and if $\gamma\approx 0$ in $G$ then
$\frac{1}{2\pi i}\int_\gamma f = \sum_{k=1}^m n(\gamma;a_k) \text{Res}(f;a_k).$

\textbf{Theorem 2 (Maximum Modulus).}
\emph{Let $G$ be a bounded open set in $\mathbb{C}$ and suppose that $f$ is a continuous function on $G^-$ which is analytic in $G$. Then}
$\max\{|f(z)|:z\in G^-\}=\max \{|f(z)|:z\in \partial G \}.$
\vspace*{-1em}

\newcommand{\abc}{abcdefghijklmnopqrstuvwxyz}
\newcommand{\ABC}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\newcommand{\alphabeta}{\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\varkappa\lambda\mu\nu\xi o\pi\varpi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega}
\newcommand{\AlphaBeta}{\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega}

{\par \tolerance=0 \emergencystretch=100em $a\alpha b \beta c \partial d \delta e \epsilon \varepsilon f \zeta \xi g \gamma h \hbar \hslash \iota i \imath j \jmath k \kappa \varkappa l \ell \lambda m n \eta \theta \vartheta o \sigma \varsigma \phi \varphi \wp p \rho \varrho q r s t \tau \pi u \mu \nu v \upsilon w \omega \varpi x \chi y \psi z$ \linebreak $\infty \propto \emptyset \varnothing \mathrm{d}\eth \backepsilon$\par}

\end{document}


producing: So the text seems right, the math not. During my fiddling the past hours I once got the math right, but the heading were wrong. I don't remember how I did this, but I think it doesn't matter.

unicode-math makes only sense if you also have a sensible "unicode math" font that you want to use as base math font. There is no "cm bright math" (sans serif math fonts are sparse ...). So it is better to use for the math setup the non-unicode way:

\documentclass[a4paper,12pt]{article}
\usepackage{cmbright}
\usepackage{amsmath,amssymb}
\usepackage{fontspec}          % lualatex font engine

\setmainfont[Numbers = Uppercase,
Ligatures = TeX,
BoldFont  = CMU Bright SemiBold,
ItalicFont = CMU Bright Oblique,
]{CMU Bright Roman}

\begin{document}

\section{Let's try!}

\textbf{Theorem 1 (Residue Theorem).}
Let $f$ be analytic in the region $G$ except for the isolated singularities $a_1,a_2,\ldots,a_m$. If $\gamma$ is a closed rectifiable curve in $G$ which does not pass through any of the points $a_k$ and if $\gamma\approx 0$ in $G$ then
$\frac{1}{2\pi i}\int_\gamma f = \sum_{k=1}^m n(\gamma;a_k) \text{Res}(f;a_k).$

\textbf{Theorem 2 (Maximum Modulus).}
\emph{Let $G$ be a bounded open set in $\mathbb{C}$ and suppose that $f$ is a continuous function on $G^-$ which is analytic in $G$. Then}
$\max\{|f(z)|:z\in G^-\}=\max \{|f(z)|:z\in \partial G \}.$
\vspace*{-1em}

\newcommand{\abc}{abcdefghijklmnopqrstuvwxyz}
\newcommand{\ABC}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\newcommand{\alphabeta}{\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\varkappa\lambda\mu\nu\xi o\pi\varpi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega}
\newcommand{\AlphaBeta}{\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega}

{\par \tolerance=0 \emergencystretch=100em $a\alpha b \beta c \partial d \delta e \epsilon \varepsilon f \zeta \xi g \gamma h \hbar \hslash \iota i \imath j \jmath k \kappa \varkappa l \ell \lambda m n \eta \theta \vartheta o \sigma \varsigma \phi \varphi \wp p \rho \varrho q r s t \tau \pi u \mu \nu v \upsilon w \omega \varpi x \chi y \psi z$ \linebreak $\infty \propto \emptyset \varnothing \mathrm{d}\eth \backepsilon$\par}

\end{document}

• Thanks for your answer. But I realized that I have deeper problems. Applying this to my actual document my headings are still screwed up. I use the base class scrbook and have certain things like caption labels and headings defined with \sffamily and \bfseries, e.g.: \setkomafont{captionlabel}{\sffamily\bfseries} Everywhere where this is the case, still Latin Modern Roman is used instead of CM Bright. What do I need to do to set \sffamily and \bfseries also to CM Bright? Apr 6, 2015 at 12:17
• Alright I got it. I need to set the \setsansfont as well. Apr 6, 2015 at 12:27