You don't need to reset everything to do this if all you want is to use your sans serif font as the titling font. You can just set your sans font with fontspec
and then pass the [sf]
option to titlesec
. If you also want to change the title formatting you will need to load the titling
package, which provides simple hooks for doing so.
If you do want to set the font separately using titlesec
, §9.2 of the titlesec
documentation gives the exact format for the standard classes.
In the following example I've combined both methods to show the possibilities. I've chosen a silly font for the title just for illustrative purposes.
% !TEX TS-program = XeLaTeX
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\newfontfamily\mytitlefont{TeX Gyre Chorus}
\usepackage{titling}
\renewcommand\maketitlehooka{\mytitlefont}
\usepackage[sf]{titlesec}
\titleformat*{\section}{\Large\mytitlefont}
\title{A title}
\author{An author}
\begin{document}
\maketitle
\section{A section}
Some text.
\subsection{A subsection}
\end{document}