0

This question already has an answer here:

I am putting a top header in my thesis and have obtained this results:

enter image description here

I don’t like the repetition of the world “chapter” and I don’t understand why the width of the line is larger than the text width.

Here is my preamble:

\documentclass[11pt,a4paper,openright,fleqn,twoside]{report}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[caption=false]{subfig}
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{color}
\usepackage{colortbl}
\usepackage[colorlinks=true,citecolor=blue]{hyperref}
\hypersetup{linktocpage}
\usepackage[noadjust]{cite}
\usepackage{amsmath,amssymb}            
\usepackage{enumerate}  
\usepackage{rotating}  
\usepackage[scriptsize]{caption} 
\usepackage{fancyhdr} 

\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\nouppercase\leftmark}
\fancyhead[OR]{\nouppercase\rightmark}
\fancyhead[ER,OL]{\thepage}

%\setlength{\paperwidth}{16cm}
%\setlength{\paperheight}{24cm}
%\setlength{\oddsidemargin} {2. cm}
%\setlength{\evensidemargin} {2. cm}
%\addtolength{\oddsidemargin} {-0.4 cm}
%\addtolength{\evensidemargin} {-0.4 cm}
\linespread{1.1}
\usepackage[paperwidth=16cm,paperheight=24cm]{geometry}

\usepackage[utf8]{inputenc}

\newcommand{\p}{\partial}   
\newcommand{\vect}[1]{\bold {#1} }
\newcommand{\aver}[1]{\left\langle {#1} \right\rangle}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}

\pagestyle{empty}

\begin{document}

Every chapter which is included in an external file starts with these lines:

\chapter{Introduction}
\label{capitolo1}
\pagestyle{fancy}

marked as duplicate by Schweinebacke, user36296, Stefan Pinnow, Mensch, CarLaTeX Nov 29 '17 at 16:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

The line is too long because you are changing the page geometry after you load fancyhdr. To remove "Chapter" from the title, you could change the definition of \chaptermark (thanks to Schweinebacke for his comment).

Off-topic:

  • hyperref should be loaded as one of the last packages
  • your \headheight is too small, as a warning tells you, it should be at least 13.59pt

\documentclass[11pt,a4paper,openright,fleqn,twoside]{report}

\usepackage[paperwidth=16cm,paperheight=24cm,headheight=13.6pt]{geometry}% -< before fancyhdr

\usepackage{fancyhdr} 
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\nouppercase\leftmark}
\fancyhead[OR]{\nouppercase\rightmark}
\fancyhead[ER,OL]{\thepage}

\renewcommand{\chaptermark}[1]{%
 \markboth{\thechapter.\ #1}{}}

\pagestyle{empty}

\usepackage{lipsum}% hust for this example

\begin{document}

\chapter{Introduction}
\pagestyle{fancy}

\lipsum

\end{document}

enter image description here

1

I think it's simpler with titleps, which comes with titlesec, but can be used independently. We don't have to change chaptername to none (which can have unwanted side-effects):

\documentclass[11pt,a4paper,openright,fleqn,twoside]{report}

\usepackage[paperwidth=16cm,paperheight=24cm]{geometry}

\usepackage{titleps}
\newpagestyle{mystyle}{%
\headrule%
\sethead[\bfseries\thepage][][\bfseries\thechapter.~\chaptertitle]{\bfseries\thechapter. ~\chaptertitle}{}{\bfseries\thepage}
\setfoot{}{}{}
}%

\usepackage{lipsum}%

\pagestyle{mystyle}
\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

enter image description here

  • That's right. I'll do it in a moment. Thanks for pointing me to this thread! – Bernard Nov 29 '17 at 15:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.