# font change for chapter, section, subsection titles

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}

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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: 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)

Do you want something like this?

Here’s modified code

\documentclass[fontsize=12pt]{book}

\usepackage[T1]{fontenc}

\usepackage{amsmath}

\usepackage{mathpazo}

\usepackage{fontspec}

% changing font of section/chapter title

\usepackage{titlesec}

\setcounter{secnumdepth}{3}
\renewcommand{\thechapter}{\arabic{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thesubsection}{(\arabic{chapter})\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesection.\arabic{subsection}.\arabic{subsubsection}}

\begin{document}

\tableofcontents

\chapter{introduction}
text : intro
\section{first section}
text : section
\subsection{this subsection}
text : subsection
\subsubsection{this and that subsection}
text : subsub

\end{document}


\titleformat takes five non-optional parameters \titleformat{which}[shape]{format}{label}{hsep}{before-code}[after-code] (see http://ctan.altspu.ru/macros/latex/contrib/titlesec/titlesec.pdf). When you wish to change just format, then you would probably like its *-variant \titleformat*{which}{format}

For chapter, you may wish to place its text on other line, in such case use \titleformat{\chapter}[display] not [hang]

\setcounter{secnumdepth}{3} is that thing which adds numbering to “subsub”s too