[Tex/LaTex] Chaptername in header except for Chapter page using fancyhdr

fancyhdrheader-footer

I am trying to achieve a header that displays topic, chapter and page number on every page except on pages where a new chapter begins. In that case the chapter space should be empty.

I use fancyhdr and tried the following:

\documentclass[fontsize=12pt, paper=a4, headinclude, twoside=false, parskip=half+, pagesize=auto, numbers=noenddot, open=right, toc=listof, toc=bibliography]{scrreprt}

\usepackage{fancyhdr}
\fancyhf{}
\lhead{\itshape BA TOPIC}
\chead{\itshape{\nouppercase{\leftmark}}}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}

%define header style for chapter pages
\fancypagestyle{chapt}{
    \fancyhf{}
    \fancyhead[L]{\itshape{BA THEMA}}
    \fancyhead[C]{}
    \fancyhead[R]{\thepage}
}

\renewcommand*{\chapterpagestyle}{chapt}

\begin{document}
\pagestyle{empty}
\pagenumbering{Roman}

%Titlepage
\input{title.tex}

%ToC etc
{
\hypersetup{linkcolor=black}
    \pdfbookmark[1]{Inhaltsverzeichnis}{toc}
    \tableofcontents
    \listoffigures
    \listoftables
}

\clearpage
\pagestyle{fancy}

% actual Content
\chapter{Einleitung}
\pagenumbering{arabic}

\end{document}

now i get the topic+pagenumber header for my chapter pages, but also for the ToC, and more important – i dont get any of the following pages to display the corresponding chapter name in its header.

Any help would be appreciated.

Best Answer

Try this code:

\documentclass{book}
\usepackage{fancyhdr}
\fancyhf{}
\lhead{\itshape BA TOPIC}
\chead{\itshape{\nouppercase{\leftmark}}}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\usepackage[ocgcolorlinks]{hyperref}
\usepackage{bookmark}
\usepackage{lipsum}    %% for dummy text

\begin{document}
\frontmatter
\pagestyle{plain}

%Titlepage
%\input{title.tex}

%ToC etc
    \tableofcontents
    \listoffigures
    \listoftables

\cleardoublepage
\pagestyle{fancy}

%define header style for chapter pages and put it here
\fancypagestyle{plain}{%
    \fancyhf{}
    \fancyhead[L]{\itshape{BA THEMA}}
    \fancyhead[C]{}
    \fancyhead[R]{\thepage}
}
\mainmatter
% actual Content
\chapter{Einleitung}
\lipsum[1]
\section{Some section}
\lipsum[2-8]
\chapter{Second}
\lipsum[1]
\section{Some other section}
\lipsum

\end{document}

You can define a fancy page style like:

\fancypagestyle{myfancy}{%
\fancyhf{}
\fancyhead[L]{<your settings>}
\fancyhead[C]{<your settings>}
\fancyhead[R]{<your settings>}
\fancyfoot[L]{<your settings>}
\fancyfoot[C]{<your settings>}
\fancyfoot[R]{<your settings>}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}

and use it as \pagestyle{myfancy}. But if you want to change the page style of chapter pages, you should do it by changing the plain style as shown above.

Related Question