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.

The current section name + chapter.section number is shown in the header. This is normal behaviour (what I want).

Example:

enter image description here

How can I remove the header text, if there is no section on the page. The following example illustrate my problem. The header is "1.0" but I want to show nothing.

Example:

enter image description here

Here my MWE:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

\fancyhead{}
\fancyhead[LE]{\makebox[2cm][r]{}{}}
\fancyhead[RO]{\rightmark\hspace*{0.2cm}\thesection}


\begin{document}

\chapter{An example chapter}

\blindtext[25]

\section{An example section}

\blindtext
\end{document}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

Using fancyhdr with scrbook is not recommended. However, here's a solution: issue the \thesection command within \markright. Note that \markright takes only one argument (whereas \markboth needs two).

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
  \markright{#1\ \thesection}%
}

\fancyhf{}
\fancyhead[RO]{\rightmark}
\fancyfoot[C]{\thepage}

\begin{document}

\chapter{An example chapter}

\lipsum[1-20]

\section{An example section}

\lipsum[1-20]
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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