6

When compiling the code below, there is no line in the header in the beginning of the chapter.

How do I change it such that the header looks the same on all pages? Thanks

\documentclass{report}
\usepackage{fancyhdr}
\usepackage[USenglish]{babel}
\usepackage{blindtext}

\pagestyle{fancyplain} %eigener Seitenstil
\fancyhf{} %alle Kopf- und Fußzeilenfelder bereinigen
\fancyhead[L]{Titel} %Kopfzeile links
\fancyhead[C]{} %zentrierte Kopfzeile
\fancyhead[R]{Name} %Kopfzeile rechts
\renewcommand{\headrulewidth}{0.4pt} %obere Trennlinie

\begin{document}
\renewcommand{\chaptername}{Lektion}
\chapter{velo}
\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext
\chapter{tram}
\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext
\end{document}
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Sep 28 '13 at 6:47
  • You want to redefine the plain page style by \fancypagestyle. Section 7 of the »fancyhdr« manual has a detailed example. – Thorsten Donig Sep 28 '13 at 7:06
  • @ThorstenDonig, fancyplain is used to change headers in all pages, including plain ones. – karlkoeller Sep 28 '13 at 7:21
  • @karlkoeller: This seems not to be documented in the manual. – Thorsten Donig Sep 28 '13 at 7:37
  • @ThorstenDonig Unfortunately not... I know about that from en.wikibooks.org/wiki/LaTeX/… (you can find something in this site as well searching for fancyplain. – karlkoeller Sep 28 '13 at 7:41
6

The fancyplain style defines a new style for all pages, including plain ones.

So commands like \fancyhead take effect in all pages, but \headrulewidth not.

To change the behavior of the rule in plain pages you have to modify \plainheadrulewidth.

So, you have to add also

\renewcommand{\plainheadrulewidth}{0.4pt}

Complete MWE:

\documentclass{report}
\usepackage{fancyhdr}
\usepackage[american]{babel}
\usepackage{blindtext}

\pagestyle{fancyplain} %eigener Seitenstil
\fancyhf{} %alle Kopf- und Fußzeilenfelder bereinigen
\fancyhead[L]{Titel} %Kopfzeile links
\fancyhead[C]{} %zentrierte Kopfzeile
\fancyhead[R]{Name} %Kopfzeile rechts
\renewcommand{\headrulewidth}{0.4pt} %obere Trennlinie
\renewcommand{\plainheadrulewidth}{0.4pt}

\begin{document}
\renewcommand{\chaptername}{Lektion}
\chapter{velo}
\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext
\chapter{tram}
\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext
\end{document} 

Output (first page):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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