I have the following template to writing my thesis.
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{pdfpages}
\usepackage{geometry}\geometry{top=3cm,bottom=3cm,left=3.7cm,right=2.5cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[CO,CE]{This is the title of the thesis}
\renewcommand{\headrulewidth}{0.4pt}
\setlength{\headheight}{15pt}
\setcounter{secnumdepth}{4}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\Huge\bfseries}{\chaptertitlename \ \thechapter}{15pt}{\Huge}
\titlespacing*{\chapter}{0pt}{-3\baselineskip}{20pt}[3.7cm]
\hyphenpenalty=10000
\tolerance=2500
\raggedbottom
\usepackage{units}
\usepackage{nomentbl}
\usepackage{enumitem,calc}
\usepackage{setspace}\linespread{1.6}
\title{This is the title of the thesis}
Obviously, it gives all the page header as ''This is the title of the thesis'', which is centered.
I want the page headers on odd page numbers to be the current section title and right alignment, which is on the second level, such as 1.1, 1.2,... and those on even page numbers to be the current chapter title and left alignment, which is on the first level, such as 1, 2,...
Some titles of the chapter or section are too long to be shown in one line in the header. In this case, I want to show it as a shorter title.
How do I achieve the customized page header by modifying the template? Thank you a lot!
\fancyhead
to get the default header entries.\fancyhead[CO,CE]{This is the title of the thesis}
must be replaced by\fancyhead[LE]{\leftmark}
and\fancyhead[RO]{\rightmark}
.