[Tex/LaTex] Change font of document title

fontsfontspectitles

I have used fontspec to style all of my headers with a new font with:

% Specify different font for section headings
\newfontfamily\headingfont[]{Gill Sans}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\titleformat*{\subsubsection}{\large\headingfont}

Now I want to style my document title to use Gill Sans as well since it would match the style of the rest of the document. How do I do this?

Best Answer

For the standard document classes you can use the titling package to do this:

\documentclass{article}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec}
% Specify different font for section headings
\newfontfamily\headingfont[]{Gill Sans}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\titleformat*{\subsubsection}{\large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
\author{An author}
\title{The title of the article}
\date{\today}
\begin{document}
\maketitle
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}

output of code

Related Question