I use a template with a documentclass{book} for my thesis, but for some reson the page numbering is messed up, in some pages numbers are in the middle of the page (as it should be) and in some pages, they are at the top of the page. So I fixed this with \usepackage{fancyhdr} and \pagestyle{fancy}, but now headers are messed, for example: Here is a "main.tex" code example:
\documentclass[12pt,a4paper,oneside,onecolumn]{book}
\usepackage[letterpaper, portrait]{geometry}
\usepackage{lipsum}
%SET AVERAGE MARGIN
\geometry{
left={4cm},
right={2cm},
top={1.5cm},
bottom={2.5cm},
}
\usepackage{layout}
\usepackage{fancyhdr}
\usepackage{libertine}
\usepackage{courier}
\usepackage[utf8x]{inputenc}
\usepackage[hebrew,english]{babel}
\usepackage[longnamesfirst,square,numbers,comma,sort&compress]{natbib}
\usepackage{titlesec}
\usepackage{float}
\usepackage{graphicx,caption}
\usepackage{amsmath}
\usepackage{mathpazo}
\usepackage{datetime}
\usepackage{hyperref}
\usepackage{bookmark}
%
\usepackage{float}
\usepackage{xcolor}
\usepackage{amssymb}
\usepackage{eufrak}
\usepackage{accents}
\usepackage{mathtools}
\usepackage{nicematrix}
\newcommand*{\bfrac}[2]{\genfrac{\lbrace}{\rbrace}{0pt}{}{#1}{#2}} %bar free fraction
\usepackage{romannum} %Roman numerals
\usepackage{bm}
%\addbibresource{ref.bib} %Imports bibliography file
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt}
\titleformat{\chapter}[hang]{\bf\huge}{\thechapter}{2pc}{}
\title{Thesis Template}
\begin{document}
%\layout
\include{cover}
\include{cover_heb}
\include{cover_sig}
\frontmatter
\pagestyle{fancy}
\include{Chapters/abstract_heb}
\include{Chapters/abstract}
\include{Chapters/table_of_abb}
\include{Chapters/acknowledgements}
\tableofcontents
\include{Chapters/table_of_symbols}
\listoffigures
\listoftables
\mainmatter
\pagestyle{fancy}
\input{Chapters/introduction}
\input{Chapters/previous_work}
\input{Chapters/Metasurface_analysis}
\input{Chapters/research_question}
\input{Chapters/methods}
\input{Chapters/results}
\input{Chapters/conclusion}
\section{}
\bibliographystyle{IEEEtran}
\bibliography{ref}
\end{document}
Any help is appreciated.
\pagestyle{plain}
.book
class using a different page style for first pages of a chapter and all other pages.