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

1 Answer 1

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

2
  • 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? Feb 2, 2013 at 16:45
  • @user1301428 See section 9 of the fancyhdr manual for a good explanation.
    – lockstep
    Feb 2, 2013 at 16:48

You must log in to answer this question.

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