I'm using XeTeX
to edit a document in which I am trying to use titlesec
and titling
to set a different font for some headings.
I'm using the approach suggested as a reply to a similar question, but so far my success is really partial.
The section
and subsection
titles change the font as desired, but the chapter
title ignores the setting.
Here is a snippet of my code
%%% to allow custom headings
\usepackage{titlesec}
% to change titles font family
\usepackage{titling}
%%% declare fonts and set some formats
% fontspec to use non-latex with xetex
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}
% font declaration and title settings
\newfontfamily\headingfont[]{Armata}
\titleformat{\chapter}{\LARGE\headingfont}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
The chapter setting is something I tried while mimicking the solution provided in the link above. I learnt that removing the *
is required somehow as the easy mode
would not work with chapter titles. I didn't find why, yet. But truth is that removing the asterisk also gets rid of the error… but it doesnt seem to work regarding the font face setting.
Any ideas?
Thanks 🙂
Edit: I found a really silly error, that led me to a (partial) solution and a new error showing up. I just set \documentclass{book}
and now the renderer tries to put the desired font, but titlesec
throws an error:
Titles must not be nested
The LaTeX code is this:
\begin{document}
\chapter{First Chapter}
The title above does not show any font.
\section{First Section}
Works as desired.
\subsection{Subsection}
Hiya! This also shows up as expected.
\subsubsection{Subsubsection}
We have not declared a titleformat for this heading, and so it is shown with the default font.
\section{Second section}
Repeating the success
\end{document}
The chapter
title is the one that triggers the titlesec error.
Best Answer
The line
is the culprit. The syntax is wrong. The right one is
So, the MWE (I've used Arial instead of Armata since I don't have that font installed):
yields the following output