# XeLaTeX: System font for headers only?

I know that you can use `\setmainfont` for normal text but is there any command that will apply a font only to headers (chapters, sections, subsections)?

-

## migrated from stackoverflow.comAug 22 '11 at 13:24

This question came from our site for professional and enthusiast programmers.

Using `fontspec`, you can define any font you want in XeTeX. You can then use them in the places of your choice by using the macro names you chose.

If you want to change the fonts used in sections, you can combine `fontspec` with `titlesec`. Example:

``````\usepackage{fontspec}
\usepackage{xunicode}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Linux Libertine O}
\newfontfamily\secfont{EB Garamond}

\usepackage{titlesec}

\newcommand{\secstyle}{\secfont\large\itshape}
\titleformat{\section}%
{\secstyle} % format
{} % label
{10pt} % sep
{} % before
[\normalfont] % after
``````

will use Linux Libertine O as main font and EB Garamond as section font.

-