font change for chapter, section, subsection titles

kada picture kada · Feb 25, 2019 · Viewed 7.1k times · Source

So, i am struggling to change the font for title/section/subsection in latex.

Here is my code :

% !TEX TS?program = pdflatexmk

\documentclass[fontsize=12pt]{book}

\usepackage[T1]{fontenc}

\usepackage{amsmath}

\usepackage{mathpazo}

%changing font of section/chapter title
\usepackage{fontspec}
\usepackage{titlesec}
\newfontfamily\headingfont{Papyrus}
\titleformat{\chapter}{\LARGE\headingfont}
\titleformat{\section}{\LARGE\headingfont}
\titleformat{\subsection}{\Large\headingfont}
\titleformat{\subsubsection}{\large\headingfont}



\title{my report}
\author{user name}
\date


\linespread{1.5}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tableofcontents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{introduction}
text : intro
\section{first section}
text :  section
\subsection{this subsection}
text :section
\subsubsection{this and that subsection}
text :subsub
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

And this is the output: enter image description here The font is only implemented in the chapter and subsection. Not for others. And also the numbering is lost. For example, without titlesecand fontspec this is what it looks like. The chapter and subsection numbering is lost with that. I cant find the bug. (also kind of annoying to use fontspec as it could not find the default latex font, so had to copy paste the otf file in the working directory)

enter image description here

Answer