[Tex/LaTex] fancyhdr and chapter*

fancyhdrheader-footer

I'm using fancydr like this:

\usepackage{titlesec} % Normal chapter titles
\titleformat{\chapter}{\normalfont\LARGE\bfseries}{\thechapter.}{1em}{}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\emph{\leftmark}}
\rhead{\nouppercase{\emph{\rightmark}}}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space#1}{}} 
\setlength{\headheight}{15pt}

This doesn't work well with chapter*{}, as it leaves the last chapter's details to the header.

e.g. I have

\chapter{Conclusions and future directions}
\input{./tex/conclusions}

\chapter*{Summary}
\input{./tex/summary}
\addcontentsline{toc}{chapter}{Summary}

Then the pages in summary show Conclusions and future directions in their header. How could I make fancyhdr work with chapter*? and is there a possibility to disable the fancyhdr for some pages?

Best Answer

You should define \chaptermark in a better way:

\renewcommand{\chaptermark}[1]{%
  \markboth{%
    \ifnum\value{chapter}>0
      \thechapter.\space
    \fi
    #1%
  }{}%
}

so “0.” will not be added when the chapter number is zero (that is, for the chapters before the first).

For the conclusion, use

\chapter*{Summary}
\addcontentsline{toc}{chapter}{Summary}\markboth{Summary}{}
\input{./tex/summary}

Notice the different order, because you want to execute those commands at the start of the chapter text, not at the end.