15

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?

  • 2
    It depends on the class used: KoMa classes probably have their method for managing the font for the title, the standard classes don't. The solution depends also on what you want precisely: only the title or the whole title block? – egreg May 18 '11 at 7:50
17

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

| improve this answer | |
4

I am a beginner with LaTeX. This answer helped me change the font type of the sections. But it did not change the font type of the title to match that of the sectioning. It was not so obvious to me, so I am putting the answer.

It turned out all I had to do is the following:

\title{\headingfont {The title of the article} }
| improve this answer | |
  • 1
    This will probably do what you want, but it has unintended consequences. The \title command is for declaring the title of the document. The document title is The title of the article, not \headingfont{The title of the article}. Anything that looks at the content of \title (e.g., hyperref) will be confused or complain. – Matthew Leingang Dec 11 '19 at 14:16
0

fontspec package requires either XeTeX or LuaTeX.

| improve this answer | |

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.