Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share
add comment

1 Answer

up vote 2 down vote accepted

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.

share
    
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 '13 at 10:30
    
@voiDnyx See the edit. But for chapters the page style plain has to be changed. –  Harish Kumar Jan 28 '13 at 13:57
add comment

This site is currently not accepting new answers.

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