3

I am writing a report using the scrreprt KOMA class. Currently my header looks like this:

Current header

Introduction is the chapter name.

I would like to make two changes to it:

  1. I would like to have the chapter name on the left of the header and the section name on the right. I have already tried \lhead{\thechapter} but this only gives me the chapter number, not the title.
  2. How can I change the font used in the header to match the one in the figure? It looks like it's the default font for section titles in the KOMA classes, but I'm not 100% sure. New header font
4

Redefine \chaptermark/ \sectionmark to display sectioning number plus title, and redefine \lhead/\rhead to use \leftmark/\rightmark plus the formatting instructions \sffamily\bfseries.

\documentclass{scrreprt}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand*{\chaptermark}[1]{\markboth{\thechapter.~~#1}{}}
\renewcommand*{\sectionmark}[1]{\markright{\thesection.~~#1}}

\lhead{\sffamily\bfseries \leftmark}
\rhead{\sffamily\bfseries \rightmark}

\usepackage{lipsum}

\begin{document}

\chapter{foo}

\section{foobar}

\lipsum[1-12]

\end{document}​

enter image description here

  • Thank you, this worked perfectly! However I have a couple of questions about your code: 1) what is the difference between \markboth and \markright? 2) What is the meaning of \leftmark and \rightmark? – user1301428 Feb 2 '13 at 16:45
  • @user1301428 See section 9 of the fancyhdr manual for a good explanation. – lockstep Feb 2 '13 at 16:48

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.