[Tex/LaTex] Overlap of section and chapter name in the header

formattingheader-footer

In the header of the book I'm writing using Latex, the Chapter name and a Section name are overlapping due to the large number of characters. For instance, in the final pdf file, the header is "2.1. Application of the classical approach Chapter 2. Efficient Initializations to…" Note that by header I assume the text that is displayed at each page above the main text.

Obviously, the both the Section name and Chapter name cannot fit one page. How could I specify that I only need "Chapter 2" to be written after the section name in the header?

The main file looks like:

\documentclass[a4paper,12pt]{book}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{url}
\usepackage[algoruled,vlined]{algorithm2e}
\documentclass[a4paper,12pt]{book}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{url}
\usepackage[algoruled,vlined]{algorithm2e}
\usepackage{graphicx,subfigure}
\usepackage{booktabs}
\usepackage[usenames,dvipsnames]{color}

\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}

% fancy headers and footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.1pt} % for upper line
\renewcommand{\footrulewidth}{0.1pt} % for lower line
 \fancyhead[LE,RO]{\itshape \nouppercase \rightmark}\fancyhead[LO,RE]           {\itshape \nouppercase \leftmark}
\fancyfoot[C]{\thepage}

 \usepackage[semicolon]{natbib}

\usepackage{fancybox}

\usepackage{xcolor}
\usepackage{framed}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\newenvironment{myfancybox}{%
\def\FrameCommand{\fboxsep=\FrameSep \fcolorbox{black}}%
\color{black}\MakeFramed {\FrameRestore}}%
{\endMakeFramed}


\usepackage{rotating}


\usepackage{sectsty}
\allsectionsfont{\itshape}

\setlength{\headheight}{15pt}

\parskip1ex
\begin{document}

\include{forTest}
\end{document}

In a document forTest.tex put

\chapter{sakdlf fsadfkjdls kfkjs dflasfj ihfowijif}
\label{ch:grid}

\section{adfafdfklkjsaf  fksajflls lasfjl sfjls flafj }

and then some arbitrary text that goes to the second page. On the second page
you'll see an overlap at the top. So, I would only like "Chapter 1" to be written, without the chapter name.

Best Answer

Since you are already using the fancyhdr package, you just need to change \leftmark to Chapter \arabic{chapter} in your example.

\documentclass[a4paper,12pt]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LE,RO]{\itshape \nouppercase \rightmark}
\fancyhead[LO,RE]{\itshape \nouppercase Chapter \arabic{chapter}}
\begin{document}
\chapter{This chapter has a rather long name}
\section{This section also has a long name}
\eject
abc
\eject
def
\eject
ghi
\end{document}
Related Question