3

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.

0

1 Answer 1

3

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.

2
  • Thanks, that code gives the right headers. Now just out of curiosity could you define an extra pagestyle and not change the plain-style as i tried?
    – voiDnyx
    Jan 28, 2013 at 10:30
  • @voiDnyx See the edit. But for chapters the page style plain has to be changed.
    – user11232
    Jan 28, 2013 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .